[antlr-interest] Re: nice threads

mzukowski at yci.com mzukowski at yci.com
Fri Jun 14 13:35:58 PDT 2002


> But, how do you specify the joinpoints? Wouldn't you use the grammar 
> rules as the join-points? If so, then you really haven't 
> gained anything.
> 
> Have you looked at SableCC? They don't allow you to put any 
> rules into 
> your grammar. Instead, they automatically generate a bunch of classes 
> that represent a heterogeneous AST. Then you subclass these generated 
> classes to include your code.

But then what do you do about multiple passes?  What you end up doing is
having a bunch of parallel subclasses representing each pass.  The beauty of
a tree grammar is that you abstract away the AST into the rules and get to
reason about it at the scale of the grammar and rules instead of a bunch of
different classes.  

I routinely use "grammar subclassing" to override rules from a master tree
grammar in order to implement a pass.  An aspect would probably not look
much different than one of these subclasses, but instead of overriding rules
(with the potential of inadvertently changing a rule) it would locate a rule
as a joinpoint and then have the action code to weave in.  Should be a
little more robust with a master tree grammar that is under development and
continually changing.

By the way folks, there is an interesting project at www.brics.dk/metafront.
The paper "Growing Languages with Metamorphic Syntax Macros" has some
interesting reasoning about grammar extensions.  Granted the paper is about
LL(1) parsing without actions, but it's pretty cool to see they can reason
about grammar additions and decide whether a particular extension will work
or not.  I am envious and will be lobbying hard for the hooks to allow a
similar functionality to be built into antlr 3.

Monty

www.codetransform.com (Check out my new style sheets!)


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list