[antlr-interest] Newbie Help
Mike Gering
mgering at us.ibm.com
Wed Jan 14 07:52:19 PST 2009
Markus,
Thanks for the response. I'm stuck with 2.7.7 because our legal guys have
not approved us to use any version 3 releases, and I have no realistic
hope that they will any time soon :-(
The problem with setting the lookahead depth is that no number is
sufficient because the (SLASH simple_name)* block comes between the two
problem blocks. So this example should be matched: a*b*c/d/e/f*2. The
lookahead has to span the /d/e/f tokens.
Mike
IBM
(919) 732-5020
From:
Markus Stoeger <markus.stoeger at fh-hagenberg.at>
To:
Mike Gering/Raleigh/IBM at IBMUS
Date:
01/13/2009 06:07 PM
Subject:
Re: [antlr-interest] Newbie Help
Hi Mike,
I'm using ANTLR 3.1.1 and it compiles without errors or warnings. Is
there a reason why you're still using 2.x?
The STAR in a and b would only cause a problem if you used only one
token of lookahead. With more than one token of lookahead ANTLR should
be able to figure out the correct symbol itself.
Can you try setting the following option at the top of your grammar and
see if that helps?
options {
k=2;
}
Max
Mike Gering schrieb:
>
> I'm learning Antlr (version 2.7.7) and cannot figure out how to
> disambiguate a simple grammar:
>
> programmatic_unit
> : simple_name a b
> ;
>
> a
> : (STAR simple_name )*
> (SLASH simple_name)*
> ;
>
> b
> :
> ( (STAR)
> INT)?
> ;
>
> simple_name
> : NAME_FRAG
> ((SPACE)? NAME_FRAG)*
> ;
>
> 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.
>
> Thanks,
> Mike
> IBM
> (919) 732-5020
> ------------------------------------------------------------------------
>
>
> 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/daa9915f/attachment.html
More information about the antlr-interest
mailing list