Improving parsing and specs

This commit is contained in:
Martino Ferrari
2026-01-22 03:15:42 +01:00
parent b2e963fc04
commit a88f833f49
5 changed files with 59 additions and 9 deletions

View File

@@ -22,6 +22,7 @@ const (
TokenPragma
TokenComment
TokenDocstring
TokenComma
)
type Token struct {
@@ -109,7 +110,7 @@ func (l *Lexer) NextToken() Token {
return l.emit(TokenEOF)
}
if unicode.IsSpace(r) || r == ',' {
if unicode.IsSpace(r) {
l.ignore()
continue
}
@@ -121,6 +122,8 @@ func (l *Lexer) NextToken() Token {
return l.emit(TokenLBrace)
case '}':
return l.emit(TokenRBrace)
case ',':
return l.emit(TokenComma)
case '"':
return l.lexString()
case '/':

View File

@@ -235,6 +235,10 @@ func (p *Parser) parseValue() (Value, error) {
arr.EndPosition = endTok.Position
break
}
if t.Type == TokenComma {
p.next()
continue
}
val, err := p.parseValue()
if err != nil {
return nil, err