gpt4 book ai didi

java - 是否有 Xtext 的 java 语法文件?

转载 作者:搜寻专家 更新时间:2023-11-01 03:53:02 24 4
gpt4 key购买 nike

我想从 Java 源文件创建某些文件(输入:*.java 文件;输出:一些东西)。 Xtext 似乎是一个很好的工具。当然,您必须先定义语法(在本例中为 Java)。但是 Xtext 应该能够解析 Java 文件并从中生成一些文件(如果我编写模板)。

不知何故,我无法想象,这是以前没有做过的。我查了一下,但没有找到任何东西。所以问题是:

是否有用于 Java 的 Xtext-grammar 文件(定义 Java 语法)?

最佳答案

I had the same issue. Since Xtext uses Antlr under the hood, I was trying to find an Antlr Java grammar. I found this file from Terence Parr. I got about 1000 lines ...

I took this post into consideration and adjusted the grammar line by line. I took me while Wink I wasn't able to adapt every statement, so I just commented some of them out. I attached the grammar if someone else is trying to build a DSL on top of Java. I don't think that the grammar is completely right, it at least contains the issues listed in the original grammar.

http://www.eclipse.org/forums/index.php/t/251746/

关于java - 是否有 Xtext 的 java 语法文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19632437/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com