Explorar o código

Parsing Return Statement--AST

runningwater %!s(int64=3) %!d(string=hai) anos
pai
achega
fb05623fd6
Modificáronse 1 ficheiros con 14 adicións e 0 borrados
  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")
+}