From 25ebb2556ea388656346b0efafa80e66f61057de Mon Sep 17 00:00:00 2001 From: David Kerkeslager Date: Tue, 8 Aug 2017 12:04:08 -0400 Subject: [PATCH] variable assignment renamed to variable initialization for accuracy --- generation.py | 4 ++-- normalization.py | 14 +++++++------- transformation.py | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/generation.py b/generation.py index 92d07be..4b0ad7e 100644 --- a/generation.py +++ b/generation.py @@ -81,7 +81,7 @@ def generate_symbol_assignment_statement(c_assignment_statement): generate_expression(c_assignment_statement.expression), ) -def generate_variable_assignment_statement(statement): +def generate_variable_initialization_statement(statement): return 'Object {} = {};'.format( statement.variable, generate_expression(statement.expression), @@ -91,7 +91,7 @@ def generate_statement(statement): return { transformation.CSymbolAssignmentStatement: generate_symbol_assignment_statement, transformation.CExpressionStatement: generate_expression_statement, - transformation.CVariableAssignmentStatement: generate_variable_assignment_statement, + transformation.CVariableInitializationStatement: generate_variable_initialization_statement, }[type(statement)](statement) def generate(program): diff --git a/normalization.py b/normalization.py index 0d967d7..94d3a7c 100644 --- a/normalization.py +++ b/normalization.py @@ -27,8 +27,8 @@ NormalFunctionCallExpression = collections.namedtuple( ], ) -NormalVariableAssignmentStatement = collections.namedtuple( - 'NormalVariableAssignmentStatement', +NormalVariableInitializationStatement = collections.namedtuple( + 'NormalVariableInitializationStatement', [ 'variable', 'expression', @@ -65,7 +65,7 @@ def normalize_function_call_expression(counter, expression): prestatements.append(s) variable = '${}'.format(counter) - prestatements.append(NormalVariableAssignmentStatement( + prestatements.append(NormalVariableInitializationStatement( variable=variable, expression=normalized_argument, )) @@ -93,11 +93,11 @@ def normalize_basic_infix_operation(counter, expression): counter += 1 root_prestatements = ( - NormalVariableAssignmentStatement( + NormalVariableInitializationStatement( variable=left_variable, expression=left_expression, ), - NormalVariableAssignmentStatement( + NormalVariableInitializationStatement( variable=right_variable, expression=right_expression, ), @@ -130,11 +130,11 @@ def normalize_comparison_expression(counter, expression): counter += 1 root_prestatements = ( - NormalVariableAssignmentStatement( + NormalVariableInitializationStatement( variable=left_variable, expression=left_expression, ), - NormalVariableAssignmentStatement( + NormalVariableInitializationStatement( variable=right_variable, expression=right_expression, ), diff --git a/transformation.py b/transformation.py index b6d21c8..2d729fa 100644 --- a/transformation.py +++ b/transformation.py @@ -73,8 +73,8 @@ CSymbolAssignmentStatement = collections.namedtuple( ], ) -CVariableAssignmentStatement = collections.namedtuple( - 'CVariableAssignmentStatement', +CVariableInitializationStatement = collections.namedtuple( + 'CVariableInitializationStatement', [ 'variable', 'expression', @@ -264,8 +264,8 @@ def transform_expression_statement(accumulators, statement): expression=expression, ) -def transform_variable_assignment_statement(accumulators, statement): - return CVariableAssignmentStatement( +def transform_variable_initialization_statement(accumulators, statement): + return CVariableInitializationStatement( variable=statement.variable, expression=transform_expression(accumulators, statement.expression), ) @@ -274,7 +274,7 @@ def transform_statement(accumulators, statement): return { parsing.FurAssignmentStatement: transform_symbol_assignment_statement, parsing.FurExpressionStatement: transform_expression_statement, - normalization.NormalVariableAssignmentStatement: transform_variable_assignment_statement, + normalization.NormalVariableInitializationStatement: transform_variable_initialization_statement, normalization.NormalExpressionStatement: transform_expression_statement, }[type(statement)](accumulators, statement) -- 2.20.1