Just pass through the internals of parentheses, unwrapped
authorDavid Kerkeslager <kerkeslager@gmail.com>
Fri, 11 Aug 2017 21:55:35 +0000 (17:55 -0400)
committerDavid Kerkeslager <kerkeslager@gmail.com>
Fri, 11 Aug 2017 21:55:35 +0000 (17:55 -0400)
normalization.py
parsing.py
transformation.py

index 1cba840..9505b33 100644 (file)
@@ -294,9 +294,6 @@ def normalize_negation_expression(counter, expression):
         NormalNegationExpression(internal_expression=NormalVariableExpression(variable=internal_variable)),
     )
 
-def normalize_parenthesized_expression(counter, expression):
-    return normalize_expression(counter, expression.internal)
-
 def normalize_expression(counter, expression):
     return {
         NormalInfixExpression: fake_normalization,
@@ -305,7 +302,6 @@ def normalize_expression(counter, expression):
         parsing.FurInfixExpression: normalize_infix_expression,
         parsing.FurIntegerLiteralExpression: fake_normalization,
         parsing.FurNegationExpression: normalize_negation_expression,
-        parsing.FurParenthesizedExpression: normalize_parenthesized_expression,
         parsing.FurStringLiteralExpression: fake_normalization,
         parsing.FurSymbolExpression: fake_normalization,
     }[type(expression)](counter, expression)
index 6734af7..42f0ec8 100644 (file)
@@ -64,14 +64,6 @@ FurNegationExpression = collections.namedtuple(
     ],
 )
 
-# TODO We don't need to wrap this type
-FurParenthesizedExpression = collections.namedtuple(
-    'FurParenthesizedExpression',
-    [
-        'internal',
-    ],
-)
-
 FurInfixExpression = collections.namedtuple(
     'FurInfixExpression',
     [
@@ -124,7 +116,7 @@ def _parenthesized_expression_parser(index, tokens):
             tokens[index].match,
         ))
 
-    return True, index, FurParenthesizedExpression(internal=internal)
+    return True, index, internal
 
 def _negation_expression_parser(index, tokens):
     failure = (False, index, None)
index 41cd712..0eed799 100644 (file)
@@ -254,10 +254,6 @@ def transform_infix_expression(accumulators, expression):
 def transform_integer_literal_expression(accumulators, expression):
     return CIntegerLiteral(value=expression.value)
 
-def transform_parenthesized_expression(accumulators, expression):
-    # Parentheses can be removed because everything in the C output is explicitly parenthesized
-    return transform_expression(accumulators, expression.internal)
-
 def transform_negation_expression(accumulators, expression):
     return CNegationExpression(
         value=transform_expression(accumulators, expression.internal_expression),
@@ -270,7 +266,6 @@ def transform_expression(accumulators, expression):
         parsing.FurInfixExpression: transform_infix_expression,
         parsing.FurIntegerLiteralExpression: transform_integer_literal_expression,
         parsing.FurNegationExpression: transform_negation_expression,
-        parsing.FurParenthesizedExpression: transform_parenthesized_expression,
         parsing.FurStringLiteralExpression: transform_string_literal,
         parsing.FurSymbolExpression: transform_symbol_expression,
         normalization.NormalFunctionCallExpression: transform_function_call_expression,