12345678910111213141516171819202122232425262728293031323334353637 |
- package ast
- import (
- "bytes"
- "code.osinet.fr/fgm/waiig15/token"
- )
- // InfixExpression fulfills the Node and Statement interfaces.
- // It represents a prefixed expression like:
- // "-5;"
- type InfixExpression struct {
- Token token.Token
- Left Expression
- Operator string
- Right Expression
- }
- // String satisfies the Node and fmt.Stringer interfaces.
- func (ie *InfixExpression) String() string {
- var out bytes.Buffer
- out.WriteString("(")
- out.WriteString(ie.Left.String())
- out.WriteString(" " + ie.Operator + " ")
- out.WriteString(ie.Right.String())
- out.WriteString(")")
- return out.String()
- }
- func (ie *InfixExpression) expressionNode() {}
- // TokenLiteral satisfies the Node interface.
- func (ie *InfixExpression) TokenLiteral() string {
- return ie.Token.Literal
- }
|