[antlr-interest] ANTLR translation - e.g. Java->tree->Java

mzukowski at yci.com mzukowski at yci.com
Tue Jun 24 09:55:14 PDT 2003


There are many different reasons to go from source to tree to source.  How
extensively you want to manipulate the tree will dictate how well you can
preserve whitespace and comments.  

Sometimes comments are attached to the preceeding construct, sometimes the
following.  Sometimes it depends on if it's on the same line or not.
Sometimes expressions get special formatting and sometimes they don't.
Sometimes you delete, sometimes you rearrange, sometimes you just replace
the text in the node.

There is no easy general approach to preserving whitespace and comments.  If
you're not rearranging the tree then it's trivial.  Otherwise there are lots
of semantics to work out.

Monty

-----Original Message-----
From: Tim Tyler [mailto:tt2333 at yahoo.co.uk] 
Sent: Sunday, June 22, 2003 5:44 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] ANTLR translation - e.g. Java->tree->Java


I'm contemplating an ANTLR translation project.

To do this I need to reconstruct the Java file from its tree.

There seem to be several problems.

One is that unicode information seems to get blatted.

Another is that most of the Java parsers I can see
strip out comments and white space.  I'm likely to
be wanting to preserve these as much as possible -
and maybe have them in the parse tree.

About the only existing Java ANTLR translation project
I'm aware of is Jalopy: http://jalopy.sourceforge.net/

Jalopy suggests that something is at least possible - but
it is big and complex - and I'd like a bit of a less hairy example.

Are there any other ANTLR translation projects out there?

I'm a bit suprised ANTLR isn't already a little more translation- oriented.

After all, being able to reconstruct the original file is a good 
test for having parsed it correctly ;-)



 

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