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 <[email protected]> To: Mike Gering/Raleigh/i...@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 > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
