diff options
Diffstat (limited to 'pkg/lang/ast')
| -rw-r--r-- | pkg/lang/ast/op.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pkg/lang/ast/op.go b/pkg/lang/ast/op.go index f5fce51..6f48e0c 100644 --- a/pkg/lang/ast/op.go +++ b/pkg/lang/ast/op.go @@ -59,14 +59,15 @@ func BinOpFromToken(tok token.Token) (BinOp, bool) { func (op BinOp) Precedence() int { switch op { - case BinOpPlus, BinOpMinus: + case BinOpAssign: return 1 - case BinOpStar, BinOpSlash, BinOpPercent: + case BinOpEq, BinOpNeq, BinOpLt, BinOpLte, BinOpGt, BinOpGte: return 2 - case BinOpAssign: + case BinOpPlus, BinOpMinus: return 3 - case BinOpEq, BinOpNeq, BinOpLt, BinOpLte, BinOpGt, BinOpGte: + case BinOpStar, BinOpSlash, BinOpPercent: return 4 + default: panic(fmt.Sprintf("unknown binary operator: %d", op)) } |
