@@ -1087,7 +1087,7 @@ impl<'a> Parser<'a> {
10871087 // Support parsing Databricks has a function named `exists`.
10881088 if !dialect_of!(self is DatabricksDialect)
10891089 || matches!(
1090- self.peek_nth_token (1).token,
1090+ self.peek_nth_token_ref (1).token,
10911091 Token::Word(Word {
10921092 keyword: Keyword::SELECT | Keyword::WITH,
10931093 ..
@@ -1099,15 +1099,15 @@ impl<'a> Parser<'a> {
10991099 Keyword::EXTRACT => Ok(Some(self.parse_extract_expr()?)),
11001100 Keyword::CEIL => Ok(Some(self.parse_ceil_floor_expr(true)?)),
11011101 Keyword::FLOOR => Ok(Some(self.parse_ceil_floor_expr(false)?)),
1102- Keyword::POSITION if self.peek_token ().token == Token::LParen => {
1102+ Keyword::POSITION if self.peek_token_ref ().token == Token::LParen => {
11031103 Ok(Some(self.parse_position_expr(w.to_ident(w_span))?))
11041104 }
11051105 Keyword::SUBSTRING => Ok(Some(self.parse_substring_expr()?)),
11061106 Keyword::OVERLAY => Ok(Some(self.parse_overlay_expr()?)),
11071107 Keyword::TRIM => Ok(Some(self.parse_trim_expr()?)),
11081108 Keyword::INTERVAL => Ok(Some(self.parse_interval()?)),
11091109 // Treat ARRAY[1,2,3] as an array [1,2,3], otherwise try as subquery or a function call
1110- Keyword::ARRAY if self.peek_token () == Token::LBracket => {
1110+ Keyword::ARRAY if * self.peek_token_ref () == Token::LBracket => {
11111111 self.expect_token(&Token::LBracket)?;
11121112 Ok(Some(self.parse_array_expr(true)?))
11131113 }
@@ -1139,7 +1139,7 @@ impl<'a> Parser<'a> {
11391139 let expr = self.parse_subexpr(self.dialect.prec_value(Precedence::PlusMinus))?;
11401140 Ok(Some(Expr::Prior(Box::new(expr))))
11411141 }
1142- Keyword::MAP if self.peek_token () == Token::LBrace && self.dialect.support_map_literal_syntax() => {
1142+ Keyword::MAP if * self.peek_token_ref () == Token::LBrace && self.dialect.support_map_literal_syntax() => {
11431143 Ok(Some(self.parse_duckdb_map_literal()?))
11441144 }
11451145 _ => Ok(None)
@@ -1152,27 +1152,28 @@ impl<'a> Parser<'a> {
11521152 w: &Word,
11531153 w_span: Span,
11541154 ) -> Result<Expr, ParserError> {
1155- match self.peek_token().token {
1155+ let dialect = self.dialect;
1156+ match self.peek_token_ref().token {
11561157 Token::LParen | Token::Period => {
11571158 let mut id_parts: Vec<Ident> = vec![w.to_ident(w_span)];
11581159 let mut ending_wildcard: Option<TokenWithSpan> = None;
11591160 while self.consume_token(&Token::Period) {
1160- let next_token = self.next_token ();
1161- match next_token.token {
1161+ let next_token = self.next_token_ref ();
1162+ match & next_token.token {
11621163 Token::Word(w) => id_parts.push(w.to_ident(next_token.span)),
11631164 Token::Mul => {
11641165 // Postgres explicitly allows funcnm(tablenm.*) and the
11651166 // function array_agg traverses this control flow
1166- if dialect_of!(self is PostgreSqlDialect) {
1167- ending_wildcard = Some(next_token);
1167+ if dialect_is!(dialect is PostgreSqlDialect) {
1168+ ending_wildcard = Some(next_token.clone() );
11681169 break;
11691170 } else {
1170- return self.expected ("an identifier after '.'", next_token );
1171+ return self.expected_current ("an identifier after '.'");
11711172 }
11721173 }
11731174 Token::SingleQuotedString(s) => id_parts.push(Ident::with_quote('\'', s)),
11741175 _ => {
1175- return self.expected ("an identifier or a '*' after '.'", next_token );
1176+ return self.expected_current ("an identifier or a '*' after '.'");
11761177 }
11771178 }
11781179 }
0 commit comments