小编Cha*_*nry的帖子

扩展循环中断

在 Xtend 中,是否可以中断循环或检查以中断循环?

\n\n
\xc2\xabFOR e:d.entitys\xc2\xbb\n    \xc2\xabFOR a:e.attributes\xc2\xbb\n        \xc2\xabIF a.eClass.name.contentEquals(\'Something\')\xc2\xbb\n            \xc2\xabe.name\xc2\xbb "This output should be output one for each Entity e"\n        \xc2\xabENDIF\xc2\xbb\n    \xc2\xabENDFOR\xc2\xbb\n\xc2\xabENDFOR\xc2\xbb\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的输出是:

\n\n
Entity 1 "This output should be output one for each Entity e"\nEntity 1 "This output should be output one for each Entity e"\nEntity 1 "This output should be output one for each Entity e"\nEntity 2 "This output should be output one for each Entity e"\nEntity 4 "This output should be output one for each …
Run Code Online (Sandbox Code Playgroud)

loops code-generation break xtend

5
推荐指数
1
解决办法
2028
查看次数

Xtext DSL语法范围定制

我知道有一个简单的解决方案,但我不知道如何实现它.

我正在寻找如何实现答案而不是我需要做的事情.答案的一半已经在这个页面上: Xtext交叉引用和范围

我的问题是下面的语法:

DomainModel:
    "DOMAINMODEL" name=ID "{"
        "ENTITYS" "{"
            (Entitys+=Entity)*
        "}"
        "ENTITY_RELATIONSHIP" "{"
            (Relationships+=Relationship)*
        "}" 
    "}";

Entity:
    name=ID "{"
        (Attributes+=Attribute)*
    "}";

Attribute:
    StringAttribute | NumberAttribute | ImageAttribute;

StringAttribute:
    "STRING" name=ID;

NumberAttribute:
    "NUMBER" name=ID;

ImageAttribute:
    "IMAGE" name=ID;

// Relationship = [new table name] : [shared key name] -> ref_table(ref_id)
Relationship:
    name=ID ":" newEntityName=ID "->" refEntityName=[Entity|ID]"("refName=[Attribute|ID]")"; // <- Problem here
Run Code Online (Sandbox Code Playgroud)

当我编写模型时,我无法获得"refName = [Attribute | ID]"来引用实体内部的属性.在下面的代码中

DOMAINMODEL auctionHouse{
    ENTITYS {

       lots{      
          NUMBER id0
          NUMBER lotNo
          STRING name
          STRING priceEstimate
          STRING description …
Run Code Online (Sandbox Code Playgroud)

dsl grammar reference scoping xtext

4
推荐指数
1
解决办法
2438
查看次数

标签 统计

break ×1

code-generation ×1

dsl ×1

grammar ×1

loops ×1

reference ×1

scoping ×1

xtend ×1

xtext ×1