DDMMPetriNetPackage.tom 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. %typeterm PetriNet extends EObject {
  2. implement { petrinetsemantics.DDMMPetriNet.PetriNet }
  3. is_sort(t) { $t instanceof petrinetsemantics.DDMMPetriNet.PetriNet }
  4. equals(l1,l2) { $l1.equals($l2) }
  5. }
  6. %typeterm Node extends EObject {
  7. implement { petrinetsemantics.DDMMPetriNet.Node }
  8. is_sort(t) { $t instanceof petrinetsemantics.DDMMPetriNet.Node }
  9. equals(l1,l2) { $l1.equals($l2) }
  10. }
  11. %include { string.tom }
  12. %typeterm Arc extends EObject {
  13. implement { petrinetsemantics.DDMMPetriNet.Arc }
  14. is_sort(t) { $t instanceof petrinetsemantics.DDMMPetriNet.Arc }
  15. equals(l1,l2) { $l1.equals($l2) }
  16. }
  17. %typeterm ArcKind {
  18. implement { petrinetsemantics.DDMMPetriNet.ArcKind }
  19. is_sort(t) { $t instanceof petrinetsemantics.DDMMPetriNet.ArcKind }
  20. equals(l1,l2) { $l1.equals($l2) }
  21. }
  22. %op ArcKind ArcKindnormal() {
  23. is_fsym(t) { t == petrinetsemantics.DDMMPetriNet.ArcKind.get("normal") }
  24. make() { (petrinetsemantics.DDMMPetriNet.ArcKind)petrinetsemantics.DDMMPetriNet.DDMMPetriNetFactory.eINSTANCE.createFromString((EDataType)petrinetsemantics.DDMMPetriNet.DDMMPetriNetPackage.eINSTANCE.getArcKind(), "normal") }
  25. }
  26. %op ArcKind ArcKindread_arc() {
  27. is_fsym(t) { t == petrinetsemantics.DDMMPetriNet.ArcKind.get("read_arc") }
  28. make() { (petrinetsemantics.DDMMPetriNet.ArcKind)petrinetsemantics.DDMMPetriNet.DDMMPetriNetFactory.eINSTANCE.createFromString((EDataType)petrinetsemantics.DDMMPetriNet.DDMMPetriNetPackage.eINSTANCE.getArcKind(), "read_arc") }
  29. }
  30. %include { int.tom }
  31. %op Arc Arc(target : Node, source : Node, net : PetriNet, kind : ArcKind, weight : int) {
  32. is_fsym(t) { $t instanceof petrinetsemantics.DDMMPetriNet.Arc }
  33. get_slot(target, t) { (petrinetsemantics.DDMMPetriNet.Node)$t.eGet($t.eClass().getEStructuralFeature("target")) }
  34. get_slot(source, t) { (petrinetsemantics.DDMMPetriNet.Node)$t.eGet($t.eClass().getEStructuralFeature("source")) }
  35. get_slot(net, t) { (petrinetsemantics.DDMMPetriNet.PetriNet)$t.eGet($t.eClass().getEStructuralFeature("net")) }
  36. get_slot(kind, t) { (petrinetsemantics.DDMMPetriNet.ArcKind)$t.eGet($t.eClass().getEStructuralFeature("kind")) }
  37. get_slot(weight, t) { (java.lang.Integer)$t.eGet($t.eClass().getEStructuralFeature("weight")) }
  38. get_default(kind) { `ArcKindnormal() }
  39. get_default(weight) { 0 }
  40. make(target, source, net, kind, weight) { constructArc((petrinetsemantics.DDMMPetriNet.Arc)petrinetsemantics.DDMMPetriNet.DDMMPetriNetFactory.eINSTANCE.create((EClass)petrinetsemantics.DDMMPetriNet.DDMMPetriNetPackage.eINSTANCE.getEClassifier("Arc")), new Object[]{ $target, $source, $net, $kind, $weight }) }
  41. implement() { petrinetsemantics.DDMMPetriNet.impl.ArcImpl }
  42. }
  43. public static <O extends org.eclipse.emf.ecore.EObject> O constructArc(O o, Object[] objs) {
  44. int i=0;
  45. EList<EStructuralFeature> sfes = o.eClass().getEAllStructuralFeatures();
  46. for(EStructuralFeature esf : sfes) {
  47. if(esf.isChangeable()) {
  48. o.eSet(esf, objs[i]);
  49. i++;
  50. }
  51. }
  52. return o;
  53. }
  54. %typeterm ArcEList {
  55. implement { org.eclipse.emf.common.util.EList<petrinetsemantics.DDMMPetriNet.Arc> }
  56. is_sort(t) { $t instanceof org.eclipse.emf.common.util.EList<?> && (((org.eclipse.emf.common.util.EList<petrinetsemantics.DDMMPetriNet.Arc>)$t).size() == 0 || (((org.eclipse.emf.common.util.EList<petrinetsemantics.DDMMPetriNet.Arc>)$t).size()>0 && ((org.eclipse.emf.common.util.EList<petrinetsemantics.DDMMPetriNet.Arc>)$t).get(0) instanceof petrinetsemantics.DDMMPetriNet.Arc)) }
  57. equals(l1,l2) { $l1.equals($l2) }
  58. }
  59. %oparray ArcEList ArcEList ( Arc* ) {
  60. is_fsym(t) { $t instanceof org.eclipse.emf.common.util.EList<?> && ($t.size() == 0 || ($t.size()>0 && $t.get(0) instanceof petrinetsemantics.DDMMPetriNet.Arc)) }
  61. make_empty(n) { new org.eclipse.emf.common.util.BasicEList<petrinetsemantics.DDMMPetriNet.Arc>($n) }
  62. make_append(e,l) { appendArcEList($e,$l) }
  63. get_element(l,n) { $l.get($n) }
  64. get_size(l) { $l.size() }
  65. }
  66. private static <O> org.eclipse.emf.common.util.EList<O> appendArcEList(O e,org.eclipse.emf.common.util.EList<O> l) {
  67. l.add(e);
  68. return l;
  69. }
  70. %typeterm NodeEList {
  71. implement { org.eclipse.emf.common.util.EList<petrinetsemantics.DDMMPetriNet.Node> }
  72. is_sort(t) { $t instanceof org.eclipse.emf.common.util.EList<?> && (((org.eclipse.emf.common.util.EList<petrinetsemantics.DDMMPetriNet.Node>)$t).size() == 0 || (((org.eclipse.emf.common.util.EList<petrinetsemantics.DDMMPetriNet.Node>)$t).size()>0 && ((org.eclipse.emf.common.util.EList<petrinetsemantics.DDMMPetriNet.Node>)$t).get(0) instanceof petrinetsemantics.DDMMPetriNet.Node)) }
  73. equals(l1,l2) { $l1.equals($l2) }
  74. }
  75. %oparray NodeEList NodeEList ( Node* ) {
  76. is_fsym(t) { $t instanceof org.eclipse.emf.common.util.EList<?> && ($t.size() == 0 || ($t.size()>0 && $t.get(0) instanceof petrinetsemantics.DDMMPetriNet.Node)) }
  77. make_empty(n) { new org.eclipse.emf.common.util.BasicEList<petrinetsemantics.DDMMPetriNet.Node>($n) }
  78. make_append(e,l) { appendNodeEList($e,$l) }
  79. get_element(l,n) { $l.get($n) }
  80. get_size(l) { $l.size() }
  81. }
  82. private static <O> org.eclipse.emf.common.util.EList<O> appendNodeEList(O e,org.eclipse.emf.common.util.EList<O> l) {
  83. l.add(e);
  84. return l;
  85. }
  86. %op PetriNet PetriNet(nodes : NodeEList, arcs : ArcEList, name : String) {
  87. is_fsym(t) { $t instanceof petrinetsemantics.DDMMPetriNet.PetriNet }
  88. get_slot(nodes, t) { (org.eclipse.emf.common.util.EList<petrinetsemantics.DDMMPetriNet.Node>)$t.eGet($t.eClass().getEStructuralFeature("nodes")) }
  89. get_slot(arcs, t) { (org.eclipse.emf.common.util.EList<petrinetsemantics.DDMMPetriNet.Arc>)$t.eGet($t.eClass().getEStructuralFeature("arcs")) }
  90. get_slot(name, t) { (java.lang.String)$t.eGet($t.eClass().getEStructuralFeature("name")) }
  91. make(nodes, arcs, name) { constructPetriNet((petrinetsemantics.DDMMPetriNet.PetriNet)petrinetsemantics.DDMMPetriNet.DDMMPetriNetFactory.eINSTANCE.create((EClass)petrinetsemantics.DDMMPetriNet.DDMMPetriNetPackage.eINSTANCE.getEClassifier("PetriNet")), new Object[]{ $nodes, $arcs, $name }) }
  92. implement() { petrinetsemantics.DDMMPetriNet.impl.PetriNetImpl }
  93. }
  94. public static <O extends org.eclipse.emf.ecore.EObject> O constructPetriNet(O o, Object[] objs) {
  95. int i=0;
  96. EList<EStructuralFeature> sfes = o.eClass().getEAllStructuralFeatures();
  97. for(EStructuralFeature esf : sfes) {
  98. if(esf.isChangeable()) {
  99. o.eSet(esf, objs[i]);
  100. i++;
  101. }
  102. }
  103. return o;
  104. }
  105. %typeterm Transition extends Node {
  106. implement { petrinetsemantics.DDMMPetriNet.Transition }
  107. is_sort(t) { $t instanceof petrinetsemantics.DDMMPetriNet.Transition }
  108. equals(l1,l2) { $l1.equals($l2) }
  109. }
  110. %op Transition Transition(name : String, net : PetriNet, outgoings : ArcEList, incomings : ArcEList, min_time : int, max_time : int) {
  111. is_fsym(t) { $t instanceof petrinetsemantics.DDMMPetriNet.Transition }
  112. get_slot(name, t) { (java.lang.String)$t.eGet($t.eClass().getEStructuralFeature("name")) }
  113. get_slot(net, t) { (petrinetsemantics.DDMMPetriNet.PetriNet)$t.eGet($t.eClass().getEStructuralFeature("net")) }
  114. get_slot(outgoings, t) { (org.eclipse.emf.common.util.EList<petrinetsemantics.DDMMPetriNet.Arc>)$t.eGet($t.eClass().getEStructuralFeature("outgoings")) }
  115. get_slot(incomings, t) { (org.eclipse.emf.common.util.EList<petrinetsemantics.DDMMPetriNet.Arc>)$t.eGet($t.eClass().getEStructuralFeature("incomings")) }
  116. get_slot(min_time, t) { (java.lang.Integer)$t.eGet($t.eClass().getEStructuralFeature("min_time")) }
  117. get_slot(max_time, t) { (java.lang.Integer)$t.eGet($t.eClass().getEStructuralFeature("max_time")) }
  118. get_default(min_time) { 0 }
  119. get_default(max_time) { 0 }
  120. make(name, net, outgoings, incomings, min_time, max_time) { constructTransition((petrinetsemantics.DDMMPetriNet.Transition)petrinetsemantics.DDMMPetriNet.DDMMPetriNetFactory.eINSTANCE.create((EClass)petrinetsemantics.DDMMPetriNet.DDMMPetriNetPackage.eINSTANCE.getEClassifier("Transition")), new Object[]{ $name, $net, $outgoings, $incomings, $min_time, $max_time }) }
  121. implement() { petrinetsemantics.DDMMPetriNet.impl.TransitionImpl }
  122. }
  123. public static <O extends org.eclipse.emf.ecore.EObject> O constructTransition(O o, Object[] objs) {
  124. int i=0;
  125. EList<EStructuralFeature> sfes = o.eClass().getEAllStructuralFeatures();
  126. for(EStructuralFeature esf : sfes) {
  127. if(esf.isChangeable()) {
  128. o.eSet(esf, objs[i]);
  129. i++;
  130. }
  131. }
  132. return o;
  133. }
  134. %typeterm Place extends Node {
  135. implement { petrinetsemantics.DDMMPetriNet.Place }
  136. is_sort(t) { $t instanceof petrinetsemantics.DDMMPetriNet.Place }
  137. equals(l1,l2) { $l1.equals($l2) }
  138. }
  139. %op Place Place(name : String, net : PetriNet, outgoings : ArcEList, incomings : ArcEList, initialMarking : int) {
  140. is_fsym(t) { $t instanceof petrinetsemantics.DDMMPetriNet.Place }
  141. get_slot(name, t) { (java.lang.String)$t.eGet($t.eClass().getEStructuralFeature("name")) }
  142. get_slot(net, t) { (petrinetsemantics.DDMMPetriNet.PetriNet)$t.eGet($t.eClass().getEStructuralFeature("net")) }
  143. get_slot(outgoings, t) { (org.eclipse.emf.common.util.EList<petrinetsemantics.DDMMPetriNet.Arc>)$t.eGet($t.eClass().getEStructuralFeature("outgoings")) }
  144. get_slot(incomings, t) { (org.eclipse.emf.common.util.EList<petrinetsemantics.DDMMPetriNet.Arc>)$t.eGet($t.eClass().getEStructuralFeature("incomings")) }
  145. get_slot(initialMarking, t) { (java.lang.Integer)$t.eGet($t.eClass().getEStructuralFeature("initialMarking")) }
  146. get_default(initialMarking) { 0 }
  147. make(name, net, outgoings, incomings, initialMarking) { constructPlace((petrinetsemantics.DDMMPetriNet.Place)petrinetsemantics.DDMMPetriNet.DDMMPetriNetFactory.eINSTANCE.create((EClass)petrinetsemantics.DDMMPetriNet.DDMMPetriNetPackage.eINSTANCE.getEClassifier("Place")), new Object[]{ $name, $net, $outgoings, $incomings, $initialMarking }) }
  148. implement() { petrinetsemantics.DDMMPetriNet.impl.PlaceImpl }
  149. }
  150. public static <O extends org.eclipse.emf.ecore.EObject> O constructPlace(O o, Object[] objs) {
  151. int i=0;
  152. EList<EStructuralFeature> sfes = o.eClass().getEAllStructuralFeatures();
  153. for(EStructuralFeature esf : sfes) {
  154. if(esf.isChangeable()) {
  155. o.eSet(esf, objs[i]);
  156. i++;
  157. }
  158. }
  159. return o;
  160. }