xgo/compiler/ast/binary_expr.go

31 lines
689 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package ast
import (
2019-01-11 13:27:28 +03:00
"github.com/d5/tengo/compiler/source"
"github.com/d5/tengo/compiler/token"
2019-01-09 10:17:42 +03:00
)
// BinaryExpr represents a binary operator expression.
2019-01-09 10:17:42 +03:00
type BinaryExpr struct {
LHS Expr
RHS Expr
2019-01-09 10:17:42 +03:00
Token token.Token
TokenPos source.Pos
2019-01-09 10:17:42 +03:00
}
func (e *BinaryExpr) exprNode() {}
// Pos returns the position of first character belonging to the node.
func (e *BinaryExpr) Pos() source.Pos {
return e.LHS.Pos()
2019-01-09 10:17:42 +03:00
}
// End returns the position of first character immediately after the node.
func (e *BinaryExpr) End() source.Pos {
return e.RHS.End()
2019-01-09 10:17:42 +03:00
}
func (e *BinaryExpr) String() string {
return "(" + e.LHS.String() + " " + e.Token.String() + " " + e.RHS.String() + ")"
2019-01-09 10:17:42 +03:00
}