commit cfa21e313f6b842cf3c1e4e8c02c021cde91a2af
parent bf1df56370215b914d5a0e9ff416da6eb50b1500
Author: bsandro <email@bsandro.tech>
Date: Sun, 19 Jun 2022 00:13:34 +0300
go fmt
Diffstat:
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/ast/ast.go b/ast/ast.go
@@ -178,11 +178,12 @@ func (il *IntegerLiteral) String() string {
}
type IfExpression struct {
- Token token.Token
- Condition Expression
+ Token token.Token
+ Condition Expression
Consequence *BlockStatement
Alternative *BlockStatement
}
+
func (ie *IfExpression) expressionNode() {}
func (ie *IfExpression) TokenLiteral() string {
return ie.Token.Literal
@@ -201,9 +202,10 @@ func (ie *IfExpression) String() string {
}
type BlockStatement struct {
- Token token.Token
+ Token token.Token
Statements []Statement
}
+
func (bs *BlockStatement) expressionNode() {}
func (bs *BlockStatement) TokenLiteral() string {
return bs.Token.Literal
diff --git a/parser/parser.go b/parser/parser.go
@@ -290,7 +290,7 @@ func (p *Parser) parseBlockStatement() *ast.BlockStatement {
p.nextToken()
for !p.curTokenIs(token.RCURLY) && !p.curTokenIs(token.EOF) {
statement := p.parseStatement()
- if statement != nil {
+ if statement != nil {
block.Statements = append(block.Statements, statement)
}
p.nextToken()