[antlr-interest] Can subrules be set to 'n-to-m'?
John D. Mitchell
johnm-antlr at non.net
Fri Mar 25 15:27:29 PST 2005
>>>>> "Jamie" == Jamie Ferguson <jferguson at aptas.com> writes:
[...]
> Why do you consider these cases:
> (XYZ)*[0,n] means 0..n occurrences. (XYZ)*[n,m] means 0, or n..m
> occurrences. (XYZ)*[n] means 0 or exactly n occurrences.
> not justifiable to include?
(A) Thanks for asking!
(B) To be clear, please note that I wrote that I wasn't sure whether they
are justifiable or not. That's a good bit different from your restatement.
(C) Basically, it's easy to argue that they aren't used much and that they
are so close to the + variety that people would get weird behavior that
they wouldn't understand. It's also arguable that the zero versus some
number of instances test should be done in a semantic pass against e.g.,
the AST rather than in the parser.
(D) As I mentioned, I think they are actually useful; would be
consistent and coherent with the * vs. + separation that we already have
now; and should be in lexers, parsers, and tree walkers.
Hope this makes sense,
John
More information about the antlr-interest
mailing list