Bläddra i källkod

Fixed bugs surfacing in the constructors_models_compiled test

Yentl Van Tendeloo 8 år sedan
förälder
incheckning
ca5976a2e8

BIN
bootstrap/bootstrap.m.gz


+ 0 - 1
bootstrap/conformance_scd.alc

@@ -173,7 +173,6 @@ String function conformance_scd(model : Element):
 							if (integer_gt(cardinalities[check_type]["tlc"], instances)):
 								String error
 								error = (("Lower cardinality violation for outgoing edge of type " + check_type) + " at ") + model_info(model, model_name)
-								log("NAME: " + cast_e2s(read_attribute(model, check_type, "name")))
 								return error!
 						if (dict_in(cardinalities[check_type], "tuc")):
 							// An upper cardinality was defined at the target

+ 3 - 12
integration/code/several_petrinets.mvc

@@ -13,23 +13,14 @@ SCD PetriNets{
          $
     }
     Class Place{
-        tokens : Natural {
-            target_lower_cardinality = 1
-            target_upper_cardinality = 1
-            }
+        tokens : Natural
     }
     Class Transition{}
     Association P2T (Place, Transition) {
-        weight : Natural {
-            target_lower_cardinality = 1
-            target_upper_cardinality = 1
-            }
+        weight : Natural
     }
     Association T2P (Transition, Place) {
-        weight : Natural {
-            target_lower_cardinality = 1
-            target_upper_cardinality = 1
-            }
+        weight : Natural
     }
 }
 

+ 1 - 1
integration/test_constructors_models_compiled.py

@@ -88,7 +88,7 @@ class TestConstructorsModelsCompiled(unittest.TestCase):
         self.assertTrue(run_barebone(commands, ["OK", 
                     "Natural does not have a positive or zero value at p1.tokens",
                     "Natural does not have a positive or zero value at p2t.weight",
-                    "Destination of model edge not typed by source of type: wrong_p2t",
+                    "Destination of model edge not typed by destination of type: wrong_p2t",
                     "Source of model edge not typed by source of type: wrong_t2p",
                     "Lower cardinality violation for outgoing edge of type Place_tokens at p1",
                     "Lower cardinality violation for outgoing edge of type P2T_weight at p2t",

+ 2 - 1
interface/HUTN/grammars/modelling.g

@@ -12,7 +12,7 @@ grammar{
     inheritance: COLON MODEL_ID (COMMA MODEL_ID)*;
 
     model_attribute : ((LCURLY MODEL_ID RCURLY)? model_element)
-                    | (MODEL_ID COLON MODEL_ID (LCURLY NEWLINE? model_attr_instance* RCURLY)? NEWLINE?)
+                    | (MODEL_ID OPTIONAL? COLON MODEL_ID (LCURLY NEWLINE? model_attr_instance* RCURLY)? NEWLINE?)
                     | (model_attr_instance)
                     | (NEWLINE? DOLLAR ANYTHING_EXCEPT_DOLLAR DOLLAR NEWLINE?);
 
@@ -28,6 +28,7 @@ grammar{
 
     tokens{
         IMPORT: 'import';
+        OPTIONAL: '\?';
         AS: 'as';
         MODEL_ID: '[a-zA-Z_][a-zA-Z_0-9/]*';
         MV_URL: '[a-zA-Z_0-9/]*';

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

@@ -95,10 +95,8 @@ class ModelVisitor(Visitor):
             attr_name = children[0].get_text()
             attr_optional = len(tree.get_children("OPTIONAL")) > 0
             attr_type = children[1].get_text()
-            self.constructors.extend(["instantiate_link", self.current_model, "Attribute", self.current_element[-1] + "_" + attr_name, self.current_element[-1], attr_type])
+            self.constructors.extend(["model_define_attribute", self.current_model, self.current_element[-1], attr_name, attr_optional, attr_type])
             full_attribute_name = self.current_element[-1] + "_" + attr_name
-            self.constructors.extend(["instantiate_attribute", self.current_model, full_attribute_name, "name", attr_name])
-            self.constructors.extend(["instantiate_attribute", self.current_model, full_attribute_name, "optional", attr_optional])
 
             if is_assign:
                 # There are also some attributes to set!
@@ -124,7 +122,7 @@ class ModelVisitor(Visitor):
                 f.flush()
             directory = os.path.realpath(__file__).rsplit(os.sep, 1)[0]
             compiled = do_compile(".constraint.alc", directory + "/../grammars/actionlanguage.g", "CS")
-            self.constructors.extend(["add_constraint", self.current_model, self.current_element[-1]] + compiled)
+            self.constructors.extend(["instantiate_attribute_code", self.current_model, self.current_element[-1], "constraint"] + compiled)
         elif is_nested:
             if tree.get_children("MODEL_ID"):
                 contains_link = tree.get_children("MODEL_ID")[0].get_text()

+ 2 - 2
scripts/run_local_modelverse.py

@@ -7,5 +7,5 @@ if len(sys.argv) < 2:
     sys.stderr.write("    %s port\n" % sys.argv[0])
 else:
     subprocess.check_call([sys.executable, "-m", "sccd.compiler.sccdc", "-p", "threads", "server.xml"], cwd="hybrid_server")
-    subprocess.call([sys.executable, "run_mvk_server.py"] + sys.argv[1:] + ["--kernel=baseline-jit"], cwd="hybrid_server")
-    #subprocess.call([sys.executable, "run_mvk_server.py"] + sys.argv[1:] + ["--kernel=legacy-interpreter"], cwd="hybrid_server")
+    #subprocess.call([sys.executable, "run_mvk_server.py"] + sys.argv[1:] + ["--kernel=baseline-jit"], cwd="hybrid_server")
+    subprocess.call([sys.executable, "run_mvk_server.py"] + sys.argv[1:] + ["--kernel=legacy-interpreter"], cwd="hybrid_server")