Skip to content

Commit

Permalink
support block comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rapiz1 committed Nov 3, 2021
1 parent 92a5564 commit 88ee955
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions scanner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ void Scanner::scanToken() {
case '/':
if (match('/')) {
while (peek() != '\n' && !eof()) advance();
} else if (match('*')) {
char prev = 0, now = 0;
while (!eof()) {
prev = now;
now = advance();
if (now == '\n') line++;
if (now == '/' && prev == '*') break;
}
if (now == '/' && prev == '*')
;
else
error("unterminate block comment");
} else {
addToken(match('=') ? SLASH_EQUAL : SLASH);
}
Expand Down

0 comments on commit 88ee955

Please sign in to comment.