From: David Kerkeslager Date: Fri, 11 Aug 2017 21:55:35 +0000 (-0400) Subject: Just pass through the internals of parentheses, unwrapped X-Git-Url: https://code.kerkeslager.com/?a=commitdiff_plain;h=b059a00e0e2511a2ca2477db1e91d53fc5d2ec0f;p=fur Just pass through the internals of parentheses, unwrapped --- diff --git a/normalization.py b/normalization.py index 1cba840..9505b33 100644 --- a/normalization.py +++ b/normalization.py @@ -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) diff --git a/parsing.py b/parsing.py index 6734af7..42f0ec8 100644 --- a/parsing.py +++ b/parsing.py @@ -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) diff --git a/transformation.py b/transformation.py index 41cd712..0eed799 100644 --- a/transformation.py +++ b/transformation.py @@ -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,