Reuse normalize_basic_infix_operation in implementation of normalize_comparison_expre...
authorDavid Kerkeslager <kerkeslager@gmail.com>
Thu, 14 Sep 2017 23:23:06 +0000 (19:23 -0400)
committerDavid Kerkeslager <kerkeslager@gmail.com>
Thu, 14 Sep 2017 23:23:06 +0000 (19:23 -0400)
normalization.py

index 5b5bd94..3b492a3 100644 (file)
@@ -481,37 +481,7 @@ def normalize_comparison_expression(counter, expression):
     if isinstance(expression.left, parsing.FurInfixExpression) and expression.order == 'comparison_level':
         return desugar_ternary_comparison(counter, expression)
 
-    counter, left_prestatements, left_expression = normalize_expression(counter, expression.left)
-    counter, right_prestatements, right_expression = normalize_expression(counter, expression.right)
-
-    left_variable = '${}'.format(counter)
-    counter += 1
-    right_variable = '${}'.format(counter)
-    counter += 1
-
-    root_prestatements = (
-        NormalVariableInitializationStatement(
-            variable=left_variable,
-            expression=left_expression,
-        ),
-        NormalVariableInitializationStatement(
-            variable=right_variable,
-            expression=right_expression,
-        ),
-    )
-
-    counter, result_prestatements, result_expression = (
-        counter,
-        left_prestatements + right_prestatements + root_prestatements,
-        NormalInfixExpression(
-            order=expression.order,
-            operator=expression.operator,
-            left=NormalVariableExpression(variable=left_variable),
-            right=NormalVariableExpression(variable=right_variable),
-        ),
-    )
-
-    return (counter, result_prestatements, result_expression)
+    return normalize_basic_infix_operation(counter, expression)
 
 def normalize_boolean_expression(counter, expression):
     counter, left_prestatements, left_expression = normalize_expression(counter, expression.left)