Lexer now returns TOKEN_EOF only once and afterwards TOKEN_FATAL

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-08-20 18:12:04 +02:00
parent 198e35a823
commit e0ffcfb74b
2 changed files with 9 additions and 1 deletions

View file

@ -146,6 +146,7 @@ lex_file* lex_open(const char *file)
lex->line = 1; /* we start counting at 1 */
lex->peekpos = 0;
lex->eof = false;
lex_filenames_add(lex->name);
@ -557,8 +558,13 @@ int lex_do(lex_file *lex)
lex->tok->ctx.line = lex->sline;
lex->tok->ctx.file = lex->name;
if (ch == EOF)
if (lex->eof)
return (lex->tok->ttype = TOKEN_FATAL);
if (ch == EOF) {
lex->eof = true;
return (lex->tok->ttype = TOKEN_EOF);
}
/* modelgen / spiritgen commands */
if (ch == '$') {

View file

@ -95,6 +95,8 @@ typedef struct {
char peek[256];
size_t peekpos;
bool eof;
token *tok;
struct {