[antlr-interest] 3.0 multiple language support

Jamie Herre jlst at gettysgroup.com
Mon Aug 2 09:14:40 PDT 2004


On Jul 31, 2004, at 4:04 PM, Terence Parr wrote:

> On Jul 30, 2004, at 10:38 PM, Tom Moog wrote:
>
>>
>> The problem of maintaining one grammar with language
>> dependent actions may be partly due to our inclination
>> to think of grammars as simple text files.  Imagine that
>> we used a text editor which could maintain multiple
>> versions of a file.  Such things exist for technical
>> documentation.  I remember reading that this was used
>> for airplane maintenance manuals so that common
>> features were updated for all airplanes, while
>> new models could have custom sections.  A printout
>> was customized according to the model selected.
>
> Yes, this is what we've considered for an IDE: use revision control not
> inheritance to change actions.  You are essentially forking a new
> branch.  Changes can be pushed forward with diff3 like behavior. :)
>

Although I don't have a good idea in mind of how it should be done, I 
have various reasons for wanting ANTLR to be able to do code weaving.

Multiple target languages;
Break up giant .g files;
Help for editors;
Make the grammar easier to read by relocating big actions.

It seems like the LHS could be used as a signature for weaving in 
actions from alternate grammars in a manner similar to the mixin 
pattern.  There's no super, the mixed in grammar overwrites methods for 
each LHS it implements.  I guess that's basically how inheritance works 
now but with multiple mixins.  If you overwrite an existing rule, it 
becomes inaccessible and is forever known as the new rule.

There might also be a special LHS syntax for overwriting just the 
action.  Like,

NEWLINE:: { gotit(); } ;

So that you could write out a grammar with no actions and mix in the 
actions from elsewhere.  This would allow .g files to be used as 
documentation as-is with implementation maintained elsewhere.








 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list