[antlr-interest] Strange ambiguous decision warning

Martin Probst mail at martin-probst.com
Wed Apr 2 11:44:03 PDT 2008


> If you use ANTLRWorks, it will help you to see the following:

Well, ANTLRWorks comes with ANTLR 3.0.1, and that doesn't work at  
all :-(

> Alt1 starts with EMPTY_SEQUENCE
> Alt2 goes to itemType
> At3  goes to itemType
>
> itemType goes to atomicType
>
> atomicType goes to qNameOrIndent
>
> qNameOrIndent contains EMTPY_SEQUENCE
>
> hence all three alts can start with EMPTY_SEQUENCE. as  
> occurenceIndicator is optional, then it is ambiguous.

Why? The parentheses following the literal EMPTY_SEQUENCE are not  
optional, and the occurrence indicator after the second rule is not  
optional either, so all three rules have a different second token -  
k=2 should be sufficient to disambiguate.

> sequenceType	: (EMPTY_SEQUENCE '(')=>(EMPTY_SEQUENCE '(' ')')
> 			| itemType ((occurrenceIndicator)=>occurrenceIndicator)?
> 			;

Thanks, this worked. Though I'm still curious why this was ambiguous...

> Though it is somewhat irrelevant to the issue, you will find your  
> grammar more maintainable if you format it a little ;-)

You don't really want to argue about indentation style, do you? :-)

Thanks again,
Martin


More information about the antlr-interest mailing list