XText不提供ANTLR的功能是什么? [英] What are features of ANTLR that XText Does not provide?

查看:217
本文介绍了XText不提供ANTLR的功能是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚遇到了非常好的工具Xtext来创建DSL以及IDE进行编辑。我在网上做了一些搜索,发现人们说它不提供ANTLR的所有功能。我使用ANTLR作为我的解析器生成器。

I just came across very nice tool Xtext to creat DSL as well as IDE for there editing. I did some search on the web and found people saying it dows not provide all the features of ANTLR. I am using ANTLR as my parser generator.

我甚至不确定ANTLR的哪些功能需要为mylanguage编写完整的解析器,但是ANTLR在很长的一段时间内时间可能支持比Xtext更多的功能。

I am not even sure what features of ANTLR I will need to write complete parser for mylanguage but ANTLR is around for quite a long time and probably supports more features than Xtext.

任何人都可以参考一些Xtext语法中无法指定的例子?

Can anyone please gove some examples of what CANNOT be specified in a Xtext grammar?

推荐答案

您不能在Xtext语法中指定语义谓词。此外,不可能使用Xtext包含任意操作(读取:目标语言代码块)。唯一支持的目标平台是Java。

You cannot specify semantic predicates in an Xtext grammar. Furthermore it's not possible to include arbitrary actions (read: target language code blocks) with Xtext. The only supported target platform is Java.

好消息是,Xtext通过诱导这些约束获得了很大的好处,例如你会得到一个更加无聊的,允许序列化符合你的语法的任意模型/语法图。说到语法图,使用Xtext,您将得到一个类型为您的语言的AST,您可以在IDE中编辑。

The good news is, that Xtext gains great benefit by inducing these constraints, e.g. you'll get an unparser that allows to serialize arbitrary models / syntax graphs that match your grammar. Speaking about syntax graphs, with Xtext you'll get a typed AST for your language that you can edit in your IDE.

Xtext表示中唯一的语法功能是无序组也就是说,您可以直接表达您的语法中的某些元素可能会以任意顺序发生,但每个元素只能发生一次。如果你考虑java修饰符,这可能非常方便:

A grammar feature that is unique in Xtext's representation are unordered groups. That is, you can directly express that certain elements in your grammar may occur in arbitrary order but each one only once. If you think about the java modifiers, this may be very handy:

  visibility=('public'|'private') // this is a mandatory assignment
& abstractOrFinal=('abstract'|'final')? // this is optional
& static?='static'? // this will become a boolean value in your ast

中的布尔值查看 Xtext docs 了解更多关于语法语言的细节。

Have a look at the Xtext docs for more details on the grammar language.

这篇关于XText不提供ANTLR的功能是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