Last active
August 29, 2015 14:27
-
-
Save Swoorup/28d90d10c0b56514e837 to your computer and use it in GitHub Desktop.
Scan Input, build lexical tokens
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// keep getline in a loop in case interruption occurs | |
int again = 1; | |
while (again) { | |
again = 0; | |
printf("%s", getprompt()); | |
linebuffer = NULL; | |
len = 0; | |
ssize_t nread = getline(&linebuffer, &len, stdin); | |
if (nread <= 0 && errno == EINTR) { | |
again = 1; // signal interruption, read again | |
clearerr(stdin); // clear the error | |
} | |
} | |
// user pressed ctrl-D | |
if (feof(stdin)) { | |
exit(0); | |
return 0; | |
} | |
// lexically analyze and build a list of tokens | |
lexer_build(linebuffer, len, &lexerbuf); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment