From: Wolfgang (Blub) Bumiller Date: Mon, 20 Aug 2012 16:12:04 +0000 (+0200) Subject: Lexer now returns TOKEN_EOF only once and afterwards TOKEN_FATAL X-Git-Tag: 0.1-rc1~132 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e0ffcfb74bdb3cfe37d53911ea91a18cc7518224;p=xonotic%2Fgmqcc.git Lexer now returns TOKEN_EOF only once and afterwards TOKEN_FATAL --- diff --git a/lexer.c b/lexer.c index d9483d8..8416255 100644 --- a/lexer.c +++ b/lexer.c @@ -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 == '$') { diff --git a/lexer.h b/lexer.h index b3114ec..6cdb5a5 100644 --- a/lexer.h +++ b/lexer.h @@ -95,6 +95,8 @@ typedef struct { char peek[256]; size_t peekpos; + bool eof; + token *tok; struct {