Fixed obscure EOF bug in lexer

This commit is contained in:
2025-01-14 12:45:11 +11:00
parent 13daf95933
commit 513d8f130c
2 changed files with 5 additions and 22 deletions

View File

@@ -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;
}

View File

@@ -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;