[antlr-interest] Producing multiple output file from a single AST - best strategy?
researcher0x00 at gmail.com
Fri Oct 28 04:12:52 PDT 2011
On Fri, Oct 28, 2011 at 1:50 AM, Voelkel, Andy <andy.voelkel at plantronics.com
> I have a project where I have to produce multiple output files (C source
> files) from a single AST. It seems clear at this point that using
> StringTemplate to produce the output files makes the most sense. So how do I
> get multiple StringTemplate "streams" from a single AST? I can think two
> 1. Write separate tree grammars to produce the separate outputs,
> using built-in ANTLR-to-StringTemplate integration.
> 2. Write one tree grammar, and use helper functions to build the
> separate outputs using manual creation of StringTemplates.
> 3. Or is there another way?
> Approach #1 has the advantage of being able to use the built in integration
> between ANTLR and StringTemplate. But the disadvantage is that if I change
> the AST structure, I have to change all the tree grammar files, rerun the
> code generation, etc. Right now I'm leaning towards the helper functions
> which construct StringTemplates manually. Does anyone have any advice? I'm
> assuming that I can't use ANTLR-StringTemplate integration and also produce
> multiple StringTemplates with a single tree grammar. Do I have this right?
> - Andy
Take a look at the cminus example in
http://www.antlr.org/download/examples-v3.tar.gz. Cminus demonstrates String
Templates by emitting source code for Python, Java, and Bytecode.
Hope that helps, Eric
> CONFIDENTIALITY NOTICE: This e-mail transmission, and any documents, files
> or previous e-mail messages attached to it, may contain information that is
> confidential and/or legally privileged. If you are not the intended
> recipient, or a person responsible for delivering it to the intended
> recipient, please DO NOT disclose the contents to another person, store or
> copy the information in any medium, or use any of the information contained
> in or attached to this transmission for any purpose. If you have received
> this transmission in error, please immediately notify the sender by reply
> email or at privacy at plantronics.com, and destroy the original transmission
> and its attachments without reading or saving in any manner.
> For further information about Plantronics - the Company, its products,
> brands, partners, please visit our website www.plantronics.com.
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
More information about the antlr-interest