@@ -44,6 +44,8 @@ pub enum Token {
4444 /// This should retains the escaped character sequences so that
4545 /// .to_string() of the value will give the value that was in the input
4646 SingleQuotedString ( String ) ,
47+ /// Single quoted string: i.e: 'string'
48+ BacktickQuotedString ( String ) ,
4749 /// "National" string literal: i.e: N'string'
4850 NationalStringLiteral ( String ) ,
4951 /// Hexadecimal string literal: i.e.: X'deadbeef'
@@ -159,6 +161,7 @@ impl fmt::Display for Token {
159161 Token :: Number ( ref n) => f. write_str ( n) ,
160162 Token :: Char ( ref c) => write ! ( f, "{}" , c) ,
161163 Token :: SingleQuotedString ( ref s) => write ! ( f, "'{}'" , s) ,
164+ Token :: BacktickQuotedString ( ref s) => write ! ( f, "`{}`" , s) ,
162165 Token :: NationalStringLiteral ( ref s) => write ! ( f, "N'{}'" , s) ,
163166 Token :: HexStringLiteral ( ref s) => write ! ( f, "X'{}'" , s) ,
164167 Token :: Comma => f. write_str ( "," ) ,
@@ -343,6 +346,7 @@ impl<'a> Tokenizer<'a> {
343346 Token :: Word ( w) if w. quote_style != None => self . col += w. value . len ( ) as u64 + 2 ,
344347 Token :: Number ( s) => self . col += s. len ( ) as u64 ,
345348 Token :: SingleQuotedString ( s) => self . col += s. len ( ) as u64 ,
349+ Token :: BacktickQuotedString ( s) => self . col += s. len ( ) as u64 ,
346350 _ => self . col += 1 ,
347351 }
348352
@@ -411,6 +415,18 @@ impl<'a> Tokenizer<'a> {
411415 let s = self . tokenize_single_quoted_string ( chars) ?;
412416 Ok ( Some ( Token :: SingleQuotedString ( s) ) )
413417 }
418+ // string
419+ '`' if dialect_of ! ( self is BigQueryDialect ) => {
420+ chars. next ( ) ; // consume opening backtick
421+ let s = peeking_take_while ( chars, |ch| ch != '`' ) ;
422+ match chars. peek ( ) {
423+ Some ( '`' ) => {
424+ chars. next ( ) ; // consume closing backtick
425+ Ok ( Some ( Token :: BacktickQuotedString ( s) ) )
426+ }
427+ _ => self . tokenizer_error ( "Unterminated backtick literal" ) ,
428+ }
429+ }
414430 // delimited (quoted) identifier
415431 quote_start if self . dialect . is_delimited_identifier_start ( quote_start) => {
416432 chars. next ( ) ; // consume the opening quote
0 commit comments