Skip to content

Conversation

@kamaln7
Copy link
Collaborator

@kamaln7 kamaln7 commented May 14, 2025

  • syntax: function_name(argument1, argument2)
  • functions can accept zero or more arguments
  • arguments can be of any type including arrays and nested function calls
  • add a "functions standard library" initially with just a starts_with function.

kamaln7 added 4 commits May 14, 2025 15:17
- evaluate and validate function arguments
- create a standard pattern for defining functions
- add a "functions standard library" initially with just a `starts_with` function for strings.
@kamaln7 kamaln7 requested a review from jonfriesen May 14, 2025 14:18
@jonfriesen jonfriesen requested a review from Copilot May 14, 2025 14:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for functions within the rule parser and evaluator and introduces the functions standard library with an initial implementation of the starts_with function. Key changes include:

  • Updates to the parser (grammar and tokenization) to distinguish function calls from field identifiers.
  • New tests and standard library files supporting function evaluation.
  • Adjustments to lexer and parser generation to recognize function syntax.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
rule_test.go Adds tests for function parsing and evaluation.
rule.go Updates rule string formatting and introduces RuleFunc helper.
parser.y, parser.go Extends grammar and token handling to support function calls.
parser.gen.go Regenerates parser constants for function-related tokens.
lexer.rl, lexer.go Modifies lexer rules to tokenize function names using token_FUNCTION.
functions_stdlib*.go Introduces functions standard library and tests, including starts_with.
functions.go Implements FunctionValue with evaluation, validation, and argument mapping.
errors.go Adds error type for invalid function arguments.

Copy link
Contributor

@jonfriesen jonfriesen left a comment

Choose a reason for hiding this comment

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

This is epic!!! ❤️

@kamaln7 kamaln7 merged commit 8bfcf8d into main May 14, 2025
1 check passed
@kamaln7 kamaln7 deleted the functions branch May 14, 2025 14:34
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.

3 participants