Skip to content

This commit introduces support for calling functions within expressions.#12

Merged
danielgtaylor merged 4 commits intodanielgtaylor:mainfrom
vrancurel:vrancurel/first_class_function_support
Apr 22, 2026
Merged

This commit introduces support for calling functions within expressions.#12
danielgtaylor merged 4 commits intodanielgtaylor:mainfrom
vrancurel:vrancurel/first_class_function_support

Conversation

@vrancurel
Copy link
Copy Markdown
Contributor

The key changes are:

  • Interpreter:
    • Added a new NodeFunctionCall AST node to represent a function call.
    • The interpreter can now execute functions passed in the variables map. It supports functions with 0 to 3 parameters of type any.
    • Implemented short-circuiting for AND and OR logical operators.
  • Parser:
    • The parser now recognizes function call syntax (identifier(...)).
    • It can parse comma-separated arguments in function calls.
  • Lexer:
    • Added a TokenComma to tokenize function argument lists.
  • Conversions:
    • Type conversion functions now handle func() types, allowing for lazy evaluation of values.
  • Testing:
    • Added a comprehensive test suite for the new function call functionality.

The key changes are:

- Interpreter:
  - Added a new `NodeFunctionCall` AST node to represent a function call.
  - The interpreter can now execute functions passed in the variables map. It supports
    functions with 0 to 3 parameters of type `any`.
  - Implemented short-circuiting for `AND` and `OR` logical operators.
- Parser:
  - The parser now recognizes function call syntax (`identifier(...)`).
  - It can parse comma-separated arguments in function calls.
- Lexer:
  - Added a `TokenComma` to tokenize function argument lists.
- Conversions:
  - Type conversion functions now handle `func()` types, allowing for lazy evaluation
    of values.
- Testing:
  - Added a comprehensive test suite for the new function call functionality.
@vrancurel vrancurel force-pushed the vrancurel/first_class_function_support branch from c2b04d0 to fd5b4ca Compare July 18, 2025 17:41
Copy link
Copy Markdown
Owner

@danielgtaylor danielgtaylor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! I made a few changes to support more function types via reflection, but the interface to use this feature remains the same as your original PR!

@danielgtaylor danielgtaylor merged commit ec5a972 into danielgtaylor:main Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants