Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] De Morgan with ATL (Calling called rules)
[ATL] De Morgan with ATL (Calling called rules) [message #506326] Wed, 06 January 2010 20:11 Go to next message
Shannon is currently offline ShannonFriend
Messages: 6
Registered: December 2009
Location: Wellington, NZ
Junior Member
Hi,

I am trying to perform de Morgans laws as a transformation. My current problem is that I don't know how to execute called rules.

For a simple start, I just want to achieve the simple transform A and B becomes A or B. Later I want to achieve an actual law eg :
not (A and B) becomes not A or not B.

Here is my metamodel, developed with xText (grammar follows):

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="prop"
    nsURI="http://www.xtext.org/example/Prop" nsPrefix="prop">
  <eClassifiers xsi:type="ecore:EClass" name="Prop" eSuperTypes="#//SubProp">
    <eStructuralFeatures xsi:type="ecore:EReference" name="left" eType="#//SubProp"
        containment="true"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="op" eType="#//BinOp" containment="true"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="UnOp" eSuperTypes="#//SubProp">
    <eStructuralFeatures xsi:type="ecore:EReference" name="right" eType="#//SubProp"
        containment="true"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="SubProp">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="BinOp">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="right" eType="#//SubProp"
        containment="true"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="op" eType="#//BinOp" containment="true"/>
  </eClassifiers>
</ecore:EPackage>


xText Grammar:

grammar org.xtext.example.Prop with org.eclipse.xtext.common.Terminals

generate prop "http://www.xtext.org/example/Prop"

Prop : left=SubProp op=BinOp
	;
	
UnOp : name='not'
	;

SubProp : '(' Prop ')'
		| name=ID
		| UnOp right=SubProp
		;

BinOp : (name=('and' | 'or' | 'impl' | 'eq') right=SubProp op=BinOp)?
	 ;


Finally, here is my attempt at the first transformation:

module PropATL;
create OUT : Prop from IN : Prop;

rule newOp (s : String){
	to t : Prop!Op (
		name <- s	
	)
}

helper context Prop!Prop def: isAnd() : Boolean =
	if self.op.name = 'and' then 
		true
	else
		false
	endif;

rule And2Or {
	from s : Prop!Prop (s.isAnd())	
	to t : Prop!Prop (
			left <- s.left
		)
	do {	
		t.op <- newOp('or');
		t.op.right <- s.op.right;
	}
}


Currently I am having trouble calling the called rule, newOp.
Any help appreciated.

Cheers,

Shannon

[Updated on: Thu, 07 January 2010 01:15]

Report message to a moderator

Re: [ATL] De Morgan with ATL (Calling called rules) [message #506346 is a reply to message #506326] Thu, 07 January 2010 03:43 Go to previous message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
Hi,

You just need a thisModule. :

t.op <- thisModule.newOp('or');
Previous Topic:[ATL] unique lazy rules
Next Topic:Modifying Global variables in Xtend Script
Goto Forum:
  


Current Time: Tue Oct 22 13:56:34 GMT 2019

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

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

Back to the top