Add C style block comments

This commit is contained in:
Gal 2024-02-09 01:14:02 +01:00
parent d3aa8063d2
commit e89e089af2
Signed by: gal
GPG Key ID: F035BC65003BC00B
1 changed files with 14 additions and 2 deletions

View File

@ -81,7 +81,14 @@ class Scanner {
addToken(SEMICOLON); addToken(SEMICOLON);
break; break;
case '*': case '*':
addToken(STAR); if (match('/') && !isAtEnd()) {
advance();
} else if (isAtEnd()) {
break;
}
else {
addToken(STAR);
}
break; break;
case '!': case '!':
addToken(match('=') ? BANG_EQUAL : BANG); addToken(match('=') ? BANG_EQUAL : BANG);
@ -98,7 +105,12 @@ class Scanner {
if (match('/')) { if (match('/')) {
while (peek() != '\n' && !isAtEnd()) while (peek() != '\n' && !isAtEnd())
advance(); advance();
} else { }
else if (match('*')) {
while (peek() != '*')
advance();
}
else {
addToken(SLASH); addToken(SLASH);
} }
break; break;