sdiehl / kaleidoscope

Haskell LLVM JIT Compiler Tutorial
http://www.stephendiehl.com/llvm
Other
1.03k stars 131 forks source link

Precedence on `|` operator is problematic #44

Open yigitozkavci opened 7 years ago

yigitozkavci commented 7 years ago

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.