From: David Kerkeslager Date: Sun, 6 Aug 2017 06:45:13 +0000 (-0400) Subject: Parse function call names using the symbol expression X-Git-Url: https://code.kerkeslager.com/?a=commitdiff_plain;h=16053b5010b39609edcd0051092cb02d275243a1;p=fur Parse function call names using the symbol expression --- diff --git a/parsing.py b/parsing.py index b660013..84e08de 100644 --- a/parsing.py +++ b/parsing.py @@ -220,7 +220,7 @@ def _comma_separated_list_parser(index, tokens): FurFunctionCallExpression = collections.namedtuple( 'FurFunctionCallExpression', [ - 'name', + 'function', 'arguments', ], ) @@ -244,10 +244,10 @@ def _function_call_expression_parser(index, tokens): # TODO Use a FurSymbolExpression for the name failure = (False, index, None) - if tokens[index].type != 'symbol': + success, index, function = _symbol_expression_parser(index, tokens) + + if not success: return failure - name = tokens[index].match - index += 1 if tokens[index].type != 'open_parenthese': return failure @@ -265,7 +265,7 @@ def _function_call_expression_parser(index, tokens): )) index += 1 - return True, index, FurFunctionCallExpression(name=name, arguments=arguments) + return True, index, FurFunctionCallExpression(function=function, arguments=arguments) _expression_parser = _multiplication_level_expression_parser diff --git a/transformation.py b/transformation.py index 3f52e43..0260696 100644 --- a/transformation.py +++ b/transformation.py @@ -140,11 +140,11 @@ def transform_negation_expression(builtin_dependencies, negation_expression): return CNegationExpression(value=transform_expression(builtin_dependencies, negation_expression.value)) def transform_function_call_expression(builtin_dependencies, function_call): - if function_call.name in BUILTINS.keys(): - builtin_dependencies.add(function_call.name) + if function_call.function.value in BUILTINS.keys(): + builtin_dependencies.add(function_call.function.value) return CFunctionCallExpression( - name='builtin$' + function_call.name, + name='builtin$' + function_call.function.value, arguments=tuple(transform_expression(builtin_dependencies, arg) for arg in function_call.arguments), )