[antlr-interest] Confusing, hopefully-final, problems

Johannes Luber jaluber at gmx.de
Mon Mar 2 09:38:33 PST 2009


Sam Barnett-Cormack schrieb:
> Jim Idle wrote:
>> The things you are seeing are standard things that happen when you
>> start out by typing in a grammar from the normative grammar of some
>> language spec. Such language specs are not really written with writing
>> a parser spec in mind (most say this) and even if they are they are
>> usually written with yacc/bison in mind. Consequently they are full of
>> ambiguities that you must left factor as you go.
> 
> Well, I didn't just blindly copy them out, although I'll admit I got
> tied up in left-recursion issues. The grammar actually seems to have
> some ambiguities that would be ambiguous anywhere, actually, which is a
> pain in the neck, by c'est la vie.
> 
> I also didn't want to refactor it anymore than necessary because there
> is a relationship between the structure of rules in the standard and the
> semantic structure, which should help at later stages.

You can undo the left-factoring when doing rewrites of the AST. It helps
if you use imaginary tokens to disambiguate ambiguities for the tree parser.

Johannes


More information about the antlr-interest mailing list