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

Loring Craymer Loring.G.Craymer at jpl.nasa.gov
Thu Mar 24 15:08:20 PST 2005


The ISO standard for EBNF, <http://www.cl.cam.ac.uk/~mgk25/iso-14977.pdf>, 
supports fixed count repetition.  However, I find that the cases where you 
would want to restrict repetition are not so common as to merit special 
case treatment:  if you are being this careful, then you have sprinkled in 
enough semantic predicates for other conditions that one more does not 
matter.  Also, you may want to treat a count that is out of range as an 
error condition during a tree walk instead of in the parser.  I must admit 
that I wish for a limited repeat feature whenever I run into the 
problem--the sem preds look ugly--but I don't think that adding a repeat 
count to ANTLR syntax makes sense.

--Loring


At 01:45 PM 3/24/2005, Nigel Sheridan-Smith wrote:



> > -----Original Message-----
> > From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> > bounces at antlr.org] On Behalf Of Prashant Deva
> > Sent: Friday, 25 March 2005 8:38 AM
> > To: antlr-interest at antlr.org
> > Subject: Re: [antlr-interest] Can subrules be set to 'n-to-m'?
> >
> > Ter,
> >  I think you should put this in 3.0 only if it is widely useful, which
> > it doesn't seem to be.
> > For special cases like this, people can use the code like its provided
> > above.
> >
>
>
>Actually I think (...)+[n,m] comes up often enough to make it a useful
>feature of the ANTLR grammar. Using the action code is unwieldy and messy,
>but if there are no other options, then it's the only way.
>
>--
>Nigel Sheridan-Smith
>PhD research student
>
>Faculty of Engineering
>University of Technology, Sydney
>Phone: 02 9514 7946
>Fax: 02 9514 2435




More information about the antlr-interest mailing list