Parse function call names using the symbol expression
authorDavid Kerkeslager <kerkeslager@gmail.com>
Sun, 6 Aug 2017 06:45:13 +0000 (02:45 -0400)
committerDavid Kerkeslager <kerkeslager@gmail.com>
Sun, 6 Aug 2017 06:45:13 +0000 (02:45 -0400)
parsing.py
transformation.py

index b660013..84e08de 100644 (file)
@@ -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
 
index 3f52e43..0260696 100644 (file)
@@ -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),
         )