ftg.alc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. include "primitives.alh"
  2. include "modelling.alh"
  3. include "library.alh"
  4. Void function visit_ftg(ftg : Element, root : Element, path : String, current : Element):
  5. log("Visit FTG: " + path)
  6. if (dict_in(current, "source")):
  7. // Is a transformation, and therefore an edge for the FTG
  8. if (bool_not(dict_in(ftg["model"], path))):
  9. if (bool_not(dict_in(ftg["model"], current["source"]))):
  10. visit_ftg(ftg, root, current["source"], root[current["source"]])
  11. if (bool_not(dict_in(ftg["model"], current["target"]))):
  12. visit_ftg(ftg, root, current["target"], root[current["source"]])
  13. instantiate_link(ftg, "Transformation", path, current["source"], current["target"])
  14. instantiate_attribute(ftg, path, "location", path)
  15. else:
  16. // Is a model, and therefore a node for the FTG
  17. if (bool_not(dict_in(ftg["model"], path))):
  18. instantiate_node(ftg, "Formalism", path)
  19. instantiate_attribute(ftg, path, "location", path)
  20. return !
  21. Element function create_ftg(root : Element):
  22. Element queue
  23. Element current
  24. Element submodels
  25. Element ftg
  26. String path
  27. String submodel
  28. queue = create_node()
  29. set_add(queue, create_tuple("models", root))
  30. ftg = instantiate_model(import_node("models/FTG"))
  31. while (read_nr_out(queue) > 0):
  32. current = set_pop(queue)
  33. path = current[0]
  34. current = current[1]
  35. log("Check node: " + cast_e2s(current))
  36. if (dict_in(current, "__hierarchy_node" )):
  37. log("IS HIERARCHY: " + path)
  38. submodels = dict_keys(current)
  39. // Is a browser structure, and therefore not part of the FTG
  40. while (read_nr_out(submodels) > 0):
  41. submodel = set_pop(submodels)
  42. set_add(queue, create_tuple((path + "/") + submodel, current[submodel]))
  43. else:
  44. log("IS MODEL: " + path)
  45. visit_ftg(ftg, root, path, current)
  46. return ftg!