MCPcopy Create free account
hub / github.com/cel-expr/cel-go / CompileOptions

Method CompileOptions

ext/regex.go:135–166  ·  view source on GitHub ↗

CompileOptions implements the cel.Library interface method.

()

Source from the content-addressed store, hash-verified

133
134// CompileOptions implements the cel.Library interface method.
135func (r *regexLib) CompileOptions() []cel.EnvOption {
136 optionalTypesEnabled := func(env *cel.Env) (*cel.Env, error) {
137 if !env.HasLibrary("cel.lib.optional") {
138 return nil, errors.New("regex library requires the optional library")
139 }
140 return env, nil
141 }
142 opts := []cel.EnvOption{
143 cel.Function(regexExtract,
144 cel.Overload("regex_extract_string_string", []*cel.Type{cel.StringType, cel.StringType}, cel.OptionalType(cel.StringType),
145 cel.BinaryBinding(extract))),
146
147 cel.Function(regexExtractAll,
148 cel.Overload("regex_extractAll_string_string", []*cel.Type{cel.StringType, cel.StringType}, cel.ListType(cel.StringType),
149 cel.BinaryBinding(extractAll))),
150
151 cel.Function(regexReplace,
152 cel.Overload("regex_replace_string_string_string", []*cel.Type{cel.StringType, cel.StringType, cel.StringType}, cel.StringType,
153 cel.FunctionBinding(regReplace)),
154 cel.Overload("regex_replace_string_string_string_int", []*cel.Type{cel.StringType, cel.StringType, cel.StringType, cel.IntType}, cel.StringType,
155 cel.FunctionBinding((regReplaceN))),
156 ),
157 cel.CostEstimatorOptions(
158 checker.OverloadCostEstimate("regex_extract_string_string", estimateExtractCost()),
159 checker.OverloadCostEstimate("regex_extractAll_string_string", estimateExtractAllCost()),
160 checker.OverloadCostEstimate("regex_replace_string_string_string", estimateReplaceCost()),
161 checker.OverloadCostEstimate("regex_replace_string_string_string_int", estimateReplaceCost()),
162 ),
163 cel.EnvOption(optionalTypesEnabled),
164 }
165 return opts
166}
167
168// ProgramOptions implements the cel.Library interface method
169func (r *regexLib) ProgramOptions() []cel.ProgramOption {

Callers

nothing calls this directly

Calls 12

FunctionFunction · 0.92
OverloadFunction · 0.92
BinaryBindingFunction · 0.92
FunctionBindingFunction · 0.92
CostEstimatorOptionsFunction · 0.92
OverloadCostEstimateFunction · 0.92
EnvOptionFuncType · 0.92
estimateExtractCostFunction · 0.85
estimateExtractAllCostFunction · 0.85
estimateReplaceCostFunction · 0.85
HasLibraryMethod · 0.80
NewMethod · 0.80

Tested by

no test coverage detected