I've usually addressed the problem with a grammar rule roughly like this:

expr : term
| term op term

term : NUMBER
| '(' expr ')'

No recursion. No repetition. If user wants 2+3+4, they have to explicitly write (2+3)+4 or 2+(3+4). Basically, no implicit precedence/assoc.

Comments