[antlr-interest] ANTLR 3.0 question about common actions

Terence Parr parrt at cs.usfca.edu
Wed Jul 28 17:03:40 PDT 2004


On Jul 28, 2004, at 2:09 PM, Tiller, Michael (M.M.) wrote:
> This is a difficult issue and I'm not sure how to address everything 
> you
> are asking for, but I did find it interesting that SLK
> (http://home.earthlink.net/~slkpg/) addresses this by having named
> actions in the grammar.  In other words, there isn't any target code in
> the grammar at all, just names (e.g. method names) that will be filled
> in by the object that implement the parser (in whatever language).

Well, top down recognizers have the advantage (well recursive-descent 
LL anyway) that you can define locals and such and pass parameters 
easily to rules.  Actions need access to these things and moving 
actions into another method somewhere makes this much harder.  This is 
one reason why I don't like this "event model" type action placement.

> This seems like a good way to handle the first issue you raised which 
> is
> how to deal with retargeting since the grammar only defines the hooks
> that an eventual parser must have, but not all the action code.

It is one way, but I'm mainly talking about standard actions like 
'build tree node' not translation actions.

> The tricky part is the "predicate standard actions"?  By this I'm
> assuming you mean things like disambiguation of symbols vs. keywords by
> checking a symbol table.

Something like that or python's messy lexer that needs to decide when 
to ignore NEWLINES etc...

>  It seems like this would be nearly impossible
> to make target language neutral.  Taking the ideas from SLK a step
> further, perhaps you could have a different notation for semantic
> predicates (which should return a Boolean type in the target language)
> from actions.

I've thought that perhaps standard actions go in {...} and language 
specific actions go in <<...>>.  Just a thought.

Thanks,
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