1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- include "primitives.alh"
- include "services.alh"
- include "constructors.alh"
- include "modelling.alh"
- Element function generic_compile(code : String, port : String):
- comm_set(port, code)
-
- String response
- response = comm_get(port)
- if (response == "OK"):
- Element lst
- lst = comm_get_list(port)
- comm_close(port)
- return lst!
- else:
- log("Compilation error: " + response)
- comm_close(port)
- return read_root()!
- Element function compile_code(code : String):
- if (code == "__LOCAL__"):
- Element list
- Integer length
- list = list_create()
- length = input()
- while (list_len(list) < length):
- list_append(list, input())
-
- return construct_function_list(list)!
- else:
- String port
- port = ""
- while (port == ""):
- port = comm_connect("compiler")
- comm_set(port, "code")
- Element list
- list = generic_compile(code, port)
- if (element_eq(list, read_root())):
- return read_root()!
- else:
- return construct_function_list(list)!
- Element function compile_model(code : String, metamodel : Element):
- if (code == "__LOCAL__"):
- Element list
- Integer length
- list = list_create()
- length = input()
- while (list_len(list) < length):
- list_append(list, input())
-
- return construct_model_list(instantiate_model(metamodel), list)!
- else:
- String port
- port = ""
- while (port == ""):
- port = comm_connect("compiler")
- sleep(0.5)
- comm_set(port, "model")
- Element list
- list = generic_compile(code, port)
- if (element_eq(list, read_root())):
- return read_root()!
- else:
- return construct_model_list(instantiate_model(metamodel), list)!
|