[antlr-interest] Newbie Help
Mike Gering
mgering at us.ibm.com
Wed Jan 14 07:53:27 PST 2009
Gavin,
Ooops -- my example should have been a little different: x*x*x*y/y/y*2
Mike
IBM
(919) 732-5020
From:
Mike Gering/Raleigh/IBM at IBMUS
To:
Gavin Lambert <antlr at mirality.co.nz>
Cc:
antlr-interest at antlr.org
Date:
01/14/2009 10:44 AM
Subject:
Re: [antlr-interest] Newbie Help
Gavin,
Thanks for the suggestion, but no value of k will work because the grammar
accepts an optional list of tokens between (STAR simple_name)* and "b".
For example:
x*x*x*y/y/y*z
should be accepted. The series of slash terms can be arbitrarily long or
absent.
Mike
IBM
(919) 732-5020
From:
Gavin Lambert <antlr at mirality.co.nz>
To:
Mike Gering/Raleigh/IBM at IBMUS, antlr-interest at antlr.org
Date:
01/14/2009 04:42 AM
Subject:
Re: [antlr-interest] Newbie Help
At 09:50 14/01/2009, Mike Gering wrote:
>I'm learning Antlr (version 2.7.7) and cannot figure out how to
>disambiguate a simple grammar:
[...]
>a
> : (STAR simple_name )*
> (SLASH simple_name)*
> ;
[...]
>The generator complains that the "a" rule above is
>nondeterministic upon STAR. I understand (I think) why -- when
>matching programmatic_unit/a, it is ambiguous whether to use "a"
>or "b" when STAR is the next token. But how do I repair the
>grammar? Any advice would be very welcome.
Setting the option k=2 should do the trick. ANTLR needs to look
ahead two tokens (ie. to the token following the STAR) to figure
out whether it's a NAME_FRAG or an INT (and hence which path it
should take).
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090114/4a7d7011/attachment.html
More information about the antlr-interest
mailing list