[antlr-interest] Is ANTLR Hallucinating?
Randall R Schulz
rschulz at sonic.net
Mon Jun 25 12:13:23 PDT 2007
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.
> ...
>
> Without seeing your entire grammar I can't comment on what the
> problem is but ANTLR evidently thinks there is more than one way to
> match rule "clText" zero or more times followed by an EOF. That is,
> although there are no explicit alternatives in your "clifFile" rule,
> the ambiguity creeps in anyway in the other rule(s) referenced from
> that rule.
It's too large a grammar to include in toto.
The grammar is somewhat Lisp-like (or KIF like, if you're familiar with
that language), so all the top-level constructs begin with an open
parenthesis (the Open token in the rule I showed).
It's possible this is the consequence of some other ambiguities I have
yet to resolve. The people who wrote the BNF from which this ANTLR
grammar is being derived are not accustomed to dealing with parser
generators, I don't think.
> Cheers,
> Wincent
Randall Schulz
More information about the antlr-interest
mailing list