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

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="" xmlns:xsi=""
    xmlns:ecore="" name="prop"
    nsURI="" nsPrefix="prop">
  <eClassifiers xsi:type="ecore:EClass" name="Prop" eSuperTypes="#//SubProp">
    <eStructuralFeatures xsi:type="ecore:EReference" name="left" eType="#//SubProp"
    <eStructuralFeatures xsi:type="ecore:EReference" name="op" eType="#//BinOp" containment="true"/>
  <eClassifiers xsi:type="ecore:EClass" name="UnOp" eSuperTypes="#//SubProp">
    <eStructuralFeatures xsi:type="ecore:EReference" name="right" eType="#//SubProp"
  <eClassifiers xsi:type="ecore:EClass" name="SubProp">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType"/>
  <eClassifiers xsi:type="ecore:EClass" name="BinOp">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="right" eType="#//SubProp"
    <eStructuralFeatures xsi:type="ecore:EReference" name="op" eType="#//BinOp" containment="true"/>

xText Grammar:

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

generate 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 = 'and' then 

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.



[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

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: Sat May 30 22:28:17 GMT 2020

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

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

Back to the top