|
@@ -223,7 +223,7 @@ def bootstrap():
|
|
f.write("Edge _new_user(root, user_root)\n")
|
|
f.write("Edge _new_user(root, user_root)\n")
|
|
f.write("Edge __new_user(_new_user, ___new_user)\n")
|
|
f.write("Edge __new_user(_new_user, ___new_user)\n")
|
|
|
|
|
|
- def compile_code_AL(code, target, prepend="", is_file=False, main=False):
|
|
|
|
|
|
+ def compile_code_AL(code, target, prepend="", is_file=False, main=False, symbols=None):
|
|
import sys
|
|
import sys
|
|
sys.path.append("interface/HUTN/")
|
|
sys.path.append("interface/HUTN/")
|
|
from hutn_compiler.compiler import main as compile_code
|
|
from hutn_compiler.compiler import main as compile_code
|
|
@@ -234,7 +234,7 @@ def bootstrap():
|
|
filename = "bootstrap/bootstrap.al"
|
|
filename = "bootstrap/bootstrap.al"
|
|
else:
|
|
else:
|
|
filename = code
|
|
filename = code
|
|
- code = compile_code(filename, "interface/HUTN/grammars/actionlanguage.g", "BS", ["--debug", "--prepend:%s" % prepend, "--main" if main else "--not-main"])
|
|
|
|
|
|
+ code = compile_code(filename, "interface/HUTN/grammars/actionlanguage.g", "BS", ["--debug", "--prepend:%s" % prepend, "--main" if main else "--not-main"], symbols=symbols)
|
|
if not is_file:
|
|
if not is_file:
|
|
os.remove("bootstrap/bootstrap.al")
|
|
os.remove("bootstrap/bootstrap.al")
|
|
return code.replace("auto_initial_IP", target)
|
|
return code.replace("auto_initial_IP", target)
|
|
@@ -250,8 +250,10 @@ def bootstrap():
|
|
for bootstrap_file in bootstrap_files:
|
|
for bootstrap_file in bootstrap_files:
|
|
# Compile the subfile
|
|
# Compile the subfile
|
|
print("[COMP] %s" % bootstrap_file)
|
|
print("[COMP] %s" % bootstrap_file)
|
|
- result = compile_code_AL(bootstrap_file, "initial_IP", prepend=bootstrap_file, is_file=True)
|
|
|
|
|
|
+ symbols = {}
|
|
|
|
+ result = compile_code_AL(bootstrap_file, "initial_IP", prepend=bootstrap_file, is_file=True, symbols=symbols)
|
|
f.write(result, both=False)
|
|
f.write(result, both=False)
|
|
|
|
+
|
|
# Now link the code with the compilation manager structure
|
|
# Now link the code with the compilation manager structure
|
|
f.write("Node elem()\n", both=False)
|
|
f.write("Node elem()\n", both=False)
|
|
f.write('Node initializers("initializers")\n', both=False)
|
|
f.write('Node initializers("initializers")\n', both=False)
|
|
@@ -266,7 +268,18 @@ def bootstrap():
|
|
f.write('Node hash_value("%s")\n' % md5.hexdigest(), both=False)
|
|
f.write('Node hash_value("%s")\n' % md5.hexdigest(), both=False)
|
|
f.write("Edge _(elem, hash_value)\n", both=False)
|
|
f.write("Edge _(elem, hash_value)\n", both=False)
|
|
f.write("Edge _(_, hash)\n", both=False)
|
|
f.write("Edge _(_, hash)\n", both=False)
|
|
|
|
+
|
|
#TODO add the symbols as well!
|
|
#TODO add the symbols as well!
|
|
|
|
+ f.write('Node symbols("symbols")\n', both=False)
|
|
|
|
+ f.write('Node __symbols()\n', both=False)
|
|
|
|
+ f.write('Edge _(elem, __symbols)\n', both=False)
|
|
|
|
+ f.write('Edge _(_, symbols)\n', both=False)
|
|
|
|
+
|
|
|
|
+ for k, v in symbols.items():
|
|
|
|
+ f.write('Node v(%s)\n' % v, both=False)
|
|
|
|
+ f.write('Node k("%s")\n' % k, both=False)
|
|
|
|
+ f.write('Edge _(__symbols, v)\n', both=False)
|
|
|
|
+ f.write('Edge _(_, k)\n', both=False)
|
|
|
|
|
|
# Create code for initial user
|
|
# Create code for initial user
|
|
print("[BOOT] initial_user")
|
|
print("[BOOT] initial_user")
|