Skip to content

Commit

Permalink
dsl: add submatches experimental API (#362)
Browse files Browse the repository at this point in the history
Refs #28
  • Loading branch information
quasilyte committed Jan 20, 2022
1 parent d6c6e6b commit cac87d4
Showing 1 changed file with 10 additions and 0 deletions.
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

0 comments on commit cac87d4

Please sign in to comment.