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

Method CreateAST

tools/compiler/compiler.go:563–577  ·  view source on GitHub ↗

CreateAST creates a CEL AST from a raw CEL expression using the provided compiler.

(compiler Compiler)

Source from the content-addressed store, hash-verified

561
562// CreateAST creates a CEL AST from a raw CEL expression using the provided compiler.
563func (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}

Callers 1

Calls 4

InferFileFormatFunction · 0.85
ErrMethod · 0.80
CreateEnvMethod · 0.65
CompileMethod · 0.65

Tested by 1