0

I had generated AST of java grammer using Antlr.

I had made some alterations in the AST, Now I need to write the AST as Java File at a particular location.

Could any one suggest me the available ways to do the same.

Thanks in Advance!

Anoob C I
  • 171
  • 13
  • To generate a String of Java code from the AST you should be able to just traverse the tree and output each node's content in the right order. Writing the data to a file is straight forward then. – JimmyB Nov 18 '14 at 11:10
  • @IraBaxter Thank you so much. Hope this helps me a lot. – Anoob C I Nov 19 '14 at 06:02

1 Answers1

1

There's more to this than "walk the tree and spit text". See this SO answer for how to do prettyprinting

ANTLR has so-called "string templates" which are likely to be of some help here.

Community
  • 1
  • 1
Ira Baxter
  • 91,210
  • 21
  • 166
  • 327