Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Scoping / Linking
Scoping / Linking [message #1838316] Mon, 22 February 2021 09:58 Go to next message
Alfredo Aldundi is currently offline Alfredo AldundiFriend
Messages: 38
Registered: July 2009
Member
I have two DSL. The first is the input DSL:

Model:
  attributes += Attribute*
;

Attribute:
  name=ID
;


And here is the mapping DSL:

Model:
  mappings += Mapping*
;

Mapping:
  target=[input::Attribute] '=' source=[input::Attribute]
;


Now, I want to extend the mapping with sources which are defined in the mapping DSL, e.g.:

Property:
   'property' name=ID '=' value=STRING
;


And then write such DSL files:

property prop = "somevalue"

A = prop
B = SourceAttribute


The question is, how to extend the Mapping grammar. Property and Attribute are in different DSLs. Preferrably, I would not want to modify the input DSL. The following is obviously ambiguous and does not work:

Mapping:
  target=[input::Attribute] '=' source=[Source]
;

Source:
  attribute=[input::Attribute] 
  |
  property=[Property]
;


I know of a few ways I could solve this but would like to hear from experts how they would solve this situation.
Re: Scoping / Linking [message #1838322 is a reply to message #1838316] Mon, 22 February 2021 11:07 Go to previous message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

I would introduce a notation that would distinguish between references to Attribute and Property. Since an Attribute is an external concept, I'd probably add it there.
Mapping:
  target=[input::Attribute] '=' source=[Source]
;

Source:
  '#' attribute=[input::Attribute] 
  |
  property=[Property]
;



property prop = "somevalue"

A = prop
B = #SourceAttribute

[Updated on: Mon, 22 February 2021 11:08]

Report message to a moderator

Previous Topic:Validator Testing with JUnit 5
Next Topic:Xtext integration with Sirius and Papyrus
Goto Forum:
  


Current Time: Sun May 05 12:50:35 GMT 2024

Powered by FUDForum. Page generated in 0.02254 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top