Browse Source

Added reRAMify operator and fixed many small things to make test work
(almost)

Yentl Van Tendeloo 8 years ago
parent
commit
85292a43d4

BIN
bootstrap/bootstrap.m.gz


+ 21 - 0
bootstrap/modelling.alc

@@ -528,24 +528,45 @@ Element function construct_model_raw(metamodel : Element):
 	while (True):
 		command = input()
 		if (command == "add_node"):
+			input()
 			model_add_node(model, input())
 		elif (command == "add_value"):
+			input()
 			model_add_value(model, input(), input())
 		elif (command == "add_edge"):
+			input()
 			model_add_edge(model, input(), input(), input())
 		elif (command == "exit"):
 			return model!
 		elif (command == "instantiate_node"):
+			input()
 			instantiate_node(model, input(), input())
 		elif (command == "instantiate_attribute"):
+			input()
 			instantiate_attribute(model, input(), input(), input())
 		elif (command == "instantiate_attribute_ref"):
+			input()
 			instantiate_attribute_ref(model, input(), input(), input())
 		elif (command == "instantiate_attribute_code"):
+			input()
 			instantiate_attribute_code(model, input(), input(), construct_function())
 		elif (command == "instantiate_link"):
+			input()
 			instantiate_link(model, input(), input(), input(), input())
 		elif (command == "add_constraint"):
+			input()
 			add_constraint(model, input(), construct_function())
+		elif (command == "import_node"):
+			log("Dropping import_node as not allowed")
+			input()
+			input()
+		elif (command == "export_node"):
+			log("Dropping export_node as not allowed")
+			input()
+			input()
+		elif (command == "instantiate_model"):
+			log("Dropping instantiate_model as not allowed")
+			input()
+			input()
 		else:
 			log("Modelling error: did not understand command " + command)

+ 0 - 3
bootstrap/transform.alc

