ANTLR从Java到C# [英] ANTLR from Java to C#
问题描述
我正计划创建一些东西,以进行从Java到C#的自动翻译(此后相反).我需要的是可以用来将Java源代码转换为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.
我遇到了ANTLR,但是我不确定如何在任务中使用它.我知道ANTLR对Java和C#都有很强的支持,并且两者都已经存在语法,包括词法/解析过程,AST创建,最后是树遍历器.从理论上讲,我明白了,但是当涉及到将其实际投入使用时,我会停滞不前.
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.
有人找不到我可以找到任何有关如何使用ANTLR的不错的教程吗?
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?
推荐答案
一旦您熟悉了ANTLR的基础知识,您将需要这些: openjdk.java.net/projects/compiler-grammar/antlrworks/Java.g + http://antlrcsharp.codeplex.com/
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/
这篇关于ANTLR从Java到C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!