Skip to content

Commit

Permalink
Fixed logical operator precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
jairo-litman committed Feb 17, 2024
1 parent 3b6c32b commit 1741c51
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (
const (
_ int = iota
LOWEST
LOGICAL // && or ||
LOGICAL_OR // ||
LOGICAL_AND // &&
EQUALS // == or !=
LESSGREATER // <, >, <=, or >=
SUM // + or -
Expand All @@ -29,8 +30,8 @@ For example, the expression 5 + 10 * 2 is grouped as 5 + (10 * 2) because the *
has a higher precedence than the + operator.
*/
var precedences = map[token.TokenType]int{
token.AND: LOGICAL,
token.OR: LOGICAL,
token.OR: LOGICAL_OR,
token.AND: LOGICAL_AND,
token.EQ: EQUALS,
token.NOT_EQ: EQUALS,
token.LT: LESSGREATER,
Expand Down

0 comments on commit 1741c51

Please sign in to comment.