ANTLR de Java a C #

I'm planning to create something that would do automated translation from Java to C# (and in reverse afterwards). What I need is something that you could use to translate Java source code into C# source code.

I ran across ANTLR, but I'm not exactly sure of how go about using it for my task. I know ANTLR has a strong support for both Java and C#, and there are already existing grammars for both of them, the lexing/parsing process, then the AST creation, and then finally the tree walker. Theoretically, I get it, but when it comes to actually putting it to work, I stall hardcore.

Can someone provide a generic step-by-step of "how to" that can be used for any language, because I can't find any decent tutorials of how to even use ANTLR?

preguntado el 30 de enero de 12 a las 19:01

"can't find any decent tutorials of how to even use ANTLR?", I can't believe you searched real hard. Using your favorite search engine (be it Google, Bing or Yahoo) with the keywords "ANTLR tutorial", you must have seen the excellent tutorials of Scott Stanchfield. Also browse through the answers already given in the ANTLR tag here on SO: there are many that contain copy-paste ready answers for you to try. -

There is also Terry Parr's (the inventor of ANTLR) book: pragprog.com/book/tpdsl/language-implementation-patterns for probably the "ultimate" tutorial on ANTLR. -

You should also visit my SO answer regarding building such a translator: "How to translate between programming languages" stackoverflow.com/a/3460977/120163 -

@Alexey: At the risk of offending you, from the nature of the discussion so far, I don't think you have the understanding or the background to use ANTLR to build a langauge translator. Suggest a compiler class first, and then revisit the topic. Language translations are en las to do right. -

And no, you didn't offend me at all. I am always open for any type of criticism ;) (I sometimes even prefer that, because it points out flaws in my programming and/or researching skills) -

1 Respuestas

Once you made yourself familiar with the basics of ANTLR you will need these: openjdk.java.net/projects/compiler-grammar/antlrworks/Java.g + http://antlrcsharp.codeplex.com/

Respondido 09 Feb 12, 05:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.