Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » ATL file generation and Rule printing
ATL file generation and Rule printing [message #1691189] Fri, 03 April 2015 01:23 Go to next message
Pinank Dagli is currently offline Pinank DagliFriend
Messages: 6
Registered: February 2015
Junior Member
I am trying to generate an ATL file containing ATL rules.
1. I have java implementations of OCL and ATL classes.
2. I have instantiated all the necessary classes to generate specific rules
ModuleImpl module = new ModuleImpl();
		module.setName("testmodule");
		
		MatchedRuleImpl mr1 = new MatchedRuleImpl(); 
		mr1.setName("R1");

		OclModelImpl inmetamodel=new OclModelImpl();
		inmetamodel.setName("GPCAModel");
		
		OclModelImpl inmodel=new OclModelImpl();
		inmodel.setName("IN");
		inmodel.setMetamodel(inmetamodel);
		
		OclModelImpl outmetamodel=new OclModelImpl();
		outmetamodel.setName("GSN");
		
		OclModelImpl outmodel=new OclModelImpl();
		outmodel.setName("OUT");
		outmodel.setMetamodel(outmetamodel);

3. I also have printing methods which takes in particular objects and formats the rules
public void printModule(ModuleImpl m, MatchedRuleImpl mr1){
		System.out.println("module "+m.getName()+";\n");
		System.out.print("create "+m.getOutModels().get(0).getName()+":"+m.getOutModels().get(0).getMetamodel().getName());
		System.out.println(" from "+m.getInModels().get(0).getName()+":"+m.getInModels().get(0).getMetamodel().getName());
		printMatchedRule(mr1);
		
	}
	
	private void printMatchedRule(MatchedRuleImpl mr1) {
		System.out.println("\nrule "+mr1.getName()+"{");
		printInPattern(mr1.getInPattern());
		printOutPattern(mr1.getOutPattern());
		System.out.println("}");
	}
	
	private void printInPattern(InPattern ip) {
		System.out.println("\tfrom");
		System.out.print("\t\t"+ip.getElements().get(0).getVarName()+":");
		System.out.println(ip.getElements().get(0).getModels().get(0).getMetamodel().getName()+"!"+ip.getElements().get(0).getType().getName());
		//System.out.println("}");


is there a easy way to do this printing of ATL rules?

Since I am not using IModel, IReference, so I cannot use this method of printing ATL from the extract method of ATL Parser

FileOutputStream fos = new FileOutputStream("testmodule.atl");
try {
	atlParser.getDefault().extract(atlM, fos, Collections.emptyMap());
} finally {
	if (fos != null) {
		fos.close();
	}
}


Re: ATL file generation and Rule printing [message #1691262 is a reply to message #1691189] Sat, 04 April 2015 07:32 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

Quick answer: use EMFModel.

Just out of curiosity: in MDE, we generate stuff using M2M and M2T transformations to raise the level of abstraction, yet you use Java to generate ATL? That's sort of ironic, isn't it?


Cheers,
Dennis
Re: ATL file generation and Rule printing [message #1691640 is a reply to message #1691262] Wed, 08 April 2015 16:47 Go to previous messageGo to next message
Pinank Dagli is currently offline Pinank DagliFriend
Messages: 6
Registered: February 2015
Junior Member
No My question is how should i printout the ATL format with keywords

public void printModule(ModuleImpl m, MatchedRuleImpl mr1){
		System.out.println("module "+m.getName()+";\n");
		System.out.print("create "+m.getOutModels().get(0).getName()+":"+m.getOutModels().get(0).getMetamodel().getName());
		System.out.println(" from "+m.getInModels().get(0).getName()+":"+m.getInModels().get(0).getMetamodel().getName());
		printMatchedRule(mr1);


I can get name of module, but module keyword, I have to provide


Is there a easy way to get keywords with specific name and attributes


With correct syntax, just like EMFExtractor

Re: ATL file generation and Rule printing [message #1693719 is a reply to message #1691640] Mon, 27 April 2015 20:38 Go to previous message
Pinank Dagli is currently offline Pinank DagliFriend
Messages: 6
Registered: February 2015
Junior Member
Hello,

Is there a way from an ATL file, i can generate Abstract Syntax Tree(AST) for that particular ATL program and use that AST for a java program as an input?
Previous Topic:[EMFTVM] Inheritance in lazy rule
Next Topic:DiagnosticException in own ATL-Plugin
Goto Forum:
  


Current Time: Fri Apr 19 02:42:59 GMT 2024

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

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

Back to the top