MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / consumeUntil

Method consumeUntil

parser/parser.cc:1599–1611  ·  view source on GitHub ↗

Override the ANTLR implementation to introduce a token lookahead limit as this prevents pathologically constructed, yet small (< 16kb) inputs from consuming inordinate amounts of compute. This method is only called on error recovery paths.

Source from the content-addressed store, hash-verified

1597 //
1598 // This method is only called on error recovery paths.
1599 void consumeUntil(Parser* recognizer, const IntervalSet& set) override {
1600 size_t ttype = recognizer->getInputStream()->LA(1);
1601 int recovery_search_depth = 0;
1602 while (ttype != Token::EOF && !set.contains(ttype) &&
1603 recovery_search_depth++ < recovery_token_lookahead_limit_) {
1604 recognizer->consume();
1605 ttype = recognizer->getInputStream()->LA(1);
1606 }
1607 // Halt all parsing if the lookahead limit is reached during error recovery.
1608 if (recovery_search_depth == recovery_token_lookahead_limit_) {
1609 throw ParseCancellationException("Unable to find a recovery token");
1610 }
1611 }
1612
1613 protected:
1614 std::string escapeWSAndQuote(const std::string& s) const override {

Callers

nothing calls this directly

Calls 2

LAMethod · 0.80
consumeMethod · 0.80

Tested by

no test coverage detected