aboutsummaryrefslogtreecommitdiff
path: root/ast
diff options
context:
space:
mode:
Diffstat (limited to 'ast')
-rw-r--r--ast/ast.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/ast/ast.go b/ast/ast.go
index 021b387..1942a68 100644
--- a/ast/ast.go
+++ b/ast/ast.go
@@ -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