[antlr-interest] Composite Tree Grammars are things of beauty, but ...

Jim Idle jimi at temporal-wave.com
Thu Mar 10 06:35:40 PST 2011


Gary,

Hope things are good and that your product is coming along nicely!

The best way to deal with this to have your main including grammar
implement a superclass, then all the other grammars will inherit it. That
is where all your extra code and variables go and it works better that
way. If you use Maven, my archetype will create this structure for you out
of the box. Don’t put anything in the .g files that you can put in the
super class.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Gary Miller
> Sent: Wednesday, March 09, 2011 7:15 PM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Composite Tree Grammars are things of
> beauty, but ...
>
> Hey Terrance,
>
> tree grammar T;
> a : some horrible mess of a RECURSIVE rule; b : B ;
>
> tree grammar U;
> import T;
> a : {pre action} T.a {post action}; // <-- wants to be able to refer to
> super rule
>
> It wouldn't be enough to just expose the super rule T.a.
> In the generated walker A_T the rule 'a' would need to call the
> delegators.a().
>
> > ANTLR technically doesn't expose x.y syntax to the user and so I
> didn't recognize the fact that you invoked the super rule.  It
> extracted only those rules from your super grammar that it needed. It
> does this so that you can fill up libraries of grammars with rules and
> then pick out which ones you want without bloating your generated code.
>
> Thanks for raising the issue.
> Based on my bias ("Composite Tree Grammars are things of beauty") I
> would hope for more than a minor ;-) How do I get a login the JIRA so
> that I can follow issues?
>
> > That said, I am adding an improvement request for consideration.
> >
> > http://www.antlr.org/jira/browse/ANTLR-452
>
> Sorry, I can't parse this. Are you saying that you would like to
> removed imports from ANTLR?
>
> > I'd like to retract or how ANTLR it handles imports anyway.
>
> Regards
> Gary
>
> P.S. is there any reason for ANTLR over Antlr | AntLR | AntLr | antlr
> etc.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list