pn_interface.alc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. include "primitives.alh"
  2. include "constructors.alh"
  3. include "object_operations.alh"
  4. include "library.alh"
  5. include "conformance_scd.alh"
  6. include "io.alh"
  7. include "metamodels.alh"
  8. include "modelling.alh"
  9. Element function tf_printNode(tf_pn_model: Element, tf_pn_node: Element):
  10. //print header name
  11. String tf_pn_node_name
  12. tf_pn_node_name = getName(tf_pn_model, tf_pn_node)
  13. log("== NAME OF THE ELEMENT")
  14. log(tf_pn_node_name)
  15. //log(find_attribute_type(tf_pn_model, tf_pn_node_name, name : String)
  16. log("== ATTRIBUTELIST")
  17. // Get all outgoing "dictionary" links
  18. Element tf_pn_attributelist
  19. tf_pn_attributelist = dict_keys(getAttributeList(tf_pn_model, tf_pn_node_name))
  20. String tf_pn_attributename
  21. String tf_pn_attributetype
  22. while (integer_lt(0, read_nr_out(tf_pn_attributelist))):
  23. tf_pn_attributename = set_pop(tf_pn_attributelist)
  24. tf_pn_attributetype = find_attribute_type(tf_pn_model, tf_pn_node_name, tf_pn_attributename)
  25. log( tf_pn_attributetype)
  26. if( tf_pn_attributetype == "String"):
  27. log(string_join(string_join(tf_pn_attributename, " : "),read_attribute(tf_pn_model, tf_pn_node_name, tf_pn_attributename)))
  28. elif (tf_pn_attributetype == "Integer"):
  29. log(string_join(string_join(tf_pn_attributename, " : "),cast_i2s(read_attribute(tf_pn_model, tf_pn_node_name, tf_pn_attributename))))
  30. else:
  31. log(string_join(tf_pn_attributename, " : "))
  32. log(read_attribute(tf_pn_model, tf_pn_node_name, tf_pn_attributename))
  33. return 0
  34. //namespace is tf_ma_
  35. Element function tf_matchAll(tf_ma_transformation: Element, tf_ma_pattern : Element, tf_ma_model: Element ):
  36. //log("executing: tf_matchAll()")
  37. Element tf_ma_metamodelTransf
  38. //log(tf_ma_pattern)
  39. tf_ma_metamodelTransf = dict_read(dict_read(tf_ma_transformation, "metamodel"), "model")
  40. Element tf_ma_pattern_nodes
  41. tf_ma_pattern_nodes = create_node()
  42. tf_ma_pattern_nodes = allOutgoingAssociationInstances(tf_ma_transformation, tf_ma_pattern, dict_read(tf_ma_metamodelTransf, "pre2ram"))
  43. //check if this works
  44. Element tf_ma_ramified_node
  45. while (integer_lt(0, read_nr_out(tf_ma_pattern_nodes))):
  46. tf_ma_ramified_node = read_edge_dst(set_pop(tf_ma_pattern_nodes))
  47. //plabel not found
  48. //log(readAttribute(tf_ma_transformation,tf_ma_ramified_node, "plabel"))
  49. Element tf_ma_attrlist
  50. return 0
  51. //namespace tf_er_
  52. Element function tf_executeRule(tf_er_transformation: Element,tf_er_rule: Element, tf_er_model: Element):
  53. //log("find matches based on lhs")
  54. Element tf_er_lhs
  55. tf_er_lhs = allOutgoingAssociationInstances(tf_er_transformation, tf_er_rule, dict_read(dict_read(dict_read(tf_er_transformation, "metamodel"), "model"), "lhs"))
  56. tf_matchAll(tf_er_transformation, read_edge_dst(set_pop(tf_er_lhs)), tf_er_model)
  57. return 0
  58. //namespace tf_tf_
  59. Element function tf_transform(tf_tf_transformation: Element, tf_tf_model: Element):
  60. //log("getting rule")
  61. //create a list of all rules
  62. Element tf_tf_rules
  63. tf_tf_rules = allInstances(tf_tf_transformation, dict_read(dict_read(dict_read(tf_tf_transformation, "metamodel"), "model"), "Rule")) //print rules
  64. //log("execute rule")
  65. Element tf_tf_rule
  66. while (integer_lt(0, read_nr_out(tf_tf_rules))):
  67. tf_tf_rule = set_pop(tf_tf_rules)
  68. tf_printNode(tf_tf_transformation, tf_tf_rule)
  69. tf_executeRule(tf_tf_transformation, tf_tf_rule, tf_tf_model)
  70. return 0
  71. Element function petrinet_transformation(root: Element):
  72. // Create A transformation model for petrinets (useful for testing)
  73. //////////////////////////////////
  74. //initialise an empty transformation model for petrinet
  75. Element my_model
  76. my_model = instantiate_model(root["PetriNets_MTransformation"])
  77. define_inheritance(my_model, "l3")
  78. dict_add(root, "transf_petrinet_fire", my_model)
  79. ////////////////////////////
  80. // root node
  81. instantiate_node(my_model, "Transformation", "PetrinetFire")
  82. instantiate_attribute(my_model, "PetrinetFire", "name", "PetriNetFire")
  83. ////////////////////////////
  84. // rule: find transitions
  85. //rule: find_transitions
  86. log("find_transitions")
  87. instantiate_node(my_model, "Rule", "find_transitions")
  88. instantiate_attribute(my_model, "find_transitions", "name", "find_transitions")
  89. instantiate_attribute(my_model, "find_transitions", "precedence", 1)
  90. //connect to transformation
  91. instantiate_link(my_model, "transformation_to_rule", "", "PetrinetFire", "find_transitions")
  92. //precondition: lhs_precondition
  93. log("lhs_precondition")
  94. instantiate_node(my_model, "Precondition","lhs_precondition")
  95. //connect to rule
  96. instantiate_link(my_model, "lhs", "", "find_transitions", "lhs_precondition")
  97. //Transition_LHS: lhs_find_all
  98. log("lhs_find_all")
  99. instantiate_node(my_model, "Transition_LHS","lhs_find_all")
  100. instantiate_attribute(my_model, "lhs_find_all", "plabel", 1)
  101. //connect to rule
  102. instantiate_link(my_model, "pre2ram", "", "lhs_precondition", "lhs_find_all")
  103. //precondition: nac_precondition
  104. log("nac_precondition")
  105. instantiate_node(my_model, "Precondition","nac_precondition")
  106. //connect to rule
  107. instantiate_link(my_model, "nac", "", "find_transitions", "nac_precondition")
  108. //Transition_LHS: nac_transition_place_before
  109. log("nac_transition_place_before")
  110. instantiate_node(my_model, "Transition_LHS","nac_transition_place_before")
  111. instantiate_attribute(my_model, "nac_transition_place_before", "plabel", 1)
  112. //connect to rule
  113. instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_transition_place_before")
  114. //Place_LHS: nac_place_before
  115. log("nac_place_before")
  116. instantiate_node(my_model, "Place_LHS","nac_place_before")
  117. instantiate_attribute(my_model, "nac_place_before", "plabel", 2)
  118. instantiate_attribute(my_model, "nac_place_before", "tokens", "lambda x: sum([1 for i in x.out if i.weight<x.tokens]) == len(x.transition)")
  119. //connect to rule
  120. instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_place_before")
  121. //P2T_LHS: nac_ft_p2t
  122. log("nac_transition_place_before")
  123. instantiate_link(my_model, "P2T_LHS", "nac_p2tlhs_before", "nac_place_before", "nac_transition_place_before")
  124. instantiate_attribute(my_model, "nac_p2tlhs_before", "plabel", 3)
  125. instantiate_attribute(my_model, "nac_p2tlhs_before", "weight", "lambda x: True")
  126. //connect to rule
  127. instantiate_link(my_model, "pre2ram", "", "nac_precondition", "nac_p2tlhs_before")
  128. return my_model
  129. Element function pn_operations():
  130. Element ops
  131. ops = create_node()
  132. dict_add(ops, "fire", petrinet_fire)
  133. dict_add(ops, "enabled", petrinet_enabled)
  134. return ops
  135. Element function petrinet_enabled(model : Element):
  136. Element set_enabled
  137. set_enabled = petrinet_enabled_set(model)
  138. output("Enabled transitions:")
  139. while (0 < read_nr_out(set_enabled)):
  140. output(getName(model, set_pop(set_enabled)))
  141. return model
  142. Element function petrinet_enabled_set(model : Element):
  143. Element all_transitions
  144. all_transitions = allInstances(model, model["metamodel"]["model"]["Transition"])
  145. Element enabled_transitions
  146. enabled_transitions = create_node()
  147. Element under_study
  148. Element in_arcs
  149. Element arc_under_study
  150. Boolean enabled
  151. while (0 < read_nr_out(all_transitions)):
  152. under_study = set_pop(all_transitions)
  153. enabled = True
  154. // Find all incoming transitions
  155. in_arcs = allIncomingAssociationInstances(model, under_study, model["metamodel"]["model"]["P2T"])
  156. while (0 < read_nr_out(in_arcs)):
  157. arc_under_study = set_pop(in_arcs)
  158. Integer present_tokens
  159. Integer required_tokens
  160. required_tokens = read_attribute(model, getName(model, arc_under_study), "weight")
  161. present_tokens = read_attribute(model, getName(model, read_edge_src(arc_under_study)), "tokens")
  162. if (present_tokens < required_tokens):
  163. // Less tokens than required, so disable the transition completely
  164. enabled = False
  165. if (enabled):
  166. set_add(enabled_transitions, under_study)
  167. return enabled_transitions
  168. Element function petrinet_fire(model : Element):
  169. output("Transition to fire?")
  170. Element transition
  171. transition = input()
  172. if (dict_in(model["model"], transition)):
  173. transition = model["model"][transition]
  174. if (set_in(petrinet_enabled_set(model), transition)):
  175. Element workset
  176. Element working_place
  177. Element working_arc
  178. Integer new_value
  179. // Consume tokens
  180. workset = allIncomingAssociationInstances(model, transition, model["metamodel"]["model"]["P2T"])
  181. while (0 < read_nr_out(workset)):
  182. working_arc = set_pop(workset)
  183. working_place = read_edge_src(working_arc)
  184. new_value = integer_subtraction(read_attribute(model, getName(model, working_place), "tokens"), read_attribute(model, getName(model, working_arc), "weight"))
  185. unset_attribute(model, getName(model, working_place), "tokens")
  186. instantiate_attribute(model, getName(model, working_place), "tokens", new_value)
  187. output(((" " + getName(model, working_place)) + ": ") + cast_i2s(read_attribute(model, getName(model, working_place), "tokens")))
  188. // Add tokens
  189. workset = allOutgoingAssociationInstances(model, transition, model["metamodel"]["model"]["T2P"])
  190. while (0 < read_nr_out(workset)):
  191. working_arc = set_pop(workset)
  192. working_place = read_edge_dst(working_arc)
  193. new_value = integer_addition(read_attribute(model, getName(model, working_place), "tokens"), read_attribute(model, getName(model, working_arc), "weight"))
  194. unset_attribute(model, getName(model, working_place), "tokens")
  195. instantiate_attribute(model, getName(model, working_place), "tokens", new_value)
  196. output(((" " + getName(model, working_place)) + ": ") + cast_i2s(read_attribute(model, getName(model, working_place), "tokens")))
  197. output("Transition fired!")
  198. else:
  199. output("Cannot fire if not enabled; aborting")
  200. else:
  201. output("Unknown transition; aborting")
  202. return model
  203. Element function petrinet_loaded(model : Element):
  204. String cmd
  205. Element attr_list_pn
  206. Element attr_keys_pn
  207. String attr_key_pn
  208. Element metamodel_element_pn
  209. String typename
  210. Boolean bottom
  211. Element other_metamodel
  212. bottom = False
  213. other_metamodel = create_node()
  214. dict_add(other_metamodel, "model", model["model"])
  215. dict_add(other_metamodel, "type_mapping", create_node())
  216. dict_add(other_metamodel, "metamodel", import_node("models/LTM_bottom"))
  217. dict_add(other_metamodel, "inheritance", other_metamodel["metamodel"]["model"]["__Inheritance"])
  218. output("Model loaded, ready for commands!")
  219. output("Use 'help' command for a list of possible commands")
  220. while (True):
  221. output("Please give your command.")
  222. cmd = input()
  223. if (cmd == "help"):
  224. output("Generic model operations:")
  225. output(" instantiate -- Create a new model element")
  226. output(" delete -- Delete an existing element")
  227. output(" attr_add -- Add an attribute to an element")
  228. output(" attr_del -- Delete an attribute of an element")
  229. output(" rename -- Rename an existing element")
  230. output(" modify -- Modify the attributes of an element")
  231. output(" list -- Prints the list of elements in the model")
  232. output(" types -- Prints the list of elements that can be instantiated")
  233. output(" read -- Prints the current state of a model element")
  234. output(" verify -- Check whether the model conforms to the metamodel")
  235. output(" retype -- Change the type of an element")
  236. output(" switch -- Switch between conformance bottom and the linguistic metamodel")
  237. output(" exit -- Unload the model and go back to the loading prompt")
  238. if (bool_not(bottom)):
  239. output("Model-specific operations:")
  240. Element specific_ops
  241. specific_ops = dict_keys(pn_operations())
  242. String specific_op
  243. while (0 < dict_len(specific_ops)):
  244. specific_op = set_pop(specific_ops)
  245. output(" " + specific_op)
  246. elif (cmd == "exit"):
  247. return model
  248. elif (cmd == "instantiate"):
  249. String mm_type_name
  250. output("Type to instantiate?")
  251. mm_type_name = input()
  252. if (dict_in(model["metamodel"]["model"], mm_type_name)):
  253. String element_name
  254. output("Name of new element?")
  255. element_name = input()
  256. if (dict_in(model["model"], element_name)):
  257. output("Element already exists; aborting")
  258. else:
  259. if (is_edge(model["metamodel"]["model"][mm_type_name])):
  260. output("Source name?")
  261. String src_name
  262. src_name = input()
  263. if (dict_in(model["model"], src_name)):
  264. output("Destination name?")
  265. String dst_name
  266. dst_name = input()
  267. if (dict_in(model["model"], dst_name)):
  268. instantiate_link(model, mm_type_name, element_name, src_name, dst_name)
  269. if (dict_in(model["model"], element_name)):
  270. output("Instantiation successful!")
  271. else:
  272. output("Instantiation error!")
  273. else:
  274. output("Unknown destination; aborting")
  275. else:
  276. output("Unknown source; aborting")
  277. else:
  278. instantiate_node(model, mm_type_name, element_name)
  279. if (dict_in(model["model"], element_name)):
  280. output("Instantiation successful!")
  281. else:
  282. output("Instantiation error!")
  283. else:
  284. output("Unknown type specified; aborting")
  285. elif (cmd == "modify"):
  286. String model_name
  287. output("Element to modify?")
  288. model_name = input()
  289. if (dict_in(model["model"], model_name)):
  290. Element attrs
  291. attrs = getAttributeList(model, model_name)
  292. String attr_name
  293. output("Attribute to modify?")
  294. attr_name = input()
  295. if (set_in(dict_keys(attrs), attr_name)):
  296. output("New value?")
  297. unset_attribute(model, model_name, attr_name)
  298. instantiate_attribute(model, model_name, attr_name, input())
  299. output("Modified!")
  300. else:
  301. output("No such attribute!")
  302. else:
  303. output("No such model!")
  304. elif (cmd == "attr_add"):
  305. String model_name
  306. output("Which model do you want to assign an attribute to?")
  307. model_name = input()
  308. if (dict_in(model["model"], model_name)):
  309. Element attrs
  310. attrs = getAttributeList(model, model_name)
  311. String attr_name
  312. output("Which attribute do you wish to assign?")
  313. attr_name = input()
  314. if (set_in(dict_keys(attrs), attr_name)):
  315. output("Value of attribute?")
  316. instantiate_attribute(model, model_name, attr_name, input())
  317. output("Added attribute!")
  318. else:
  319. output("No such attribute!")
  320. else:
  321. output("No such model!")
  322. elif (cmd == "attr_del"):
  323. String model_name
  324. output("Which model do you want to remove an attribute of?")
  325. model_name = input()
  326. if (dict_in(model["model"], model_name)):
  327. Element attrs
  328. attrs = getAttributeList(model, model_name)
  329. output(print_dict(attrs))
  330. String attr_name
  331. output("Which attribute do you want to delete?")
  332. attr_name = input()
  333. if (set_in(dict_keys(attrs), attr_name)):
  334. unset_attribute(model, model_name, attr_name)
  335. else:
  336. output("No such attribute!")
  337. else:
  338. output("No such model!")
  339. elif (cmd == "delete"):
  340. output("What is the name of the element you want to delete?")
  341. cmd = input()
  342. if (dict_in(model["model"], cmd)):
  343. model_delete_element(model, cmd)
  344. output("Deleted!")
  345. else:
  346. output("No such element; aborting")
  347. elif (cmd == "rename"):
  348. output("Old name?")
  349. String old_name_e
  350. old_name_e = input()
  351. if (dict_in(model["model"], old_name_e)):
  352. output("New name?")
  353. String new_name_e
  354. new_name_e = input()
  355. if (dict_in(model["model"], new_name_e)):
  356. output("New name already used; aborting")
  357. else:
  358. dict_add(model["model"], new_name_e, model["model"][old_name_e])
  359. dict_delete(model["model"], old_name_e)
  360. output("Rename complete!")
  361. else:
  362. output("Unknown element; aborting")
  363. elif (cmd == "list"):
  364. Element keys_m
  365. keys_m = dict_keys(model["model"])
  366. output("List of all elements:")
  367. String v_m
  368. while (read_nr_out(keys_m) > 0):
  369. v_m = set_pop(keys_m)
  370. // Filter out anonymous objects
  371. typename = getName(model["metamodel"], dict_read_node(model["type_mapping"], model["model"][v_m]))
  372. if (bool_not(string_startswith(v_m, "__"))):
  373. output(((" " + v_m) + " : ") + typename)
  374. elif (cmd == "read"):
  375. output("Element to read?")
  376. cmd = input()
  377. if (dict_in(model["model"], cmd)):
  378. Element read_elem
  379. read_elem = model["model"][cmd]
  380. metamodel_element_pn = dict_read_node(model["type_mapping"], read_elem)
  381. output("Name: " + cmd)
  382. output("Type: " + getName(model["metamodel"], metamodel_element_pn))
  383. if (is_edge(read_elem)):
  384. output("Source: " + getName(model, read_edge_src(read_elem)))
  385. output("Destination: " + getName(model, read_edge_dst(read_elem)))
  386. if (cast_v2s(read_elem) != "None"):
  387. output("Value: " + cast_v2s(read_elem))
  388. output("Defines attributes:")
  389. attr_list_pn = getInstantiatableAttributes(model, read_elem)
  390. attr_keys_pn = dict_keys(attr_list_pn)
  391. while (0 < read_nr_out(attr_keys_pn)):
  392. attr_key_pn = set_pop(attr_keys_pn)
  393. output((((" " + attr_key_pn) + " : ") + cast_v2s(attr_list_pn[attr_key_pn])))
  394. output("Attributes:")
  395. attr_list_pn = getAttributeList(model, cmd)
  396. attr_keys_pn = dict_keys(attr_list_pn)
  397. while (0 < read_nr_out(attr_keys_pn)):
  398. attr_key_pn = set_pop(attr_keys_pn)
  399. output(((((" " + cast_v2s(attr_key_pn)) + " : ") + cast_v2s(attr_list_pn[attr_key_pn])) + " = ") + cast_v2s(read_attribute(model, getName(model, read_elem), attr_key_pn)))
  400. else:
  401. output("Unknown element; aborting")
  402. elif (cmd == "verify"):
  403. output(conformance_scd(model))
  404. elif (cmd == "types"):
  405. Element keys_t
  406. keys_t = dict_keys(model["metamodel"]["model"])
  407. output("List of types:")
  408. String v_t
  409. while (read_nr_out(keys_t) > 0):
  410. v_t = set_pop(keys_t)
  411. if (bool_not(string_startswith(v_t, "__"))):
  412. output(string_join((" " + v_t) + " : ", getName(model["metamodel"]["metamodel"], dict_read_node(model["metamodel"]["type_mapping"], model["metamodel"]["model"][v_t]))))
  413. elif (cmd == "retype"):
  414. output("Element to retype?")
  415. String elementname
  416. elementname = input()
  417. if (dict_in(model["model"], elementname)):
  418. output("New type")
  419. typename = input()
  420. if (dict_in(model["metamodel"]["model"], typename)):
  421. // OK, do the retyping
  422. // First try removing the previous type if it exists
  423. dict_delete(model["type_mapping"], model["model"][elementname])
  424. // Now add the new type
  425. dict_add(model["type_mapping"], model["model"][elementname], model["metamodel"]["model"][typename])
  426. output("Retyped!")
  427. else:
  428. output("Unknown type; aborting")
  429. else:
  430. output("Unknown element; aborting")
  431. elif (cmd == "switch"):
  432. bottom = bool_not(bottom)
  433. Element tmp_model
  434. tmp_model = model
  435. model = other_metamodel
  436. other_metamodel = tmp_model
  437. if (bottom):
  438. // The type mapping we are using is probably not complete for our model
  439. // so we completely recreate it from the model we have.
  440. output("Switching to conformance bottom mode!")
  441. generate_bottom_type_mapping(model)
  442. else:
  443. // We already switched the models and such, so we are already done!
  444. output("Switching to linguistic metamodel!")
  445. elif (bool_and(dict_in(pn_operations(), cmd), bool_not(bottom))):
  446. // A model-specific operation, so execute that one
  447. Element specific_op
  448. specific_op = dict_read(pn_operations(), cmd)
  449. specific_op(model)
  450. else:
  451. output("Unknown command; aborting")
  452. output("Use command 'help' to get a list of available commands")
  453. Element function initial_prompt():
  454. output("Welcome to the Model Management Interface, running live on the Modelverse!")
  455. output("Use 'help' command for a list of possible commands")
  456. String command
  457. Element root
  458. Element metamodel
  459. String name
  460. Element my_model
  461. String mm_name
  462. root = create_metamodels()
  463. while (True):
  464. output("Please give your command.")
  465. command = input()
  466. if (command == "help"):
  467. output("Currently no model is loaded, so your operations are limited to:")
  468. output(" new -- Create a new model and save it for future use")
  469. output(" load -- Load a previously made model")
  470. output(" rename -- Rename a previously made model")
  471. output(" delete -- Delete a previously made model")
  472. output(" list -- Show a list of all stored models")
  473. output(" help -- Show a list of possible commands")
  474. elif (command == "new"):
  475. output("Metamodel to instantiate?")
  476. mm_name = input()
  477. if (dict_in(root, mm_name)):
  478. output("Name of model?")
  479. name = input()
  480. if (dict_in(root, name)):
  481. output("Model exists; aborting")
  482. else:
  483. my_model = instantiate_model(root[mm_name])
  484. dict_add(root, name, my_model)
  485. petrinet_loaded(my_model)
  486. else:
  487. output("Unknown metamodel; aborting")
  488. elif (command == "load"):
  489. output("Model to load?")
  490. name = input()
  491. if (dict_in(root, name)):
  492. my_model = root[name]
  493. petrinet_loaded(my_model)
  494. else:
  495. output("Model not found; aborting")
  496. elif (command == "list"):
  497. Element keys
  498. String m_menu_list
  499. keys = dict_keys(root)
  500. output("Found models:")
  501. while (read_nr_out(keys) > 0):
  502. m_menu_list = set_pop(keys)
  503. output(((" " + m_menu_list) + " : ") + reverseNameLookup(root, root[m_menu_list]["metamodel"]))
  504. elif (command == "delete"):
  505. output("Model to delete?")
  506. name = input()
  507. if (dict_in(root, name)):
  508. dict_delete(root, name)
  509. output("Deleted!")
  510. else:
  511. output("Model not found; aborting")
  512. elif (command == "rename"):
  513. output("Old name?")
  514. String old_name
  515. old_name = input()
  516. if (dict_in(root, old_name)):
  517. output("New name?")
  518. String new_name
  519. new_name = input()
  520. if (dict_in(root, new_name)):
  521. output("Model exists; aborting")
  522. else:
  523. dict_add(root, new_name, root[old_name])
  524. dict_delete(root, old_name)
  525. output("Rename complete!")
  526. else:
  527. output("Model not found; aborting")
  528. else:
  529. output("Command not recognized, use 'help' for a list of possible commands")
  530. Void function main():
  531. //initial_prompt()
  532. log("==========================================================================")
  533. log("creating metamodels")
  534. Element root
  535. root = create_metamodels()
  536. log("load instantiation of transformation metamodel")
  537. Element transf
  538. transf = petrinet_transformation(root)
  539. log("check conformance of transformation")
  540. log(conformance_scd(transf))
  541. log("run transform")
  542. tf_transform(transf, create_node())
  543. log("done")
  544. log("==========================================================================")
  545. return