ANTLR 从 Java 到 C#
我计划创建一些可以自动从 Java 翻译到 C# 的东西(然后反过来)。我需要的是可以用来将 Java 源代码转换为 C# 源代码的东西。
我遇到了 ANTLR,但我不太确定如何使用它来完成我的任务。我知道 ANTLR 对 Java 和 C# 都有强大的支持,并且它们都已经存在语法,词法分析/解析过程,然后是 AST 创建,最后是树遍历器。从理论上讲,我明白了,但当真正付诸实践时,我却停滞不前。
有人可以提供可用于任何语言的通用“如何做”步骤吗,因为我找不到任何关于如何使用 ANTLR 的像样的教程?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一旦您熟悉了 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/