@@ -120,7 +120,6 @@ Element function get_possible_bindings(host_model : Element, schedule_model : El
 		if (read_nr_out(options) == 0):
 			// Is a node and no connections, so we just pick all options
 			options = allInstances(host_model, original_typename)
-			log("Finding all instances of " + original_typename)
 		elif (read_nr_out(options) > 1):
 			// Multiple "only" options, which will not work out: no options!
 			return create_node()!
@@ -361,10 +360,8 @@ Element function transform(host_model : Element, schedule_model : Element):
 
 	if (transform_composite(host_model, schedule_model, current)):
 		// Success, so return True if it is in-place, or the new model if it is out-place
-		log("Transform success!")
 		return True!
 	else:
-		log("Transform failed!")
 		return False!
 
 Boolean function transform_composite(host_model : Element, schedule_model : Element, composite : String):

+ 43 - 4
core/core_algorithm.alc

@@ -304,7 +304,7 @@ Void function user_function_skip_init(user_id : String):
 			output("    model_overwrite                 -- Overwrites a model with an uploaded model, leaving all metadata")
 			output("")
 			output("Transformation-specific operations")
-			output("    transformation_add_MT_language  -- Create a RAMified metamodel")
+			output("    transformation_add_MT_language  -- Create a RAMified metamodel of a set of models")
 			output("    transformation_add_MT           -- Initialize a new model transformation")
 			output("    transformation_add_AL           -- [TODO] Initialize a new action language transformation")
 			output("    transformation_add_EXT          -- [TODO] Initialize a new external tool transformation")
@@ -312,6 +312,7 @@ Void function user_function_skip_init(user_id : String):
 			output("    transformation_list             -- List all model transformations")
 			output("    transformation_list_full        -- List all model transformations with permissions")
 			output("    transformation_detail           -- List transformation details")
+			output("    transformation_RAMify           -- RAMify a metamodel (again)")
 			output("")
 			output("Model permission operations")
 			output("    permission_modify               -- Change model permissions")
@@ -477,7 +478,10 @@ Void function user_function_skip_init(user_id : String):
 									output_keys = dict_keys(outputs)
 									while (read_nr_out(output_keys) > 0):
 										key = set_pop(output_keys)
-										desired_metamodel_id = set_pop(followAssociation(core, outputs[key], "instanceOf"))
+										log("Key: " + key)
+										log("Model id: " + get_model_id(key))
+										desired_metamodel_id = set_pop(followAssociation(core, get_model_id(key), "instanceOf"))
+										log("Instance of: " + desired_metamodel_id)
 										split_off_model = model_split(merged_model, import_node(read_attribute(core, desired_metamodel_id, "location")), key + "+")
 
 										// Check if the destination model already exists
@@ -660,6 +664,43 @@ Void function user_function_skip_init(user_id : String):
 			else:
 				output("At least one formalism is required")
 
+		elif (cmd == "transformation_RAMify"):
+			// RAMify a metamodel
+			String merged_model_id
+			String target_model_name
+			String target_model_id
+			Element target_model
+			String tracability_link
+
+			output("Which metamodel do you want to RAMify?")
+			merged_model_id = get_model_id(input())
+			if (merged_model_id != ""):
+				if (allow_read(user_id, merged_model_id)):
+					output("Where do you want to store the RAMified metamodel?")
+					target_model_name = input()
+					target_model_id = get_model_id(target_model_name)
+					if (target_model_id == ""):
+						// New model, so everything is fine
+						target_model = ramify(import_node(read_attribute(core, merged_model_id, "location")))
+						model_create(target_model, target_model_name, user_id, set_pop(allAssociationDestinations(core, merged_model_id, "instanceOf")), "Model")
+						target_model_id = get_model_id(target_model_name)
+						tracability_link = instantiate_link(core, "tracability", "", target_model_id, merged_model_id)
+						instantiate_attribute(core, tracability_link, "type", "RAMified")
+					else:
+						// Existing model, so overwrite
+						if (allow_write(user_id, target_model_id)):
+							target_model = ramify(import_node(read_attribute(core, merged_model_id, "location")))
+							model_overwrite(target_model, target_model_id)
+							model_delete_element(core, set_pop(allOutgoingAssociationInstances(core, target_model_id, "tracability")))
+							tracability_link = instantiate_link(core, "tracability", "", target_model_id, merged_model_id)
+							instantiate_attribute(core, tracability_link, "type", "RAMified")
+						else:
+							output("Permission denied")
+				else:
+					output("Permission denied!")
+			else:
+				output("No such model")
+
 		elif (cmd == "transformation_add_MT"):
 			// Add a model transformation model
 			// Just a usual model instantiation, but need to add the source and target links based on user info
@@ -758,8 +799,6 @@ Void function user_function_skip_init(user_id : String):
 							dst = set_pop(target)
 							link = instantiate_link(core, "transformOutput", "", model_id, dst)
 							instantiate_attribute(core, link, "name", read_attribute(core, dst, "name"))
-
-						output("Meta-info correctly set!")
 					else:
 						output("Model already exists")
 				else:

+ 2 - 0
integration/code/pn_design.mvc

@@ -2,9 +2,11 @@ import models/SimpleClassDiagrams as SimpleClassDiagrams
 
 SimpleClassDiagrams PetriNets_Design{
     Class Natural {}
+    Class String {}
 
     Class Place {
         tokens : Natural
+        name : String
     }
     Class Transition {}
     Association P2T (Place, Transition) {

+ 3 - 0
integration/code/pn_design_model.mvc

@@ -3,12 +3,15 @@ import models/PetriNets_Design as PetriNets
 PetriNets pn {
     Place p1 {
         tokens = 1
+        name = "p1"
     }
     Place p2 {
         tokens = 2
+        name = "p2"
     }
     Place p3 {
         tokens = 3
+        name = "p3"
     }
     Transition t1 {}
     P2T (p1, t1) {

+ 39 - 39
integration/code/pn_design_to_runtime.mvc

@@ -6,15 +6,15 @@ RAM_PN_DR annotate {
         {Contains} Success success {}
         {Contains} ForAll copy_transitions {
             LHS {
-                Pre_SOURCE_Transition {
+                Pre_PetriNets_Transition {
                     label = "0"
                 }
             }
             RHS {
-                Post_SOURCE_Transition ct1 {
+                Post_PetriNets_Transition ct1 {
                     label = "0"
                 }
-                Post_TARGET_Transition ct2 {
+                Post_PetriNets_Runtime_Transition ct2 {
                     label = "1"
                     action = $
                         include "primitives.alh"
@@ -24,84 +24,84 @@ RAM_PN_DR annotate {
                             return!
                         $
                 }
-                Post_TransitionLink (ct1, ct2){
+                Post_D2R_TransitionLink (ct1, ct2){
                     label = "2"
                 }
             }
         }
         {Contains} ForAll copy_places {
             LHS {
-                Pre_SOURCE_Place {
+                Pre_PetriNets_Place {
                     label = "0"
                 }
             }
             RHS {
-                Post_SOURCE_Place cp1 {
+                Post_PetriNets_Place cp1 {
                     label = "0"
                 }
-                Post_TARGET_Place cp2 {
+                Post_PetriNets_Runtime_Place cp2 {
                     label = "1"
                     action = $
                         include "primitives.alh"
                         include "modelling.alh"
                         Void function action(host_model : Element, name : String, mapping : Element):
                             instantiate_attribute(host_model, name, "tokens", read_attribute(host_model, mapping["0"], "tokens"))
-                            instantiate_attribute(host_model, name, "name", mapping["0"])
+                            instantiate_attribute(host_model, name, "name", read_attribute(host_model, mapping["0"], "name"))
                             return!
                         $
                 }
-                Post_PlaceLink (cp1, cp2){
+                Post_D2R_PlaceLink (cp1, cp2){
                     label = "2"
                 }
             }
         }
         {Contains} ForAll copy_P2T {
             LHS {
-                Pre_SOURCE_Place cp2t_p{
+                Pre_PetriNets_Place cp2t_p{
                     label = "0"
                 }
-                Pre_SOURCE_Transition cp2t_t{
+                Pre_PetriNets_Transition cp2t_t{
                     label = "1"
                 }
-                Pre_SOURCE_P2T (cp2t_p, cp2t_t){
+                Pre_PetriNets_P2T (cp2t_p, cp2t_t){
                     label = "2"
                 }
-                Pre_TARGET_Place cp2t_p2{
+                Pre_PetriNets_Runtime_Place cp2t_p2{
                     label = "3"
                 }
-                Pre_TARGET_Transition cp2t_t2{
+                Pre_PetriNets_Runtime_Transition cp2t_t2{
                     label = "4"
                 }
-                Pre_PlaceLink (cp2t_p, cp2t_p2){
+                Pre_D2R_PlaceLink (cp2t_p, cp2t_p2){
                     label = "5"
                 }
-                Pre_TransitionLink (cp2t_t, cp2t_t2){
+                Pre_D2R_TransitionLink (cp2t_t, cp2t_t2){
                     label = "6"
                 }
             }
             RHS {
-                Post_SOURCE_Place rhs_cp2t_p{
+                Post_PetriNets_Place rhs_cp2t_p{
                     label = "0"
                 }
-                Post_SOURCE_Transition rhs_cp2t_t{
+                Post_PetriNets_Transition rhs_cp2t_t{
                     label = "1"
                 }
-                Post_SOURCE_P2T rhs_cp2t_p2t (rhs_cp2t_p, rhs_cp2t_t){
+                Post_PetriNets_P2T rhs_cp2t_p2t (rhs_cp2t_p, rhs_cp2t_t){
                     label = "2"
                 }
-                Post_TARGET_Place rhs_cp2t_p2 {
+                Post_PetriNets_Runtime_Place rhs_cp2t_p2 {
                     label = "3"
                 }
-                Post_TARGET_Transition rhs_cp2t_t2 {
+                Post_PetriNets_Runtime_Transition rhs_cp2t_t2 {
                     label = "4"
                 }
-                Post_PlaceLink (rhs_cp2t_p, rhs_cp2t_p2){
+                Post_D2R_PlaceLink (rhs_cp2t_p, rhs_cp2t_p2){
                     label = "5"
                 }
-                Post_TransitionLink (rhs_cp2t_t, rhs_cp2t_t2){
+                Post_D2R_TransitionLink (rhs_cp2t_t, rhs_cp2t_t2){
                     label = "6"
                 }
-                Post_TARGET_P2T rhs_cp2t_p2t2(rhs_cp2t_p2, rhs_cp2t_t2) {
+                Post_PetriNets_Runtime_P2T rhs_cp2t_p2t2(rhs_cp2t_p2, rhs_cp2t_t2) {
                     label = "7"
                     action = $
                         include "primitives.alh"
@@ -115,51 +115,51 @@ RAM_PN_DR annotate {
         }
         {Contains} ForAll copy_T2P {
             LHS {
-                Pre_SOURCE_Place ct2p_p{
+                Pre_PetriNets_Place ct2p_p{
                     label = "0"
                 }
-                Pre_SOURCE_Transition ct2p_t{
+                Pre_PetriNets_Transition ct2p_t{
                     label = "1"
                 }
-                Pre_SOURCE_T2P (ct2p_t, ct2p_p){
+                Pre_PetriNets_T2P (ct2p_t, ct2p_p){
                     label = "2"
                 }
-                Pre_TARGET_Place ct2p_p2{
+                Pre_PetriNets_Runtime_Place ct2p_p2{
                     label = "3"
                 }
-                Pre_TARGET_Transition ct2p_t2{
+                Pre_PetriNets_Runtime_Transition ct2p_t2{
                     label = "4"
                 }
-                Pre_PlaceLink (ct2p_p, ct2p_p2){
+                Pre_D2R_PlaceLink (ct2p_p, ct2p_p2){
                     label = "5"
                 }
-                Pre_TransitionLink (ct2p_t, ct2p_t2){
+                Pre_D2R_TransitionLink (ct2p_t, ct2p_t2){
                     label = "6"
                 }
             }
             RHS {
-                Post_SOURCE_Place rhs_ct2p_p{
+                Post_PetriNets_Place rhs_ct2p_p{
                     label = "0"
                 }
-                Post_SOURCE_Transition rhs_ct2p_t{
+                Post_PetriNets_Transition rhs_ct2p_t{
                     label = "1"
                 }
-                Post_SOURCE_T2P (rhs_ct2p_t, rhs_ct2p_p){
+                Post_PetriNets_T2P (rhs_ct2p_t, rhs_ct2p_p){
                     label = "2"
                 }
-                Post_TARGET_Place rhs_ct2p_p2 {
+                Post_PetriNets_Runtime_Place rhs_ct2p_p2 {
                     label = "3"
                 }
-                Post_TARGET_Transition rhs_ct2p_t2 {
+                Post_PetriNets_Runtime_Transition rhs_ct2p_t2 {
                     label = "4"
                 }
-                Post_PlaceLink (rhs_ct2p_p, rhs_ct2p_p2){
+                Post_D2R_PlaceLink (rhs_ct2p_p, rhs_ct2p_p2){
                     label = "5"
                 }
-                Post_TransitionLink (rhs_ct2p_t, rhs_ct2p_t2){
+                Post_D2R_TransitionLink (rhs_ct2p_t, rhs_ct2p_t2){
                     label = "6"
                 }
-                Post_TARGET_T2P (rhs_ct2p_t2, rhs_ct2p_p2) {
+                Post_PetriNets_Runtime_T2P (rhs_ct2p_t2, rhs_ct2p_p2) {
                     label = "7"
                     action = $
                         include "primitives.alh"

+ 2 - 2
integration/code/pn_print.mvc

@@ -5,12 +5,12 @@ RAM_PN_R print {
         {Contains} Success success {}
         {Contains} ForAll print_tokens {
             LHS {
-                Pre_Place {
+                Pre_PetriNets_Place {
                     label = "0"
                 }
             }
             RHS {
-                Post_Place {
+                Post_PetriNets_Place {
                     label = "0"
                     action = $
                         include "primitives.alh"

+ 3 - 0
integration/code/pn_runtime_model.mvc

@@ -3,12 +3,15 @@ import models/PetriNets_Runtime as PetriNets_Runtime
 PetriNets_Runtime pn {
 	Place p1 {
 		tokens = 1
+        name = "p1"
 	}
 	Place p2 {
 		tokens = 2
+        name = "p2"
 	}
 	Place p3 {
 		tokens = 3
+        name = "p3"
 	}
 	Transition t1 {
 		executing = False

+ 186 - 0
integration/code/pn_runtime_to_design.mvc

@@ -0,0 +1,186 @@
+import models/RAM_PetriNets_Design_Runtime as RAM_PN_DR
+
+RAM_PN_DR annotate {
+    Composite schedule {
+        {Contains} Failure failure {}
+        {Contains} Success success {}
+        {Contains} ForAll copy_transitions {
+            LHS {
+                Pre_PetriNets_Runtime_Transition {
+                    label = "0"
+                }
+            }
+            RHS {
+                Post_PetriNets_Runtime_Transition ct1 {
+                    label = "0"
+                }
+                Post_PetriNets_Transition ct2 {
+                    label = "1"
+                    action = $
+                        include "primitives.alh"
+                        include "modelling.alh"
+                        Void function action(host_model : Element, name : String, mapping : Element):
+                            instantiate_attribute(host_model, name, "executing", False)
+                            return!
+                        $
+                }
+                Post_R2D_TransitionLink (ct1, ct2){
+                    label = "2"
+                }
+            }
+        }
+        {Contains} ForAll copy_places {
+            LHS {
+                Pre_PetriNets_Runtime_Place {
+                    label = "0"
+                }
+            }
+            RHS {
+                Post_PetriNets_Runtime_Place cp1 {
+                    label = "0"
+                }
+                Post_PetriNets_Place cp2 {
+                    label = "1"
+                    action = $
+                        include "primitives.alh"
+                        include "modelling.alh"
+                        Void function action(host_model : Element, name : String, mapping : Element):
+                            instantiate_attribute(host_model, name, "tokens", read_attribute(host_model, mapping["0"], "tokens"))
+                            instantiate_attribute(host_model, name, "name", read_attribute(host_model, mapping["0"], "name"))
+                            return!
+                        $
+                }
+                Post_R2D_PlaceLink (cp1, cp2){
+                    label = "2"
+                }
+            }
+        }
+        {Contains} ForAll copy_P2T {
+            LHS {
+                Pre_PetriNets_Runtime_Place cp2t_p{
+                    label = "0"
+                }
+                Pre_PetriNets_Runtime_Transition cp2t_t{
+                    label = "1"
+                }
+                Pre_PetriNets_Runtime_P2T (cp2t_p, cp2t_t){
+                    label = "2"
+                }
+                Pre_PetriNets_Place cp2t_p2{
+                    label = "3"
+                }
+                Pre_PetriNets_Transition cp2t_t2{
+                    label = "4"
+                }
+                Pre_R2D_PlaceLink (cp2t_p, cp2t_p2){
+                    label = "5"
+                }
+                Pre_R2D_TransitionLink (cp2t_t, cp2t_t2){
+                    label = "6"
+                }
+            }
+            RHS {
+                Post_PetriNets_Runtime_Place rhs_cp2t_p{
+                    label = "0"
+                }
+                Post_PetriNets_Runtime_Transition rhs_cp2t_t{
+                    label = "1"
+                }
+                Post_PetriNets_Runtime_P2T rhs_cp2t_p2t (rhs_cp2t_p, rhs_cp2t_t){
+                    label = "2"
+                }
+                Post_PetriNets_Place rhs_cp2t_p2 {
+                    label = "3"
+                }
+                Post_PetriNets_Transition rhs_cp2t_t2 {
+                    label = "4"
+                }
+                Post_R2D_PlaceLink (rhs_cp2t_p, rhs_cp2t_p2){
+                    label = "5"
+                }
+                Post_R2D_TransitionLink (rhs_cp2t_t, rhs_cp2t_t2){
+                    label = "6"
+                }
+                Post_PetriNets_P2T rhs_cp2t_p2t2(rhs_cp2t_p2, rhs_cp2t_t2) {
+                    label = "7"
+                    action = $
+                        include "primitives.alh"
+                        include "modelling.alh"
+                        Void function action(host_model : Element, name : String, mapping : Element):
+                            instantiate_attribute(host_model, name, "weight", read_attribute(host_model, mapping["2"], "weight"))
+                            return!
+                        $
+                }
+            }
+        }
+        {Contains} ForAll copy_T2P {
+            LHS {
+                Pre_PetriNets_Runtime_Place ct2p_p{
+                    label = "0"
+                }
+                Pre_PetriNets_Runtime_Transition ct2p_t{
+                    label = "1"
+                }
+                Pre_PetriNets_Runtime_T2P (ct2p_t, ct2p_p){
+                    label = "2"
+                }
+                Pre_PetriNets_Place ct2p_p2{
+                    label = "3"
+                }
+                Pre_PetriNets_Transition ct2p_t2{
+                    label = "4"
+                }
+                Pre_R2D_PlaceLink (ct2p_p, ct2p_p2){
+                    label = "5"
+                }
+                Pre_R2D_TransitionLink (ct2p_t, ct2p_t2){
+                    label = "6"
+                }
+            }
+            RHS {
+                Post_PetriNets_Runtime_Place rhs_ct2p_p{
+                    label = "0"
+                }
+                Post_PetriNets_Runtime_Transition rhs_ct2p_t{
+                    label = "1"
+                }
+                Post_PetriNets_Runtime_T2P (rhs_ct2p_t, rhs_ct2p_p){
+                    label = "2"
+                }
+                Post_PetriNets_Place rhs_ct2p_p2 {
+                    label = "3"
+                }
+                Post_PetriNets_Transition rhs_ct2p_t2 {
+                    label = "4"
+                }
+                Post_R2D_PlaceLink (rhs_ct2p_p, rhs_ct2p_p2){
+                    label = "5"
+                }
+                Post_R2D_TransitionLink (rhs_ct2p_t, rhs_ct2p_t2){
+                    label = "6"
+                }
+                Post_PetriNets_T2P (rhs_ct2p_t2, rhs_ct2p_p2) {
+                    label = "7"
+                    action = $
+                        include "primitives.alh"
+                        include "modelling.alh"
+                        Void function action(host_model : Element, name : String, mapping : Element):
+                            instantiate_attribute(host_model, name, "weight", read_attribute(host_model, mapping["2"], "weight"))
+                            return!
+                        $
+                }
+            }
+        }
+    }
+    OnSuccess (copy_places, copy_transitions) {}
+    OnSuccess (copy_transitions, copy_P2T) {}
+    OnSuccess (copy_P2T, copy_T2P) {}
+    OnSuccess (copy_T2P, success) {}
+    OnFailure (copy_places, copy_transitions) {}
+    OnFailure (copy_transitions, copy_P2T) {}
+    OnFailure (copy_P2T, copy_T2P) {}
+    OnFailure (copy_T2P, success) {}
+    Initial (schedule, copy_places) {}
+}
+
+export annotate to models/pn_annotate

+ 16 - 16
integration/code/pn_simulate.mvc

@@ -6,7 +6,7 @@ RAM_PN_R s {
         {Contains} Success success {}
         {Contains} Atomic mark {
             LHS {
-                Pre_Transition {
+                Pre_PetriNets_Transition {
                     label = "1"
                     constraint = $
                         include "primitives.alh"
@@ -27,7 +27,7 @@ RAM_PN_R s {
                 }
             }
             RHS {
-                Post_Transition {
+                Post_PetriNets_Transition {
                     label = "1"
                     action = $
                         include "primitives.alh"
@@ -42,7 +42,7 @@ RAM_PN_R s {
         }
         {Contains} ForAll consume {
             LHS {
-                Pre_Transition lhs_consume_t{
+                Pre_PetriNets_Transition lhs_consume_t{
                     label = "0"
                     constraint = $
                         include "primitives.alh"
@@ -52,18 +52,18 @@ RAM_PN_R s {
                             return value_eq(read_attribute(host_model, name, "executing"), True)!
                         $
                 }
-                Pre_Place lhs_consume_p{
+                Pre_PetriNets_Place lhs_consume_p{
                     label = "1"
                 }
-                Pre_P2T lhs_consume_p2t(lhs_consume_p, lhs_consume_t){
+                Pre_PetriNets_P2T lhs_consume_p2t(lhs_consume_p, lhs_consume_t){
                     label = "2"
                 }
             }
             RHS {
-                Post_Transition rhs_consume_t {
+                Post_PetriNets_Transition rhs_consume_t {
                     label = "0"
                 }
-                Post_Place rhs_consume_p {
+                Post_PetriNets_Place rhs_consume_p {
                     label = "1"
                     action = $
                         include "primitives.alh"
@@ -81,14 +81,14 @@ RAM_PN_R s {
                             return!
                         $
                 }
-                Post_P2T (rhs_consume_p, rhs_consume_t){
+                Post_PetriNets_P2T (rhs_consume_p, rhs_consume_t){
                     label = "2"
                 }
             }
         }
         {Contains} ForAll produce {
             LHS {
-                Pre_Transition lhs_produce_t{
+                Pre_PetriNets_Transition lhs_produce_t{
                     label = "0"
                     constraint = $
                         include "primitives.alh"
@@ -98,18 +98,18 @@ RAM_PN_R s {
                             return value_eq(read_attribute(host_model, name, "executing"), True)!
                         $
                 }
-                Pre_Place lhs_produce_p{
+                Pre_PetriNets_Place lhs_produce_p{
                     label = "1"
                 }
-                Pre_T2P (lhs_produce_t, lhs_produce_p){
+                Pre_PetriNets_T2P (lhs_produce_t, lhs_produce_p){
                     label = "2"
                 }
             }
             RHS {
-                Post_Transition rhs_produce_t{
+                Post_PetriNets_Transition rhs_produce_t{
                     label = "0"
                 }
-                Post_Place rhs_produce_p{
+                Post_PetriNets_Place rhs_produce_p{
                     label = "1"
                     action = $
                         include "primitives.alh"
@@ -127,14 +127,14 @@ RAM_PN_R s {
                             return!
                         $
                 }
-                Post_T2P (rhs_produce_t, rhs_produce_p){
+                Post_PetriNets_T2P (rhs_produce_t, rhs_produce_p){
                     label = "2"
                 }
             }
         }
         {Contains} Atomic unmark_transition {
             LHS {
-                Pre_Transition {
+                Pre_PetriNets_Transition {
                     label = "0"
                     constraint = $
                         include "primitives.alh"
@@ -146,7 +146,7 @@ RAM_PN_R s {
                 }
             }
             RHS {
-                Post_Transition {
+                Post_PetriNets_Transition {
                     label = "0"
                     action = $
                         include "primitives.alh"

+ 313 - 13
integration/test_mvc.py

@@ -1,6 +1,6 @@
 import unittest
 
-from utils import run_file, get_constructor, get_raw_model_constructor
+from utils import run_file, get_constructor, get_model_constructor
 
 all_files = [   "core/mini_modify.alc",
                 "core/core_formalism.mvc",
@@ -241,7 +241,7 @@ class TestModelverseCore(unittest.TestCase):
                 "model_add",
                 "SimpleClassDiagrams",
                 "PetriNets",
-                ] + get_raw_model_constructor(open("integration/code/petrinets.mvc", "r").read()) + [
+                ] + get_model_constructor(open("integration/code/petrinets.mvc", "r").read()) + [
                 "model_list_full",
                 "transformation_add_MT_language",
                 "PetriNets",
@@ -272,7 +272,7 @@ class TestModelverseCore(unittest.TestCase):
                      "  200  root nobody    14   PetriNets : SimpleClassDiagrams",
                      "  200  root nobody    14   __merged_PetriNets_RAM : SimpleClassDiagrams",
                      "  200  root nobody    328   PetriNets_RAM : SimpleClassDiagrams",
-                     "  200  root admin    76   core : CoreFormalism"]),
+                     "  200  root admin    79   core : CoreFormalism"]),
                 "Ready for command...",
             ],
             mode))
@@ -286,7 +286,7 @@ class TestModelverseCore(unittest.TestCase):
                 "model_add",
                 "SimpleClassDiagrams",
                 "PetriNets",
-                ] + get_raw_model_constructor(open("integration/code/petrinets.mvc", "r").read()) + [
+                ] + get_model_constructor(open("integration/code/petrinets.mvc", "r").read()) + [
                 "model_list_full",
                 "transformation_add_MT_language",
                 "PetriNets",
@@ -339,7 +339,6 @@ class TestModelverseCore(unittest.TestCase):
                 "Which ones do you want to use as target (empty string to finish)?",
                 "Name of new transformation?",
                 "Waiting for model constructors...",
-                "Meta-info correctly set!",
                 "Ready for command...",
                 set(["  221  root admin    673   SimpleClassDiagrams : SimpleClassDiagrams",
                      "  221  root admin    86   CoreFormalism : SimpleClassDiagrams",
@@ -347,7 +346,7 @@ class TestModelverseCore(unittest.TestCase):
                      "  200  root nobody    14   __merged_PetriNets_RAM : SimpleClassDiagrams",
                      "  200  root nobody    328   PetriNets_RAM : SimpleClassDiagrams",
                      "  200  root nobody    0   PetriNets_Print : PetriNets_RAM",
-                     "  200  root admin    90   core : CoreFormalism"]),
+                     "  200  root admin    92   core : CoreFormalism"]),
                 "Ready for command...",
                 set(["[ModelTransformation] PetriNets_Print : PetriNets_RAM",
                     ]),
@@ -367,7 +366,7 @@ class TestModelverseCore(unittest.TestCase):
                 "model_add",
                 "SimpleClassDiagrams",
                 "PetriNets",
-                ] + get_raw_model_constructor(open("integration/code/pn_runtime_MR.mvc", "r").read()) + [
+                ] + get_model_constructor(open("integration/code/pn_runtime.mvc", "r").read()) + [
                 "model_list_full",
                 "transformation_add_MT_language",
                 "PetriNets",
@@ -380,7 +379,7 @@ class TestModelverseCore(unittest.TestCase):
                 "",
                 "",
                 "PetriNets_Print",
-                ] + get_raw_model_constructor(open("integration/code/pn_print_MR.mvc", "r").read()) + [
+                ] + get_model_constructor(open("integration/code/pn_print.mvc", "r").read()) + [
                 "transformation_list_full",
             ],
             [   "Desired username for admin user?",
@@ -418,7 +417,6 @@ class TestModelverseCore(unittest.TestCase):
                 "Which ones do you want to use as target (empty string to finish)?",
                 "Name of new transformation?",
                 "Waiting for model constructors...",
-                "Meta-info correctly set!",
                 "Ready for command...",
                 set(["  200  root nobody    26   [ModelTransformation] PetriNets_Print : PetriNets_RAM"
                     ]),
@@ -435,11 +433,11 @@ class TestModelverseCore(unittest.TestCase):
                 "model_add",
                 "SimpleClassDiagrams",
                 "PetriNets",
-                ] + get_raw_model_constructor(open("integration/code/pn_runtime_MR.mvc", "r").read()) + [
+                ] + get_model_constructor(open("integration/code/pn_runtime.mvc", "r").read()) + [
                 "model_add",
                 "PetriNets",
                 "my_pn",
-                ] + get_raw_model_constructor(open("integration/code/pn_runtime_model_MR.mvc", "r").read()) + [
+                ] + get_model_constructor(open("integration/code/pn_runtime_model.mvc", "r").read()) + [
                 "model_list_full",
                 "transformation_add_MT_language",
                 "PetriNets",
@@ -452,7 +450,7 @@ class TestModelverseCore(unittest.TestCase):
                 "",
                 "",
                 "PetriNets_Print",
-                ] + get_raw_model_constructor(open("integration/code/pn_print_MR.mvc", "r").read()) + [
+                ] + get_model_constructor(open("integration/code/pn_print.mvc", "r").read()) + [
                 "transformation_list_full",
                 "transformation_execute",
                 "PetriNets_Print",
@@ -502,7 +500,6 @@ class TestModelverseCore(unittest.TestCase):
                 "Which ones do you want to use as target (empty string to finish)?",
                 "Name of new transformation?",
                 "Waiting for model constructors...",
-                "Meta-info correctly set!",
                 "Ready for command...",
                 set(["  200  root nobody    26   [ModelTransformation] PetriNets_Print : PetriNets_RAM"
                     ]),
@@ -517,3 +514,306 @@ class TestModelverseCore(unittest.TestCase):
                 "Ready for command...",
             ],
             mode))
+
+    def test_po_transform_add_MT_pn_simulate(self):
+        self.transform_add_MT_pn_simulate("PO")
+
+    def transform_add_MT_pn_simulate(self, mode):
+        self.assertTrue(run_file(all_files,
+            [ "root",
+                "model_add",
+                    "SimpleClassDiagrams",
+                    "PetriNets",
+                    ] + get_model_constructor(open("integration/code/pn_design.mvc", "r").read()) + [
+                "model_add",
+                    "SimpleClassDiagrams",
+                    "PetriNets_Runtime",
+                    ] + get_model_constructor(open("integration/code/pn_runtime.mvc", "r").read()) + [
+                "model_add",
+                    "PetriNets",
+                    "my_pn",
+                    ] + get_model_constructor(open("integration/code/pn_design_model.mvc", "r").read()) + [
+                "model_list",
+                "transformation_add_MT_language",
+                    "PetriNets_Runtime",
+                    "PetriNets",
+                    "",
+                    "PetriNets_RAM",
+                "model_list",
+                "model_modify",
+                    "__merged_PetriNets_RAM",
+                        "instantiate",
+                            "Association",
+                            "D2R_PlaceLink",
+                            "PetriNets_Place",
+                            "PetriNets_Runtime_Place",
+                        "instantiate",
+                            "Association",
+                            "D2R_TransitionLink",
+                            "PetriNets_Transition",
+                            "PetriNets_Runtime_Transition",
+                        "instantiate",
+                            "Association",
+                            "R2D_PlaceLink",
+                            "PetriNets_Runtime_Place",
+                            "PetriNets_Place",
+                        "instantiate",
+                            "Association",
+                            "R2D_TransitionLink",
+                            "PetriNets_Runtime_Transition",
+                            "PetriNets_Transition",
+                        "exit",
+                "transformation_RAMify",
+                    "__merged_PetriNets_RAM",
+                    "PetriNets_RAM",
+                "transformation_add_MT",
+                    "PetriNets_RAM",
+                    "PetriNets",
+                    "",
+                    "PetriNets_Runtime",
+                    "",
+                    "pn_design_to_runtime",
+                    ] + get_model_constructor(open("integration/code/pn_design_to_runtime.mvc", "r").read()) + [
+                "transformation_add_MT",
+                    "PetriNets_RAM",
+                    "PetriNets_Runtime",
+                    "",
+                    "PetriNets",
+                    "",
+                    "pn_runtime_to_design",
+                    ] + get_model_constructor(open("integration/code/pn_runtime_to_design.mvc", "r").read()) + [
+                "transformation_add_MT",
+                    "PetriNets_RAM",
+                    "PetriNets_Runtime",
+                    "",
+                    "PetriNets_Runtime",
+                    "",
+                    "pn_step",
+                    ] + get_model_constructor(open("integration/code/pn_simulate.mvc", "r").read()) + [
+                "transformation_add_MT",
+                    "PetriNets_RAM",
+                    "PetriNets",
+                    "",
+                    "",
+                    "pn_print",
+                    ] + get_model_constructor(open("integration/code/pn_print.mvc", "r").read()) + [
+                "model_list",
+                "transformation_list",
+                "transformation_execute",
+                "pn_print",
+                "my_pn",
+                "transformation_execute",
+                "pn_design_to_runtime",
+                "my_pn",
+                "my_pn_runtime",
+                "transformation_execute",
+                "pn_step",
+                "my_pn_runtime",
+                "my_pn_runtime",
+                "transformation_execute",
+                "pn_runtime_to_design",
+                "my_pn_runtime",
+                "my_pn",
+                "transformation_execute",
+                "pn_print",
+                "my_pn",
+            ],
+            [   # bootup phase
+                "Desired username for admin user?",
+                "Welcome to the Model Management Interface v2.0!",
+                "Use the 'help' command for a list of possible commands",
+                "Ready for command...",
+                # model_add
+                "Creating new model!",
+                "Model type?",
+                "Model name?",
+                "Waiting for model constructors...",
+                "Model upload success!",
+                "Ready for command...",
+                # model_add
+                "Creating new model!",
+                "Model type?",
+                "Model name?",
+                "Waiting for model constructors...",
+                "Model upload success!",
+                "Ready for command...",
+                # model_add
+                "Creating new model!",
+                "Model type?",
+                "Model name?",
+                "Waiting for model constructors...",
+                "Model upload success!",
+                "Ready for command...",
+                # model_list
+                set(["  SimpleClassDiagrams : SimpleClassDiagrams",
+                     "  CoreFormalism : SimpleClassDiagrams",
+                     "  PetriNets : SimpleClassDiagrams",
+                     "  my_pn : PetriNets",
+                     "  PetriNets_Runtime : SimpleClassDiagrams",
+                     "  core : CoreFormalism"]),
+                "Ready for command...",
+                # transformation_add_MT_language
+                "Formalisms to include (terminate with empty string)?",
+                "Name of the RAMified transformation metamodel?",
+                "Ready for command...",
+                # model_list
+                set(["  SimpleClassDiagrams : SimpleClassDiagrams",
+                     "  CoreFormalism : SimpleClassDiagrams",
+                     "  PetriNets_Runtime : SimpleClassDiagrams",
+                     "  PetriNets : SimpleClassDiagrams",
+                     "  __merged_PetriNets_RAM : SimpleClassDiagrams",
+                     "  PetriNets_RAM : SimpleClassDiagrams",
+                     "  my_pn : PetriNets",
+                     "  core : CoreFormalism"]),
+                "Ready for command...",
+                # model_modify
+                "Which model do you want to modify?",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                # instantiate 1
+                "Type to instantiate?",
+                "Name of new element?",
+                "Source name?",
+                "Destination name?",
+                "Instantiation successful!",
+                "Please give your command.",
+                # instantiate 2
+                "Type to instantiate?",
+                "Name of new element?",
+                "Source name?",
+                "Destination name?",
+                "Instantiation successful!",
+                "Please give your command.",
+                # instantiate 3
+                "Type to instantiate?",
+                "Name of new element?",
+                "Source name?",
+                "Destination name?",
+                "Instantiation successful!",
+                "Please give your command.",
+                # instantiate 4
+                "Type to instantiate?",
+                "Name of new element?",
+                "Source name?",
+                "Destination name?",
+                "Instantiation successful!",
+                "Please give your command.",
+                "Ready for command...",
+                # transformation_RAMify
+                "Which metamodel do you want to RAMify?",
+                "Where do you want to store the RAMified metamodel?",
+                "Ready for command...",
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNets",
+                     "  PetriNets_Runtime",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Model added as target",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNets",
+                     "  PetriNets_Runtime",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Model added as target",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNets",
+                     "  PetriNets_Runtime",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Model added as target",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # transformation_add_MT
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set(["  PetriNets",
+                     "  PetriNets_Runtime",
+                    ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                # model_list
+                set(["  SimpleClassDiagrams : SimpleClassDiagrams",
+                     "  CoreFormalism : SimpleClassDiagrams",
+                     "  PetriNets_Runtime : SimpleClassDiagrams",
+                     "  PetriNets : SimpleClassDiagrams",
+                     "  pn_print : PetriNets_RAM",
+                     "  pn_design_to_runtime : PetriNets_RAM",
+                     "  pn_runtime_to_design : PetriNets_RAM",
+                     "  pn_step : PetriNets_RAM",
+                     "  __merged_PetriNets_RAM : SimpleClassDiagrams",
+                     "  PetriNets_RAM : SimpleClassDiagrams",
+                     "  my_pn : PetriNets",
+                     "  core : CoreFormalism"]),
+                "Ready for command...",
+                # transformation_list
+                set(["[ModelTransformation] pn_print : PetriNets_RAM",
+                     "[ModelTransformation] pn_design_to_runtime : PetriNets_RAM",
+                     "[ModelTransformation] pn_runtime_to_design : PetriNets_RAM",
+                     "[ModelTransformation] pn_step : PetriNets_RAM"]),
+                "Ready for command...",
+                # transformation_execute (pn_print)
+                "Which transformation do you want to execute?",
+                "Which model to bind for source element PetriNets",
+                set(['"p1" --> 1',
+                     '"p2" --> 2',
+                     '"p3" --> 3',
+                    ]),
+                "Transformation executed with result: True",
+                "Ready for command...",
+                # transformation_execute (pn_design_to_runtime)
+                "Which transformation do you want to execute?",
+                "Which model to bind for source element PetriNets",
+                "Which model to create for target element PetriNets_Runtime",
+                "Transformation executed with result: True",
+                "Ready for command...",
+                # transformation_execute (pn_step)
+                "Which transformation do you want to execute?",
+                "Which model to bind for source element PetriNets_Runtime",
+                "Which model to create for target element PetriNets_Runtime",
+                "Transformation executed with result: True",
+                "Ready for command...",
+                # transformation_execute (pn_runtime_to_design)
+                "Which transformation do you want to execute?",
+                "Which model to bind for source element PetriNets_Runtime",
+                "Which model to create for target element PetriNets",
+                "Transformation executed with result: True",
+                "Ready for command...",
+                # transformation_execute (pn_print)
+                "Which transformation do you want to execute?",
+                "Which model to bind for source element PetriNets",
+                set(['"p1" --> 0',
+                     '"p2" --> 1',
+                     '"p3" --> 5',
+                    ]),
+                "Transformation executed with result: True",
+                "Ready for command...",
+            ],
+            mode))

+ 4 - 18
integration/utils.py

@@ -100,10 +100,13 @@ def compile_file(address, mod_filename, filename, mode, proc):
         except UnboundLocalError:
             pass
 
-def run_file(files, parameters, expected, mode):
+def run_file(files, parameters, expected, mode, wait=False):
     # Resolve file
     import os.path
 
+    if wait is True:
+        expected = None
+
     time.sleep(0.01)
     port = getFreePort()
     address = "http://127.0.0.1:%i" % port
@@ -302,20 +305,3 @@ def get_model_constructor(code):
     constructors = do_compile("__model.mvc", "interface/HUTN/grammars/modelling.g", "M") + ["exit"]
 
     return constructors
-
-def get_raw_model_constructor(code):
-    # First change multiple spaces to a tab
-    code_fragments = code.split("\n")
-    code_fragments = [i for i in code_fragments if i.strip() != ""]
-    code_fragments = [i.replace("    ", "\t") for i in code_fragments]
-    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)
-
-    with open("__model.mvc", "w") as f:
-        f.write(code)
-        f.flush()
-
-    constructors = do_compile("__model.mvc", "interface/HUTN/grammars/modelling_raw.g", "MR") + ["exit"]
-
-    return constructors

+ 0 - 50
interface/HUTN/grammars/modelling_raw.g

@@ -1,50 +0,0 @@
-grammar{
-    start: (include_files | model | NEWLINE)+;
-
-    include_files: INCLUDE STRVALUE NEWLINE;
-
-    model: MODEL_ID MODEL_ID NEWLINE? LCURLY NEWLINE? (model_element)* RCURLY;
-
-    model_element: MODEL_ID MODEL_ID? inheritance? (LPAR MODEL_ID COMMA MODEL_ID RPAR)? NEWLINE? LCURLY NEWLINE? (model_attribute)* RCURLY NEWLINE?;
-
-    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_attr_instance)
-                    | (NEWLINE? DOLLAR ANYTHING_EXCEPT_DOLLAR DOLLAR NEWLINE?);
-
-    model_attr_instance: (MODEL_ID ASSIGN value NEWLINE?)
-                       | (MODEL_ID ASSIGN NEWLINE? DOLLAR ANYTHING_EXCEPT_DOLLAR DOLLAR NEWLINE?);
-
-    value
-        : DEC_NUMBER
-        | FLOAT_NUMBER
-        | TRUE
-        | FALSE
-        | STRVALUE;
-
-    tokens{
-        MODEL_ID: '[a-zA-Z_][a-zA-Z_0-9]*';
-        MV_URL: '[a-zA-Z_0-9/]*';
-        LCURLY: '{';
-        RCURLY: '}';
-        NEWLINE: '(\r?\n)+';
-        DEC_NUMBER: '[+-]?(0|[1-9]\d*[lL]?)';
-        FLOAT_NUMBER: '[+-]?((\d+\.\d*|\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+)';
-        STRVALUE: 'u?r?("(?!"").*?(?<!\\)(\\\\)*?"|\'(?!\'\').*?(?<!\\)(\\\\)*?\')';
-        TRUE: 'True';
-        FALSE: 'False';
-        ASSIGN: '=';
-        DOLLAR: '\$';
-        WS: '[ ]+' @Impl;
-        TAB: '[\t]+' @Impl;
-        COLON : ':';
-        LPAR: '\(';
-        RPAR: '\)';
-        COMMA: ',';
-        ANYTHING_EXCEPT_DOLLAR: '[^$]*';
-        INCLUDE: 'include';
-        EXCLAMATION: '!';
-    }
-}

+ 0 - 2
interface/HUTN/hutn_compiler/compiler.py

@@ -146,7 +146,6 @@ def main(input_file, grammar_file, mode, args=[], symbols=None):
     from constructors_object_visitor import ConstructorsObjectVisitor
     from model_visitor import ModelVisitor
     from model_object_visitor import ModelObjectVisitor
-    from model_raw_visitor import ModelRawVisitor
 
     modes = {
         "N" : [],
@@ -160,7 +159,6 @@ def main(input_file, grammar_file, mode, args=[], symbols=None):
         "CO" : [SemanticsVisitor, ConstructorsObjectVisitor],
         "M" : [ModelVisitor],
         "MO" : [ModelObjectVisitor],
-        "MR" : [ModelRawVisitor],
     }
     try:
         visitors = [v(args) for v in modes[mode]]

+ 0 - 161
interface/HUTN/hutn_compiler/model_raw_visitor.py

@@ -1,161 +0,0 @@
-from visitor import Visitor
-from compiler import main as do_compile
-import os
-
-def empty(s):
-    return None
-
-class ModelRawVisitor(Visitor):
-    def __init__(self, args):
-        Visitor.__init__(self, args)
-        self.constructors = []
-        self.free_id = 0
-        self.name_maps = {}
-        self.current_model = None
-        self.current_element = []
-        self.includes = []
-
-    def dump(self):
-        return self.constructors
-
-    def __getattr__(self, attr):
-        if attr.startswith("visit_"):
-            return empty
-        else:
-            raise AttributeError()
-
-    def visit_start(self, tree):
-        for t in tree.get_tail():
-            self.visit(t)
-
-    def visit_include_files(self, tree):
-        self.includes.append(tree.get_children("STRVALUE")[0].get_text())
-
-    def visit_model(self, tree):
-        children = tree.get_children("MODEL_ID")
-        model_type = children[0].get_text()
-        model_name = children[-1].get_text()
-        self.current_model = model_name
-        for element in tree.get_children("model_element"):
-            self.visit(element)
-
-    def visit_model_element(self, tree):
-        children = tree.get_children("MODEL_ID")
-        element_type = children[0].get_text()
-        if len(children) == 2 or len(children) == 4:
-            element_name = children[1].get_text()
-        else:
-            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!
-            source_name = children[-2].get_text()
-            target_name = children[-1].get_text()
-            self.constructors.extend(["instantiate_link", element_type, element_name, source_name, target_name])
-        else:
-            self.constructors.extend(["instantiate_node", element_type, element_name])
-
-        self.current_element.append(element_name)
-
-        if tree.get_children("inheritance"):
-            self.visit(tree.get_children("inheritance")[0])
-            
-        for attr in tree.get_children("model_attribute"):
-            self.visit(attr)
-
-        self.current_element.pop()
-
-        return element_name
-
-    def visit_inheritance(self, tree):
-        for token in tree.get_children("MODEL_ID"):
-            superclass = token.get_text()
-            self.constructors.extend(["instantiate_link", "Inheritance", "%s_inherits_from_%s" % (self.current_element[-1], superclass), self.current_element[-1], superclass])
-
-    def visit_model_attribute(self, tree):
-        children = tree.get_children("MODEL_ID")
-        is_definition = bool(tree.get_children("COLON"))
-        is_constraint = bool(tree.get_children("DOLLAR"))
-        is_assign = bool(tree.get_children("model_attr_instance"))
-        is_nested = bool(tree.get_children("model_element"))
-
-        if is_definition:
-            attr_name = children[0].get_text()
-            attr_type = children[1].get_text()
-            self.constructors.extend(["instantiate_link", "Association", self.current_element[-1] + "_" + attr_name, self.current_element[-1], attr_type])
-            full_attribute_name = self.current_element[-1] + "_" + attr_name
-            self.constructors.extend(["instantiate_attribute", full_attribute_name, "name", attr_name])
-            if is_assign:
-                # There are also some attributes to set!
-                self.current_element.append(full_attribute_name)
-
-                for f in tree.get_children("model_attr_instance"):
-                    self.visit(f)
-
-                self.current_element.pop()
-        elif is_assign:
-            self.visit(tree.get_children("model_attr_instance")[0])
-        elif is_constraint:
-            constraint = tree.get_children("ANYTHING_EXCEPT_DOLLAR")[0].get_text()
-            whitespaces = len(constraint) - len(constraint.lstrip())
-            constraint = "\n".join(["\t" + line[whitespaces-1:].replace("    ", "\t") for line in constraint.split("\n") if len(line.strip()) != 0])
-            constraint = "".join(["include %s\n" % i for i in self.includes]) + \
-                         "String function constraint(model : Element, name : String):\n" + \
-                         "\tElement self\n" + \
-                         '\tself = model["model"][name]\n' + \
-                         constraint + "\n"
-            with open(".constraint.alc", 'w') as f:
-                f.write(constraint)
-                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_element[-1]] + compiled)
-        elif is_nested:
-            if tree.get_children("MODEL_ID"):
-                contains_link = tree.get_children("MODEL_ID")[0].get_text()
-            else:
-                contains_link = ""
-            entry = self.visit(tree.get_children("model_element")[0])
-            self.constructors.extend(["instantiate_link", contains_link, "__%s" % self.free_id, self.current_element[-1], entry])
-            self.free_id += 1
-
-    def visit_model_attr_instance(self, tree):
-        def constructors_compile(code):
-            code_fragments = code.split("\n")
-	    code_fragments = [i for i in code_fragments if i.strip() != ""]
-	    code_fragments = [i.replace("    ", "\t") for i in code_fragments]
-	    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)
-                f.flush()
-            directory = os.path.realpath(__file__).rsplit(os.sep, 1)[0]
-            compiled = do_compile(".code.alc", directory + "/../grammars/actionlanguage.g", "CS")
-            return compiled
-
-        children = tree.get_children("MODEL_ID")
-        attr_name = children[0].get_text()
-        if tree.get_children("value"):
-            # Value attribute
-            attr_value = tree.get_children("value")[0].get_tail()[0]
-            if attr_value.head == "STRVALUE":
-                attr_value = attr_value.get_text()[1:-1]
-            elif attr_value.head == "TRUE":
-                attr_value = True
-            elif attr_value.head == "FALSE":
-                attr_value = False
-            elif attr_value.head == "DEC_NUMBER":
-                attr_value = int(attr_value.get_text())
-            elif attr_value.head == "FLOAT_NUMBER":
-                attr_value = float(attr_value.get_text())
-            else:
-                raise Exception(attr_value.head)
-            self.constructors.extend(["instantiate_attribute", self.current_element[-1], attr_name, attr_value])
-        elif tree.get_children("DOLLAR"):
-            # Coded attribute
-            self.constructors.extend(["instantiate_attribute_code", self.current_element[-1], attr_name])
-            self.constructors.extend(constructors_compile(tree.get_children("ANYTHING_EXCEPT_DOLLAR")[0].get_text()))