From 79cc8e14b86c08200a7ac4659019f2987c89cc60 Mon Sep 17 00:00:00 2001 From: mido Date: Wed, 11 Jan 2023 03:49:10 -0800 Subject: [PATCH] fix merge conflict --- parser/parser.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/parser/parser.go b/parser/parser.go index d5ccc6b..0a8af5b 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -2,7 +2,6 @@ package parser import ( "fmt" - "reflect" "strconv" "strings" @@ -108,9 +107,7 @@ func (p *parser) parseProgram() *ast.Program { } } - if stmt != nil && - (reflect.ValueOf(stmt).Kind() == reflect.Ptr && !reflect.ValueOf(stmt).IsNil()) && - strings.TrimSpace(stmt.String()) != "" { + if stmt != nil && strings.TrimSpace(stmt.String()) != "" { program.Statements = append(program.Statements, stmt) } @@ -162,6 +159,9 @@ func (p *parser) parseStatement() ast.Statement { switch p.curToken.Type { case token.LET: l := p.parseLetStatement() + if l == nil { + return nil + } return l case token.S_START: p.nextToken() @@ -202,7 +202,7 @@ func (p *parser) parseLetStatement() *ast.LetStatement { stmt.Name = &ast.Identifier{TokenAble: ast.TokenAble{Token: p.curToken}, Value: p.curToken.Literal} if !p.expectPeek(token.ASSIGN) { - return nil + return stmt } p.nextToken()