[antlr-interest] from antrl-generated AST back to java-file?

Matthew Ford Matthew.Ford at forward.com.au
Thu Feb 28 02:36:09 PST 2002


Here is a sample of what I use to output statements from a tree (after
transforming them)

statement
{ String str,lhsStr;
 }

 : #(as:ASSIGN_EXPR lhsStr=identOrConstant str = expression)
  {
   Output.out(lhsStr + " " + as.getText() + " " + str + "; //
ASSIGN_EXPR",debug);
  }

expression returns [String str]
{ str = "";
 }
 : (
   #(EXPRESSION (str=operator | str=identOrConstant | str=just_expression) )
  | str=operator
  | str=identOrConstant
  )
 ;

----- Original Message -----
From: "pc_poppe" <pc_poppe at hotmail.com>
To: <antlr-interest at yahoogroups.com>
Sent: Thursday, February 28, 2002 8:51 PM
Subject: [antlr-interest] from antrl-generated AST back to java-file?


> Hi I'm working on a refactoring tool for java and I'm using antlr to
> parse java-files.(the java example that you can download). the result
> is an AST. and then I make some changes to that AST.These are very
> simple like renaming a method.
>
>
> My question is how can i get a working java-file from my altered AST?
>
> If I try to write out the AST additional words like modifiers and
> class-def,... are written out with the rest and then I dont have a
> java-file I can compile and execute.
>
> To resume I want my sourcecode back, starting from an AST.
>
> Who can help me?
>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list