[antlr-interest] Can subrules be set to 'n-to-m'?

Jamie Ferguson jferguson at aptas.com
Fri Mar 25 14:38:12 PST 2005


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?

Jamie



On Fri, 2005-03-25 at 14:13 -0800, John D. Mitchell wrote:

> >>>>> "Martin" == Martin Probst <mail at martin-probst.com> writes:
> [...]
> 
> >> (...)+[n,m]
> 
> >> with the ,m part optional.
> 
> > Uh, better make only the "m" optional, e.g.
> >> (...)+[n,]
> > Otherwise it might be mistaken as "exactly n times". Maybe this should
> > indeed be the case for (...)+[n].
> 
> Yes, I meant that to mean 'exactly".  To be clear...
> 
> (XYZ)+[n,m]  means XYZ must occur anywhere from n through m times
> (inclusive on both ends).
> 
> (XYZ)+[n]  means XYZ must occur exactly n times.
> 
> (XYZ)+[0,n]  should be an error telling people that they should b using:
> 
> (XYZ)*[0,n]  means 0..n occurrences.
> 
> (XYZ)*[n,m]  means 0, or n..m occurrences.
> 
> (XYZ)*[n]  means 0 or exactly n occurrences.
> 
> [Though, personally, I'm not sure that the last three cases are
> justifiable to include in the Antlr core.  I'd like them for completeness
> and consistency and would actually be using them but I know that I'm a
> wacko. :-)]
> 
> > Also (...)[1,] looks at least understandable for me - maybe as an alias
> > for (...)+.
> 
> Naw, if you're going to support an "at least" construct then you've gotta
> make it more clearly distinct than that.  Something like:
> 
> (XYZ)+[n...]   or
> (XYZ)+[n,...]   or
> (XYZ)+[n,+]
> 
> Hope this helps,
> 		John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050325/62516be3/attachment.html


More information about the antlr-interest mailing list