mini_modify.alc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  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. include "typing.alh"
  10. include "compiler.alh"
  11. include "utils.alh"
  12. Boolean verbose = True
  13. String function cmd_help_m(write : Boolean):
  14. String result
  15. result = ""
  16. result = result + "Allowed operations:\n"
  17. if (write):
  18. result = result + " == READ/WRITE ==\n"
  19. result = result + " instantiate_node -- Create a new model element (node)\n"
  20. result = result + " instantiate_edge -- Create a new model element (edge)\n"
  21. result = result + " delete -- Delete an existing element\n"
  22. result = result + " attr_add -- Add an attribute to an element\n"
  23. result = result + " attr_add_code -- Add a coded attribute to an element\n"
  24. result = result + " attr_del -- Delete an attribute of an element\n"
  25. result = result + " attr_modify -- Modify an attribute of an element\n"
  26. result = result + " retype -- Change the type of an element\n"
  27. result = result + " upload -- Upload a completely new model\n"
  28. else:
  29. result = result + " == READ-ONLY ==\n"
  30. result = result + " read_outgoing -- Prints the list of outgoing links of an element\n"
  31. result = result + " read_incoming -- Prints the list of incoming links to an element\n"
  32. result = result + " list -- Prints the list of elements in the model\n"
  33. result = result + " list_full -- Prints the list of all elements in the model\n"
  34. result = result + " types -- Prints the list of elements that can be instantiated\n"
  35. result = result + " read -- Prints the current state of a model element\n"
  36. result = result + " verify -- Check whether the model conforms to the metamodel\n"
  37. result = result + " exit -- Leave the modification interface\n"
  38. return result!
  39. String function cmd_upload(write : Boolean, model : Element):
  40. Element new_model
  41. if (write):
  42. output("Waiting for model constructors...")
  43. new_model = compile_model(input(), model["metamodel"])
  44. if (is_physical_string(new_model)):
  45. return "Compilation error: " + cast_string(new_model)!
  46. dict_overwrite(model, "model", new_model["model"])
  47. set_type_mapping(model, get_type_mapping(new_model))
  48. return "Success"!
  49. else:
  50. return "Write permission denied"!
  51. String function cmd_instantiate_node(write : Boolean, model : Element, mm_type_name : String, element_name : String):
  52. if (write):
  53. if (dict_in(model["metamodel"]["model"], mm_type_name)):
  54. if (dict_in(model["model"], element_name)):
  55. return "Element exists: " + element_name!
  56. else:
  57. if (is_edge(model["metamodel"]["model"][mm_type_name])):
  58. return "Incorrect format: " + mm_type_name + " is an edge instead of a node"!
  59. element_name = instantiate_node(model, mm_type_name, element_name)
  60. return "Success: " + element_name!
  61. else:
  62. return "Element not found: " + mm_type_name!
  63. else:
  64. return "Write permission denied"!
  65. String function cmd_instantiate_edge(write : Boolean, model : Element, mm_type_name : String, element_name : String, source_name : String, target_name : String):
  66. if (write):
  67. if (dict_in(model["metamodel"]["model"], mm_type_name)):
  68. if (dict_in(model["model"], element_name)):
  69. return "Element exists: " + element_name!
  70. else:
  71. if (is_edge(model["metamodel"]["model"][mm_type_name])):
  72. if (dict_in(model["model"], source_name)):
  73. if (dict_in(model["model"], target_name)):
  74. element_name = instantiate_link(model, mm_type_name, element_name, source_name, target_name)
  75. return "Success: " + element_name!
  76. else:
  77. return "Element not found: " + target_name!
  78. else:
  79. return "Element not found: " + source_name!
  80. else:
  81. return "Incorrect format: " + mm_type_name + " is a node instead of an edge"!
  82. else:
  83. return "Element not found: " + mm_type_name!
  84. else:
  85. return "Write permission denied"!
  86. String function cmd_define_attribute(write : Boolean, model : Element, element_name : String, attr_name : String, type : String):
  87. if (write):
  88. if (dict_in(model["model"], element_name)):
  89. if (dict_in(model["model"], type)):
  90. //TODO automatically find name AttributeLink, as this might change with merging...
  91. if (dict_in(model["metamodel"]["model"], "AttributeLink")):
  92. Element attrs
  93. attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
  94. if (bool_not(set_in(dict_keys(attrs), attr_name))):
  95. model_define_attribute(model, element_name, attr_name, False, type)
  96. return "Success"!
  97. else:
  98. return "Attribute exists: " + attr_name!
  99. else:
  100. return "Not a SimpleClassDiagrams model!"!
  101. else:
  102. return "Element not found: " + type!
  103. else:
  104. return "Element not found: " + element_name!
  105. else:
  106. return "Write permission denied"!
  107. String function cmd_attr_add(write : Boolean, model : Element, element_name : String, attr_name : String, value : Element):
  108. if (write):
  109. if (dict_in(model["model"], element_name)):
  110. Element attrs
  111. attrs = getAttributeList(model, element_name)
  112. if (set_in(dict_keys(attrs), attr_name)):
  113. instantiate_attribute(model, element_name, attr_name, value)
  114. return "Success"!
  115. else:
  116. return "Attribute not found: " + attr_name!
  117. else:
  118. return "Element not found: " + element_name!
  119. else:
  120. return "Write permission denied"!
  121. String function cmd_attr_add_code(write : Boolean, model : Element, element_name : String, attr_name : String):
  122. if (write):
  123. if (dict_in(model["model"], element_name)):
  124. Element attrs
  125. attrs = getAttributeList(model, element_name)
  126. if (set_in(dict_keys(attrs), attr_name)):
  127. output("Waiting for code constructors...")
  128. Element compiled
  129. compiled = compile_code(input())
  130. if (is_physical_string(compiled)):
  131. return "Compilation error: " + cast_string(compiled)!
  132. instantiate_attribute_code(model, element_name, attr_name, compiled)
  133. return "Success"!
  134. else:
  135. return "Attribute not found: " + attr_name!
  136. else:
  137. return "Element not found: " + element_name!
  138. else:
  139. return "Write permission denied"!
  140. String function cmd_attr_del(write : Boolean, model : Element, element_name : String, attr_name : String):
  141. if (write):
  142. if (dict_in(model["model"], element_name)):
  143. Element attrs
  144. attrs = getAttributeList(model, element_name)
  145. if (set_in(dict_keys(attrs), attr_name)):
  146. unset_attribute(model, element_name, attr_name)
  147. return "Success"!
  148. else:
  149. return "Attribute not found: " + attr_name!
  150. else:
  151. return "Element not found: " + element_name!
  152. else:
  153. return "Write permission denied"!
  154. String function cmd_attr_name(write : Boolean, model : Element, element_name : String, attr_name : String, new_attr_name : String):
  155. if (write):
  156. if (dict_in(model["model"], element_name)):
  157. Element attrs
  158. // TODO automatically find AttributeLink name
  159. if (dict_in(model["metamodel"]["model"], "AttributeLink")):
  160. attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
  161. if (set_in(dict_keys(attrs), attr_name)):
  162. if (set_in(dict_keys(attrs), attr_name)):
  163. if (bool_not(set_in(dict_keys(attrs), new_attr_name))):
  164. if (dict_in(model["model"][element_name], attr_name)):
  165. Boolean optional
  166. String attr_edge
  167. attr_edge = reverseKeyLookup(model["model"], dict_read_edge(model["model"][element_name], attr_name))
  168. optional = read_attribute(model, attr_edge, "optional")
  169. model_undefine_attribute(model, element_name, attr_name)
  170. model_define_attribute_ID(model, element_name, new_attr_name, optional, attrs[attr_name], attr_edge)
  171. return "Success"!
  172. else:
  173. return "Attribute not defined here: " + new_attr_name!
  174. else:
  175. return "Attribute exists: " + new_attr_name!
  176. else:
  177. return "Attribute not found: " + attr_name!
  178. else:
  179. return "Attribute not found: " + attr_name!
  180. else:
  181. return "Not a SimpleClassDiagrams model!"!
  182. else:
  183. return "Element not found: " + element_name!
  184. else:
  185. return "Write permission denied"!
  186. String function cmd_attr_type(write : Boolean, model : Element, element_name : String, attr_name : String, new_attr_type : String):
  187. if (write):
  188. if (dict_in(model["model"], element_name)):
  189. Element attrs
  190. // TODO automatically find AttributeLink name
  191. if (dict_in(model["metamodel"]["model"], "AttributeLink")):
  192. attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
  193. if (set_in(dict_keys(attrs), attr_name)):
  194. if (set_in(dict_keys(attrs), attr_name)):
  195. if (dict_in(model["model"][element_name], attr_name)):
  196. Boolean optional
  197. String attr_edge
  198. attr_edge = reverseKeyLookup(model["model"], dict_read_edge(model["model"][element_name], attr_name))
  199. optional = read_attribute(model, attr_edge, "optional")
  200. model_undefine_attribute(model, element_name, attr_name)
  201. model_define_attribute_ID(model, element_name, attr_name, optional, new_attr_type, attr_edge)
  202. return "Success"!
  203. else:
  204. return "Attribute not defined here: " + attr_name!
  205. else:
  206. return "Attribute not defined: " + attr_name!
  207. else:
  208. return "Attribute not found: " + attr_name!
  209. else:
  210. return "Not a SimpleClassDiagrams model!"!
  211. else:
  212. return "Element not found: " + element_name!
  213. else:
  214. return "Write permission denied"!
  215. String function cmd_attr_optional(write : Boolean, model : Element, element_name : String, attr_name : String, optional : Boolean):
  216. if (write):
  217. if (dict_in(model["model"], element_name)):
  218. Element attrs
  219. // TODO automatically find AttributeLink name
  220. if (dict_in(model["metamodel"]["model"], "AttributeLink")):
  221. attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
  222. if (set_in(dict_keys(attrs), attr_name)):
  223. if (set_in(dict_keys(attrs), attr_name)):
  224. if (dict_in(model["model"][element_name], attr_name)):
  225. String attr_edge
  226. attr_edge = reverseKeyLookup(model["model"], dict_read_edge(model["model"][element_name], attr_name))
  227. model_undefine_attribute(model, element_name, attr_name)
  228. model_define_attribute_ID(model, element_name, attr_name, optional, attrs[attr_name], attr_edge)
  229. return "Success"!
  230. else:
  231. return "Attribute not defined here: " + attr_name!
  232. else:
  233. return "Attribute not defined: " + attr_name!
  234. else:
  235. return "Attribute not found: " + attr_name!
  236. else:
  237. return "Not a SimpleClassDiagrams model!"!
  238. else:
  239. return "Element not found: " + element_name!
  240. else:
  241. return "Write permission denied"!
  242. String function cmd_undefine_attribute(write : Boolean, model : Element, element_name : String, attr_name : String):
  243. if (write):
  244. if (dict_in(model["model"], element_name)):
  245. //TODO automatically find name AttributeLink, as this might change with merging...
  246. if (dict_in(model["metamodel"]["model"], "AttributeLink")):
  247. Element attrs
  248. attrs = getInstantiatableAttributes(model, element_name, "AttributeLink")
  249. if (set_in(dict_keys(attrs), attr_name)):
  250. if (set_in(dict_keys(attrs), attr_name)):
  251. if (dict_in(model["model"][element_name], attr_name)):
  252. model_undefine_attribute(model, element_name, attr_name)
  253. return "Success"!
  254. else:
  255. return "Attribute not defined here: " + attr_name!
  256. else:
  257. return "Attribute not defined: " + attr_name!
  258. else:
  259. return "Attribute not found: " + attr_name!
  260. else:
  261. return "Not a SimpleClassDiagrams model!"!
  262. else:
  263. return "Element not found: " + element_name!
  264. else:
  265. return "Write permission denied"!
  266. String function cmd_delete(write : Boolean, model : Element, element_name : String):
  267. if (write):
  268. if (dict_in(model["model"], element_name)):
  269. model_delete_element(model, element_name)
  270. return "Success"!
  271. else:
  272. return "Element not found: " + element_name!
  273. else:
  274. return "Write permission denied"!
  275. String function cmd_list_full(model : Element):
  276. Element keys_m
  277. String v_m
  278. String result
  279. String typename
  280. result = "Success: "
  281. keys_m = dict_keys(model["model"])
  282. while (set_len(keys_m) > 0):
  283. v_m = set_pop(keys_m)
  284. // Filter out anonymous objects
  285. typename = read_type(model, v_m)
  286. result = result + " " + v_m + " : " + typename + "\n"
  287. return result!
  288. String function cmd_read_outgoing(model : Element, element_name : String, type : String):
  289. String result
  290. Element elems
  291. if (dict_in(model["model"], element_name)):
  292. if (bool_or(dict_in(model["metamodel"]["model"], type), type == "")):
  293. result = "Success: "
  294. elems = allOutgoingAssociationInstances(model, element_name, type)
  295. while (set_len(elems) > 0):
  296. result = string_join(result, set_pop(elems)) + "\n"
  297. return result!
  298. else:
  299. return "Element not found: " + type!
  300. else:
  301. return "Element not found: " + element_name!
  302. String function cmd_read_incoming(model : Element, element_name : String, type : String):
  303. String result
  304. Element elems
  305. if (dict_in(model["model"], element_name)):
  306. if (bool_or(dict_in(model["metamodel"]["model"], type), type == "")):
  307. result = "Success: "
  308. elems = allIncomingAssociationInstances(model, element_name, type)
  309. while (set_len(elems) > 0):
  310. result = string_join(result, set_pop(elems)) + "\n"
  311. return result!
  312. else:
  313. return "Element not found: " + type!
  314. else:
  315. return "Element not found: " + element_name!
  316. String function cmd_connections_between(model : Element, source_name : String, target_name : String):
  317. String result
  318. Element options
  319. if (dict_in(model["model"], source_name)):
  320. if (dict_in(model["model"], target_name)):
  321. result = "Success: "
  322. options = allowedAssociationsBetween(model, source_name, target_name)
  323. while (set_len(options) > 0):
  324. result = string_join(result, set_pop(options)) + "\n"
  325. return result!
  326. else:
  327. return ("Element not found: " + target_name)!
  328. else:
  329. return ("Element not found: " + source_name)!
  330. String function cmd_read(model : Element, element_name : String):
  331. String result
  332. Element attr_list
  333. Element attr_keys
  334. String attr_key
  335. result = "Success: "
  336. if (dict_in(model["model"], element_name)):
  337. result = result + "Type: " + read_type(model, element_name) + "\n"
  338. if (is_edge(model["model"][element_name])):
  339. result = result + "Source: " + reverseKeyLookup(model["model"], read_edge_src(model["model"][element_name])) + "\n"
  340. result = result + "Destination: " + reverseKeyLookup(model["model"], read_edge_dst(model["model"][element_name])) + "\n"
  341. if (has_value(model["model"][element_name])):
  342. result = result + "Value: " + cast_value(model["model"][element_name]) + "\n"
  343. return result!
  344. else:
  345. return "Element not found: " + element_name!
  346. String function cmd_read_attrs(model : Element, element_name : String):
  347. String result
  348. Element attr_list
  349. Element attr_keys
  350. String attr_key
  351. String attr
  352. result = "Success: "
  353. if (dict_in(model["model"], element_name)):
  354. attr_list = getAttributeList(model, element_name)
  355. attr_keys = dict_keys(attr_list)
  356. while (0 < set_len(attr_keys)):
  357. attr_key = set_pop(attr_keys)
  358. attr = read_attribute(model, element_name, attr_key)
  359. if (read_type(model["metamodel"], attr_list[attr_key]) == "ActionLanguage"):
  360. if (element_eq(attr, read_root())):
  361. result = result + attr_key + " : " + cast_value(attr_list[attr_key]) + " = {\"AL\": \"\"}\n"
  362. else:
  363. result = result + attr_key + " : " + cast_value(attr_list[attr_key]) + " = {\"AL\": " + cast_value(attr) + "}\n"
  364. else:
  365. result = result + attr_key + " : " + cast_value(attr_list[attr_key]) + " = " + cast_value(attr) + "\n"
  366. return result!
  367. else:
  368. return "Element not found: " + element_name!
  369. String function cmd_read_defined_attrs(model : Element, element_name : String):
  370. String result
  371. Element attr_list
  372. Element attr_keys
  373. String attr_key
  374. Element optionality
  375. result = "Success: "
  376. if (dict_in(model["model"], element_name)):
  377. //TODO automatically find name AttributeLink, as this might change with merging...
  378. if (dict_in(model["metamodel"]["model"], "AttributeLink")):
  379. attr_list = getInstantiatableAttributes(model, element_name, "AttributeLink")
  380. optionality = getAttributeOptionality(model, element_name, "AttributeLink")
  381. attr_keys = dict_keys(attr_list)
  382. while (0 < set_len(attr_keys)):
  383. attr_key = set_pop(attr_keys)
  384. if (optionality[attr_key]):
  385. result = string_join(result, attr_key) + " ?: " + cast_string(attr_list[attr_key]) + "\n"
  386. else:
  387. result = string_join(result, attr_key) + " : " + cast_string(attr_list[attr_key]) + "\n"
  388. return result!
  389. else:
  390. return "Not a SimpleClassDiagrams model!"!
  391. else:
  392. return "Element not found: " + element_name!
  393. String function cmd_types(model : Element):
  394. Element keys_t
  395. String v_t
  396. String result
  397. keys_t = dict_keys(model["metamodel"]["model"])
  398. result = "Success: "
  399. while (set_len(keys_t) > 0):
  400. v_t = set_pop(keys_t)
  401. result = result + string_join(" " + v_t + " : ", read_type(model["metamodel"], v_t)) + "\n"
  402. return result!
  403. String function cmd_retype(write : Boolean, model : Element, element_name : String, new_type : String):
  404. if (write):
  405. if (dict_in(model["model"], element_name)):
  406. if (dict_in(model["metamodel"]["model"], new_type)):
  407. retype(model, element_name, new_type)
  408. return "Success"!
  409. else:
  410. return "Element not found: " + new_type!
  411. else:
  412. return "Element not found: " + element_name!
  413. else:
  414. return "Write permission denied"!
  415. String function cmd_read_association_source(write : Boolean, model : Element, element_name : String):
  416. if (dict_in(model["model"], element_name)):
  417. if (is_edge(model["model"][element_name])):
  418. return "Success: " + readAssociationSource(model, element_name)!
  419. else:
  420. return "Not an association: " + element_name!
  421. else:
  422. return "Element not found: " + element_name!
  423. String function cmd_read_association_destination(write : Boolean, model : Element, element_name : String):
  424. if (dict_in(model["model"], element_name)):
  425. if (is_edge(model["model"][element_name])):
  426. return "Success: " + readAssociationDestination(model, element_name)!
  427. else:
  428. return "Not an association: " + element_name!
  429. else:
  430. return "Element not found: " + element_name!
  431. String function cmd_all_instances(model : Element, type : String):
  432. String result
  433. Element elems
  434. if (dict_in(model["metamodel"]["model"], type)):
  435. result = "Success: "
  436. elems = allInstances(model, type)
  437. while (set_len(elems) > 0):
  438. result = string_join(result, set_pop(elems)) + "\n"
  439. return result!
  440. else:
  441. return "Element not found: " + type!
  442. Boolean function modify(model : Element, write : Boolean):
  443. String cmd
  444. output("Model loaded, ready for commands!")
  445. while (True):
  446. cmd = input()
  447. if (cmd == "help"):
  448. output(cmd_help_m(write))
  449. elif (cmd == "exit"):
  450. return True!
  451. elif (cmd == "upload"):
  452. output(cmd_upload(write, model))
  453. elif (cmd == "instantiate_node"):
  454. output(cmd_instantiate_node(write, model, single_input("Type?"), single_input("Name?")))
  455. elif (cmd == "instantiate_edge"):
  456. output(cmd_instantiate_edge(write, model, single_input("Type?"), single_input("Name?"), single_input("Source?"), single_input("Target?")))
  457. elif (cmd == "attr_add"):
  458. output(cmd_attr_add(write, model, single_input("Name?"), single_input("Attribute name?"), single_input("Value?")))
  459. elif (cmd == "attr_add_code"):
  460. output(cmd_attr_add_code(write, model, single_input("Name?"), single_input("Attribute name?")))
  461. elif (cmd == "attr_delete"):
  462. output(cmd_attr_del(write, model, single_input("Name?"), single_input("Attribute name?")))
  463. elif (cmd == "attr_name"):
  464. output(cmd_attr_name(write, model, single_input("Name?"), single_input("Attribute name?"), single_input("New name?")))
  465. elif (cmd == "attr_type"):
  466. output(cmd_attr_type(write, model, single_input("Name?"), single_input("Attribute name?"), single_input("Type name?")))
  467. elif (cmd == "attr_optional"):
  468. output(cmd_attr_optional(write, model, single_input("Name?"), single_input("Attribute name?"), input()))
  469. elif (cmd == "delete"):
  470. output(cmd_delete(write, model, single_input("Name?")))
  471. elif (cmd == "list_full"):
  472. output(cmd_list_full(model))
  473. elif (cmd == "JSON"):
  474. output("Success: " + JSON_print(model))
  475. elif (cmd == "read_outgoing"):
  476. output(cmd_read_outgoing(model, single_input("Name?"), single_input("Type?")))
  477. elif (cmd == "read_incoming"):
  478. output(cmd_read_incoming(model, single_input("Name?"), single_input("Type?")))
  479. elif (cmd == "read"):
  480. output(cmd_read(model, single_input("Name?")))
  481. elif (cmd == "read_attrs"):
  482. output(cmd_read_attrs(model, single_input("Name?")))
  483. elif (cmd == "read_defined_attrs"):
  484. output(cmd_read_defined_attrs(model, single_input("Name?")))
  485. elif (cmd == "types"):
  486. output(cmd_types(model))
  487. elif (cmd == "retype"):
  488. output(cmd_retype(write, model, single_input("Name?"), single_input("New type?")))
  489. elif (cmd == "read_association_source"):
  490. output(cmd_read_association_source(write, model, single_input("Name?")))
  491. elif (cmd == "read_association_destination"):
  492. output(cmd_read_association_destination(write, model, single_input("Name?")))
  493. elif (cmd == "connections_between"):
  494. output(cmd_connections_between(model, single_input("Source element?"), single_input("Target element?")))
  495. elif (cmd == "all_instances"):
  496. output(cmd_all_instances(model, single_input("Type?")))
  497. elif (cmd == "define_attribute"):
  498. output(cmd_define_attribute(write, model, single_input("On which element?"), single_input("Attribute name?"), single_input("Type?")))
  499. elif (cmd == "undefine_attribute"):
  500. output(cmd_undefine_attribute(write, model, single_input("On which element?"), single_input("Attribute name?")))
  501. else:
  502. output("Unknown command while modelling: " + cast_value(cmd))
  503. output("Use command 'help' to get a list of available commands")
  504. String function single_input(prompt : String):
  505. if (verbose):
  506. output(prompt)
  507. return input()!
  508. Element function set_input(prompt : String):
  509. Element result
  510. Element inp
  511. if (verbose):
  512. output(prompt)
  513. output("-- Set input: empty string to terminate set")
  514. result = set_create()
  515. while (True):
  516. inp = input()
  517. if (value_eq(inp, "")):
  518. return result!
  519. else:
  520. set_add(result, inp)
  521. Element function dict_input(prompt : String):
  522. Element result
  523. Element key
  524. if (verbose):
  525. output(prompt)
  526. output("-- Dict input: empty key to terminate dict")
  527. result = set_create()
  528. while (True):
  529. key = input()
  530. if (value_eq(key, "")):
  531. return result!
  532. else:
  533. dict_add(result, key, input())
  534. Void function set_verbose(v : Boolean):
  535. verbose = v
  536. return!