Browse Source

Working way of finding the first "real" instruction

Yentl Van Tendeloo 7 years ago
parent
commit
7e7d3fe55b
4 changed files with 29 additions and 9 deletions
  1. 26 7
      models/AL_to_py.alc
  2. 1 0
      services/HUTN/main.py
  3. 1 1
      test_printer.py
  4. 1 1
      wrappers/modelverse_SCCD.py

+ 26 - 7
models/AL_to_py.alc

@@ -103,17 +103,36 @@ include "object_operations.alh"
 //
 //        raise primitive_functions.PrimitiveFinished(instruction + next_inst)
 
+String function get_indent(indentation : Integer):
+	String code
+	code = ""
+	while (indentation > 0):
+		code = code + "\t"
+		indentation = indentation - 1
+	return code!
+
+String function code_print(node : Element, indentation : Integer):
+	String code
+	code = "(no_printer_for_" + cast_value(node) + ")"
+	return code!
+
 Boolean function main(model : Element):
 	// Read out the main function
 	String initial_function
 	String al_node
+	Element initial_function_element
+	get_indent(0)
 
 	initial_function = set_pop(allInstances(model, "AL/Initial"))
-	initial_function = set_pop(allAssociationDestinations(model, initial_function))
-	al_node = cast_value(initial_function)
-	log("Read out initial node: " + initial_function)
-	log("Value: " + al_node)
-
-	// Ready, now branch out
-	// TODO
+	initial_function = set_pop(allAssociationDestinations(model, initial_function, "AL/initial_funcdef"))
+	initial_function_element = model["model"][initial_function]["body"]
+	al_node = cast_value(initial_function_element)
+	while (cast_value(initial_function_element) == "global"):
+		initial_function_element = initial_function_element["next"]["next"]
+	log("Started execution at " + cast_value(initial_function_element))
+	log("Started REAL execution at " + cast_value(initial_function_element))
+	String code
+	code = code_print(initial_function_element, 0)
+	log("Generated code:")
+	log(code)
 	return True!

+ 1 - 0
services/HUTN/main.py

@@ -39,6 +39,7 @@ def compile_service(port):
             f.flush()
 
         compiled = do_compile(temp_file, COMPILER_PATH + "/grammars/actionlanguage.g", "CS")
+        print("Compiled: " + str(compiled))
         os.remove(temp_file)
         return compiled
 

+ 1 - 1
test_printer.py

@@ -7,4 +7,4 @@ login("admin", "admin")
 
 model_add("formalisms/String", "formalisms/SimpleClassDiagrams", open("models/String.mvc", 'r').read())
 transformation_add_AL({"AL": "formalisms/ActionLanguage"}, {"String": "formalisms/String"}, "models/AL_to_Py", open("models/AL_to_py.alc", 'r').read())
-transformation_execute_AL("models/AL_to_PY", {"AL": "models/AL_to_Py"}, {"String": "models/printed_string"})
+transformation_execute_AL("models/AL_to_Py", {"AL": "models/AL_to_Py"}, {"String": "models/printed_string"})

+ 1 - 1
wrappers/modelverse_SCCD.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Sat Mar 24 15:39:35 2018
+Date:   Wed Mar 28 10:16:04 2018
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server