[antlr-interest] 3.0 multiple language support

Sebastian Kaliszewski sk at z.pl
Wed Aug 4 05:29:42 PDT 2004


Tiller, Michael (M.M.) wrote:
>>How about allowing different language versions of the same action in
>>the same file? Something like:
>>
>>my_prod
>>   : my_subpod %C{ /* here C action comes */  }
>>               %J{ /* here java action goes */ }
>>               %P{ /* here python action goes */ }
> 
> 
> 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 */
> }
> 

I really don't like this. Actions (esp. predicates) are part of the grammar. 
Separating them makes code much harder to read, analyse and maitain, as one 
has to jump around the code text.
Macros might be a nice idea, but they should be intermixable with the 
parser/lexer definition in the same file.

rgds
-- 
Sebastian Kaliszewski



 
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