Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'dsls/Outline/Compiler/KM32Outline.atl')
-rw-r--r--dsls/Outline/Compiler/KM32Outline.atl74
1 files changed, 74 insertions, 0 deletions
diff --git a/dsls/Outline/Compiler/KM32Outline.atl b/dsls/Outline/Compiler/KM32Outline.atl
new file mode 100644
index 0000000..d3de7da
--- /dev/null
+++ b/dsls/Outline/Compiler/KM32Outline.atl
@@ -0,0 +1,74 @@
+module KM32Outline;
+create OUT : Outline from IN : KM3;
+
+uses KM3Helpers;
+
+helper context KM3!Package def: allClasses : Sequence(KM3!Class) =
+ self.contents->iterate(e; acc : Sequence(KM3!Class) = Sequence {} |
+ if e.oclIsKindOf(KM3!Class) then
+ acc->including(e)
+ else if e.oclIsKindOf(KM3!Package) then
+ acc->union(e.allClasses)
+ else
+ acc
+ endif endif
+ );
+
+rule Metamodel2Outline {
+ from
+ s : KM3!Metamodel
+ to
+ t : Outline!Outline (
+ nodes <- s.contents->collect(e | e.allClasses)->flatten()
+ )
+}
+
+helper context KM3!Class def: hasName : Boolean =
+ self.allStructuralFeatures->exists(e | e.name = 'name');
+
+rule UnnamedClass2Node {
+ from
+ s : KM3!Class (
+ not s.hasName
+ )
+ to
+ t : Outline!Node (
+ name <- s.name,
+ label <- label,
+ icon <- 'dummy',
+ mapping <- map
+ ),
+ label : Outline!Label (
+ label <- s.name
+ ),
+ map : Outline!"Map" (
+ mapString <- s.name
+ )
+}
+
+rule NamedClass2Node {
+ from
+ s : KM3!Class (
+ s.hasName
+ )
+ to
+ t : Outline!Node (
+ name <- s.name,
+ label <- label,
+ icon <- 'dummy',
+ mapping <- map
+ ),
+ label : Outline!Label (
+ label <- s.name,
+ labelSuite <- Sequence {colon, name}
+ ),
+ map : Outline!"Map" (
+ mapString <- s.name
+ ),
+ colon : Outline!LabelSuite (
+ label <- ' : '
+ ),
+ name : Outline!LabelSuite (
+ methodCall <- 'name'
+ )
+}

Back to the top