diff options
Diffstat (limited to 'ast')
| -rw-r--r-- | ast/ast.go | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -151,6 +151,33 @@ func (pe *PrefixExpression) String() string { return out.String() } +// InfixExpression represents an infix expression. + +type InfixExpression struct { + Token tokens.Token // the operator token, e.g. + + Left Expression + Operator string + Right Expression +} + +func (ie *InfixExpression) expressionNode() {} +func (ie *InfixExpression) TokenLiteral() string { + return ie.Token.Literal +} +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() +} + + // IntegerLiteral represents an integer literal. type IntegerLiteral struct { Token tokens.Token // the token.INT token |
