I know that there is a simple solution for this , but I have no idea how to implement it.
I am looking for how to implement an answer, not what I need to do. Half the answer is already on this page: Cross-references and the Xtext scope
My problem is with the grammar below:
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
When I write a model, I cannot get "refName = [Attribute | ID]" to refer to attributes inside the object. In the code below
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' } }
How can I expand the scope? How can I distinguish two attributes with the same name, but in different areas?
source share