Skip to content

Commit cac87d4

Browse files
authored
dsl: add submatches experimental API (#362)
Refs #28
1 parent d6c6e6b commit cac87d4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

dsl/dsl.go

+10
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,16 @@ type Var struct {
154154
// For example, `VarFilterContext.Type` is mapped to `Var.Type`.
155155
func (Var) Filter(pred func(*VarFilterContext) bool) bool { return boolResult }
156156

157+
// Contains runs a sub-search from a given pattern using the captured
158+
// vars from the original pattern match.
159+
//
160+
// For example, given the Match(`$lhs = append($lhs, $x)`) pattern,
161+
// we can do m["lhs"].Contains(`$x`) and learn whether $lhs contains
162+
// $x as its sub-expression.
163+
//
164+
// Experimental: this function is not part of the stable API.
165+
func (Var) Contains(pattern string) bool { return boolResult }
166+
157167
// MatchedNode represents an AST node associated with a named submatch.
158168
type MatchedNode struct{}
159169

0 commit comments

Comments
 (0)