[antlr-interest] warning(200), error(201), error(211) and error(208). Help!

John B. Brodie jbb at acm.org
Fri Oct 7 18:09:10 PDT 2011


On Fri, 2011-10-07 at 16:22 -0700, mglyons wrote:
> Thanks again!  I did what you said and also figured out how to do some
> left-factoring.  I had to fix 3 left-factoring issues and resolved two of
> them.  This one I cannot seem to figure out:
> 
> *expr		: var '=' expr | simple_expr;*
> 
> I do not think you need any more info to solve or understand that one. I
> need some guidance or a push in the right direction for this one.

actually without seeing the rest of the grammar i am not really sure.
but it looks like you can recast the above expr rule as this:

expr : ( var '=' )* simple_expr ;

however this will introduce an ambiguity if var is a complex structure
that can match an infinite sentential form, which is probably the case
in your c-like language...

> 
> My long list of errors is getting smaller and smaller and it feels good. 
> After I finish this last left-factor problem, I will move on to the other
> issues.
> 

sometimes, i find, that when trying to convert an existing grammar into
the LL(*) form used by ANTLR that it can be easier to start with a very
small unambiguous "core" portion of the original language and then add
language features slowly in small steps resolving any issues that arise
at each small step. build up a suite of short sentential forms that
exercise the grammar at each step and that can be used to regression
test the next step in order to ensure no language feature got broken as
the grammar evolves.




More information about the antlr-interest mailing list