123456789101112131415161718192021222324252627282930313233343536 |
- package ast
- import (
- "bytes"
- "code.osinet.fr/fgm/waiig15/token"
- )
- // ReturnStatement fulfills the Node and Statement interfaces.
- type ReturnStatement struct {
- Token token.Token // the token.RETURN token. Why do we need it ?
- Name *Identifier
- ReturnValue Expression
- }
- // String satisfies the Node and fmt.Stringer interfaces.
- 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()
- }
- func (rs *ReturnStatement) statementNode() {}
- // TokenLiteral satisfies the Node interface.
- func (rs *ReturnStatement) TokenLiteral() string {
- return rs.Token.Literal
- }
|