[email protected] wrote:
It is only inherently ambiguous because you have not encode the semantics within the grammar. The change I made probably does encode the correct semantics as when things are ambiguous like this, the 'reference parser', should there be such a thing, will be choosing one way or another (although really poor languages/parsers sometimes choose one way over the other inconsistently - too many examples to quote here) .On Tue, 3 March, 2009 9:07 pm, Jim Idle wrote:Sam Barnett-Cormack wrote: So, all I did with the predicates is force the parser to consume tokens in the longest match. Say you can have: a : r1 | r2; r1 : A B?; r2 : B; Obviously the B can match in rule r1 or rule r2 (although ANTLR can deal with that, it is because your grammar is more complicated that it cannot in your case). So you have to define the behavior. Usually, you will want the B? to belong to r1: r1 : A ((B)=>B)? ; Which is the nature of the predicates I added to your grammar. I finally found a version of the language spec for ASN.1 and I think that the predicates I gave you are correct, but I cannot guarantee either that, or that your grammar is complete and correct ;-) Jim --~--~---------~--~----~------------~-------~--~----~ 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
