Expression parsing
token term { <variable> | <number> | \( <expression> \) } token unaryop { \+ | - } token mulop { \* | / } token addop { \+ | - } token cmpop { == | \<= | \< | \> | =\> } token andop { \&\& } token orop { \|\| | \^\^ } rule powterm { <term> [ \*\* <term> ]* } rule unaryterm { <unaryop>? <powterm> } rule multerm { <unaryterm> [ <mulop> <unaryterm> ]* } rule addterm { <multerm> [ <addop> <multerm> ]* } rule cmpterm { <addterm> [ <cmpop> <addterm> ]* } rule andterm { <cmpterm> [ <andop> <cmpterm> ]* } rule expression { <andterm> [ <orop> <andterm> ]* }
This gets very tedious. It's also very slow to parse.