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

Function NewParser

parser/parser.go:32–73  ·  view source on GitHub ↗

NewParser builds and returns a new Parser using the provided options.

(opts ...Option)

Source from the content-addressed store, hash-verified

30
31// NewParser builds and returns a new Parser using the provided options.
32func NewParser(opts ...Option) (*Parser, error) {
33 p := &Parser{}
34 p.enableHiddenAccumulatorName = true
35 p.enableIdentEscapeSyntax = true
36 for _, opt := range opts {
37 if err := opt(&p.options); err != nil {
38 return nil, err
39 }
40 }
41 if p.errorReportingLimit == 0 {
42 p.errorReportingLimit = 100
43 }
44 if p.maxRecursionDepth == 0 {
45 p.maxRecursionDepth = 250
46 }
47 if p.maxRecursionDepth == -1 {
48 p.maxRecursionDepth = math.MaxInt
49 }
50 if p.errorRecoveryTokenLookaheadLimit == 0 {
51 p.errorRecoveryTokenLookaheadLimit = 256
52 }
53 if p.errorRecoveryLimit == 0 {
54 p.errorRecoveryLimit = 30
55 }
56 if p.errorRecoveryLimit == -1 {
57 p.errorRecoveryLimit = math.MaxInt
58 }
59 if p.expressionSizeCodePointLimit == 0 {
60 p.expressionSizeCodePointLimit = 100_000
61 }
62 if p.expressionSizeCodePointLimit == -1 {
63 p.expressionSizeCodePointLimit = math.MaxInt
64 }
65 if p.maxExpressionNodeCount == 0 {
66 p.maxExpressionNodeCount = 100_000
67 }
68 if p.maxExpressionNodeCount == -1 {
69 p.maxExpressionNodeCount = math.MaxInt
70 }
71 // Bool is false by default, so populateMacroCalls will be false by default
72 return p, nil
73}
74
75// mustNewParser does the work of NewParser and panics if an error occurs.
76//

Callers 15

TestPruneFunction · 0.92
parseMutabilityExprFunction · 0.92
TestListMapAccessCostFunction · 0.92
programFunction · 0.92
testMustParseFunction · 0.92
evalTestMemoryTrackerFunction · 0.92
benchmarkMemoryTrackerFunction · 0.92
runOptionsBenchmarkFunction · 0.92

Calls

no outgoing calls

Tested by 15

TestPruneFunction · 0.74
parseMutabilityExprFunction · 0.74
TestListMapAccessCostFunction · 0.74
programFunction · 0.74
testMustParseFunction · 0.74
evalTestMemoryTrackerFunction · 0.74
benchmarkMemoryTrackerFunction · 0.74
runOptionsBenchmarkFunction · 0.74