parser
This commit is contained in:
+19
@@ -1,5 +1,7 @@
|
||||
package ast
|
||||
|
||||
import "gointerpreter/token"
|
||||
|
||||
type Node interface {
|
||||
TokenLiteral() string
|
||||
}
|
||||
@@ -25,3 +27,20 @@ func (p *Program) TokenLiteral() string {
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
type LetStatement struct {
|
||||
Token token.Token
|
||||
Name *Identifier
|
||||
Value Expression
|
||||
}
|
||||
|
||||
func (ls *LetStatement) statementNode() {}
|
||||
func (ls *LetStatement) TokenLiteral() string { return ls.Token.Literal }
|
||||
|
||||
type Identifier struct {
|
||||
Token token.Token
|
||||
Value string
|
||||
}
|
||||
|
||||
func (i *Identifier) expressionNode() {}
|
||||
func (i *Identifier) TokenLiteral() string { return i.Token.Literal }
|
||||
|
||||
Reference in New Issue
Block a user