Sfoglia il codice sorgente

Parsing Return Statement--AST

runningwater 3 anni fa
parent
commit
fb05623fd6
1 ha cambiato i file con 14 aggiunte e 0 eliminazioni
  1. 14 0
      ast/ast.go

+ 14 - 0
ast/ast.go

@@ -82,3 +82,17 @@ func (i *Identifier) expressionNode() {
 func (i *Identifier) TokenLiteral() string {
 	return i.Token.Literal
 }
+
+// return <expression>;
+type ReturnStatement struct {
+	Token       token.Token // the token.RETURN
+	returnValue Expression
+}
+
+func (rs *ReturnStatement) TokenLiteral() string {
+	return rs.Token.Literal
+}
+
+func (rs *ReturnStatement) statementNode() {
+	panic("implement me")
+}