kaleidoscope
kaleidoscope copied to clipboard
Precedence on `|` operator is problematic
In the kicking-the-tires part, we used:
def binary == 9 (LHS, RHS) =
!(LHS < RHS | LHS > RHS);
However, precedence of |
should be higher than both <
and >
in order to use it properly without brackets. These two expressions are being evaluated to two different results now:
putchar(30 < 31 | 30 > 31); # 0.0, wrong
putchar((30 < 31) | (30 > 31)); # 1.0, right
It's fixed by adding binary ">" Ex.AssocLeft
just in near binary "<" Ex.AssocLeft
in the parser, but don't know if it's the right solution.