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

标签 java xtext

我想从 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/

相关文章:

java - 为什么人们写--i?

java - 未指定 maxSize 时,Google Guava Cache 逐出 SIZE 条目

java - Xtext Xtype : What's the difference between JvmType and JvmTypeReference?

eclipse - org.eclipse.xtext.resource.FileNotFoundOnClasspathException : Couldn't find resource on classpath. URI 是 'classpath:/../Less.xtext'

java - 通过 Xtext 和 Java 程序提供自动化

validation - 如何使 Xtext 中的 Enum 文字不区分大小写

java - @Required 属性检查一个 bean,但不检查另一个 bean

java - 相当于 Objective-C 的 Guava Preconditions.checkNotNull(...) 吗?

Java OutOfMemory 异常无法在 Lollipop 之前的设备上启动应用程序

abstract-syntax-tree - 在 xtext 中查看解析树/节点模型/AST