[antlr-interest] antlr should throw NoViableAltException

femto gary femtowin at gmail.com
Sun Apr 15 07:38:15 PDT 2007


Hi David, thanks for the information,
I'll check it out.

On 4/15/07, David Holroyd <dave at badgers-in-foil.co.uk> wrote:
> On Sun, Apr 15, 2007 at 08:11:39PM +0800, femto gary wrote:
> > also, generating parser will also produce the following warning:
> > [20:08:36] warning(200): Rubyv3.g:101:32: Decision can match input
> > such as "SEMI" using multiple alternatives: 1, 2
> > As a result, alternative(s) 2 were disabled for that input
> >
> > but for the grammar:
> > statement
> >       :       expression (modifier_line)* SEMI? -> ^(STATEMENT expression
> > (modifier_line)*)
> >       |       SEMI!
> >       ;
> > input SEMI shouldn't cause an ambiguity, because expression can't be empty,
> > so either match the alt1 or alt2, why does it will report that warning.
> > Anybody has any ideas? Thanks.
>
> I think that since the grammar allows,
>
>  statement*
>
> the ambiguity is between the alternatives of,
>
>  1) matching 'SEMI?' right now, in this invocation of 'statement', and,
>
>  2) not matching 'SEMI?', exiting this invocation of the 'statement' rule
>    and then matching the 'SEMI!' alternative the next time around the
>    'statement*' loop
>
> Is "1;" to be parsed as
>
>  (STATEMENT 1) (STATEMENT ;)
> or
>  (STATEMENT 1;)
>
>
>
> i.e. the decision being referred to in the message is probably the one
> at the '?', not the one at the '|', if that helps at all :)
>
>
> ta,
> dave
>
> --
> http://david.holroyd.me.uk/
>


-- 
Best Regards
XRuby http://xruby.com
femto http://hi.baidu.com/femto


More information about the antlr-interest mailing list