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

Method CreateAST

tools/compiler/compiler.go:472–482  ·  view source on GitHub ↗

CreateAST creates a CEL AST from a checked expression file. The file must be in one of the following formats: - Binarypb - Textproto

(_ Compiler)

Source from the content-addressed store, hash-verified

470// - Binarypb
471// - Textproto
472func (c *CompiledExpression) CreateAST(_ Compiler) (*cel.Ast, map[string]any, error) {
473 var expr exprpb.CheckedExpr
474 format := InferFileFormat(c.Path)
475 if format != BinaryProto && format != TextProto {
476 return nil, nil, fmt.Errorf("invalid file extension wanted: .binarypb or .textproto found: %v", format)
477 }
478 if err := loadProtoFile(c.Path, format, &expr); err != nil {
479 return nil, nil, err
480 }
481 return cel.CheckedExprToAst(&expr), nil, nil
482}
483
484// FileExpression is an InputExpression which loads a CEL expression or policy from a file.
485type FileExpression struct {

Callers

nothing calls this directly

Calls 3

CheckedExprToAstFunction · 0.92
InferFileFormatFunction · 0.85
loadProtoFileFunction · 0.85

Tested by

no test coverage detected