[antlr-interest] what does '##' stand for?
Don Caton
dcaton at shorelinesoftware.com
Sun Mar 13 06:31:15 PST 2005
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org
> [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Prashant Deva
> Sent: Sunday, March 13, 2005 6:19 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] what does '##' stand for?
>
> I am not too familiar with tree grammar stuff.
> What does '##' stand for inside an action.
>
> For example, what does the following rule do -
>
> grammar
> : headerDef ( classDef )* EOF!
> { ## = #([GRAMMAR,"grammar"], ##) ; }
> ;
>
> PRASHANT
>
It's shorthand for the tree that the rule returns. Your example is
equivalent to:
{ #grammar = #([GRAMMAR,"grammar"], #grammar) ; }
I don't think it's documented anywhere. It makes actions a bit less verbose
and if you rename the rule, the action won't break.
--
Don
More information about the antlr-interest
mailing list