add support for multi-line comments

This commit is contained in:
Neemek 2024-10-09 09:14:42 +02:00
parent 63ed021695
commit 9b1f2b8c9a
Signed by: neemek
GPG key ID: 28360A8951CD0E9B

View file

@ -185,6 +185,16 @@ func (l *Lexer) NextToken() (Token, error) {
case '*': case '*':
return l.makeToken(TokenStar), nil return l.makeToken(TokenStar), nil
case '/': case '/':
if l.match('*') {
for !l.isAtEnd() {
if l.match('*') && l.match('/') {
break
}
l.advance()
}
return l.NextToken()
}
return l.makeToken(TokenSlash), nil return l.makeToken(TokenSlash), nil
case '(': case '(':
return l.makeToken(TokenOpenParenthesis), nil return l.makeToken(TokenOpenParenthesis), nil