mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Fixed obscure EOF bug in lexer
This commit is contained in:
@@ -1,26 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
//increment & decrement (prefix)
|
|
||||||
{
|
|
||||||
var a = 42;
|
|
||||||
assert a == 42;
|
|
||||||
assert ++a == 43;
|
|
||||||
assert a == 43;
|
|
||||||
assert --a == 42;
|
|
||||||
assert a == 42;
|
|
||||||
|
|
||||||
print a;
|
var answer = 42;
|
||||||
}
|
|
||||||
|
|
||||||
|
var question: string = "How many roads must a man walk down?";
|
||||||
|
|
||||||
//increment & decrement (postfix)
|
print question;
|
||||||
{
|
|
||||||
var a = 42;
|
|
||||||
assert a == 42;
|
|
||||||
assert a++ == 42;
|
|
||||||
assert a == 43;
|
|
||||||
assert a-- == 43;
|
|
||||||
assert a == 42;
|
|
||||||
|
|
||||||
print a;
|
|
||||||
}
|
|
||||||
@@ -242,7 +242,6 @@ static Toy_Token makeString(Toy_Lexer* lexer, char terminator) {
|
|||||||
while (!isAtEnd(lexer)) {
|
while (!isAtEnd(lexer)) {
|
||||||
//stop if you've hit the terminator
|
//stop if you've hit the terminator
|
||||||
if (peek(lexer) == terminator) {
|
if (peek(lexer) == terminator) {
|
||||||
advance(lexer); //eat the terminator
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,6 +260,8 @@ static Toy_Token makeString(Toy_Lexer* lexer, char terminator) {
|
|||||||
return makeErrorToken(lexer, "Unterminated string");
|
return makeErrorToken(lexer, "Unterminated string");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
advance(lexer); //eat the terminator
|
||||||
|
|
||||||
//make the token
|
//make the token
|
||||||
Toy_Token token;
|
Toy_Token token;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user