+ for symbol in statement.symbol_list:
+ try:
+ symbol_list_index = accumulators.symbol_list.index(symbol)
+ except ValueError:
+ symbol_list_index = len(accumulators.symbol_list)
+ accumulators.symbol_list.append(symbol)
+
+ symbol_list_indices.append(symbol_list_index)
+
+ return CSymbolArrayVariableInitializationStatement(
+ variable=statement.variable,
+ symbol_list=statement.symbol_list,
+ symbol_list_indices=tuple(symbol_list_indices),
+ )
+
+def transform_variable_initialization_statement(accumulators, statement):
+ return CVariableInitializationStatement(
+ variable=statement.variable,
+ expression=transform_expression(accumulators, statement.expression),
+ )
+
+def transform_variable_reassignment_statement(accumulators, statement):
+ return CVariableReassignmentStatement(
+ variable=statement.variable,
+ expression=transform_expression(accumulators, statement.expression),
+ )
+
+def transform_function_definition_statement(accumulators, statement):
+ # TODO Allow defining the same function in different contexts
+ if any(fd.name == statement.name for fd in accumulators.function_definition_list):
+ raise Exception('A function with name "{}" already exists'.format(statement.name))
+
+ # TODO Add argument names to the symbol table
+ accumulators.function_definition_list.append(CFunctionDefinition(
+ name=statement.name,
+ argument_name_list=statement.argument_name_list,
+ statement_list=tuple(transform_statement(accumulators, s) for s in statement.statement_list)
+ ))
+
+ return CFunctionDeclaration(name=statement.name)
+
+def transform_push_statement(accumulators, statement):
+ return CPushStatement(expression=transform_expression(accumulators, statement.expression))
+
+def transform_statement(accumulators, statement):