[antlr-interest] Can subrules be set to 'n-to-m'?
jferguson at aptas.com
Thu Mar 24 15:53:56 PST 2005
Depends on your domain -- in my domain this functionality is essential.
I don't know enough about how the code generation works to know if this
is a difficult problem to solve, but if it is not it seems like a handy
thing to have even if it is not used often. I would assume that if the
EBNF standard supports it then it is used often enough to make it
I'll try the code approach for now and see how that works. Thanks to
everyone for the feedback. :)
On Thu, 2005-03-24 at 15:08 -0800, Loring Craymer wrote:
> 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.
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest