【问题标题】:Crossreferencing in xtext - also for native typesxtext 中的交叉引用 - 也适用于本机类型
【发布时间】:2014-05-30 03:42:06
【问题描述】:

我正在尝试设置具有以下特征的 xtext 语法。

草图(!):

Class:
    properties += Property*
;

Resource:
    properties += Property* 
;


Link :
    // no classes here, so no common for Resource and Class
    [Resource]  <-> [Resource]
;

BasicType:
    'int' | 'long'
;

Property:
    // this is not supported
    name ':' BasicType | [Resource] | [Class]

    // i tried
    // name ':' EObject
;

我的问题是:

我该如何解决这种情况,将属性类型交叉引用到“资源”或“类”或 BasicType?

我尝试使用 EObject 作为 BaseType 并在自定义 ScopeProvider 中解析交叉引用, 但后来我不知道如何使用 BasicTypes(int 或 long)作为属性的类型。

【问题讨论】:

    标签: xtext


    【解决方案1】:

    首先你可以通过定义一个你不调用的规则来引入常见的超类型

    Parent: Child1 | Child2
    

    那么你只能引用其他地方定义的东西。 因此您必须明确定义它们或更改语法

    XText entity example, primitive type

    【讨论】:

    • 谢谢。您的 awnser 为我提供了有价值的整数。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多