[antlr-interest] ANTLR 3.0 question about common actions

Terence Parr parrt at cs.usfca.edu
Wed Jul 28 17:51:52 PDT 2004


On Jul 28, 2004, at 1:48 PM, Monty Zukowski wrote:
> Currently you have an escape mechanism that says "this is all target
> language, but pick out the tree stuff and $ stuff," and offers Ric the
> opportunity to complain how ugly this is :)

Yep, gross.

> Inverting it might be appropriate.  How about "this is all standard
> action language, but pick out special things and treat them as target
> language?"  Think macros, real syntactic macros, not just text
> substitution.

Isn't that what we have now with $setType and #[...] that have to be 
parsed out?  Perhaps what we need as you are suggesting below is to 
have template references in code:

lexer grammar(target="Java")
....
NEWLINE : '\n' {if (some-condition) <skip()>;} ;

where <skip()> is a reference to the template called skip in your 
output templates.  It just gets replaced and ANTLR couldn't care less.  
The "Java.stg" file would contain all the stuff one would need to look 
at.

Mainly what I'm talking about is that ANTLR knows nothing about the 
ASTs, for example, defined by the target language.  THe targets pretty 
much have to look at other targets and figure out a similar mechanism 
in their language.  Because of the differences, no two tree mechanisms 
will be the same.  I'm suggesting that we define an exact behavior at 
the ANTLR language level and in the output templates.  Otherwise, the 
documentation is the spec, not the ANTLR tool itself.

So, for example, let's have ANTLR not just say "turn on AST 
construction", but also what properties you want in the tree etc...  
Then, we don't care at all how it gets implemented in the target.  At 
the ANTLR level, you could hook values from tokens into the tree nodes 
etc...

Anyway, have no fear folks...I'll make the system as simple and 
language independent as possible w/o introducing some bizarre and 
complicated mechanism.  I'm just trying to see what ideas people have. 
:)  I'm getting old and you're not supposed to have any good ideas past 
thirty (or so says my physicist friends) ;)

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!
Cofounder, http://www.peerscope.com pure link sharing





 
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