Now handles unterminated block comments without freezing

This commit is contained in:
2023-02-10 12:26:38 +00:00
parent 66ea684a90
commit c81a139c97
2 changed files with 3 additions and 26 deletions

View File

@@ -61,7 +61,7 @@ static void eatWhitespace(Toy_Lexer* lexer) {
//eat the line
if (peekNext(lexer) == '/') {
while (advance(lexer) != '\n' && !isAtEnd(lexer));
while (!isAtEnd(lexer) && advance(lexer) != '\n');
break;
}
@@ -69,7 +69,7 @@ static void eatWhitespace(Toy_Lexer* lexer) {
if (peekNext(lexer) == '*') {
advance(lexer);
advance(lexer);
while(!(peek(lexer) == '*' && peekNext(lexer) == '/')) advance(lexer);
while(!isAtEnd(lexer) && !(peek(lexer) == '*' && peekNext(lexer) == '/')) advance(lexer);
advance(lexer);
advance(lexer);
break;