diff --git a/caching_parser.go b/caching_parser.go index a833c31..54d65bf 100644 --- a/caching_parser.go +++ b/caching_parser.go @@ -10,8 +10,6 @@ import ( var ( CacheTime = time.Hour - - replace = []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t"} ) // NewCachingParser returns a CELParser which lifts quoted literals out of the expression diff --git a/lift.go b/lift.go index 47e18f0..ba594f4 100644 --- a/lift.go +++ b/lift.go @@ -6,11 +6,25 @@ import ( "strings" ) +const ( + // VarPrefix is the lifted variable name used when extracting idents from an + // expression. + VarPrefix = "vars." +) + +var ( + // replace is truly hack city. these are 20 variable names for values that are + // lifted out of expressions via liftLiterals. + replace = []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t"} +) + // LiftedArgs represents a set of variables that have been lifted from expressions and // replaced with identifiers, eg `id == "foo"` becomes `id == vars.a`, with "foo" lifted // as "vars.a". type LiftedArgs interface { + // Get a lifted variable argument from the parsed expression. Get(val string) (any, bool) + // Return all lifted variables as a map. Map() map[string]any }