|
@@ -6,94 +6,94 @@ include "io.alh"
|
|
|
Element while_stack = ?
|
|
|
|
|
|
Element function construct_top():
|
|
|
- Element elem2
|
|
|
- elem2 = input()
|
|
|
- if (string_eq(elem2, "global")):
|
|
|
+ String command
|
|
|
+ command = input()
|
|
|
+ if (command == "global"):
|
|
|
return construct_top_global()
|
|
|
- elif (string_eq(elem2, "funcdef")):
|
|
|
+ elif (command == "funcdef"):
|
|
|
return construct_top_funcdef()
|
|
|
else:
|
|
|
- log(string_join("ERROR: did not understand command ", cast_e2s(elem2)))
|
|
|
+ log("ERROR: did not understand command " + cast_e2s(command))
|
|
|
|
|
|
Element function construct_top_global():
|
|
|
- Element this_element_tg
|
|
|
- String declared_element_tg
|
|
|
- String op_tg
|
|
|
+ Element this_element
|
|
|
+ String declared_element
|
|
|
+ String op
|
|
|
|
|
|
- this_element_tg = create_value(!global)
|
|
|
- declared_element_tg = input()
|
|
|
- dict_add(this_element_tg, "var", declared_element_tg)
|
|
|
+ this_element = create_value(!global)
|
|
|
+ declared_element = input()
|
|
|
+ dict_add(this_element, "var", declared_element)
|
|
|
|
|
|
// Defines
|
|
|
- Element assign_tg
|
|
|
- Element resolve_tg
|
|
|
- Element value_tg
|
|
|
- assign_tg = create_value(!assign)
|
|
|
- dict_add(this_element_tg, "next", assign_tg)
|
|
|
- resolve_tg = create_value(!resolve)
|
|
|
- dict_add(assign_tg, "var", resolve_tg)
|
|
|
- dict_add(resolve_tg, "var", declared_element_tg)
|
|
|
- op_tg = input()
|
|
|
- value_tg = create_value(!constant)
|
|
|
- if (string_eq(op_tg, "deref")):
|
|
|
- dict_add(value_tg, "node", import_node(input()))
|
|
|
- elif (string_eq(op_tg, "empty")):
|
|
|
- dict_add(value_tg, "node", create_node())
|
|
|
- elif (string_eq(op_tg, "const")):
|
|
|
- dict_add(value_tg, "node", input())
|
|
|
- dict_add(assign_tg, "value", value_tg)
|
|
|
+ Element assign
|
|
|
+ Element resolve
|
|
|
+ Element value
|
|
|
+ assign = create_value(!assign)
|
|
|
+ dict_add(this_element, "next", assign)
|
|
|
+ resolve = create_value(!resolve)
|
|
|
+ dict_add(assign, "var", resolve)
|
|
|
+ dict_add(resolve, "var", declared_element)
|
|
|
+ op = input()
|
|
|
+ value = create_value(!constant)
|
|
|
+ if (op == "deref"):
|
|
|
+ dict_add(value, "node", import_node(input()))
|
|
|
+ elif (op == "empty"):
|
|
|
+ dict_add(value, "node", create_node())
|
|
|
+ elif (op == "const"):
|
|
|
+ dict_add(value, "node", input())
|
|
|
+ dict_add(assign, "value", value)
|
|
|
|
|
|
if (input()):
|
|
|
- dict_add(assign_tg, "next", construct_top())
|
|
|
- return this_element_tg
|
|
|
+ dict_add(assign, "next", construct_top())
|
|
|
+ return this_element
|
|
|
|
|
|
Element function construct_top_funcdef():
|
|
|
- Element funcdef_assign_top
|
|
|
- Element funcdef_resolve_top
|
|
|
- Element funcdef_constant_top
|
|
|
- Element funcdef_formal_top
|
|
|
- Element funcdef_func_top
|
|
|
- Element funcdef_params_top
|
|
|
- Element funcdef_global_top
|
|
|
-
|
|
|
- funcdef_global_top = create_value(!global)
|
|
|
- funcdef_assign_top = create_value(!assign)
|
|
|
- funcdef_resolve_top = create_value(!resolve)
|
|
|
- funcdef_constant_top = create_value(!constant)
|
|
|
- funcdef_formal_top = input()
|
|
|
- funcdef_func_top = create_node()
|
|
|
- funcdef_params_top = create_node()
|
|
|
- dict_add(funcdef_global_top, "var", funcdef_formal_top)
|
|
|
- dict_add(funcdef_global_top, "next", funcdef_assign_top)
|
|
|
- dict_add(funcdef_assign_top, "var", funcdef_resolve_top)
|
|
|
- dict_add(funcdef_assign_top, "value", funcdef_constant_top)
|
|
|
- dict_add(funcdef_resolve_top, "var", funcdef_formal_top)
|
|
|
- dict_add(funcdef_constant_top, "node", funcdef_func_top)
|
|
|
- dict_add(funcdef_func_top, "params", funcdef_params_top)
|
|
|
-
|
|
|
- Integer funcdef_nrParams_top
|
|
|
- funcdef_nrParams_top = input()
|
|
|
- Integer funcdef_counter_top
|
|
|
- funcdef_counter_top = 0
|
|
|
- Element funcdef_param_top
|
|
|
-
|
|
|
- String arg_names_decl_top
|
|
|
- arg_names_decl_top = "abcdefghijklmnopqrstuvwxyz"
|
|
|
-
|
|
|
- while (integer_lt(funcdef_counter_top, funcdef_nrParams_top)):
|
|
|
- funcdef_param_top = create_node()
|
|
|
- dict_add(funcdef_params_top, string_get(arg_names_decl_top, funcdef_counter_top), funcdef_param_top)
|
|
|
- output(funcdef_param_top)
|
|
|
+ Element assign
|
|
|
+ Element resolve
|
|
|
+ Element constant
|
|
|
+ Element formal
|
|
|
+ Element func
|
|
|
+ Element params
|
|
|
+ Element global
|
|
|
+
|
|
|
+ global = create_value(!global)
|
|
|
+ assign = create_value(!assign)
|
|
|
+ resolve = create_value(!resolve)
|
|
|
+ constant = create_value(!constant)
|
|
|
+ formal = input()
|
|
|
+ func = create_node()
|
|
|
+ params = create_node()
|
|
|
+ dict_add(global, "var", formal)
|
|
|
+ dict_add(global, "next", assign)
|
|
|
+ dict_add(assign, "var", resolve)
|
|
|
+ dict_add(assign, "value", constant)
|
|
|
+ dict_add(resolve, "var", formal)
|
|
|
+ dict_add(constant, "node", func)
|
|
|
+ dict_add(func, "params", params)
|
|
|
+
|
|
|
+ Integer nrParams
|
|
|
+ nrParams = input()
|
|
|
+ Integer counter
|
|
|
+ counter = 0
|
|
|
+ Element param
|
|
|
+
|
|
|
+ String arg_names_decl
|
|
|
+ arg_names_decl = "abcdefghijklmnopqrstuvwxyz"
|
|
|
+
|
|
|
+ while (counter < nrParams):
|
|
|
+ param = create_node()
|
|
|
+ dict_add(params, string_get(arg_names_decl, counter), param)
|
|
|
+ output(param)
|
|
|
// Output each parameter in turn
|
|
|
- funcdef_counter_top = integer_addition(funcdef_counter_top, 1)
|
|
|
+ counter = counter + 1
|
|
|
|
|
|
// Now add the body
|
|
|
- dict_add(funcdef_func_top, "body", construct_unknown())
|
|
|
+ dict_add(func, "body", construct_unknown())
|
|
|
|
|
|
if (input()):
|
|
|
- dict_add(funcdef_assign_top, "next", construct_top())
|
|
|
+ dict_add(assign, "next", construct_top())
|
|
|
|
|
|
- return funcdef_global_top
|
|
|
+ return global
|
|
|
|
|
|
Element function construct_unknown():
|
|
|
String elem
|
|
@@ -101,109 +101,109 @@ Element function construct_unknown():
|
|
|
Element new_model_model
|
|
|
elem = input()
|
|
|
|
|
|
- if (string_eq(elem, "if")):
|
|
|
+ if (elem == "if"):
|
|
|
return construct_if()
|
|
|
- elif (string_eq(elem, "while")):
|
|
|
+ elif (elem == "while"):
|
|
|
return construct_while()
|
|
|
- elif (string_eq(elem, "access")):
|
|
|
+ elif (elem == "access"):
|
|
|
return construct_access()
|
|
|
- elif (string_eq(elem, "resolve")):
|
|
|
+ elif (elem == "resolve"):
|
|
|
return construct_resolve()
|
|
|
- elif (string_eq(elem, "assign")):
|
|
|
+ elif (elem == "assign"):
|
|
|
return construct_assign()
|
|
|
- elif (string_eq(elem, "call")):
|
|
|
+ elif (elem == "call"):
|
|
|
return construct_call()
|
|
|
- elif (string_eq(elem, "return")):
|
|
|
+ elif (elem == "return"):
|
|
|
return construct_return()
|
|
|
- elif (string_eq(elem, "const")):
|
|
|
+ elif (elem == "const"):
|
|
|
return construct_const()
|
|
|
- elif (string_eq(elem, "declare")):
|
|
|
+ elif (elem == "declare"):
|
|
|
return construct_declare()
|
|
|
- elif (string_eq(elem, "global")):
|
|
|
+ elif (elem == "global"):
|
|
|
return construct_global()
|
|
|
- elif (string_eq(elem, "funcdef")):
|
|
|
+ elif (elem == "funcdef"):
|
|
|
return construct_funcdef()
|
|
|
- elif (string_eq(elem, "output")):
|
|
|
+ elif (elem == "output"):
|
|
|
return construct_output()
|
|
|
- elif (string_eq(elem, "input")):
|
|
|
+ elif (elem == "input"):
|
|
|
return construct_input()
|
|
|
- elif (string_eq(elem, "deref")):
|
|
|
+ elif (elem == "deref"):
|
|
|
return construct_deref()
|
|
|
- elif (string_eq(elem, "break")):
|
|
|
+ elif (elem == "break"):
|
|
|
return construct_break()
|
|
|
- elif (string_eq(elem, "continue")):
|
|
|
+ elif (elem == "continue"):
|
|
|
return construct_continue()
|
|
|
- elif (string_eq(elem, "tag")):
|
|
|
+ elif (elem == "tag"):
|
|
|
Element tmp_constructed
|
|
|
tmp_constructed = construct_unknown()
|
|
|
output(tmp_constructed)
|
|
|
return tmp_constructed
|
|
|
- elif (string_eq(elem, "instantiate_bottom")):
|
|
|
+ elif (elem == "instantiate_bottom"):
|
|
|
new_model = create_node()
|
|
|
dict_add(new_model, "model", create_node())
|
|
|
instantiate_bottom(new_model)
|
|
|
output(new_model)
|
|
|
return construct_unknown()
|
|
|
- elif (string_eq(elem, "instantiate_model")):
|
|
|
+ elif (elem == "instantiate_model"):
|
|
|
new_model = instantiate_new_model(input(), dict_read(dict_read(input(), "model"), input()))
|
|
|
instantiate_model(new_model)
|
|
|
output(new_model)
|
|
|
return construct_unknown()
|
|
|
- elif (string_eq(elem, "retype_model")):
|
|
|
+ elif (elem == "retype_model"):
|
|
|
retype_model(input())
|
|
|
return construct_unknown()
|
|
|
else:
|
|
|
- log(string_join("ERROR: did not understand command ", cast_e2s(elem)))
|
|
|
+ log("ERROR: did not understand command " + cast_e2s(elem))
|
|
|
|
|
|
Element function construct_if():
|
|
|
- Element this_element_1
|
|
|
- this_element_1 = create_value(!if)
|
|
|
- dict_add(this_element_1, "cond", construct_unknown())
|
|
|
- dict_add(this_element_1, "then", construct_unknown())
|
|
|
+ Element this_element
|
|
|
+ this_element = create_value(!if)
|
|
|
+ dict_add(this_element, "cond", construct_unknown())
|
|
|
+ dict_add(this_element, "then", construct_unknown())
|
|
|
if (input()):
|
|
|
- dict_add(this_element_1, "else", construct_unknown())
|
|
|
+ dict_add(this_element, "else", construct_unknown())
|
|
|
if (input()):
|
|
|
- dict_add(this_element_1, "next", construct_unknown())
|
|
|
- return this_element_1
|
|
|
+ dict_add(this_element, "next", construct_unknown())
|
|
|
+ return this_element
|
|
|
|
|
|
Element function construct_while():
|
|
|
- Element this_element_2
|
|
|
- this_element_2 = create_value(!while)
|
|
|
- dict_add(this_element_2, "cond", construct_unknown())
|
|
|
+ Element this_element
|
|
|
+ this_element = create_value(!while)
|
|
|
+ dict_add(this_element, "cond", construct_unknown())
|
|
|
|
|
|
- list_append(while_stack, this_element_2)
|
|
|
- dict_add(this_element_2, "body", construct_unknown())
|
|
|
- list_delete(while_stack, integer_subtraction(list_len(while_stack), 1))
|
|
|
+ list_append(while_stack, this_element)
|
|
|
+ dict_add(this_element, "body", construct_unknown())
|
|
|
+ list_delete(while_stack, list_len(while_stack) - 1)
|
|
|
|
|
|
if (input()):
|
|
|
- dict_add(this_element_2, "next", construct_unknown())
|
|
|
- return this_element_2
|
|
|
+ dict_add(this_element, "next", construct_unknown())
|
|
|
+ return this_element
|
|
|
|
|
|
Element function construct_access():
|
|
|
- Element this_element_3
|
|
|
- this_element_3 = create_value(!access)
|
|
|
- dict_add(this_element_3, "var", construct_unknown())
|
|
|
- return this_element_3
|
|
|
+ Element this_element
|
|
|
+ this_element = create_value(!access)
|
|
|
+ dict_add(this_element, "var", construct_unknown())
|
|
|
+ return this_element
|
|
|
|
|
|
Element function construct_resolve():
|
|
|
- Element this_element_4
|
|
|
- this_element_4 = create_value(!resolve)
|
|
|
- dict_add(this_element_4, "var", input())
|
|
|
- return this_element_4
|
|
|
+ Element this_element
|
|
|
+ this_element = create_value(!resolve)
|
|
|
+ dict_add(this_element, "var", input())
|
|
|
+ return this_element
|
|
|
|
|
|
Element function construct_assign():
|
|
|
- Element this_element_5
|
|
|
- this_element_5 = create_value(!assign)
|
|
|
- dict_add(this_element_5, "var", construct_unknown())
|
|
|
- dict_add(this_element_5, "value", construct_unknown())
|
|
|
+ Element this_element
|
|
|
+ this_element = create_value(!assign)
|
|
|
+ dict_add(this_element, "var", construct_unknown())
|
|
|
+ dict_add(this_element, "value", construct_unknown())
|
|
|
if (input()):
|
|
|
- dict_add(this_element_5, "next", construct_unknown())
|
|
|
- return this_element_5
|
|
|
+ dict_add(this_element, "next", construct_unknown())
|
|
|
+ return this_element
|
|
|
|
|
|
Element function construct_call():
|
|
|
- Element this_element_6
|
|
|
- this_element_6 = create_value(!call)
|
|
|
- dict_add(this_element_6, "func", construct_unknown())
|
|
|
+ Element this_element
|
|
|
+ this_element = create_value(!call)
|
|
|
+ dict_add(this_element, "func", construct_unknown())
|
|
|
|
|
|
Integer nrParams
|
|
|
nrParams = input()
|
|
@@ -215,216 +215,216 @@ Element function construct_call():
|
|
|
String arg_names_call
|
|
|
arg_names_call = "abcdefghijklmnopqrstuvwxyz"
|
|
|
|
|
|
- while (integer_lt(counter, nrParams)):
|
|
|
+ while (counter < nrParams):
|
|
|
param = create_node()
|
|
|
|
|
|
dict_add(param, "name", string_get(arg_names_call, counter))
|
|
|
dict_add(param, "value", construct_unknown())
|
|
|
|
|
|
- if (integer_eq(counter, 0)):
|
|
|
- dict_add(this_element_6, "params", param)
|
|
|
+ if (counter == 0):
|
|
|
+ dict_add(this_element, "params", param)
|
|
|
else:
|
|
|
dict_add(prev_param, "next_param", param)
|
|
|
prev_param = param
|
|
|
|
|
|
- counter = integer_addition(counter, 1)
|
|
|
+ counter = counter + 1
|
|
|
|
|
|
- if (integer_gt(nrParams, 0)):
|
|
|
- dict_add(this_element_6, "last_param", prev_param)
|
|
|
+ if (nrParams > 0):
|
|
|
+ dict_add(this_element, "last_param", prev_param)
|
|
|
|
|
|
if (input()):
|
|
|
- dict_add(this_element_6, "next", construct_unknown())
|
|
|
- return this_element_6
|
|
|
+ dict_add(this_element, "next", construct_unknown())
|
|
|
+ return this_element
|
|
|
|
|
|
Element function construct_return():
|
|
|
- Element this_element_7
|
|
|
- this_element_7 = create_value(!return)
|
|
|
+ Element this_element
|
|
|
+ this_element = create_value(!return)
|
|
|
if (input()):
|
|
|
- dict_add(this_element_7, "value", construct_unknown())
|
|
|
- return this_element_7
|
|
|
+ dict_add(this_element, "value", construct_unknown())
|
|
|
+ return this_element
|
|
|
|
|
|
Element function construct_const():
|
|
|
- Element this_element_8
|
|
|
- this_element_8 = create_value(!constant)
|
|
|
- dict_add(this_element_8, "node", input())
|
|
|
- return this_element_8
|
|
|
+ Element this_element
|
|
|
+ this_element = create_value(!constant)
|
|
|
+ dict_add(this_element, "node", input())
|
|
|
+ return this_element
|
|
|
|
|
|
Element function construct_declare():
|
|
|
- Element this_element_9
|
|
|
- Element declared_element_1
|
|
|
- this_element_9 = create_value(!declare)
|
|
|
- declared_element_1 = create_node()
|
|
|
- dict_add(this_element_9, "var", declared_element_1)
|
|
|
- output(declared_element_1)
|
|
|
+ Element this_element
|
|
|
+ Element declared_element
|
|
|
+ this_element = create_value(!declare)
|
|
|
+ declared_element = create_node()
|
|
|
+ dict_add(this_element, "var", declared_element)
|
|
|
+ output(declared_element)
|
|
|
if (input()):
|
|
|
- dict_add(this_element_9, "next", construct_unknown())
|
|
|
- return this_element_9
|
|
|
+ dict_add(this_element, "next", construct_unknown())
|
|
|
+ return this_element
|
|
|
|
|
|
// TODO remove global keyword
|
|
|
Element function construct_global():
|
|
|
- Element this_element_10
|
|
|
- String declared_element_2
|
|
|
- this_element_10 = create_value(!global)
|
|
|
- declared_element_2 = input()
|
|
|
- dict_add(this_element_10, "var", declared_element_2)
|
|
|
+ Element this_element
|
|
|
+ String declared_element
|
|
|
+ this_element = create_value(!global)
|
|
|
+ declared_element = input()
|
|
|
+ dict_add(this_element, "var", declared_element)
|
|
|
if (input()):
|
|
|
- dict_add(this_element_10, "next", construct_unknown())
|
|
|
- return this_element_10
|
|
|
+ dict_add(this_element, "next", construct_unknown())
|
|
|
+ return this_element
|
|
|
|
|
|
Element function construct_input():
|
|
|
- Element this_element_11
|
|
|
- this_element_11 = create_value(!input)
|
|
|
- return this_element_11
|
|
|
+ Element this_element
|
|
|
+ this_element = create_value(!input)
|
|
|
+ return this_element
|
|
|
|
|
|
Element function construct_output():
|
|
|
- Element this_element_12
|
|
|
- this_element_12 = create_value(!output)
|
|
|
- dict_add(this_element_12, "value", construct_unknown())
|
|
|
+ Element this_element
|
|
|
+ this_element = create_value(!output)
|
|
|
+ dict_add(this_element, "value", construct_unknown())
|
|
|
if (input()):
|
|
|
- dict_add(this_element_12, "next", construct_unknown())
|
|
|
- return this_element_12
|
|
|
+ dict_add(this_element, "next", construct_unknown())
|
|
|
+ return this_element
|
|
|
|
|
|
Element function construct_deref():
|
|
|
- Element this_element_13
|
|
|
- this_element_13 = create_value(!constant)
|
|
|
- dict_add(this_element_13, "node", import_node(input()))
|
|
|
- return this_element_13
|
|
|
+ Element this_element
|
|
|
+ this_element = create_value(!constant)
|
|
|
+ dict_add(this_element, "node", import_node(input()))
|
|
|
+ return this_element
|
|
|
|
|
|
Element function construct_funcdef():
|
|
|
- Element funcdef_assign
|
|
|
- Element funcdef_resolve
|
|
|
- Element funcdef_constant
|
|
|
- Element funcdef_formal
|
|
|
- Element funcdef_func
|
|
|
- Element funcdef_params
|
|
|
-
|
|
|
- funcdef_assign = create_value(!assign)
|
|
|
- funcdef_resolve = create_value(!resolve)
|
|
|
- funcdef_constant = create_value(!constant)
|
|
|
- funcdef_formal = input()
|
|
|
- funcdef_func = create_node()
|
|
|
- funcdef_params = create_node()
|
|
|
- dict_add(funcdef_assign, "var", funcdef_resolve)
|
|
|
- dict_add(funcdef_assign, "value", funcdef_constant)
|
|
|
- dict_add(funcdef_resolve, "var", funcdef_formal)
|
|
|
- dict_add(funcdef_constant, "node", funcdef_func)
|
|
|
- dict_add(funcdef_func, "params", funcdef_params)
|
|
|
-
|
|
|
- Integer funcdef_nrParams
|
|
|
- funcdef_nrParams = input()
|
|
|
- Integer funcdef_counter
|
|
|
- funcdef_counter = 0
|
|
|
- Element funcdef_param
|
|
|
+ Element assign
|
|
|
+ Element resolve
|
|
|
+ Element constant
|
|
|
+ Element formal
|
|
|
+ Element func
|
|
|
+ Element params
|
|
|
+
|
|
|
+ assign = create_value(!assign)
|
|
|
+ resolve = create_value(!resolve)
|
|
|
+ constant = create_value(!constant)
|
|
|
+ formal = input()
|
|
|
+ func = create_node()
|
|
|
+ params = create_node()
|
|
|
+ dict_add(assign, "var", resolve)
|
|
|
+ dict_add(assign, "value", constant)
|
|
|
+ dict_add(resolve, "var", formal)
|
|
|
+ dict_add(constant, "node", func)
|
|
|
+ dict_add(func, "params", params)
|
|
|
+
|
|
|
+ Integer nrParams
|
|
|
+ nrParams = input()
|
|
|
+ Integer counter
|
|
|
+ counter = 0
|
|
|
+ Element param
|
|
|
|
|
|
String arg_names_decl
|
|
|
arg_names_decl = "abcdefghijklmnopqrstuvwxyz"
|
|
|
|
|
|
- while (integer_lt(funcdef_counter, funcdef_nrParams)):
|
|
|
- funcdef_param = create_node()
|
|
|
- dict_add(funcdef_params, string_get(arg_names_decl, funcdef_counter), funcdef_param)
|
|
|
- output(funcdef_param)
|
|
|
+ while (counter < nrParams):
|
|
|
+ param = create_node()
|
|
|
+ dict_add(params, string_get(arg_names_decl, counter), param)
|
|
|
+ output(param)
|
|
|
// Output each parameter in turn
|
|
|
- funcdef_counter = integer_addition(funcdef_counter, 1)
|
|
|
+ counter = counter + 1
|
|
|
|
|
|
// Now add the body
|
|
|
- dict_add(funcdef_func, "body", construct_unknown())
|
|
|
+ dict_add(func, "body", construct_unknown())
|
|
|
|
|
|
if (input()):
|
|
|
- dict_add(funcdef_assign, "next", construct_unknown())
|
|
|
+ dict_add(assign, "next", construct_unknown())
|
|
|
|
|
|
- return funcdef_assign
|
|
|
+ return assign
|
|
|
|
|
|
Element function construct_break():
|
|
|
- Element this_element_15
|
|
|
- this_element_15 = create_value(!break)
|
|
|
- dict_add(this_element_15, "while", dict_read(while_stack, integer_subtraction(list_len(while_stack), 1)))
|
|
|
- return this_element_15
|
|
|
+ Element this_element
|
|
|
+ this_element = create_value(!break)
|
|
|
+ dict_add(this_element, "while", dict_read(while_stack, list_len(while_stack) - 1))
|
|
|
+ return this_element
|
|
|
|
|
|
Element function construct_continue():
|
|
|
- Element this_element_16
|
|
|
- this_element_16 = create_value(!continue)
|
|
|
- dict_add(this_element_16, "while", dict_read(while_stack, integer_subtraction(list_len(while_stack), 1)))
|
|
|
- return this_element_16
|
|
|
-
|
|
|
-Element function instantiate_bottom(model_18 : Element):
|
|
|
- Element this_element_18
|
|
|
- Element bottom_type
|
|
|
+ Element this_element
|
|
|
+ this_element = create_value(!continue)
|
|
|
+ dict_add(this_element, "while", dict_read(while_stack, list_len(while_stack) - 1))
|
|
|
+ return this_element
|
|
|
+
|
|
|
+Element function instantiate_bottom(model : Element):
|
|
|
+ Element this_element
|
|
|
+ String bottom_type
|
|
|
bottom_type = input()
|
|
|
- String element_name_18
|
|
|
- element_name_18 = input()
|
|
|
+ String element_name
|
|
|
+ element_name = input()
|
|
|
|
|
|
// Find out which kind of element we want to create
|
|
|
- if (string_eq(bottom_type, "node")):
|
|
|
- instantiate_bottom_node(model_18, element_name_18)
|
|
|
- elif (string_eq(bottom_type, "value")):
|
|
|
- instantiate_bottom_value(model_18, element_name_18, input())
|
|
|
- elif (string_eq(bottom_type, "edge")):
|
|
|
- instantiate_bottom_edge(model_18, element_name_18, dict_read(dict_read(model_18, "model"), input()), dict_read(dict_read(model_18, "model"), input()))
|
|
|
+ if (bottom_type == "node"):
|
|
|
+ instantiate_bottom_node(model, element_name)
|
|
|
+ elif (bottom_type == "value"):
|
|
|
+ instantiate_bottom_value(model, element_name, input())
|
|
|
+ elif (bottom_type == "edge"):
|
|
|
+ instantiate_bottom_edge(model, element_name, dict_read(dict_read(model, "model"), input()), dict_read(dict_read(model, "model"), input()))
|
|
|
|
|
|
// If there is more to come, we also add these elements
|
|
|
if (input()):
|
|
|
- return instantiate_bottom(model_18)
|
|
|
+ return instantiate_bottom(model)
|
|
|
else:
|
|
|
- return model_18
|
|
|
+ return model
|
|
|
|
|
|
-Element function instantiate_model(model_19 : Element):
|
|
|
- Element type_19
|
|
|
- type_19 = dict_read(dict_read(dict_read(model_19, "metamodel"), "model"), input())
|
|
|
+Element function instantiate_model(model : Element):
|
|
|
+ Element type
|
|
|
+ type = dict_read(dict_read(dict_read(model, "metamodel"), "model"), input())
|
|
|
|
|
|
- Element name_19
|
|
|
- name_19 = input()
|
|
|
+ Element name
|
|
|
+ name = input()
|
|
|
|
|
|
- Element params_19
|
|
|
- params_19 = create_node()
|
|
|
- if (is_edge(type_19)):
|
|
|
- list_append(params_19, dict_read(dict_read(model_19, "model"), input()))
|
|
|
- list_append(params_19, dict_read(dict_read(model_19, "model"), input()))
|
|
|
- elif (type_eq(typeof(type_19), Type)):
|
|
|
- list_append(params_19, input())
|
|
|
+ Element params
|
|
|
+ params = create_node()
|
|
|
+ if (is_edge(type)):
|
|
|
+ list_append(params, dict_read(dict_read(model, "model"), input()))
|
|
|
+ list_append(params, dict_read(dict_read(model, "model"), input()))
|
|
|
+ elif (type_eq(typeof(type), Type)):
|
|
|
+ list_append(params, input())
|
|
|
|
|
|
- Element attribute_types_19
|
|
|
- attribute_types_19 = create_node()
|
|
|
+ Element attribute_types
|
|
|
+ attribute_types = create_node()
|
|
|
while (input()):
|
|
|
- dict_add(attribute_types_19, input(), input())
|
|
|
+ dict_add(attribute_types, input(), input())
|
|
|
|
|
|
- Element attribute_instances_19
|
|
|
- attribute_instances_19 = create_node()
|
|
|
+ Element attribute_instances
|
|
|
+ attribute_instances = create_node()
|
|
|
while (input()):
|
|
|
- dict_add(attribute_instances_19, input(), input())
|
|
|
+ dict_add(attribute_instances, input(), input())
|
|
|
|
|
|
- instantiate_model_lib(model_19, type_19, name_19, params_19, attribute_types_19, attribute_instances_19)
|
|
|
+ instantiate_model_lib(model, type, name, params, attribute_types, attribute_instances)
|
|
|
|
|
|
if (input()):
|
|
|
- instantiate_model(model_19)
|
|
|
+ instantiate_model(model)
|
|
|
|
|
|
return 1
|
|
|
|
|
|
-Element function retype_model(model_20 : Element):
|
|
|
- Element metamodel_20
|
|
|
- metamodel_20 = input()
|
|
|
+Element function retype_model(model : Element):
|
|
|
+ Element metamodel
|
|
|
+ metamodel = input()
|
|
|
|
|
|
- Element inheritance_20
|
|
|
- inheritance_20 = dict_read(dict_read(input(), "model"), input())
|
|
|
+ Element inheritance
|
|
|
+ inheritance = dict_read(dict_read(input(), "model"), input())
|
|
|
|
|
|
- Element mapping_20
|
|
|
- mapping_20 = create_node()
|
|
|
+ Element mapping
|
|
|
+ mapping = create_node()
|
|
|
while (input()):
|
|
|
- dict_add(mapping_20, dict_read(dict_read(model_20, "model"), input()), dict_read(dict_read(metamodel_20, "model"), input()))
|
|
|
+ dict_add(mapping, dict_read(dict_read(model, "model"), input()), dict_read(dict_read(metamodel, "model"), input()))
|
|
|
|
|
|
- return retype(model_20, metamodel_20, inheritance_20, mapping_20)
|
|
|
+ return retype(model, metamodel, inheritance, mapping)
|
|
|
|
|
|
-Element function find_attribute(source_21 : Element, attr_name_21 : Element, types_21 : Element, inheritance_link_21 : Element):
|
|
|
- if (dict_in(source_21, attr_name_21)):
|
|
|
- return source_21
|
|
|
+Element function find_attribute(source : Element, attr_name : Element, types : Element, inheritance_link : Element):
|
|
|
+ if (dict_in(source, attr_name)):
|
|
|
+ return source
|
|
|
else:
|
|
|
- Integer counter_21
|
|
|
+ Integer counter
|
|
|
Integer i
|
|
|
Element edge
|
|
|
- counter_21 = read_nr_out(source_21)
|
|
|
+ counter = read_nr_out(source)
|
|
|
i = 0
|
|
|
- while (integer_lt(i, counter_21)):
|
|
|
- edge = read_out(source_21, i)
|
|
|
- if (element_eq(dict_read_node(types_21, edge), inheritance_link_21)):
|
|
|
- return find_attribute(read_edge_dst(edge), attr_name_21, types_21, inheritance_link_21)
|
|
|
- i = integer_addition(i, 1)
|
|
|
+ while (i < counter):
|
|
|
+ edge = read_out(source, i)
|
|
|
+ if (element_eq(dict_read_node(types, edge), inheritance_link)):
|
|
|
+ return find_attribute(read_edge_dst(edge), attr_name, types, inheritance_link)
|
|
|
+ i = i + 1
|
|
|
// No return at the moment, as this crashes the MvK
|