Skip to content

Commit 5476fb3

Browse files
committed
Lower precedence of || + &&.
This will resolve problems with the following program: if ( name == "Steve" && age == 32 ) { puts( "OK\n"); }
1 parent 926e783 commit 5476fb3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

parser/parser.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ type (
2323
const (
2424
_ int = iota
2525
LOWEST
26-
ASSIGN // =
27-
EQUALS // == or !=
28-
CMP
26+
COND // OR or AND
27+
ASSIGN // =
28+
EQUALS // == or !=
2929
LESSGREATER // > or <
3030
SUM // + or -
3131
PRODUCT // * or /
@@ -55,8 +55,8 @@ var precedences = map[token.Type]int{
5555
token.ASTERISK_EQUALS: PRODUCT,
5656
token.POW: POWER,
5757
token.MOD: MOD,
58-
token.AND: CMP,
59-
token.OR: CMP,
58+
token.AND: COND,
59+
token.OR: COND,
6060
token.LPAREN: CALL,
6161
token.PERIOD: CALL,
6262
token.LBRACKET: INDEX,

0 commit comments

Comments
 (0)