[antlr-interest] Strange ambiguous decision warning

Martin Probst mail at martin-probst.com
Wed Apr 2 01:19:20 PDT 2008


Hi all,

I'm running into a seemingly strange ambiguity warning with ANTLR 3  
(latest beta).

I have a rule like this:
sequenceType	:	(EMPTY_SEQUENCE '(' ')')
			| (itemType occurrenceIndicator) => (itemType occurrenceIndicator)
			| itemType ;
occurrenceIndicator	
		:	'?' | '*' | '+';
itemType	:	kindTest | (ITEM '(' ')') | atomicType ;
kindTest	:	...;
atomicType	:	qNameOrIdent ;
qNameOrIdent	:	QNAME | EMPTY_SEQUENCE | ...;

ANTLR complains about sequenceType:
ANTLR Parser Generator  Version 3.1b1 (??)  1989-2007
warning(200): /Users/martin/workspace/XQPretty/src/antlr/XQuery.g: 
235:14: Decision can match input such as "EMPTY_SEQUENCE" using  
multiple alternatives: 1, 2, 3
As a result, alternative(s) 2,3 were disabled for that input

Now the problem is: I cannot isolate the (apparent) bug into a small  
example. The sequenceType rule is of course part of a larger grammar  
(XQuery), which is quite complex. If I just excerpt all the rules  
below sequenceType, the problem does not occur. Which is pretty  
strange, as there is no more recursion, sequenceType is a dead end wrt  
the grammar.

I've attached the full XQuery grammar. There are still some lexical  
issues, but I've more or less disabled those rules, so this is the  
only problem the grammar currently has (I hope...).

I'd be grateful for any input on this.

Thanks,
Martin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: XQuery.g
Type: application/octet-stream
Size: 14772 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080402/bf7cbf2f/attachment.obj 
-------------- next part --------------



More information about the antlr-interest mailing list