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

Function NewParser

parser/parser.go:42–77  ·  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

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

Callers 15

TestPruneFunction · 0.92
computeCostFunction · 0.92
programFunction · 0.92
testMustParseFunction · 0.92
TestCheckFunction · 0.92
BenchmarkCheckFunction · 0.92
TestCheckErrorDataFunction · 0.92
TestCostFunction · 0.92
configureMethod · 0.92
TestConvertExprFunction · 0.92
TestSourceInfoToProtoFunction · 0.92

Calls

no outgoing calls

Tested by 15

TestPruneFunction · 0.74
computeCostFunction · 0.74
programFunction · 0.74
testMustParseFunction · 0.74
TestCheckFunction · 0.74
BenchmarkCheckFunction · 0.74
TestCheckErrorDataFunction · 0.74
TestCostFunction · 0.74
TestConvertExprFunction · 0.74
TestSourceInfoToProtoFunction · 0.74
mustTypeCheckFunction · 0.74