return (counter, (), thing)
def normalize_function_call_expression(counter, expression):
+ assert isinstance(expression, parsing.FurFunctionCallExpression)
+
prestatements = []
arguments = []
for argument in expression.arguments:
+ counter, argument_prestatements, normalized_argument = normalize_expression(counter, argument)
+
+ for s in argument_prestatements:
+ prestatements.append(s)
+
variable = '${}'.format(counter)
prestatements.append(NormalVariableAssignmentStatement(
variable=variable,
- expression=argument, # TODO Normalize each argument
+ expression=normalized_argument,
))
arguments.append(NormalVariableExpression(
variable=variable,
),
)
+def normalize_expression(counter, expression):
+ return {
+ parsing.FurFunctionCallExpression: normalize_function_call_expression,
+ parsing.FurInfixExpression: fake_normalization, # TODO This should not be faked
+ parsing.FurIntegerLiteralExpression: fake_normalization,
+ parsing.FurNegationExpression: fake_normalization,
+ parsing.FurStringLiteralExpression: fake_normalization,
+ parsing.FurSymbolExpression: fake_normalization,
+ }[type(expression)](counter, expression)
+
def normalize_expression_statement(counter, statement):
counter, prestatements, normalized = {
parsing.FurFunctionCallExpression: normalize_function_call_expression,
# TODO Handle all possible types in this form
return {
normalization.NormalVariableExpression: transform_variable_expression,
+ normalization.NormalFunctionCallExpression: transform_function_call_expression,
}[type(expression)](accumulators, expression)
def transform_symbol_assignment_statement(accumulators, assignment_statement):
)
def transform_function_call_expression(accumulators, function_call):
+ # TODO Function should be a full expression
if function_call.function.value in BUILTINS.keys():
# TODO Check that the builtin is actually callable
accumulators.builtin_set.add(function_call.function.value)