The problem is the decision inside rule r. Since ANTLR uses lookahead only (as opposed to lookbehind), the decision making doesn't know which instance of r is being parsed. The following would resolve the issue:
s : X r1 A B | Y r2 B ; r1 : A | ; r2 : A | ; -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Alan D. Cabrera Sent: Wednesday, February 02, 2011 11:08 AM To: [email protected] Subject: [antlr-interest] SLL(2) in "The Definitive ANTLR Reference" I was reading about the following grammar on page 287 of the PDF document grammar t; s : X r A B | Y r B ; r : A | ; I don't see where the problem is since the alternatives in s begin with two different tokens X and Y. I think that since these two tokens are different I can easily construct a DFA that would unambiguously parse a stream of tokens. I sense that this example was supposed to bring out a finer point about how ANTLR generates parsers but I'm afraid that it is being lost on me. Regards, Alan List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address 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.
