|
@@ -14,7 +14,9 @@ Action function construct_top():
|
|
|
if (command == "global"):
|
|
|
return construct_global()!
|
|
|
elif (command == "funcdef"):
|
|
|
- return construct_top_funcdef()!
|
|
|
+ return construct_top_funcdef(False)!
|
|
|
+ elif (command == "mutable_funcdef"):
|
|
|
+ return construct_top_funcdef(True)!
|
|
|
else:
|
|
|
log("ERROR: did not understand command " + cast_e2s(command))
|
|
|
|
|
@@ -58,7 +60,7 @@ Action function construct_global():
|
|
|
dict_add(assign, "next", construct_top())
|
|
|
return this_element!
|
|
|
|
|
|
-Action function construct_top_funcdef():
|
|
|
+Action function construct_top_funcdef(mutable : Boolean):
|
|
|
Action assign
|
|
|
Action resolve
|
|
|
Action constant
|
|
@@ -87,6 +89,9 @@ Action function construct_top_funcdef():
|
|
|
dict_add(constant, "node", func)
|
|
|
dict_add(func, "params", params)
|
|
|
|
|
|
+ if (mutable):
|
|
|
+ dict_add(func, "mutable", create_node())
|
|
|
+
|
|
|
Integer nrParams
|
|
|
nrParams = input()
|
|
|
Integer counter
|
|
@@ -308,12 +313,14 @@ Action function construct_function():
|
|
|
Element param
|
|
|
Element params
|
|
|
String arg_names_decl
|
|
|
+ String inp
|
|
|
|
|
|
variable_map = create_node()
|
|
|
|
|
|
- while (value_neq(input(), "funcdef")):
|
|
|
+ inp = input()
|
|
|
+ while (bool_or(inp == "funcdef", inp == "mutable_funcdef")):
|
|
|
// We skip over everything that is not a funcdef, as these are all just definitions of global stuff
|
|
|
- log("Skip over input!")
|
|
|
+ inp = input()
|
|
|
|
|
|
// Consume the name
|
|
|
input()
|
|
@@ -325,6 +332,9 @@ Action function construct_function():
|
|
|
arg_names_decl = "abcdefghijklmnopqrstuvwxyz"
|
|
|
dict_add(func, "params", params)
|
|
|
|
|
|
+ if (inp == "mutable_funcdef"):
|
|
|
+ dict_add(func, "mutable", create_node())
|
|
|
+
|
|
|
while (counter < nrParams):
|
|
|
param = create_node()
|
|
|
dict_add(params, string_get(arg_names_decl, counter), param)
|