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

Scott Stanchfield scott at javadude.com
Fri Mar 25 04:23:47 PST 2005


I think the "+" is redundant here...

Normally I'd say

  (...){n,m}

but of course that's ambiguous with actions, so

  (...)[n,m]

Should suffice.

BUT,

While I'm at it, can (...) be optional for single-ref repetition? For
example, I'd love to be able to use:

Foo[int x]
  : fee fie+ fo CRUFT* fum[x]*
  ;

and only use parens for multiple ref repetion or action inclusion:

foo
  : fee
    ( fie {...} )+
    fo
    (a b c d)*
  ;


Of course this would mean that foo[n,m] would be ambiguous under my request,
so we would have to do something like

  foo+[x,m]

for n-m repetition...

(But think about what foo+[0,4] means... Kinda the same as foo*[4])


Thoughts?
-- Scott



> -----Original Message-----
> From: antlr-interest-bounces at antlr.org 
> [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Bryan Ewbank
> Sent: Friday, March 25, 2005 2:33 AM
> To: antlr-interest Interest
> Subject: Re: [antlr-interest] Can subrules be set to 'n-to-m'?
> 
> > I'm thinking about this for 3.0.  Perhaps (...)+[n,m] ????
> 
> Are "n" and "m" here constants, or variables?  I ask because 
> this could be used for function call support if they are variables.





More information about the antlr-interest mailing list