|
@@ -21,8 +21,6 @@ primitives = { "integer_addition": ["Integer", "Integer", "Integer"],
|
|
"integer_gte": ["Boolean", "Integer", "Integer"],
|
|
"integer_gte": ["Boolean", "Integer", "Integer"],
|
|
"integer_lt": ["Boolean", "Integer", "Integer"],
|
|
"integer_lt": ["Boolean", "Integer", "Integer"],
|
|
"integer_lte": ["Boolean", "Integer", "Integer"],
|
|
"integer_lte": ["Boolean", "Integer", "Integer"],
|
|
- "integer_eq": ["Boolean", "Integer", "Integer"],
|
|
|
|
- "integer_neq": ["Boolean", "Integer", "Integer"],
|
|
|
|
"integer_neg": ["Integer", "Integer"],
|
|
"integer_neg": ["Integer", "Integer"],
|
|
"float_addition": ["Float", "Float", "Float"],
|
|
"float_addition": ["Float", "Float", "Float"],
|
|
"float_subtraction": ["Float", "Float", "Float"],
|
|
"float_subtraction": ["Float", "Float", "Float"],
|
|
@@ -32,26 +30,18 @@ primitives = { "integer_addition": ["Integer", "Integer", "Integer"],
|
|
"float_gte": ["Boolean", "Float", "Float"],
|
|
"float_gte": ["Boolean", "Float", "Float"],
|
|
"float_lt": ["Boolean", "Float", "Float"],
|
|
"float_lt": ["Boolean", "Float", "Float"],
|
|
"float_lte": ["Boolean", "Float", "Float"],
|
|
"float_lte": ["Boolean", "Float", "Float"],
|
|
- "float_eq": ["Boolean", "Float", "Float"],
|
|
|
|
- "float_neq": ["Boolean", "Float", "Float"],
|
|
|
|
"float_neg": ["Float", "Float"],
|
|
"float_neg": ["Float", "Float"],
|
|
"bool_and": ["Boolean", "Boolean", "Boolean"],
|
|
"bool_and": ["Boolean", "Boolean", "Boolean"],
|
|
"bool_or": ["Boolean", "Boolean", "Boolean"],
|
|
"bool_or": ["Boolean", "Boolean", "Boolean"],
|
|
"bool_not": ["Boolean", "Boolean"],
|
|
"bool_not": ["Boolean", "Boolean"],
|
|
- "bool_eq": ["Boolean", "Boolean", "Boolean"],
|
|
|
|
- "bool_neq": ["Boolean", "Boolean", "Boolean"],
|
|
|
|
"string_join": ["String", "String", "String"],
|
|
"string_join": ["String", "String", "String"],
|
|
"string_get": ["String", "String", "Integer"],
|
|
"string_get": ["String", "String", "Integer"],
|
|
"string_substr": ["String", "String", "Integer", "Integer"],
|
|
"string_substr": ["String", "String", "Integer", "Integer"],
|
|
"string_len": ["Integer", "String"],
|
|
"string_len": ["Integer", "String"],
|
|
"string_split": ["Element", "String", "String"],
|
|
"string_split": ["Element", "String", "String"],
|
|
"string_startswith": ["Boolean", "String", "String"],
|
|
"string_startswith": ["Boolean", "String", "String"],
|
|
- "string_eq": ["Boolean", "String", "String"],
|
|
|
|
- "string_neq": ["Boolean", "String", "String"],
|
|
|
|
- "action_eq": ["Boolean", "Action", "Action"],
|
|
|
|
- "action_neq": ["Boolean", "Action", "Action"],
|
|
|
|
- "type_eq": ["Boolean", "Type", "Type"],
|
|
|
|
- "type_neq": ["Boolean", "Type", "Type"],
|
|
|
|
|
|
+ "value_eq": ["Boolean", "Element", "Element"],
|
|
|
|
+ "value_neq": ["Boolean", "Element", "Element"],
|
|
"cast_i2f": ["Float", "Integer"],
|
|
"cast_i2f": ["Float", "Integer"],
|
|
"cast_i2s": ["String", "Integer"],
|
|
"cast_i2s": ["String", "Integer"],
|
|
"cast_i2b": ["Boolean", "Integer"],
|
|
"cast_i2b": ["Boolean", "Integer"],
|
|
@@ -65,7 +55,6 @@ primitives = { "integer_addition": ["Integer", "Integer", "Integer"],
|
|
"cast_b2f": ["Float", "Boolean"],
|
|
"cast_b2f": ["Float", "Boolean"],
|
|
"cast_b2s": ["String", "Boolean"],
|
|
"cast_b2s": ["String", "Boolean"],
|
|
"cast_e2s": ["String", "Element"],
|
|
"cast_e2s": ["String", "Element"],
|
|
- "cast_t2s": ["String", "Type"],
|
|
|
|
"cast_a2s": ["String", "Action"],
|
|
"cast_a2s": ["String", "Action"],
|
|
"cast_v2s": ["String", "Element"],
|
|
"cast_v2s": ["String", "Element"],
|
|
"cast_id2s": ["String", "Element"],
|
|
"cast_id2s": ["String", "Element"],
|
|
@@ -89,7 +78,11 @@ primitives = { "integer_addition": ["Integer", "Integer", "Integer"],
|
|
"set_remove_node": ["Element", "Element", "Element"],
|
|
"set_remove_node": ["Element", "Element", "Element"],
|
|
"set_in": ["Boolean", "Element", "Element"],
|
|
"set_in": ["Boolean", "Element", "Element"],
|
|
"set_in_node": ["Boolean", "Element", "Element"],
|
|
"set_in_node": ["Boolean", "Element", "Element"],
|
|
- "typeof": ["Type", "Element"],
|
|
|
|
|
|
+ "is_physical_int": ["Boolean", "Element"],
|
|
|
|
+ "is_physical_bool": ["Boolean", "Element"],
|
|
|
|
+ "is_physical_string": ["Boolean", "Element"],
|
|
|
|
+ "is_physical_action": ["Boolean", "Element"],
|
|
|
|
+ "is_physical_float": ["Boolean", "Element"],
|
|
"create_node": ["Element"],
|
|
"create_node": ["Element"],
|
|
"create_edge": ["Element", "Element", "Element"],
|
|
"create_edge": ["Element", "Element", "Element"],
|
|
"create_value": ["Element", "Element"],
|
|
"create_value": ["Element", "Element"],
|
|
@@ -116,7 +109,7 @@ Element function dict_read(a: Element, b: Element) = ?primitives/dict_read
|
|
Element function create_node() = ?primitives/create_node
|
|
Element function create_node() = ?primitives/create_node
|
|
Element function create_value(a: Element) = ?primitives/create_value
|
|
Element function create_value(a: Element) = ?primitives/create_value
|
|
Element function dict_add(a: Element, b: Element, c: Element) = ?primitives/dict_add
|
|
Element function dict_add(a: Element, b: Element, c: Element) = ?primitives/dict_add
|
|
-Boolean function string_eq(a: String, b: String) = ?primitives/string_eq
|
|
|
|
|
|
+Boolean function value_eq(a: String, b: String) = ?primitives/value_eq
|
|
Boolean function delete_element(a: Element) = ?primitives/delete_element
|
|
Boolean function delete_element(a: Element) = ?primitives/delete_element
|
|
Boolean function bool_not(a: Boolean) = ?primitives/bool_not
|
|
Boolean function bool_not(a: Boolean) = ?primitives/bool_not
|
|
Boolean function dict_in(a: Element, b: Element) = ?primitives/dict_in
|
|
Boolean function dict_in(a: Element, b: Element) = ?primitives/dict_in
|
|
@@ -132,7 +125,7 @@ Void function __main():
|
|
\t
|
|
\t
|
|
\twhile (True):
|
|
\twhile (True):
|
|
\t\tusername = input()
|
|
\t\tusername = input()
|
|
-\t\tif (string_eq(username, "__delete")):
|
|
|
|
|
|
+\t\tif (value_eq(username, "__delete")):
|
|
\t\t\tuser_root = dict_read(read_root(), input())
|
|
\t\t\tuser_root = dict_read(read_root(), input())
|
|
\t\t\tdelete_element(user_root)
|
|
\t\t\tdelete_element(user_root)
|
|
\t\telse:
|
|
\t\telse:
|
|
@@ -173,12 +166,12 @@ Void function __main():
|
|
\tInteger interface
|
|
\tInteger interface
|
|
\twhile (True):
|
|
\twhile (True):
|
|
\t\tinterface = input()
|
|
\t\tinterface = input()
|
|
-\t\tif (integer_eq(interface, 0)):
|
|
|
|
|
|
+\t\tif (interface == 0):
|
|
\t\t\tlog("DO deserialize")
|
|
\t\t\tlog("DO deserialize")
|
|
\t\t\texec(deserialize(input()))
|
|
\t\t\texec(deserialize(input()))
|
|
-\t\telif (integer_eq(interface, 1)):
|
|
|
|
|
|
+\t\telif (interface == 1):
|
|
\t\t\texec(construct_unknown())
|
|
\t\t\texec(construct_unknown())
|
|
-\t\telif (integer_eq(interface, 3)):
|
|
|
|
|
|
+\t\telif (interface == 3):
|
|
\t\t\tcompilation_manager()
|
|
\t\t\tcompilation_manager()
|
|
\t\telse:
|
|
\t\telse:
|
|
\t\t\tlog("Unsupported interface!")
|
|
\t\t\tlog("Unsupported interface!")
|
|
@@ -219,10 +212,10 @@ try:
|
|
|
|
|
|
# Define all primitive functions
|
|
# Define all primitive functions
|
|
for function, parameters in primitives.iteritems():
|
|
for function, parameters in primitives.iteritems():
|
|
- if parameters[0] == "Element":
|
|
|
|
- f.write("Node _type_%s()\n" % function)
|
|
|
|
- else:
|
|
|
|
- f.write("Node _type_%s(%s)\n" % (function, parameters[0]))
|
|
|
|
|
|
+ #if parameters[0] == "Element":
|
|
|
|
+ # f.write("Node _type_%s()\n" % function)
|
|
|
|
+ #else:
|
|
|
|
+ # f.write("Node _type_%s(%s)\n" % (function, parameters[0]))
|
|
|
|
|
|
f.write("Node _func_signature_%s()\n" % function)
|
|
f.write("Node _func_signature_%s()\n" % function)
|
|
f.write("Node _func_params_%s()\n" % function)
|
|
f.write("Node _func_params_%s()\n" % function)
|
|
@@ -239,17 +232,17 @@ try:
|
|
f.write("Edge _signature_params_%s(_func_signature_%s, _func_params_%s)\n" % (function, function, function))
|
|
f.write("Edge _signature_params_%s(_func_signature_%s, _func_params_%s)\n" % (function, function, function))
|
|
f.write("Edge _signature_params_str_%s(_signature_params_%s, _params_%s)\n" % (function, function, function))
|
|
f.write("Edge _signature_params_str_%s(_signature_params_%s, _params_%s)\n" % (function, function, function))
|
|
|
|
|
|
- f.write('Node _type_str_%s("type")\n' % function)
|
|
|
|
- f.write("Edge _signature_type_%s(_func_signature_%s, _type_%s)\n" % (function, function, function))
|
|
|
|
- f.write("Edge _signature_type_str_%s(_signature_type_%s, _type_str_%s)\n" % (function, function, function))
|
|
|
|
|
|
+ #f.write('Node _type_str_%s("type")\n' % function)
|
|
|
|
+ #f.write("Edge _signature_type_%s(_func_signature_%s, _type_%s)\n" % (function, function, function))
|
|
|
|
+ #f.write("Edge _signature_type_str_%s(_signature_type_%s, _type_str_%s)\n" % (function, function, function))
|
|
|
|
|
|
parameter_names = "abcdefghijklmnopqrstuvwxyz"
|
|
parameter_names = "abcdefghijklmnopqrstuvwxyz"
|
|
for number, param in enumerate(parameters[1:]):
|
|
for number, param in enumerate(parameters[1:]):
|
|
param_encoding = "%s_%s" % (function, parameter_names[number])
|
|
param_encoding = "%s_%s" % (function, parameter_names[number])
|
|
- if param == "Element":
|
|
|
|
- f.write("Node _type_%s()\n" % param_encoding)
|
|
|
|
- else:
|
|
|
|
- f.write("Node _type_%s(%s)\n" % (param_encoding, param))
|
|
|
|
|
|
+ #if param == "Element":
|
|
|
|
+ # f.write("Node _type_%s()\n" % param_encoding)
|
|
|
|
+ #else:
|
|
|
|
+ # f.write("Node _type_%s(%s)\n" % (param_encoding, param))
|
|
|
|
|
|
f.write("Node _func_params_%s()\n" % (param_encoding))
|
|
f.write("Node _func_params_%s()\n" % (param_encoding))
|
|
f.write('Node _name_%s("%s")\n' % (param_encoding, parameter_names[number]))
|
|
f.write('Node _name_%s("%s")\n' % (param_encoding, parameter_names[number]))
|
|
@@ -258,9 +251,9 @@ try:
|
|
f.write('Node _name_str_%s("name")\n' % param_encoding)
|
|
f.write('Node _name_str_%s("name")\n' % param_encoding)
|
|
f.write("Edge _param_name_%s(_func_params_%s, _name_%s)\n" % (param_encoding, param_encoding, param_encoding))
|
|
f.write("Edge _param_name_%s(_func_params_%s, _name_%s)\n" % (param_encoding, param_encoding, param_encoding))
|
|
f.write("Edge _param_name_str_%s(_param_name_%s, _name_str_%s)\n" % (param_encoding, param_encoding, param_encoding))
|
|
f.write("Edge _param_name_str_%s(_param_name_%s, _name_str_%s)\n" % (param_encoding, param_encoding, param_encoding))
|
|
- f.write('Node _type_str_%s("type")\n' % param_encoding)
|
|
|
|
- f.write("Edge _param_type_%s(_func_params_%s, _type_%s)\n" % (param_encoding, param_encoding, param_encoding))
|
|
|
|
- f.write("Edge _param_type_str_%s(_param_type_%s, _type_str_%s)\n" % (param_encoding, param_encoding, param_encoding))
|
|
|
|
|
|
+ #f.write('Node _type_str_%s("type")\n' % param_encoding)
|
|
|
|
+ #f.write("Edge _param_type_%s(_func_params_%s, _type_%s)\n" % (param_encoding, param_encoding, param_encoding))
|
|
|
|
+ #f.write("Edge _param_type_str_%s(_param_type_%s, _type_str_%s)\n" % (param_encoding, param_encoding, param_encoding))
|
|
|
|
|
|
# Create the initial user
|
|
# Create the initial user
|
|
f.write("Node user_root()\n")
|
|
f.write("Node user_root()\n")
|