Gregofi / camel

Custom dynamic programming language
MIT License
6 stars 1 forks source link

Change the grammar of the if statement #54

Open Gregofi opened 1 year ago

Gregofi commented 1 year ago

Ifs are currently written like this: if COND { expr1 } else { expr2 }, change the grammar so they can be written like if (COND) expr1 else expr2.

With this, the dangling else comes into play, that needs to be fixed at the grammar level because LALRPOP apparently doesn't offer any support for shifting before reducing. Also, another ambiguity comes from if (COND) expr1 else expr + 1, this (probably!) can be fixed by just using right rule and not the general Expr rule.

Alternatively, just handwrite the entire parser from scratch. It would however be better to stay away from this for the time being until the grammar settles.