]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Lexer now returns TOKEN_EOF only once and afterwards TOKEN_FATAL
authorWolfgang (Blub) Bumiller <blub@speed.at>
Mon, 20 Aug 2012 16:12:04 +0000 (18:12 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Mon, 20 Aug 2012 16:12:04 +0000 (18:12 +0200)
lexer.c
lexer.h

diff --git a/lexer.c b/lexer.c
index d9483d806e9f2afe1538a9916a77881fc393d4ec..841625577a96169452930eb72557525f4e7db793 100644 (file)
--- 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 b3114ec8b0969dd6407d471ff1348a5a88b5c145..6cdb5a58ec2474a44b1dff9ee917001ae4acd76e 100644 (file)
--- a/lexer.h
+++ b/lexer.h
@@ -95,6 +95,8 @@ typedef struct {
        char    peek[256];
        size_t  peekpos;
 
+       bool    eof;
+
        token  *tok;
 
        struct {