At 04:43 15/01/2009, Mike Gering wrote: >Thanks for the suggestion, but no value of k will work because >the grammar accepts an optional list of tokens between (STAR >simple_name)* and "b". For example: > x*x*x*y/y/y*z >should be accepted. The series of slash terms can be arbitrarily >long or absent.
The slashes shouldn't be a factor. The way your rules are written, as soon as it sees a single slash term it's no longer possible for it to match the star terms as part of "a" -- any star appearing after it must be a "b". In other words, "x*x*x*y/y/y*z" is simply illegal; "x*x*x*y/y/y*2" should be interpreted as three STAR terms (from a) followed by two SLASH terms (from a) and finally one STAR term (from b). There shouldn't be any ambiguity there. Where you *will* get ambiguity with k=1 is for the input "x*x*2" -- on seeing the "*" following the "x"s, ANTLR needs to look ahead one more character (k=2) to discover that it can't satisfy the STAR block in "a", but must instead fall out and go process it as a "b" instead. So k=2 really should be all you need, given the rules you've posted thus far. 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 -~----------~----~----~----~------~----~------~--~---
