mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-18 14:21:36 +00:00
Lexer now returns TOKEN_EOF only once and afterwards TOKEN_FATAL
This commit is contained in:
parent
198e35a823
commit
e0ffcfb74b
2 changed files with 9 additions and 1 deletions
8
lexer.c
8
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 == '$') {
|
||||
|
|
2
lexer.h
2
lexer.h
|
@ -95,6 +95,8 @@ typedef struct {
|
|||
char peek[256];
|
||||
size_t peekpos;
|
||||
|
||||
bool eof;
|
||||
|
||||
token *tok;
|
||||
|
||||
struct {
|
||||
|
|
Loading…
Reference in a new issue