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

Method Parse

policy/parser.go:572–582  ·  view source on GitHub ↗

Parse generates an internal parsed policy representation from a YAML input file. The internal representation ensures that CEL expressions are tracked relative to where they occur within the file, thus making error messages relative to the whole file rather than the individual expression.

(src *Source)

Source from the content-addressed store, hash-verified

570// where they occur within the file, thus making error messages relative to the whole
571// file rather than the individual expression.
572func (parser *Parser) Parse(src *Source) (*Policy, *cel.Issues) {
573 info := ast.NewSourceInfo(src)
574 errs := common.NewErrors(src)
575 iss := cel.NewIssuesWithSourceInfo(errs, info)
576 p := newParserImpl(parser.TagVisitor, info, src, iss, parser.inlineStyleVariables)
577 policy := p.parseYAML(src)
578 if iss.Err() != nil {
579 return nil, iss
580 }
581 return policy, nil
582}
583
584// normalizeEntry extracts a key, value pair as the next two elements from the
585// content slice. val source position information is normalized depending on style.

Callers 15

TestParseFunction · 0.95
TestParseErrorFunction · 0.95
TestCustomTagVisitorFunction · 0.95
TestSimpleVariablesFunction · 0.95
parseAndComposeRuleFunction · 0.95
parsePolicySourceFunction · 0.95
parsePolicyFunction · 0.95
TestPruneFunction · 0.95
computeCostFunction · 0.95
programFunction · 0.95

Calls 6

NewSourceInfoFunction · 0.92
NewErrorsFunction · 0.92
NewIssuesWithSourceInfoFunction · 0.92
newParserImplFunction · 0.85
parseYAMLMethod · 0.80
ErrMethod · 0.80

Tested by 15

TestParseFunction · 0.76
TestParseErrorFunction · 0.76
TestCustomTagVisitorFunction · 0.76
TestSimpleVariablesFunction · 0.76
parseAndComposeRuleFunction · 0.76
parsePolicySourceFunction · 0.76
parsePolicyFunction · 0.76
TestPruneFunction · 0.76
computeCostFunction · 0.76
programFunction · 0.76