浏览代码

Future direction: add very fine grained operations

Yentl Van Tendeloo 9 年之前
父节点
当前提交
4afa306112
共有 2 个文件被更改,包括 37 次插入17 次删除
  1. 30 14
      bootstrap/constructors.alc
  2. 7 3
      integration/test_constructors_models.py

+ 30 - 14
bootstrap/constructors.alc

@@ -131,23 +131,38 @@ Action function construct_unknown():
 		return construct_break()
 	elif (elem == "continue"):
 		return construct_continue()
-	elif (elem == "instantiate_bottom"):
-		new_model = create_node()
-		dict_add(new_model, "model", create_node())
-		instantiate_bottom(new_model)
-		output(new_model)
-		return construct_unknown()
-	elif (elem == "instantiate_model"):
-		new_model = instantiate_new_model(input(), dict_read(dict_read(input(), "model"), input()))
-		instantiate_model(new_model)
-		output(new_model)
-		return construct_unknown()
-	elif (elem == "retype_model"):
-		retype_model(input())
-		return construct_unknown()
+	elif (elem == "model"):
+		return construct_model()
 	else:
 		log("ERROR: did not understand command " + cast_e2s(elem))
 
+Void function construct_model():
+	String command
+	while(True):
+		command = input()
+		if (command == "instantiate_model"):
+			// TODO
+		elif (command == "instantiate_bottom"):
+			// TODO
+		elif (command == "add_node"):
+			// TODO
+		elif (command == "add_edge"):
+			// TODO
+		elif (command == "add_value"):
+			// TODO
+		elif (command == "add_element"):
+			// TODO
+		elif (command == "add_attribute"):
+			// TODO
+		elif (command == "add_link"):
+			// TODO
+		elif (command == "retype"):
+			// TODO
+		elif (command == "code"):
+			return construct_unknown()
+		else:
+			log("Model command not understood: " + command)
+
 Action function construct_if():
 	Action this_element
 	this_element = create_value(!if)
@@ -413,3 +428,4 @@ Element function find_attribute(source : Element, attr_name : String, types : El
 			i = i + 1
 		// No return at the moment, as this crashes the MvK
 		log("ERROR: could not find attribute")
+

+ 7 - 3
integration/test_constructors_models.py

@@ -101,9 +101,13 @@ class TestConstructorsModels(unittest.TestCase):
                     '"instantiate_model"',
                         1,
                         1, '"Inheritance"',
+                        '"Type"', '"Integer"',
+                            'false',
+                            'false',
+                            'true',
                         '"Class"', '"Place"',
                             'true',
-                                '"tokens"', '{"value": "Integer"}', 'false',
+                                '"tokens"', '"Integer"', 'false',
                             'false',
                             'true',
                         '"Class"', '"Transition"',
@@ -112,12 +116,12 @@ class TestConstructorsModels(unittest.TestCase):
                             'true',
                         '"Association"', '"P2T"', '"Place"', '"Transition"',
                             'true',
-                                '"weight"', '{"value": "Integer"}', 'false',
+                                '"weight"', '"Integer"', 'false',
                             'false',
                             'true',
                         '"Association"', '"T2P"', '"Transition"', '"Place"',
                             'true',
-                                '"weight"', '{"value": "Integer"}', 'false',
+                                '"weight"', '"Integer"', 'false',
                             'false',
                             'false',
                     2,