Add null literal
Some checks failed
Build / build (push) Successful in 1m30s
Test / build (push) Has been cancelled

This commit is contained in:
Chuck Smith
2024-03-19 16:33:13 -04:00
parent 60d27f09d7
commit 97eeae0c1a
9 changed files with 59 additions and 0 deletions

View File

@@ -64,6 +64,7 @@ func New(l *lexer.Lexer) *Parser {
p.registerPrefix(token.MINUS, p.parsePrefixExpression)
p.registerPrefix(token.TRUE, p.parseBoolean)
p.registerPrefix(token.FALSE, p.parseBoolean)
p.registerPrefix(token.NULL, p.parseNull)
p.registerPrefix(token.LPAREN, p.parseGroupedExpression)
p.registerPrefix(token.IF, p.parseIfExpression)
p.registerPrefix(token.FUNCTION, p.parseFunctionLiteral)
@@ -552,3 +553,7 @@ func (p *Parser) parseAssignmentStatement() ast.Statement {
func (p *Parser) parseComment() ast.Statement {
return &ast.Comment{Token: p.curToken, Value: p.curToken.Literal}
}
func (p *Parser) parseNull() ast.Expression {
return &ast.Null{Token: p.curToken}
}