CreateAST creates a CEL AST from a raw CEL expression using the provided compiler.
(compiler Compiler)
| 561 | |
| 562 | // CreateAST creates a CEL AST from a raw CEL expression using the provided compiler. |
| 563 | func (r *RawExpression) CreateAST(compiler Compiler) (*cel.Ast, map[string]any, error) { |
| 564 | e, err := compiler.CreateEnv() |
| 565 | if err != nil { |
| 566 | return nil, nil, err |
| 567 | } |
| 568 | format := InferFileFormat(r.Value) |
| 569 | if format != Unspecified { |
| 570 | return nil, nil, fmt.Errorf("invalid raw expression found file with extension: %v", format) |
| 571 | } |
| 572 | ast, iss := e.Compile(r.Value) |
| 573 | if iss.Err() != nil { |
| 574 | return nil, nil, fmt.Errorf("e.Compile(%q) failed: %w", r.Value, iss.Err()) |
| 575 | } |
| 576 | return ast, nil, nil |
| 577 | } |