From f8f7ec04c7becbf51b2c81469887a89f3d3b0617 Mon Sep 17 00:00:00 2001 From: tijani Date: Mon, 23 May 2022 14:24:35 +0000 Subject: [PATCH] Basic AST to represent expressions, statement, identifiers I now understand how it works. git-svn-id: https://svn.tlawal.org/svn/monkey@10 f6afcba9-9ef1-4bdd-9b72-7484f5705bac --- ast/ast.go | 50 -------------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 ast/ast.go diff --git a/ast/ast.go b/ast/ast.go deleted file mode 100644 index 3080356..0000000 --- a/ast/ast.go +++ /dev/null @@ -1,50 +0,0 @@ -package ast - -import "monkey/token" - -type Node interface { - TokenLiteral() string -} - -type Statement interface { - Node - statementNode() -} - -type Expression interface { - Node - expressionNode() -} - -type Identifier struct { - Token token.Token // the token.IDENT token - Value string -} - -type Program struct { - Statements []Statement -} - -type LetStatement struct { - Token token.Token // the token.LET token - Name *Identifier - Value Expression -} - -func (ls *LetStatement) stamementNode() {} -func (ls *LetStatement) TokenLiteral() string { - return ls.Token.Literal -} - -func (i *Identifier) expressionNode() {} -func (i *Identifier) TokenLiteral() string { - return i.Token.Literal -} - -func (p *Program) TokenLiteral() string { - if len(p.Statements) > 0 { - return p.Statements[0].TokenLiteral() - } else { - return "" - } -}