[antlr-interest] 3.0 multiple language support

Rodrigo B. de Oliveira rbo at acm.org
Tue Aug 3 13:57:42 PDT 2004


Ric Klaren wrote:

>On Tue, Aug 03, 2004 at 12:55:32PM -0400, 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 */
>>}
>>    
>>
>
>Problem is that this leads to really silly naming schemes when the rule
>becomes complex. Separate stuff for before a closure, stuff for inside a
>closure. Then add a few more closures to a rule and you'll have a nice
>piece of code you'd not want to touch with a 10ft pole. You'd get lost in
>the functioncalls, the rule itself and lose the overview of what it
>actually does (as also happens with the one graphical grammar editor I've
>seen so far).
>  
>

Yes. Crazy stuff.

Sorry for getting late on the thread but have you already considered the 
idea of an action language?

By action language I mean a very simple language with basic constructs 
that could then be translated to whatever
language the generated parser will be in.

I don't know how you're planning code generation to be but maybe the 
asp.net codedom might serve you as a
good model?

asp.net pages too support multiple target languages and what they 
basically do there is to have the general asp.net parser
to just build an ast, the ast is then handled over to the appropriate 
language component that should then translate it
 to the apropriate source code form.

I understand this somewhat

>A special editor could help but I don't see that as a real option I
>*really* like plain textfiles for writing my grammars.
>
I wouldnt use antlr if it required some sort of special editor and I 
guess most coders wouldnt as well.

>How many people are actively using one grammar cross language? Is this
>really worth the effort?
>
>  
>

I'm just not using a cross language grammar because of the efforts 
involved. I'd love to be able to use my grammar
(target language is c#) as a start point to a java-based eclipse plugin 
but I cant (unless I use ikvm).

Rodrigo




 
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