[antlr-interest] Producing multiple output file from a single AST - best strategy?

Voelkel, Andy andy.voelkel at plantronics.com
Thu Oct 27 22:50:38 PDT 2011


Hi,

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 ways:


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

________________________________

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.


More information about the antlr-interest mailing list