(expr runes.Buffer, desc string)
| 247 | } |
| 248 | |
| 249 | func (p *antlrVisitor) parse(expr runes.Buffer, desc string) ast.Expr { |
| 250 | lexer := gen.NewCELLexer(newCharStream(expr, desc)) |
| 251 | lexer.RemoveErrorListeners() |
| 252 | lexer.AddErrorListener(p) |
| 253 | |
| 254 | prsr := gen.NewCELParser(antlr.NewCommonTokenStream(lexer, 0)) |
| 255 | prsr.RemoveErrorListeners() |
| 256 | |
| 257 | prsrListener := &recursionListener{ |
| 258 | maxDepth: p.maxRecursionDepth, |
| 259 | ruleTypeDepth: map[int]*int{}, |
| 260 | } |
| 261 | |
| 262 | prsr.AddErrorListener(p) |
| 263 | prsr.AddParseListener(prsrListener) |
| 264 | |
| 265 | prsr.SetErrorHandler(&recoveryLimitErrorStrategy{ |
| 266 | DefaultErrorStrategy: antlr.NewDefaultErrorStrategy(), |
| 267 | errorRecoveryLimit: p.errorRecoveryLimit, |
| 268 | errorRecoveryTokenLookaheadLimit: p.errorRecoveryLookaheadTokenLimit, |
| 269 | }) |
| 270 | |
| 271 | defer func() { |
| 272 | if val := recover(); val != nil { |
| 273 | switch err := val.(type) { |
| 274 | case *lookaheadLimitError: |
| 275 | p.errors.internalError(err.Error()) |
| 276 | case *recursionError: |
| 277 | p.errors.internalError(err.Error()) |
| 278 | case *tooManyErrors: |
| 279 | // do nothing |
| 280 | case *recoveryLimitError: |
| 281 | // do nothing, listeners already notified and error reported. |
| 282 | default: |
| 283 | panic(val) |
| 284 | } |
| 285 | } |
| 286 | }() |
| 287 | |
| 288 | return p.Visit(prsr.Start_()).(ast.Expr) |
| 289 | } |
| 290 | |
| 291 | // Visitor implementations. |
| 292 | func (p *antlrVisitor) Visit(tree antlr.ParseTree) any { |
no test coverage detected