两个文件中的 Xtext 语法

发布于 2024-12-18 06:10:37 字数 609 浏览 2 评论 0原文

我想将我的终端放入一个单独的文件中,因为我将在生产版本中使用外部词法分析器。我尝试遵循使用自定义终端定义的答案。因此,我有一个 mypackage/Tokens.xtext 文件和一个 mypackage/MyDsl.xtext 文件,其中包含

grammar mypackage.MyDsl with mypackage.Tokens

生成工作正常,但它创建了一个 MyDslStandaloneSetupGeneratesrc-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 技术交流群。

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

发布评论

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

评论(3

活泼老夫 2024-12-25 06:10:37

您还需要运行令牌语法生成器。

You need to also run a generator for the token grammar.

酒解孤独 2024-12-25 06:10:37

在 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?

沉默的熊 2024-12-25 06:10:37

原因很简单:

每个人(尤其是其他用户)都更容易阅读和使用语法

似乎 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

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