[antlr-interest] a question about warnings

Jim Idle jimi at temporal-wave.com
Thu Jul 31 20:03:40 PDT 2008


On Fri, 2008-08-01 at 08:19 +0530, Prashant Deva wrote:
> I get a warning like this -
> 
> [08:14:47] warning(200): prashant.g:27:18: Decision can match input
> such as "ANY" using multiple alternatives: 1, 2
> As a result, alternative(s) 2 were disabled for that input
> 
> In the statement  above does it mean that both alternatives were
> disabled or just the 2nd one?


As the warning says, it disables only the second option. 
Use ANTLRWorks to check the grammar and then work out which alt this
is. 

> Is there any way to tell antlr which specific alternative to disable?


No but you don't so much want that as to be able to say "A warning here
is fine", which is on a todo list somewhere. However, it is generally
better to write the grammar in such a way as these things don't arise
(if possible).

If taking the first alt is what you want it to do, then put in a
syntactic predicate of one token for alt 1, which is not massively
expensive and will make the warning go away. But, only do this if you
cannot find a way to factor the grammar such that the ambiguity goes
away. Left factoring is what is usually needed. If you are using
'literals' in your grammar, then change to real lexer rules until you
you are fully facile with ANTLR grammars.

Jim

> 
> Prashant
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080731/4db98af0/attachment.html 


More information about the antlr-interest mailing list