Browse Source

Fixes to the test

Yentl Van Tendeloo 8 years ago
parent
commit
978ff24037

+ 2 - 2
bootstrap/modelling.alc

@@ -228,8 +228,8 @@ String function instantiate_link(model : Element, type : String, name : String,
 		Element in
 		Element options
 
-		out = selectPossibleOutgoing(model, source)
-		in = selectPossibleIncoming(model, destination)
+		out = selectPossibleOutgoing(model, source, create_node())
+		in = selectPossibleIncoming(model, destination, create_node())
 		options = set_overlap(out, in)
 
 		if (read_nr_out(options) == 1):

+ 43 - 47
integration/test_pn_interface.py

@@ -931,20 +931,16 @@ Void function action(host_model : Element, name : String, mapping : Element):
                                     include "modelling.alh"
                                     include "object_operations.alh"
                                     Boolean function constraint(host_model : Element, name : String):
-                                        // Make sure that all places have enough tokens
                                         Element links
                                         String link
                                         String place
                                         links = allIncomingAssociationInstances(host_model, name, "P2T")
                                         while (read_nr_out(links) > 0):
                                             link = set_pop(links)
-                                                    place = readAssociationSource(host_model, link)
-                                                    log("Check link " + link)
-                                                    log("Check place " + place)
-                                                    if (integer_lt(read_attribute(host_model, place, "tokens"), read_attribute(host_model, link, "weight"))):
-                                                            // Not enough tokens for this weight
-                                                            return False!
-                                            return True!
+                                            place = readAssociationSource(host_model, link)
+                                            if (integer_lt(read_attribute(host_model, place, "tokens"), read_attribute(host_model, link, "weight"))):
+                                                return False!
+                                        return True!
                                     $
                             }
                         }
@@ -955,9 +951,9 @@ Void function action(host_model : Element, name : String, mapping : Element):
                                     include "primitives.alh"
                                     include "modelling.alh"
                                     Void function action(host_model : Element, name : String, mapping : Element):
-                                            unset_attribute(host_model, name, "executing")
-                                            instantiate_attribute(host_model, name, "executing", True)
-                                            return!
+                                        unset_attribute(host_model, name, "executing")
+                                        instantiate_attribute(host_model, name, "executing", True)
+                                        return!
                                     $
                             }
                         }
@@ -970,8 +966,8 @@ Void function action(host_model : Element, name : String, mapping : Element):
                                     include "primitives.alh"
                                     include "modelling.alh"
                                     Boolean function constraint(host_model : Element, name : String):
-                                            // Check if this node is executing currently
-                                            return value_eq(read_attribute(host_model, name, "executing"), True)!
+                                        // Check if this node is executing currently
+                                        return value_eq(read_attribute(host_model, name, "executing"), True)!
                                     $
                             }
                             Pre_Place {
@@ -980,8 +976,8 @@ Void function action(host_model : Element, name : String, mapping : Element):
                                     include "primitives.alh"
                                     include "modelling.alh"
                                     Boolean function constraint(host_model : Element, name : String):
-                                            // Check if this node is executing currently
-                                            return value_eq(read_attribute(host_model, name, "executed"), False)!
+                                        // Check if this node is executing currently
+                                        return value_eq(read_attribute(host_model, name, "executed"), False)!
                                     $
                             }
                             Pre_P2T {
@@ -998,15 +994,15 @@ Void function action(host_model : Element, name : String, mapping : Element):
                                     include "primitives.alh"
                                     include "modelling.alh"
                                     Void function action(host_model : Element, name : String, mapping : Element):
-                                            Integer tokens
-                                            Integer weight
-                                            tokens = read_attribute(host_model, name, "tokens")
-                                            weight = read_attribute(host_model, mapping["2"], "weight")
-                                            unset_attribute(host_model, name, "tokens")
-                                            instantiate_attribute(host_model, name, "tokens", tokens - weight)
-                                            unset_attribute(host_model, name, "executed")
-                                            instantiate_attribute(host_model, name, "executed", True)
-                                            return!
+                                        Integer tokens
+                                        Integer weight
+                                        tokens = read_attribute(host_model, name, "tokens")
+                                        weight = read_attribute(host_model, mapping["2"], "weight")
+                                        unset_attribute(host_model, name, "tokens")
+                                        instantiate_attribute(host_model, name, "tokens", tokens - weight)
+                                        unset_attribute(host_model, name, "executed")
+                                        instantiate_attribute(host_model, name, "executed", True)
+                                        return!
                                     $
                             }
                             Post_P2T {
@@ -1022,8 +1018,8 @@ Void function action(host_model : Element, name : String, mapping : Element):
                                     include "primitives.alh"
                                     include "modelling.alh"
                                     Boolean function constraint(host_model : Element, name : String):
-                                            // Check if this node is executing currently
-                                            return value_eq(read_attribute(host_model, name, "executing"), True)!
+                                        // Check if this node is executing currently
+                                        return value_eq(read_attribute(host_model, name, "executing"), True)!
                                     $
                             }
                             Pre_Place {
@@ -1032,8 +1028,8 @@ Void function action(host_model : Element, name : String, mapping : Element):
                                     include "primitives.alh"
                                     include "modelling.alh"
                                     Boolean function constraint(host_model : Element, name : String):
-                                            // Check if this node is executing currently
-                                            return value_eq(read_attribute(host_model, name, "executed"), False)!
+                                        // Check if this node is executing currently
+                                        return value_eq(read_attribute(host_model, name, "executed"), False)!
                                     $
                             }
                             Pre_T2P {
@@ -1050,15 +1046,15 @@ Void function action(host_model : Element, name : String, mapping : Element):
                                     include "primitives.alh"
                                     include "modelling.alh"
                                     Void function action(host_model : Element, name : String, mapping : Element):
-                                            Integer tokens
-                                            Integer weight
-                                            tokens = read_attribute(host_model, name, "tokens")
-                                            weight = read_attribute(host_model, mapping["2"], "weight")
-                                            unset_attribute(host_model, name, "tokens")
-                                            instantiate_attribute(host_model, name, "tokens", tokens + weight)
-                                            unset_attribute(host_model, name, "executed")
-                                            instantiate_attribute(host_model, name, "executed", True)
-                                            return!
+                                        Integer tokens
+                                        Integer weight
+                                        tokens = read_attribute(host_model, name, "tokens")
+                                        weight = read_attribute(host_model, mapping["2"], "weight")
+                                        unset_attribute(host_model, name, "tokens")
+                                        instantiate_attribute(host_model, name, "tokens", tokens + weight)
+                                        unset_attribute(host_model, name, "executed")
+                                        instantiate_attribute(host_model, name, "executed", True)
+                                        return!
                                     $
                             }
                             Post_T2P {
@@ -1074,8 +1070,8 @@ Void function action(host_model : Element, name : String, mapping : Element):
                                     include "primitives.alh"
                                     include "modelling.alh"
                                     Boolean function constraint(host_model : Element, name : String):
-                                            // Check if this node is executing currently
-                                            return value_eq(read_attribute(host_model, name, "executing"), True)!
+                                        // Check if this node is executing currently
+                                        return value_eq(read_attribute(host_model, name, "executing"), True)!
                                     $
                             }
                         }
