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

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
  • 93,541
  • 22
  • 172
  • 341