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

Method parse_at_most_one_keyword

src/sql-parser/src/parser.rs:1862–1890  ·  view source on GitHub ↗
(
        &mut self,
        keywords: &[Keyword],
        location: &str,
    )

Source from the content-addressed store, hash-verified

1860 }
1861
1862 fn parse_at_most_one_keyword(
1863 &mut self,
1864 keywords: &[Keyword],
1865 location: &str,
1866 ) -> Result<Option<Keyword>, ParserError> {
1867 match self.parse_one_of_keywords(keywords) {
1868 Some(first) => {
1869 let remaining_keywords = keywords
1870 .iter()
1871 .cloned()
1872 .filter(|k| *k != first)
1873 .collect::<Vec<_>>();
1874 if let Some(second) = self.parse_one_of_keywords(remaining_keywords.as_slice()) {
1875 let second_pos = self.peek_prev_pos();
1876 parser_err!(
1877 self,
1878 second_pos,
1879 "Cannot specify both {} and {} in {}",
1880 first,
1881 second,
1882 location,
1883 )
1884 } else {
1885 Ok(Some(first))
1886 }
1887 }
1888 None => Ok(None),
1889 }
1890 }
1891
1892 /// Look for one of the given keywords and return the one that matches.
1893 #[must_use]

Callers

nothing calls this directly

Calls 5

parse_one_of_keywordsMethod · 0.80
as_sliceMethod · 0.80
peek_prev_posMethod · 0.80
filterMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected