Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dsl: add submatches experimental API #362

Merged
merged 1 commit into from Jan 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions dsl/dsl.go
Expand Up @@ -154,6 +154,16 @@ type Var struct {
// For example, `VarFilterContext.Type` is mapped to `Var.Type`.
func (Var) Filter(pred func(*VarFilterContext) bool) bool { return boolResult }

// Contains runs a sub-search from a given pattern using the captured
// vars from the original pattern match.
//
// For example, given the Match(`$lhs = append($lhs, $x)`) pattern,
// we can do m["lhs"].Contains(`$x`) and learn whether $lhs contains
// $x as its sub-expression.
//
// Experimental: this function is not part of the stable API.
func (Var) Contains(pattern string) bool { return boolResult }

// MatchedNode represents an AST node associated with a named submatch.
type MatchedNode struct{}

Expand Down