[antlr-interest] generating multiple files from a single input file

Tom Smith yotommy at gmail.com
Tue Oct 14 11:23:52 PDT 2008


Thanks very much --- this is just the kind of advice I was seeking!

On Tue, Oct 14, 2008 at 2:16 PM, Arnulf Heller <aheller at gmx.at> wrote:
>
> If performance matters you should try to run your parser once and the code
> generation multiple times with the generated AST.
>
> If you want to make use of the string template rewrite mechanism (the "->"
> notation), I think the best way is to have one tree walker and run it
> multiple times with different string template groups (with setTemplateLib).
> If your target files are very similar (like .h and .cpp files) consider
> using the template inheritance mechanism.
>
> If you have a simple grammar, you can also build up a simple data structure
> (e.g. lists of java objects) that you can throw at your string templates
> after parsing. This is probably the fastest way.
>
> A good starting point are the ANTLR sources, particularly the code generator
>


More information about the antlr-interest mailing list