From: David Kerkeslager Date: Tue, 8 Aug 2017 07:01:38 +0000 (-0400) Subject: Minor refactor X-Git-Url: https://code.kerkeslager.com/?a=commitdiff_plain;h=744832aa13213571180f4cf1a25e4ecc9e0315f3;p=fur Minor refactor --- 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