【发布时间】:2013-06-14 05:46:03
【问题描述】:
我知道有一个简单的解决方案,但我不知道如何实施。
我正在寻找如何实施答案,而不是我需要做什么。一半的答案已经在此页面上: Xtext cross referencing and scoping
我的问题在于以下语法:
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
当我编写模型时,我无法让“refName=[Attribute|ID]”来引用实体内部的属性。 在下面的代码中
DOMAINMODEL auctionHouse{
ENTITYS {
lots{
NUMBER id0
NUMBER lotNo
STRING name
STRING priceEstimate
STRING description
}
auctions{
NUMBER id1
NUMBER date
STRING description
}
auction_lots{
NUMBER id2
STRING lot_id
NUMBER auction_id
}
}
ENTITY_RELATIONSHIP {
auction_lots : lot_id -> lots(id0) // <- Will not find 'id0'
auction_lots : auction_id -> auctions(id1) // <- Will not find 'id1'
}
}
如何扩大范围? 如何区分两个同名但范围不同的属性?
【问题讨论】:
标签: reference grammar dsl xtext scoping