Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Referencing elements of one DSL from another DSL
Referencing elements of one DSL from another DSL [message #1411013] Fri, 22 August 2014 07:07 Go to next message
Alex K is currently offline Alex KFriend
Messages: 8
Registered: August 2014
Junior Member
Hi all,

I have a problem with xtext and especially with the link between two grammars. I have two grammar : the grammar A with the extension .a and the grammar B with the extension .b which references elements from the grammar A.
Therefore, I followed this tutorial : http://christiandietrich.wordpress.com/2012/08/07/xtext-referencing-elements-of-one-dsl-from-another-dsl/
and everything works as expected. I have my grammar A and in my grammar B I can access elements from the grammar A (with the cross-references [A::Rule]).

The problem comes after. For my project, I would like to do some checking in my xtext file (for instance verify whether two rules created are identical) and in order to do that, I use EOL (epsilon object language). For the grammar A, everything works without problem but for the grammar B, when I want to check the elements which come from the grammar A, instead of having access to the attributes of the elements, I have this strange attribute :
"eProxyURI: PATH_TO/runtime-New_configuration/testRules/src/output/example.rule#xtextLink_::0.0.0::1::/2"

I understand that xtext makes a link between the element in the grammar A and his copy in the grammar B but I would like to have access to all the attributes of this element in the grammar B (for example, the attribute 'name') instead of having only the attribute 'eProxuURI'.

Thanks for any help,

Alex
Re: Referencing elements of one DSL from another DSL [message #1411036 is a reply to message #1411013] Fri, 22 August 2014 08:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

can you elaborate what you exactly do when then problem occurs (code)?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Referencing elements of one DSL from another DSL [message #1411049 is a reply to message #1411036] Fri, 22 August 2014 09:04 Go to previous messageGo to next message
Alex K is currently offline Alex KFriend
Messages: 8
Registered: August 2014
Junior Member
Hi,

First of all, I create a xml file in order to use epsilon :

<?xml version="1.0"?>
<project default="main">
<target name="loadModels">




<epsilon.emf.loadModel name="Voc" metamodeluri="http://www.nl.org/tue/voc/Voc"
read="true" store="false" modelfile="../output/example.voc"/>


<epsilon.emf.loadModel name="Rule" metamodeluri="http://www.tue.nl/xtext/sbvr/rule/Rule"
read="true" store="false" modelfile="../output/example.rule"/>


<epsilon.xml.loadModel name="XMLDoc" file="../output/reportRule.xml"
read ="false" store="true"/>

</target>
<target name="main" depends="loadModels">
<epsilon.eol src="../transformation/validateRule.eol">
<model ref="XMLDoc"/>
<model ref="Rule"/>
<model ref="Voc"/>
</epsilon.eol>

</target>
</project>

Then I have the EOL file, I will try to show you a short extract of code to make it understandable. Here is the beginning of my EOL file :

var reports = new t_reports;
XMLDoc.root = reports;

var rules : Collection;
rules = Rule!FRuleR.allInstances();


and here is the xtext part corresponding to FRuleR (with the cross references to the grammar A) :


FRuleR :
PredefinedRuleR|RuleVerbR |RuleNounR
;

PredefinedRuleR :
(key += PredefinedKeyword )+ noun1 = ([voc::FNoun|ID]) (key2 += PredefinedKeyword )* name = [voc::Verb|ID] (key3 += PredefinedKeyword )* (noun2 = [voc::FNoun|ID])? '.'
;

RuleVerbR :
(key += PredefinedKeyword )+ noun1 = ([voc::FNoun|ID]) (key2 += PredefinedKeyword )* name = PredefinedVerb (key3 += PredefinedKeyword )* (noun2 = [voc::FNoun|ID])? '.'
;

RuleNounR :
(key += PredefinedKeyword )+ noun1 = ([voc::FNoun|ID]) (key2 += PredefinedKeyword )* name = PredefinedVerb (key3 += PredefinedKeyword )* (noun2 = PredefinedNoun)? '.'

;

After, when I do something like this :

for (rule in rules) {
rule.noun1.println();
}

I would expect to see this kind of output :

voc.impl.NounImpl@593dc79c (name: blabla)

but I have :

voc.impl.FNounImpl@66fc0089 (eProxyURI: PATH_TO/runtime-New_configuration/testRules/src/output/example.rule#xtextLink_::0.0.0::1::/2)

Thank you Christian for your help.

Alex
Re: Referencing elements of one DSL from another DSL [message #1411057 is a reply to message #1411049] Fri, 22 August 2014 09:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

i dont know how the model are loaded and how/what is executed.

if you do it standalone: make sure all resources are loaded into the resourceset and both standalonesetups are called.
if you call it from eclipse (e.g. action) it should work out of the box


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Referencing elements of one DSL from another DSL [message #1411058 is a reply to message #1411057] Fri, 22 August 2014 09:29 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
p.S: i dont know what epsilon does internal when you do epsilon.emf.loadModel
but both models have to be loaded to the same resourceset (standalone)
and within eclipse platform:/resource/ usris should be used.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 22 August 2014 09:30]

Report message to a moderator

Previous Topic:formatting/serializing of optional attributes
Next Topic:[Xbase] Scripting Language
Goto Forum:
  


Current Time: Fri Mar 29 06:31:33 GMT 2024

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

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

Back to the top