compiler-in-go/pkg/ast/return.go
jmug 9c32fe1d31 Rename module to "compiler-in-go"
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
2025-01-13 19:56:56 -08:00

26 lines
587 B
Go

package ast
import (
"bytes"
"code.jmug.me/jmug/compiler-in-go/pkg/token"
)
type ReturnStatement struct {
Token token.Token // TODO: This is a little redundant, figure out if I can get rid of it.
ReturnValue Expression
}
func (rs *ReturnStatement) statementNode() {}
func (rs *ReturnStatement) TokenLiteral() string {
return rs.Token.Literal
}
func (rs *ReturnStatement) String() string {
var out bytes.Buffer
out.WriteString(rs.TokenLiteral())
if rs.ReturnValue != nil {
out.WriteString(" " + rs.ReturnValue.String())
}
out.WriteString(";")
return out.String()
}