From 4c4f0695b12c5faabfe7c3076e4b96151bb24282 Mon Sep 17 00:00:00 2001 From: Iskander Sharipov Date: Thu, 20 Jan 2022 17:11:32 +0300 Subject: [PATCH] dsl: add submatches experimental API Refs #28 --- dsl/dsl.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dsl/dsl.go b/dsl/dsl.go index 76d89d3d..c82781ab 100644 --- a/dsl/dsl.go +++ b/dsl/dsl.go @@ -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{}