两个文件中的 Xtext 语法
我想将我的终端放入一个单独的文件中,因为我将在生产版本中使用外部词法分析器。我尝试遵循使用自定义终端定义的答案。因此,我有一个 mypackage/Tokens.xtext
文件和一个 mypackage/MyDsl.xtext
文件,其中包含
grammar mypackage.MyDsl with mypackage.Tokens
生成工作正常,但它创建了一个 MyDslStandaloneSetupGenerate
在 src-gen
中,它无法编译,因为它调用了不存在的 mypackage.TokensStandaloneSetup.doSetup()
。它还生成 src-gen/mypackage/services/MyDslGrammarAccess ,它引用了一个也不存在的 TokensGrammarAccess 类。所以我的问题基本上是:当我有另一个语法文件时,我还应该做什么才能使其可用?
I want to put my terminals into a separate file, because I'll use an external lexer in the production version. I tried following the answer to using custom terminals definitions. So I have a mypackage/Tokens.xtext
file and a mypackage/MyDsl.xtext
file containing
grammar mypackage.MyDsl with mypackage.Tokens
The generation works fine, but it creates a MyDslStandaloneSetupGenerated
in src-gen
which doesn't compile, because it calls the non-existent mypackage.TokensStandaloneSetup.doSetup()
. It also generates src-gen/mypackage/services/MyDslGrammarAccess
which refers to an also non-existent TokensGrammarAccess
class. So my question is basically: when I have another grammar file, what else should I do to make it usable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您还需要运行令牌语法生成器。
You need to also run a generator for the token grammar.
在 Xtext 中,您通常将标记(终端)和解析器规则放入同一个 .xtext 文件中。您想拆分此项目有什么具体原因吗?
in Xtext you usually put the tokens (terminals) and the parser rules into the same .xtext file. Is there a specific reason why you want to split this?
原因很简单:
每个人(尤其是其他用户)都更容易阅读和使用语法
似乎 Xtext 仍然不支持使用多个 .xtext 文件
Simple Reason:
Easier to Read and work with the Grammar for everybody (especially other users)
Seems like Xtext still does not support the use of more than one .xtext file