Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed the O/X mapping megamodel; implemented some validity/well-forme…
…dness constraints
- Loading branch information
1 parent
c4a818f
commit 3769ce1
Showing
12 changed files
with
83 additions
and
25 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
*.back.megal | ||
*.back | ||
*.dot | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{- include ALL the megamodels! -} | ||
|
||
megamodel capabilities/Object_XML_mapping/root . | ||
|
||
include capabilities/Object_XML_mapping/annotation . | ||
include capabilities/Object_XML_mapping/configuration . | ||
include capabilities/Object_XML_mapping/generation . | ||
include capabilities/Object_XML_mapping/read . | ||
include capabilities/Object_XML_mapping/write . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@contributor{Vadim Zaytsev - vadim@grammarware.net - SWAT, CWI} | ||
module backend::MegaManipulate | ||
|
||
import structure::MegaADT; | ||
|
||
import List; | ||
import Set; | ||
|
||
public MegaDeclaration getByName(str name, AMegaModel m) | ||
{ | ||
list[MegaDeclaration] mine = getAllByName(name,m); | ||
if(size(mine)==1) return mine[0]; | ||
else throw "Declaration for <name> not found or not unique: <mine>"; | ||
} | ||
|
||
public list[MegaDeclaration] getAllByName(str name, AMegaModel m) = [d | d <- m.decls, d.id == name]; | ||
|
||
public list[&T] mergeLists(list[&T] xs, list[&T] ys) = toList(toSet(xs)+toSet(ys)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@contributor{Vadim Zaytsev - vadim@grammarware.net - SWAT, CWI} | ||
module structure::MegaConstraints | ||
|
||
import structure::MegaADT; | ||
import backend::MegaManipulate; | ||
|
||
import io::MegaL; | ||
import IO; // println | ||
import List; // size | ||
|
||
public void main() | ||
{ | ||
AMegaModel m = readFlat(|project://megal/lib/ox/root.megal|); | ||
println(m); | ||
println({*{r.x,r.y} | r <- m.rels}); | ||
for (n <- {*{r.x,r.y} | r <- m.rels}) | ||
println("<n> ::= <getAllByName(n,m)>;"); | ||
println(areAllDefined(m)); | ||
println(allAmbiguous(m)); | ||
println(allUndefined(m)); | ||
} | ||
|
||
public bool isValid(AMegaModel m) = areAllDefined(m); | ||
|
||
public bool areAllDefined(AMegaModel m) = (true | it && size(getAllByName(name,m))==1 | name <- {*{r.x,r.y} | r <- m.rels}); | ||
|
||
public list[str] allUndefined(AMegaModel m) = ([] | size(getAllByName(name,m))==0?(it+name):it | name <- {*{r.x,r.y} | r <- m.rels}); | ||
|
||
public list[str] allAmbiguous(AMegaModel m) = ([] | size(getAllByName(name,m))>1?(it+name):it | name <- {*{r.x,r.y} | r <- m.rels}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters