[antlr-interest] Generating initializers and headers

Gavin Lambert antlr at mirality.co.nz
Tue Jan 29 10:43:52 PST 2008


At 02:02 30/01/2008, Nikolas Everett wrote:

>I'm looking to generate C code from antlr/stringtemplate.  I'd 
>like to generate methods in a .c file, method signatures in a .h 
>file, and probably some sort of initialization method in the .c 
>file.  My problem is that any part of the AST could generate code 
>in any of those 3 places.  What is the normal way to handle this?

I did something similar a while ago by creating custom data 
structures via action code, and then iterating through them 
several times in different modes to generate the different output.

If you want to do it more ANTLR-ish, though, then you could have 
your parser create an AST, and then write two or three separate 
tree parsers (one for each output file you want to generate) that 
walk the tree and generate the desired output.


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.19.14/1247 - Release Date: 28/01/2008 10:59




More information about the antlr-interest mailing list