[antlr-interest] 3.0 multiple language support

Terence Parr parrt at cs.usfca.edu
Sun Aug 8 15:00:39 PDT 2004


On Aug 3, 2004, at 9:55 AM, Tiller, Michael (M.M.) wrote:
> Of the options I have seen so far, I prefer the one where the grammar
> just has macros and the actions themselves are specified outside the
> grammar, e.g.
>
> some_rule
>    : a:A "," b:B << process_some_rule(a,b); >>
>
> And then you could weave together an action file with a grammar file.
> So you might have a C++ action file:
>
> void process_some_rule(A *a, B* b)
> {
>   /* Do something very general in this language */
> }

Hi Mike,

The only problem with this approach is that you cannot access variables 
/ attributes of the invoking rule w/o passing them in.  Sometimes you 
need to create locals (due to requirements of recursion) that are 
currently unavailable and then modify the action event trigger 
interface, thereby invaliding all existing grammars.

> With this approach, the only thing you need to formalize are the 
> calling
> conventions (how names and arguments map between the macro language and
> the action language).  One nice consequence of this would be that, for 
> a
> given grammar, you could automatically generate the interface and/or
> function prototypes for it (based on the content of the grammar and the
> conventions).

Well action placement is very important as well.  You cannot put action 
triggers at every location.  Every time I've tried this approach it 
works "ok" for one application but not for more than that.

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