add single quote string

This commit is contained in:
Neemek 2025-09-16 20:01:38 +02:00
parent 14d7a5ce73
commit 80f4364f7e

View file

@ -303,6 +303,22 @@ func (l *Lexer) NextToken() (Token, error) {
return l.makeToken(TokenString), nil return l.makeToken(TokenString), nil
case '\'':
// include ending quote
for !l.accept('\'') {
if l.match('\n') {
return l.makeToken(TokenError), errors.New("string did not end in current line")
}
if l.isAtEnd() {
return l.makeToken(TokenError), errors.New("string did not before end of source")
}
l.advance()
}
return l.makeToken(TokenString), nil
default: default:
if unicode.IsLetter(c) || c == '_' { if unicode.IsLetter(c) || c == '_' {
// assemble variable // assemble variable