Fix returning TOKEN_EOF when lexing at EOF
This commit is contained in:
parent
ec2dcf9a72
commit
d9e4f64d2e
@ -206,6 +206,11 @@ class <%= classname %>
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (attempt_info.length == 0u)
|
||||
{
|
||||
lt.token = TOKEN_EOF;
|
||||
break;
|
||||
}
|
||||
if (!lex_continue)
|
||||
{
|
||||
if (last_accepts_info.token != TOKEN_NONE)
|
||||
|
@ -53,4 +53,11 @@ unittest
|
||||
string input = "5 + 4 * \n677 + 567";
|
||||
Testparser.Lexer lexer = new Testparser.Lexer(cast(const(ubyte) *)input.ptr, input.length);
|
||||
assert(lexer.lex_token() == LT(0, 0, Testparser.TOKEN_INT));
|
||||
assert(lexer.lex_token() == LT(0, 2, Testparser.TOKEN_PLUS));
|
||||
assert(lexer.lex_token() == LT(0, 4, Testparser.TOKEN_INT));
|
||||
assert(lexer.lex_token() == LT(0, 6, Testparser.TOKEN_TIMES));
|
||||
assert(lexer.lex_token() == LT(1, 0, Testparser.TOKEN_INT));
|
||||
assert(lexer.lex_token() == LT(1, 4, Testparser.TOKEN_PLUS));
|
||||
assert(lexer.lex_token() == LT(1, 6, Testparser.TOKEN_INT));
|
||||
assert(lexer.lex_token() == LT(1, 9, Testparser.TOKEN_EOF));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user