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,
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)
],
)
-# TODO We don't need to wrap this type
-FurParenthesizedExpression = collections.namedtuple(
- 'FurParenthesizedExpression',
- [
- 'internal',
- ],
-)
-
FurInfixExpression = collections.namedtuple(
'FurInfixExpression',
[
tokens[index].match,
))
- return True, index, FurParenthesizedExpression(internal=internal)
+ return True, index, internal
def _negation_expression_parser(index, tokens):
failure = (False, index, None)
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),
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,