[antlr-interest] more specific (lang independent?) actions (WAS: header sections)
Terence Parr
parrt at cs.usfca.edu
Thu Nov 18 10:43:59 PST 2004
On Nov 18, 2004, at 10:34 AM, Monty Zukowski wrote:
> On Nov 18, 2004, at 9:59 AM, Terence Parr wrote:
>> grammar P(...options..., package=org.antlr.test, super=DBGParser);
>>
>> import {
>> import java.io.*;
>> }
>>
>> init {
>> code, not a ctor method def. Just code to init
>> antlr will generate this into the ctor or whatever
>> }
>>
>> fields {
>> String currentMethodName;
>> int level;
>> }
>>
>> methods {
>> public void computeFoo() {
>> ...
>> }
>> }
>>
>>
>
> So are these handled by a generic rule like ID '{' (.)* '}' where the
> stuff inside is just passed as an attribute to the template? So
> antlr.g doesn't have to change if some other language needs its own
> special block?
Wow. Devious thought. I like the flexibility so any language target
could require special code sections. We'd probably have to make it
section fields {
....
}
rather than
fields {
}
A VERY interesting idea. C++ might need a whole slew of sections...
Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!
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