123456789101112131415161718192021222324252627282930313233343536 |
- package ast
- import (
- "code.osinet.fr/fgm/waiig15/token"
- "bytes"
- )
- // LetStatement is the Node type for Let statements.
- type LetStatement struct {
- Token token.Token // the token.LET token. Why do we need it ?
- Name *Identifier
- Value Expression
- }
- // String implements Node and fmt.Stringer.
- func (ls *LetStatement) String() string {
- var out bytes.Buffer
- out.WriteString(ls.TokenLiteral() + " ")
- out.WriteString(ls.Name.String())
- out.WriteString(" = ")
- if ls.Value != nil {
- out.WriteString(ls.Value.String())
- }
- out.WriteString(";")
- return out.String()
- }
- func (ls *LetStatement) statementNode() {}
- // TokenLiteral satisfies the Node interface.
- func (ls *LetStatement) TokenLiteral() string {
- return ls.Token.Literal
- }
|