From 744832aa13213571180f4cf1a25e4ecc9e0315f3 Mon Sep 17 00:00:00 2001 From: David Kerkeslager Date: Tue, 8 Aug 2017 03:01:38 -0400 Subject: [PATCH] Minor refactor --- normalization.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/normalization.py b/normalization.py index 8582bc5..c51c973 100644 --- a/normalization.py +++ b/normalization.py @@ -39,6 +39,9 @@ NormalProgram = collections.namedtuple( ], ) +def fake_normalization(counter, thing): + return (counter, (), thing) + def normalize_function_call_expression(counter, expression): prestatements = [] arguments = [] @@ -63,19 +66,22 @@ def normalize_function_call_expression(counter, expression): ), ) +def normalize_expression_statement(counter, statement): + counter, prestatements, normalized = { + parsing.FurFunctionCallExpression: normalize_function_call_expression, + }[type(statement.expression)](counter, statement.expression) + + return ( + counter, + prestatements, + NormalExpressionStatement(expression=normalized), + ) + def normalize_statement(counter, statement): - if isinstance(statement, parsing.FurExpressionStatement): - counter, prestatements, normalized = { - parsing.FurFunctionCallExpression: normalize_function_call_expression, - }[type(statement.expression)](counter, statement.expression) - - return ( - counter, - prestatements, - NormalExpressionStatement(expression=normalized), - ) - - return (counter, (), statement) + return { + parsing.FurExpressionStatement: normalize_expression_statement, + parsing.FurAssignmentStatement: fake_normalization, + }[type(statement)](counter, statement) def normalize(program): counter = 0 -- 2.20.1