[antlr-interest] Understand the stringtemplate integration

Vincent Dupuis vincedupuis at hotmail.com
Thu Jul 16 11:23:38 PDT 2009



Hi,

I've been using antlr for couple of years to do code generators for c++.

Before, to generate the output I was embedding the code to format the output directly in the grammar file.

Now, I would like to use stringtemplate to gives the programmer the flexibility to writes it's own output format using template files.
So the parser puts its output in predefined templates.

I'm in front of 2 problems:

First, a parser rule can only generate one template. Like this :

transition
    :    'on' IDENT ('if' a+=identList)? b+=action
        -> transition(tname={$IDENT.text}, conditions={$a}, actions={$b})
    ;

I would like also to generate a second template like this:
        -> event(ename={$IDENT.text})

for the same rule above.

How can I achieve that?


Second, when the template file is missing a template definition, an exception is thrown.
It can happen that the programmer (user) doesn't need all templates, is there a way to not thrown these exception rather than putting empty templates?


Thanks you,

Vincent



_________________________________________________________________
Attention à tous les Humains. Nous sommes vos photos. Libérez-nous de vos disques durs.
http://go.microsoft.com/?linkid=9666050
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090716/5ead449d/attachment.html 


More information about the antlr-interest mailing list