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

Method CompileOptions

ext/regex.go:133–164  ·  view source on GitHub ↗

CompileOptions implements the cel.Library interface method.

()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 11

FunctionFunction · 0.92
OverloadFunction · 0.92
BinaryBindingFunction · 0.92
FunctionBindingFunction · 0.92
CostModelFunction · 0.92
EnvOptionFuncType · 0.92
regexExtractCostModelFunction · 0.85
regexExtractAllCostModelFunction · 0.85
regexReplaceCostModelFunction · 0.85
HasLibraryMethod · 0.80
NewMethod · 0.80

Tested by

no test coverage detected