[antlr-interest] Is ANTLR Hallucinating?

Benjamin Niemann pink at odahoda.de
Mon Jun 25 14:19:54 PDT 2007


Randall R Schulz wrote:

> On Monday 25 June 2007 12:04, Wincent Colaiuta wrote:
>> El 25/6/2007, a las 20:33, Randall R Schulz escribió:
>> > Hi,
>> >
>> > I have this production in an ANTLR grammar:
>> >
>> > clifFile
>> >
>> >   : clText * EOF
>> >
>> >   ;
>> >
>> >
>> > It elicits this error from ANTLR:
>> >
>> > warning(200): CLIF.g:1371:4: Decision can match input such as
>> > "{EOF, Open}" using multiple alternatives: 1, 2
>> > As a result, alternative(s) 2 were disabled for that input
>> > warning(201): CLIF.g:1371:4: The following alternatives are
>> > unreachable: 2
>> >
>> >
>> > Why is it talking about alternatives in a rule that has none?
>>
>> Try looking at the syntax diagram in ANTLRWorks so that you can see
>> the two alternative paths.
> 
> Of course, there are not two paths. Just the loop back over the closed
> clText production followed by the EOF token.

After clText the parser has to decide, if it does another iteration of
clText or terminate the loop. That makes two alternatives.

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/



More information about the antlr-interest mailing list