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.
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
What do you do about explaining the more complicated algorithms? I was listening to Jeremy Siek's workshop and he mentioned that his book covers some of it in one chapter and he usually redirects students to the other books.
That's actually a very good solution in general...