Skip to content

AST Matcher library - #1471

Open
TristonianJones wants to merge 1 commit into
cel-expr:masterfrom
TristonianJones:ast-matcher
Open

AST Matcher library#1471
TristonianJones wants to merge 1 commit into
cel-expr:masterfrom
TristonianJones:ast-matcher

Conversation

@TristonianJones

Copy link
Copy Markdown
Collaborator

Use CEL to match CEL AST fragments

The idea is to build upon CEL's very fast Pratt parser to provide AST match capabilities with capture expressions:

// Match a call with 1 fixed argument and between 0 and 2 trailing arguments
<call_name>(_1, _2.atLeast(0).atMost(2))
// Match a call with 1 fixed argument and at least 1 trailing argument
<call_name>(_1, _2.atLeast(1))
// Match a call with 1 fixed argument and an optional trailing argument
<call_name>(_1, _2.optional())
// Match variadic function calls with zero or more trailing arguments
concat(_1, _2.star())
// Match a list with exactly two leading elements followed by zero or more tail elements
[_1.repeated(2), _2.star()]
// Match a list with at least one element
[_1.atLeast(1)]

@TristonianJones
TristonianJones force-pushed the ast-matcher branch 2 times, most recently from 7b43945 to 4ecb855 Compare September 10, 2026 21:16
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.

1 participant