|
@@ -5,6 +5,7 @@ include "constructors.alh"
|
|
|
include "metamodels.alh"
|
|
|
include "library.alh"
|
|
|
include "typing.alh"
|
|
|
+include "utils.alh"
|
|
|
|
|
|
Element global_models = ?
|
|
|
|
|
@@ -537,34 +538,18 @@ Element function construct_model_raw(metamodel : Element):
|
|
|
String command
|
|
|
Element model
|
|
|
|
|
|
- model = instantiate_model(metamodel)
|
|
|
-
|
|
|
- while (True):
|
|
|
- command = input()
|
|
|
- if (command == "add_node"):
|
|
|
- model_add_node(model, input())
|
|
|
- elif (command == "add_value"):
|
|
|
- model_add_value(model, input(), input())
|
|
|
- elif (command == "add_edge"):
|
|
|
- model_add_edge(model, input(), input(), input())
|
|
|
- elif (command == "exit"):
|
|
|
- return model!
|
|
|
- elif (command == "instantiate_node"):
|
|
|
- instantiate_node(model, input(), input())
|
|
|
- elif (command == "model_define_attribute"):
|
|
|
- model_define_attribute(model, input(), input(), input(), input())
|
|
|
- elif (command == "instantiate_attribute"):
|
|
|
- instantiate_attribute(model, input(), input(), input())
|
|
|
- elif (command == "instantiate_attribute_ref"):
|
|
|
- instantiate_attribute_ref(model, input(), input(), input())
|
|
|
- elif (command == "instantiate_attribute_code"):
|
|
|
- instantiate_attribute_code(model, input(), input(), construct_function())
|
|
|
- elif (command == "instantiate_link"):
|
|
|
- instantiate_link(model, input(), input(), input(), input())
|
|
|
- elif (command == "add_code_model"):
|
|
|
- add_code_model(model, input(), construct_function())
|
|
|
- else:
|
|
|
- log("Modelling error: did not understand command " + command)
|
|
|
+ Integer i
|
|
|
+ Integer count
|
|
|
+ Element lst
|
|
|
+ i = 0
|
|
|
+ count = input()
|
|
|
+ lst = list_create()
|
|
|
+
|
|
|
+ while (i < count):
|
|
|
+ list_append(lst, input())
|
|
|
+ i = i + 1
|
|
|
+
|
|
|
+ return construct_model_list(metamodel, lst)!
|
|
|
|
|
|
Element function get_func_AL_model(al_model : Element):
|
|
|
Element initial_function
|
|
@@ -580,3 +565,50 @@ Element function get_func_AL_model(al_model : Element):
|
|
|
return read_root()!
|
|
|
else:
|
|
|
return al_model["model"][set_pop(allAssociationDestinations(al_model, set_pop(initial_function), "initial_funcdef"))]!
|
|
|
+
|
|
|
+Element function trim_AL_constructors(list : Element):
|
|
|
+ Integer length
|
|
|
+ Element lst
|
|
|
+ Integer i
|
|
|
+ length = list_pop_final(list)
|
|
|
+ i = 0
|
|
|
+ lst = list_create()
|
|
|
+
|
|
|
+ while (i < length):
|
|
|
+ list_append(lst, list_pop_final(list))
|
|
|
+
|
|
|
+ return lst!
|
|
|
+
|
|
|
+Element function construct_model_list(metamodel : Element, list : Element):
|
|
|
+ String command
|
|
|
+ Element model
|
|
|
+
|
|
|
+ list = list_reverse(list)
|
|
|
+ model = instantiate_model(metamodel)
|
|
|
+
|
|
|
+ while (list_len(list) > 0):
|
|
|
+ command = list_pop_final(list)
|
|
|
+ if (command == "add_node"):
|
|
|
+ model_add_node(model, list_pop_final(list))
|
|
|
+ elif (command == "add_value"):
|
|
|
+ model_add_value(model, list_pop_final(list), list_pop_final(list))
|
|
|
+ elif (command == "add_edge"):
|
|
|
+ model_add_edge(model, list_pop_final(list), list_pop_final(list), list_pop_final(list))
|
|
|
+ elif (command == "instantiate_node"):
|
|
|
+ instantiate_node(model, list_pop_final(list), list_pop_final(list))
|
|
|
+ elif (command == "model_define_attribute"):
|
|
|
+ model_define_attribute(model, list_pop_final(list), list_pop_final(list), list_pop_final(list), list_pop_final(list))
|
|
|
+ elif (command == "instantiate_attribute"):
|
|
|
+ instantiate_attribute(model, list_pop_final(list), list_pop_final(list), list_pop_final(list))
|
|
|
+ elif (command == "instantiate_attribute_ref"):
|
|
|
+ instantiate_attribute_ref(model, list_pop_final(list), list_pop_final(list), list_pop_final(list))
|
|
|
+ elif (command == "instantiate_attribute_code"):
|
|
|
+ instantiate_attribute_code(model, list_pop_final(list), list_pop_final(list), construct_function_list(trim_AL_constructors(list)))
|
|
|
+ elif (command == "instantiate_link"):
|
|
|
+ instantiate_link(model, list_pop_final(list), list_pop_final(list), list_pop_final(list), list_pop_final(list))
|
|
|
+ elif (command == "add_code_model"):
|
|
|
+ add_code_model(model, list_pop_final(list), construct_function_list(trim_AL_constructors(list)))
|
|
|
+ else:
|
|
|
+ log("Modelling error: did not understand command " + command)
|
|
|
+
|
|
|
+ return model!
|