ThetaLang / Theta

θ A statically typed, functional programming language that compiles to WebAssembly
https://theta-lang.org
MIT License
38 stars 10 forks source link

Change parser to parse <= and >= as nested BinaryOperation nodes #18

Closed alexdovzhanyn closed 2 months ago

alexdovzhanyn commented 4 months ago

The binaryen IR doesn't support <= and >= operations directly. We could change our CodeGen to generate nested binaryen expressions if we come across a <= or >= sign, but we may as well simplify our own AST structure to match the binaryen IR.

Changing the parser to parse the <= and >= operations as:

5 >= 6

BinaryOperation
  op: "||"
  left:
    BinaryOperation
      op: ">"
      left: "5"
      right: "6"
  right:
    BinaryOperation
      op: "=="
      left: "5"
      right: "6"  

will allow a much simpler CodeGen process.

alexdovzhanyn commented 2 months ago

Turns out it was supported and I just missed it. Was fixed in this commit