ANTLR 从 Java 到 C#

发布于 2024-12-29 18:13:20 字数 276 浏览 1 评论 0原文

我计划创建一些可以自动从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

俏︾媚 2025-01-05 18:13:20

一旦您熟悉了 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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文