[antlr-interest] Re: nice threads

Brian Smith brian-l-smith at uiowa.edu
Fri Jun 14 13:03:39 PDT 2002

Terence Parr wrote:
>>Is grammar subclassing still appropriate?
> I think it should be a function of the environment.  I.e, have a library 
> of rules/grammars in your repository and then pick and choose stuff to 
> grab to begin a new grammar.  A live push-forward-changes sort of thing 
> is the same as inheritance ;) (I think they call that RCS) ;) ;)

I think that what is needed is a "rule import" mechanism, instead of 
subclassing. If you did this, then I could import rules from more than 
one grammar and do so selectively. Also, my parser could import all the 
rules from my lexer, and then when I run my parser grammer through ANTLR 
it can actually tell me which lexer rules I forgot at code-generation 
time, instead of me having to figure it out at runtime.

>>When I think about grammars and aspects I think actions--AspectANTLR 
>>be the tool to weave your actions into your pure antlr grammars.  The 
> Oooooooohhhhhh.  Now THAT is the perfect explanation of what an Aspect 
> is.  You don't want to modify a grammar physically just to add actions 
> into the right spot!.  Oohhhh.

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.

- Brian


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

More information about the antlr-interest mailing list