The operators in the rules section have no operator precedence. It's very useful to include this in the antlr grammar. Something along the lines of:
expr: mult ('+' mult)* ;
mult: atom ('*' atom)* ;
atom: INT | '(' expr ')' ;
You can then simply walk the tree to evaluate expressions.
Useful both for arithmetic and boolean expressions.
The operators in the rules section have no operator precedence. It's very useful to include this in the antlr grammar. Something along the lines of:
You can then simply walk the tree to evaluate expressions.
Useful both for arithmetic and boolean expressions.