[antlr-interest] Strange ambiguous decision warning
Martin Probst
mail at martin-probst.com
Wed Apr 2 02:08:49 PDT 2008
Am 02.04.2008 um 10:32 schrieb Jeroen Steenbeeke:
> I simplified your grammar a bit to illustrate the problem
>> sequenceType : (EMPTY_SEQUENCE '(' ')')
>> | (itemType occurrenceIndicator) =>
>> (itemType occurrenceIndicator)
>> | itemType ;
>> itemType : atomicType ;
>> atomicType : qNameOrIdent ;
>> qNameOrIdent : EMPTY_SEQUENCE;
> Every single choice in sequenceType can start with EMPTY_SEQUENCE,
> so ANTLR does not have a clue which one to pick.
Well, generally yes, but I thought the point of the LL(*) algorithm is
to disambiguate such decisions by taking the next token into
consideration. I.e. in this case:
* EMPTY_SEQUENCE -> itemType
* EMPTY_SEQUENCE ( ) -> direct match
* EMPTY_SEQUENCE + -> itemType occurrenceIndicator
Btw. as far as I can see the grammar does not allow a sequenceType
declaration to be followed by an open parenthesis, which should rule
out such an ambiguity (and such an error should of course be flagged
in the rule where the following '(' occurs, I think).
Best regards,
Martin
More information about the antlr-interest
mailing list