Hello Thomas,
> I was looking for some java2python framework to do translations for
> the pyjamas (http://pyjs.org) project.
>
> I have got some code running, but a lot of features are still missing.
That sounds familiar. :)
> Could you imagine, that the efforts could be joined in some way ?
I don't know. The approaches look very different.
> stratego is a language translation toolset. java-front brings parsing
> of java into easily readable aterm format.
Thank you for pointing out stratego; I've never seen it until now.
> In principle, I find the approach to join multiple steps to do
> transformations very appealing.
>
> A transformation looks like
>
> cat src.java | parser | transform1 | transform2 | topyrenderer >
> src.py
That is nice! I wish I had thought of pipelining the transformations like that.
What do each of the transformations accomplish? I've looked over some
of the docs and your examples, but I'm not certain what each one of
them does at each stage.
Also, the strategy files seem very specific to the sources you're
translating. Is this true? To write a tool to translate java into
python, what would you need to write beyond the grammar and these
translations? (I'm assuming you're writing the entire grammar).
> I will dig into java2python code to understand your approach.
The approach is to rely on antlr as much as possible. In the current
versions (the 0.4 branch), as the parser walks the java source file,
we invoke various functions to construct an intermediate python
object. When the walker is complete, we ask the python object to
write itself to output. At various points in the
walking/building/writing, we apply transformations in the form of
lookup replacements and regular expressions. It's not very
computer-science-y, it's mostly string-y.
> Which of the branches should I concentrate on ?
I'm tinkering these days on the 0.4 branch. I've got basic blocks
working and committed.
> Second question: is this the right place to talk about java 2 python
> translation in general ?
Yes, this would be the place. Or you can mail me directly.
troy