Fixed the '!=' detection bug.

This commit is contained in:
2022-02-14 17:21:35 +00:00
parent db54e8f888
commit 5b90c98123
+4
View File
@@ -142,6 +142,7 @@ void ScanToken(TokenList* tokens) {
case '!': case '!':
if (Match('=')) AddTokenToList(Bang_Equal, "!=", 2, tokens); if (Match('=')) AddTokenToList(Bang_Equal, "!=", 2, tokens);
else AddTokenToList(Bang, c, 1, tokens); else AddTokenToList(Bang, c, 1, tokens);
break;
case '/': case '/':
if (Match('/')) { if (Match('/')) {
while(Peek() != '\n' && !IsAtEnd()) Advance(); while(Peek() != '\n' && !IsAtEnd()) Advance();
@@ -157,6 +158,9 @@ void ScanToken(TokenList* tokens) {
case '\n': case '\n':
line++; line++;
break; break;
default:
fprintf(stderr, "Unexcpedted character %c\n", *c);
break;
} }
} }