@@ -1086,9 +1082,9 @@ Void function action(host_model : Element, name : String, mapping : Element):
                                     include "primitives.alh"
                                     include "modelling.alh"
                                     Void function action(host_model : Element, name : String, mapping : Element):
-                                            unset_attribute(host_model, name, "executingd")
-                                            instantiate_attribute(host_model, name, "executing", False)
-                                            return!
+                                        unset_attribute(host_model, name, "executingd")
+                                        instantiate_attribute(host_model, name, "executing", False)
+                                        return!
                                     $
                             }
                         }
@@ -1101,8 +1097,8 @@ Void function action(host_model : Element, name : String, mapping : Element):
                                     include "primitives.alh"
                                     include "modelling.alh"
                                     Boolean function constraint(host_model : Element, name : String):
-                                            // Check if this node is executing currently
-                                            return value_eq(read_attribute(host_model, name, "executed"), True)!
+                                        // Check if this node is executing currently
+                                        return value_eq(read_attribute(host_model, name, "executed"), True)!
                                     $
                             }
                         }
@@ -1113,9 +1109,9 @@ Void function action(host_model : Element, name : String, mapping : Element):
                                     include "primitives.alh"
                                     include "modelling.alh"
                                     Void function action(host_model : Element, name : String, mapping : Element):
-                                            unset_attribute(host_model, name, "executed")
-                                            instantiate_attribute(host_model, name, "executed", False)
-                                            return!
+                                        unset_attribute(host_model, name, "executed")
+                                        instantiate_attribute(host_model, name, "executed", False)
+                                        return!
                                     $
                             }
                         }

+ 2 - 2
interface/HUTN/hutn_compiler/grammar_compiler_visitor.py

@@ -267,7 +267,7 @@ class GrammarCompilerVisitor(Visitor):
 
             impl=  ['|'] + self.implicit
             body = [ '*', impl ]
-            msg = "Automatically generated 'Implict' rule"
+            msg = "Automatically generated 'Implicit' rule"
 
             #we add it to the rules
             self.addRule(name, body, msg)
@@ -337,4 +337,4 @@ class GrammarCompilerVisitor(Visitor):
         val = {'type': PROD_TYPE, 'body': rhs, 'errortext': msg }
         if (hidden == True):
             val['hidden'] = True
-        self.rules[name] = val
+        self.rules[name] = val

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

@@ -137,6 +137,7 @@ class ModelVisitor(Visitor):
 	    initial_tabs = min([len(i) - len(i.lstrip("\t")) for i in code_fragments])
 	    code_fragments = [i[initial_tabs:] for i in code_fragments]
 	    code = "\n".join(code_fragments)
+            code += "\n"
 
             with open(".code.alc", 'w') as f:
                 f.write(code)
@@ -164,7 +165,7 @@ class ModelVisitor(Visitor):
             self.constructors.extend(["instantiate_attribute", self.current_model, self.current_element, attr_name, attr_value])
         elif tree.get_children("DOLLAR"):
             # Coded attribute
-            self.constructors.extend(["instantiate_attribute_code", self.current_model, self.current_element, attr_name, constructors_compile(tree.get_children("ANYTHING_EXCEPT_DOLLAR")[1].get_text())])
+            self.constructors.extend(["instantiate_attribute_code", self.current_model, self.current_element, attr_name, constructors_compile(tree.get_children("ANYTHING_EXCEPT_DOLLAR")[0].get_text())])
         else:
             # Assign direct reference
             self.constructors.extend(["instantiate_attribute_ref", self.current_model, self.current_element, attr_name, tree.get_children("MODEL_ID")[1].get_text()])