[antlr-interest] Re: nice threads
    Brian Smith 
    brian-l-smith at uiowa.edu
       
    Fri Jun 14 14:31:12 PDT 2002
    
    
  
mzukowski at yci.com wrote:
>>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.
I do agree that graph-rewriting seems more useful, but only if the 
graph-rewriting language has enough "power".
But, I believe I mis-stated the SableCC technique. They generate a set 
of classes that represent the AST, _and_ they generate a "visitor" 
abstract class. The "visitor" is the basic implementation of the visitor 
pattern. Basically, each pass subclasses the visitor abstract class and 
overrides the appropriate methods.
I am doing something similar to SableCC, but instead of operating on 
grammars I am operating on Abstract Syntax Graphs in the form of MOF 
models (MOF is a subset of UML used to model the static-semantics/ 
abstract-syntax of modeling and programming languages). That is, I 
generate a visitor from the abstract syntax's UML diagram, and I call 
this visitor while walking the composition associations in the diagram.
 > 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.
> 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.
This does seem very interesting. Thanks for the pointer.
- Brian
 
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
    
    
More information about the antlr-interest
mailing list