Tom Copeland's Recent Posts

RSS Feeds

« RubyForge round numbers | Main | Rails, ActionMailer and a no-auth relay »

Java to Python converter using JJTree

I just came across this post which talks about a Java to Python converter that the author wrote and posted on Google code.  It uses a Java 1.5 JJTree grammar and a Visitor that gets callbacks for pretty much all the AST nodes.

One nice thing that it does is print some type documentation for parameterized types, e.g.:

  printer.print("# Parameterized type: <");
  for (Iterator

i = n.typeParameters.iterator(); i
                  .hasNext();) {
          TypeParameter t = i.next();
          t.accept(this, arg);
          if (i.hasNext()) {
                  printer.print(", ");
          }
  }
  printer.printLn(">");

Rather a clever idea.

The PMD jar file is in the project's lib directory, but it looks like the author ended up going with a different Java 1.5 grammar.  That's understandable since the PMD grammar is full of all sorts of PMD-specific things like NOPMD lexical states and whatnot.  Anyhow, seems like a nifty project!

My JavaCC/JJTree book is coming down the home stretch now... should have something in print in the next few months.  w00t!

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83451d3c069e200e5505cd5848833

Listed below are links to weblogs that reference Java to Python converter using JJTree:

» Java to Python converter using JJTree from PsychicProgrammer.com
I just came across this post which talks about a Java to Python converter that the author wrote and posted on Google code. It uses a Java 1.5 JJTree grammar and a Visitor that gets callbacks for pretty much all...Link:... [Read More]

Comments

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.