At 20:49 13.10.2008, Tom Smith wrote: >Hello, > >Right now I have a multipass translator to generate code based on a >program written in a DSL (using StringTemplate rewrites). I just >realized that I have enough information in my AST to generate some >other supporting files as well. Is there a straightforward way to >structure this task?
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 List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
