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

Method Parse

policy/parser.go:530–540  ·  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

528// where they occur within the file, thus making error messages relative to the whole
529// file rather than the individual expression.
530func (parser *Parser) Parse(src *Source) (*Policy, *cel.Issues) {
531 info := ast.NewSourceInfo(src)
532 errs := common.NewErrors(src)
533 iss := cel.NewIssuesWithSourceInfo(errs, info)
534 p := newParserImpl(parser.TagVisitor, info, src, iss, parser.inlineStyleVariables)
535 policy := p.parseYAML(src)
536 if iss.Err() != nil {
537 return nil, iss
538 }
539 return policy, nil
540}
541
542// normalizeEntry extracts a key, value pair as the next two elements from the
543// 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
TestCompose_SourceInfoFunction · 0.95
TestCompose_UnnestFunction · 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
TestCompose_SourceInfoFunction · 0.76
TestCompose_UnnestFunction · 0.76
parsePolicyFunction · 0.76
TestPruneFunction · 0.76
computeCostFunction · 0.76
programFunction · 0.76