@@ -40,13 +40,13 @@ use serde::{Deserialize, Serialize};
4040#[ cfg( feature = "visitor" ) ]
4141use sqlparser_derive:: { Visit , VisitMut } ;
4242
43- use crate :: dialect:: Dialect ;
43+ use crate :: ast:: DollarQuotedString ;
44+ #[ cfg( feature = "parser" ) ]
4445use crate :: dialect:: {
45- BigQueryDialect , DuckDbDialect , GenericDialect , MySqlDialect , PostgreSqlDialect ,
46- SnowflakeDialect ,
46+ BigQueryDialect , Dialect , DuckDbDialect , GenericDialect , HiveDialect , MySqlDialect ,
47+ PostgreSqlDialect , SnowflakeDialect ,
4748} ;
4849use crate :: keywords:: { Keyword , ALL_KEYWORDS , ALL_KEYWORDS_INDEX } ;
49- use crate :: { ast:: DollarQuotedString , dialect:: HiveDialect } ;
5050
5151/// SQL Token enumeration
5252#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
@@ -690,12 +690,14 @@ impl fmt::Display for TokenizerError {
690690#[ cfg( feature = "std" ) ]
691691impl std:: error:: Error for TokenizerError { }
692692
693+ #[ allow( unused) ]
693694struct State < ' a > {
694695 peekable : Peekable < Chars < ' a > > ,
695696 pub line : u64 ,
696697 pub col : u64 ,
697698}
698699
700+ #[ allow( unused) ]
699701impl State < ' _ > {
700702 /// return the next character and advance the stream
701703 pub fn next ( & mut self ) -> Option < char > {
@@ -727,6 +729,7 @@ impl State<'_> {
727729}
728730
729731/// Represents how many quote characters enclose a string literal.
732+ #[ allow( unused) ]
730733#[ derive( Copy , Clone ) ]
731734enum NumStringQuoteChars {
732735 /// e.g. `"abc"`, `'abc'`, `r'abc'`
@@ -736,6 +739,7 @@ enum NumStringQuoteChars {
736739}
737740
738741/// Settings for tokenizing a quoted string literal.
742+ #[ allow( unused) ]
739743struct TokenizeQuotedStringSettings {
740744 /// The character used to quote the string.
741745 quote_style : char ,
@@ -753,6 +757,7 @@ struct TokenizeQuotedStringSettings {
753757}
754758
755759/// SQL Tokenizer
760+ #[ cfg( feature = "parser" ) ]
756761pub struct Tokenizer < ' a > {
757762 dialect : & ' a dyn Dialect ,
758763 query : & ' a str ,
@@ -761,6 +766,7 @@ pub struct Tokenizer<'a> {
761766 unescape : bool ,
762767}
763768
769+ #[ cfg( feature = "parser" ) ]
764770impl < ' a > Tokenizer < ' a > {
765771 /// Create a new SQL tokenizer for the specified SQL statement
766772 ///
@@ -1948,6 +1954,7 @@ impl<'a> Tokenizer<'a> {
19481954/// Read from `chars` until `predicate` returns `false` or EOF is hit.
19491955/// Return the characters read as String, and keep the first non-matching
19501956/// char available as `chars.next()`.
1957+ #[ cfg( feature = "parser" ) ]
19511958fn peeking_take_while ( chars : & mut State , mut predicate : impl FnMut ( char ) -> bool ) -> String {
19521959 let mut s = String :: new ( ) ;
19531960 while let Some ( & ch) = chars. peek ( ) {
@@ -1962,6 +1969,7 @@ fn peeking_take_while(chars: &mut State, mut predicate: impl FnMut(char) -> bool
19621969}
19631970
19641971/// Same as peeking_take_while, but also passes the next character to the predicate.
1972+ #[ cfg( feature = "parser" ) ]
19651973fn peeking_next_take_while (
19661974 chars : & mut State ,
19671975 mut predicate : impl FnMut ( char , Option < char > ) -> bool ,
@@ -1979,14 +1987,17 @@ fn peeking_next_take_while(
19791987 s
19801988}
19811989
1990+ #[ cfg( feature = "parser" ) ]
19821991fn unescape_single_quoted_string ( chars : & mut State < ' _ > ) -> Option < String > {
19831992 Unescape :: new ( chars) . unescape ( )
19841993}
19851994
1995+ #[ cfg( feature = "parser" ) ]
19861996struct Unescape < ' a : ' b , ' b > {
19871997 chars : & ' b mut State < ' a > ,
19881998}
19891999
2000+ #[ cfg( feature = "parser" ) ]
19902001impl < ' a : ' b , ' b > Unescape < ' a , ' b > {
19912002 fn new ( chars : & ' b mut State < ' a > ) -> Self {
19922003 Self { chars }
@@ -2127,6 +2138,7 @@ impl<'a: 'b, 'b> Unescape<'a, 'b> {
21272138 }
21282139}
21292140
2141+ #[ cfg( feature = "parser" ) ]
21302142fn unescape_unicode_single_quoted_string ( chars : & mut State < ' _ > ) -> Result < String , TokenizerError > {
21312143 let mut unescaped = String :: new ( ) ;
21322144 chars. next ( ) ; // consume the opening quote
@@ -2162,6 +2174,7 @@ fn unescape_unicode_single_quoted_string(chars: &mut State<'_>) -> Result<String
21622174 } )
21632175}
21642176
2177+ #[ cfg( feature = "parser" ) ]
21652178fn take_char_from_hex_digits (
21662179 chars : & mut State < ' _ > ,
21672180 max_digits : usize ,
0 commit comments