浏览代码

Fixed instantiation of attributes

Yentl Van Tendeloo 8 年之前
父节点
当前提交
9993321178

+ 3 - 2
interface/HUTN/hutn_compiler/model_visitor.py

@@ -57,7 +57,8 @@ class ModelVisitor(Visitor):
         if len(children) == 2 or len(children) == 4:
             element_name = children[1].get_text()
         else:
-            element_name = ""
+            element_name = "__%s" % self.free_id
+            self.free_id += 1
 
         if len(children) > 2:
             # So we have a source and target; but aren't sure which is which, because the name is optional!
@@ -85,4 +86,4 @@ class ModelVisitor(Visitor):
             # is assign
             attr_name = children[0].get_text()
             attr_value = tree.get_children("value")[0]
-            self.constructors.extend(['"instantiate_attribute"', jsonstr(self.current_element), jsonstr(attr_name), jsonstr(attr_value.get_text()) if attr_value.head == "STRVALUE" else attr_value.get_text()])
+            self.constructors.extend(['"instantiate_attribute"', jsonstr(self.current_model), jsonstr(self.current_element), jsonstr(attr_name), jsonstr(attr_value.get_text()) if attr_value.head == "STRVALUE" else attr_value.get_text()])

+ 19 - 0
interface/HUTN/test/modelling_language/code/my_petrinet.mvc

@@ -0,0 +1,19 @@
+import models/PetriNets as PetriNets
+
+PetriNets my_petrinet {
+    Place p1 {
+        tokens = 1
+    }
+    Place p2 {
+        tokens = 3
+    }
+    Transition t1 {}
+    P2T (p1, t1) {
+        weight = 1
+    }
+    T2P (t1, p2) {
+        weight = 2
+    }
+}
+
+export my_petrinet to models/my_petrinet

+ 33 - 0
interface/HUTN/test/modelling_language/code/my_petrinet_with_MM.mvc

@@ -0,0 +1,33 @@
+import models/SimpleClassDiagrams as SCD
+
+SCD PetriNets{
+    Class Natural {}
+    Class Place{
+        tokens : Natural
+    }
+    Class Transition{}
+    Association P2T (Place, Transition) {
+        weight : Natural
+    }
+    Association T2P (Transition, Place) {
+        weight : Natural
+    }
+}
+
+PetriNets my_petrinet {
+    Place p1 {
+        tokens = 1
+    }
+    Place p2 {
+        tokens = 3
+    }
+    Transition t1 {}
+    P2T (p1, t1) {
+        weight = 1
+    }
+    T2P (t1, p2) {
+        weight = 2
+    }
+}
+
+export my_petrinet to models/my_petrinet

文件差异内容过多而无法显示
+ 1 - 1
interface/HUTN/test/modelling_language/expected/my_petrinet


文件差异内容过多而无法显示
+ 1 - 1
interface/HUTN/test/modelling_language/expected/my_petrinet_with_MM