I am trying to expand the grammar of a tiny language to handle assignment as an expression. Thus, it would be correct to write
a = b = 1;
Assignment differs from other operators in two aspects. This is the correct associative (not a big deal), and its left side should be variable. So I changed this grammar as follows
statement: assignmentExpr | functionCall ...; assignmentExpr: Identifier indexes? '=' expression; expression: assignmentExpr | condExpr;
This does not work because it contains a non-LL (*) solution. I also tried this option:
assignmentExpr: Identifier indexes? '=' (expression | condExpr);
but I got the same error. I'm interested in
- This specific question
- Given a grammar with a solution other than LL (*), how to find the two paths that cause the problem
- How to fix it.
source share