Compile takes CEL environment and syntax tree then emits an optimized Program for execution.
(env *cel.Env, src string)
| 235 | // Compile takes CEL environment and syntax tree then emits an optimized |
| 236 | // Program for execution. |
| 237 | func Compile(env *cel.Env, src string) (cel.Program, error) { |
| 238 | intermediate, iss := env.Compile(src) |
| 239 | if iss != nil { |
| 240 | return nil, iss.Err() |
| 241 | } |
| 242 | |
| 243 | ast, iss := env.Check(intermediate) |
| 244 | if iss != nil { |
| 245 | return nil, iss.Err() |
| 246 | } |
| 247 | |
| 248 | return env.Program( |
| 249 | ast, |
| 250 | cel.EvalOptions( |
| 251 | // optimize regular expressions right now instead of on the fly |
| 252 | cel.OptOptimize, |
| 253 | ), |
| 254 | ) |
| 255 | } |