compiler.alc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. include "primitives.alh"
  2. include "services.alh"
  3. include "constructors.alh"
  4. include "modelling.alh"
  5. Element function generic_compile(code : String, port : String):
  6. comm_set(port, code)
  7. String response
  8. response = comm_get(port)
  9. if (response == "OK"):
  10. Element lst
  11. lst = comm_get_list(port)
  12. comm_close(port)
  13. return lst!
  14. else:
  15. comm_close(port)
  16. return response!
  17. Element function compile_code(code : String):
  18. String port
  19. port = ""
  20. while (port == ""):
  21. port = comm_connect("compiler")
  22. comm_set(port, "code")
  23. Element list
  24. list = generic_compile(code, port)
  25. if (is_physical_string(list)):
  26. return list!
  27. else:
  28. Element model
  29. model = construct_function_list(list)
  30. dict_add(model, "__text", code)
  31. return model!
  32. Element function compile_model(code : String, metamodel : Element):
  33. String port
  34. port = ""
  35. while (port == ""):
  36. port = comm_connect("compiler")
  37. comm_set(port, "model")
  38. Element list
  39. list = generic_compile(code, port)
  40. if (is_physical_string(list)):
  41. return list!
  42. else:
  43. return construct_model_list(instantiate_model(metamodel), list)!