MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / maybe_parse

Method maybe_parse

src/sql-parser/src/parser.rs:2020–2035  ·  view source on GitHub ↗
(&mut self, mut f: F)

Source from the content-addressed store, hash-verified

2018
2019 #[must_use]
2020 fn maybe_parse<T, F>(&mut self, mut f: F) -> Option<T>
2021 where
2022 F: FnMut(&mut Self) -> Result<T, ParserError>,
2023 {
2024 if self.speculative_failures >= SPECULATIVE_FAILURES_PER_TOKEN * self.tokens.len() {
2025 return None;
2026 }
2027 let index = self.index;
2028 if let Ok(t) = f(self) {
2029 Some(t)
2030 } else {
2031 self.index = index;
2032 self.speculative_failures += 1;
2033 None
2034 }
2035 }
2036
2037 /// Parse a SQL CREATE statement
2038 fn parse_create(&mut self) -> Result<Statement<Raw>, ParserStatementError> {

Callers 4

parse_option_valueMethod · 0.80
parse_data_typeMethod · 0.80
parse_fetchMethod · 0.80

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected