],
)
+NormalIntegerLiteralExpression = collections.namedtuple(
+ 'NormalIntegerLiteralExpression',
+ [
+ 'integer',
+ ],
+)
+
+NormalStringLiteralExpression = collections.namedtuple(
+ 'NormalStringLiteralExpression',
+ [
+ 'string',
+ ],
+)
+
NormalNegationExpression = collections.namedtuple(
'NormalNegationExpression',
[
def fake_normalization(counter, thing):
return (counter, (), thing)
+def normalize_integer_literal_expression(counter, expression):
+ return (counter, (), NormalIntegerLiteralExpression(integer=expression.integer))
+
+def normalize_string_literal_expression(counter, expression):
+ return (counter, (), NormalStringLiteralExpression(string=expression.string))
+
def normalize_function_call_expression(counter, expression):
assert isinstance(expression, parsing.FurFunctionCallExpression)
NormalVariableExpression: fake_normalization,
parsing.FurFunctionCallExpression: normalize_function_call_expression,
parsing.FurInfixExpression: normalize_infix_expression,
- parsing.FurIntegerLiteralExpression: fake_normalization,
+ parsing.FurIntegerLiteralExpression: normalize_integer_literal_expression,
parsing.FurNegationExpression: normalize_negation_expression,
- parsing.FurStringLiteralExpression: fake_normalization,
+ parsing.FurStringLiteralExpression: normalize_string_literal_expression,
parsing.FurSymbolExpression: fake_normalization,
}[type(expression)](counter, expression)
FurIntegerLiteralExpression = collections.namedtuple(
'FurIntegerLiteralExpression',
[
- 'value',
+ 'integer',
],
)
FurStringLiteralExpression = collections.namedtuple(
'FurStringLiteralExpression',
[
- 'value',
+ 'string',
],
)
value = int(tokens[index].match)
index += 1
- return True, index, FurIntegerLiteralExpression(value=value)
+ return True, index, FurIntegerLiteralExpression(integer=value)
def _string_literal_expression_parser(index, tokens):
if tokens[index].type == 'single_quoted_string_literal':
- return (True, index + 1, FurStringLiteralExpression(value=tokens[index].match[1:-1]))
+ return (True, index + 1, FurStringLiteralExpression(string=tokens[index].match[1:-1]))
return (False, index, None)
(
True,
1,
- FurStringLiteralExpression(value='Hello, world'),
+ FurStringLiteralExpression(string='Hello, world'),
),
)
4,
FurFunctionCallExpression(
name='print',
- arguments=(FurStringLiteralExpression(value='Hello, world'),),
+ arguments=(FurStringLiteralExpression(string='Hello, world'),),
),
),
)
def transform_variable_expression(accumulators, expression):
return CVariableExpression(variable=expression.variable)
-def transform_string_literal(accumulators, expression):
- value = expression.value
+def transform_string_literal_expression(accumulators, expression):
+ value = expression.string
try:
index = accumulators.string_literal_list.index(value)
)
def transform_integer_literal_expression(accumulators, expression):
- return CIntegerLiteral(value=expression.value)
+ return CIntegerLiteral(value=expression.integer)
def transform_negation_expression(accumulators, expression):
return CNegationExpression(
parsing.FurInfixExpression: transform_infix_expression,
parsing.FurIntegerLiteralExpression: transform_integer_literal_expression,
parsing.FurNegationExpression: transform_negation_expression,
- parsing.FurStringLiteralExpression: transform_string_literal,
+ parsing.FurStringLiteralExpression: transform_string_literal_expression,
parsing.FurSymbolExpression: transform_symbol_expression,
normalization.NormalFunctionCallExpression: transform_function_call_expression,
normalization.NormalInfixExpression: transform_infix_expression,
+ normalization.NormalIntegerLiteralExpression: transform_integer_literal_expression,
normalization.NormalNegationExpression: transform_negation_expression,
+ normalization.NormalStringLiteralExpression: transform_string_literal_expression,
normalization.NormalVariableExpression: transform_variable_expression,
}[type(expression)](accumulators, expression)