@@ -4031,13 +4031,13 @@ impl<'a> Parser<'a> {
40314031 /// See [`Self::peek_token`] for an example.
40324032 pub fn peek_tokens_with_location<const N: usize>(&self) -> [TokenWithSpan; N] {
40334033 let mut index = self.index;
4034- core::array::from_fn(|_| loop {
4034+ core::array::from_fn(|_| {
40354035 let token = self.tokens.get(index);
40364036 index += 1;
4037- break token.cloned().unwrap_or(TokenWithSpan {
4037+ token.cloned().unwrap_or(TokenWithSpan {
40384038 token: Token::EOF,
40394039 span: Span::empty(),
4040- });
4040+ })
40414041 })
40424042 }
40434043
@@ -4047,10 +4047,10 @@ impl<'a> Parser<'a> {
40474047 /// See [`Self::peek_tokens`] for an example.
40484048 pub fn peek_tokens_ref<const N: usize>(&self) -> [&TokenWithSpan; N] {
40494049 let mut index = self.index;
4050- core::array::from_fn(|_| loop {
4050+ core::array::from_fn(|_| {
40514051 let token = self.tokens.get(index);
40524052 index += 1;
4053- break token.unwrap_or(&EOF_TOKEN);
4053+ token.unwrap_or(&EOF_TOKEN)
40544054 })
40554055 }
40564056
@@ -8546,7 +8546,7 @@ impl<'a> Parser<'a> {
85468546 return self.expected(
85478547 "FULLTEXT or SPATIAL option without constraint name",
85488548 TokenWithSpan {
8549- token: Token::make_keyword(& name.to_string()),
8549+ token: Token::make_keyword(name.to_string()),
85508550 span: next_token.span,
85518551 },
85528552 );
@@ -11125,9 +11125,9 @@ impl<'a> Parser<'a> {
1112511125 let mut parts = vec![];
1112611126 if dialect_of!(self is BigQueryDialect) && in_table_clause {
1112711127 loop {
11128- let ( ident, end_with_period) = self.parse_unquoted_hyphenated_identifier ()?;
11128+ let ident = self.parse_identifier ()?;
1112911129 parts.push(ObjectNamePart::Identifier(ident));
11130- if !self.consume_token(&Token::Period) && !end_with_period {
11130+ if !self.consume_token(&Token::Period) {
1113111131 break;
1113211132 }
1113311133 }
@@ -11141,9 +11141,9 @@ impl<'a> Parser<'a> {
1114111141 span,
1114211142 }));
1114311143 } else if dialect_of!(self is BigQueryDialect) && in_table_clause {
11144- let ( ident, end_with_period) = self.parse_unquoted_hyphenated_identifier ()?;
11144+ let ident = self.parse_identifier ()?;
1114511145 parts.push(ObjectNamePart::Identifier(ident));
11146- if !self.consume_token(&Token::Period) && !end_with_period {
11146+ if !self.consume_token(&Token::Period) {
1114711147 break;
1114811148 }
1114911149 } else if self.dialect.supports_object_name_double_dot_notation()
@@ -11322,85 +11322,6 @@ impl<'a> Parser<'a> {
1132211322 }
1132311323 }
1132411324
11325- /// On BigQuery, hyphens are permitted in unquoted identifiers inside of a FROM or
11326- /// TABLE clause.
11327- ///
11328- /// The first segment must be an ordinary unquoted identifier, e.g. it must not start
11329- /// with a digit. Subsequent segments are either must either be valid identifiers or
11330- /// integers, e.g. foo-123 is allowed, but foo-123a is not.
11331- ///
11332- /// [BigQuery-lexical](https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical)
11333- ///
11334- /// Return a tuple of the identifier and a boolean indicating it ends with a period.
11335- fn parse_unquoted_hyphenated_identifier(&mut self) -> Result<(Ident, bool), ParserError> {
11336- match self.peek_token().token {
11337- // Token::Word(w) => {
11338- // let quote_style_is_none = w.quote_style.is_none();
11339- // let mut requires_whitespace = false;
11340- // let mut ident = w.into_ident(self.next_token().span);
11341- // if quote_style_is_none {
11342- // while matches!(self.peek_token().token, Token::Minus) {
11343- // unreachable!("Something went wrong in the tokenizer!");
11344- // // self.next_token();
11345- // // ident.value.push('-');
11346-
11347- // // let token = self
11348- // // .next_token_no_skip()
11349- // // .cloned()
11350- // // .unwrap_or(TokenWithSpan::wrap(Token::EOF));
11351- // // requires_whitespace = match token.token {
11352- // // Token::Word(next_word) if next_word.quote_style.is_none() => {
11353- // // ident.value.push_str(&next_word.value);
11354- // // false
11355- // // }
11356- // // Token::Number(s, false) => {
11357- // // // A number token can represent a decimal value ending with a period, e.g., `Number('123.')`.
11358- // // // However, for an [ObjectName], it is part of a hyphenated identifier, e.g., `foo-123.bar`.
11359- // // //
11360- // // // If a number token is followed by a period, it is part of an [ObjectName].
11361- // // // Return the identifier with `true` if the number token is followed by a period, indicating that
11362- // // // parsing should continue for the next part of the hyphenated identifier.
11363- // // if s.ends_with('.') {
11364- // // let Some(s) = s.split('.').next().filter(|s| {
11365- // // !s.is_empty() && s.chars().all(|c| c.is_ascii_digit())
11366- // // }) else {
11367- // // return self.expected(
11368- // // "continuation of hyphenated identifier",
11369- // // TokenWithSpan::new(Token::Number(s, false), token.span),
11370- // // );
11371- // // };
11372- // // ident.value.push_str(s);
11373- // // return Ok((ident, true));
11374- // // } else {
11375- // // ident.value.push_str(&s);
11376- // // }
11377- // // // If next token is period, then it is part of an ObjectName and we don't expect whitespace
11378- // // // after the number.
11379- // // !matches!(self.peek_token().token, Token::Period)
11380- // // }
11381- // // _ => {
11382- // // return self
11383- // // .expected("continuation of hyphenated identifier", token);
11384- // // }
11385- // // }
11386- // }
11387-
11388- // // If the last segment was a number, we must check that it's followed by whitespace,
11389- // // otherwise foo-123a will be parsed as `foo-123` with the alias `a`.
11390- // if requires_whitespace {
11391- // let token = self.next_token();
11392- // if !matches!(token.token, Token::EOF) {
11393- // return self
11394- // .expected("whitespace following hyphenated identifier", token);
11395- // }
11396- // }
11397- // }
11398- // Ok((ident, false))
11399- // }
11400- _ => Ok((self.parse_identifier()?, false)),
11401- }
11402- }
11403-
1140411325 /// Parses a parenthesized, comma-separated list of column definitions within a view.
1140511326 fn parse_view_columns(&mut self) -> Result<Vec<ViewColumnDef>, ParserError> {
1140611327 if self.consume_token(&Token::LParen) {
0 commit comments