[antlr-interest] NoViableAltException in tree grammar
Tom Smith
yotommy at gmail.com
Thu Jul 10 10:01:47 PDT 2008
On Thu, Jul 10, 2008 at 11:41 AM, Jim Idle <jimi at temporal-wave.com> wrote:
> ... Then, while ANTLR will generally work things out for you, you should
> really factor all your parser rules for common sequences, then rewrite the
> token stream with different root nodes if you need to distinguish between
> combinations. This will generally give you the most streamlined parser and
> an AST with no ambiguities (which is what you want). So:
>
>
> top
> : BEFORE AFTER?
> | AFTER
> ;
>
After going back to my original (larger) grammar (complete with lexer
rules!) and factoring out the common part as Jim suggested, the
NoViableAltException went away. I don't yet understand why, but until my
understanding matures, I'll check for left-factoring opportunities when I
run into problems!
Thanks,
Tom.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080710/74cc45e2/attachment.html
More information about the antlr-interest
mailing list