pub struct Tokenizer<'a> {
sql: &'a str,
chars: Peekable<Chars<'a>>,
line: u64,
col: u64,
}
Expand description
SQL Tokenizer
Fields§
§sql: &'a str
§chars: Peekable<Chars<'a>>
§line: u64
§col: u64
Implementations§
source§impl<'a> Tokenizer<'a>
impl<'a> Tokenizer<'a>
sourcepub fn tokenize_with_location(
&mut self,
) -> Result<Vec<TokenWithLocation>, TokenizerError>
pub fn tokenize_with_location( &mut self, ) -> Result<Vec<TokenWithLocation>, TokenizerError>
Tokenize the statement and produce a vector of tokens with locations.
Whitespaces are skipped.
sourcefn tokenize_with_whitespace(&mut self) -> Result<Vec<Token>, TokenizerError>
fn tokenize_with_whitespace(&mut self) -> Result<Vec<Token>, TokenizerError>
Tokenize the statement and produce a vector of tokens.
Whitespaces are included.
sourcefn tokenize(&mut self) -> Result<Vec<TokenWithLocation>, TokenizerError>
fn tokenize(&mut self) -> Result<Vec<TokenWithLocation>, TokenizerError>
Tokenize the statement and produce a vector of tokens.
Whitespaces are included.
sourcefn next_token_with_location(
&mut self,
) -> Result<Option<TokenWithLocation>, TokenizerError>
fn next_token_with_location( &mut self, ) -> Result<Option<TokenWithLocation>, TokenizerError>
Get the next token or return None
sourcefn next_token(&mut self) -> Result<Option<Token>, TokenizerError>
fn next_token(&mut self) -> Result<Option<Token>, TokenizerError>
Get the next token or return None
sourcefn tokenize_dollar_preceded_value(&mut self) -> Result<Token, TokenizerError>
fn tokenize_dollar_preceded_value(&mut self) -> Result<Token, TokenizerError>
Tokenize dollar preceded value (i.e: a string/placeholder)
fn error<R>(&self, message: impl Into<String>) -> Result<R, TokenizerError>
fn reject_number_junk(&mut self) -> Result<(), TokenizerError>
fn tokenize_single_line_comment(&mut self) -> String
sourcefn tokenize_word(&mut self, first_char: char) -> String
fn tokenize_word(&mut self, first_char: char) -> String
Tokenize an identifier or keyword, after the first char is already consumed.
sourcefn tokenize_single_quoted_string(&mut self) -> Result<String, TokenizerError>
fn tokenize_single_quoted_string(&mut self) -> Result<String, TokenizerError>
Read a single quoted string, starting with the opening quote.
sourcefn tokenize_single_quoted_string_with_escape(
&mut self,
) -> Result<CstyleEscapedString, TokenizerError>
fn tokenize_single_quoted_string_with_escape( &mut self, ) -> Result<CstyleEscapedString, TokenizerError>
Read a single qutoed string with escape
sourcefn unescape_c_style(s: &str) -> Result<String, String>
fn unescape_c_style(s: &str) -> Result<String, String>
Helper function used to convert string with c-style escapes into a normal string e.g. ‘hello\x3fworld’ -> ‘hello?world’
Detail of c-style escapes refer from: https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-UESCAPE:~:text=4.1.2.2.%C2%A0String%20Constants%20With%20C%2DStyle%20Escapes
fn tokenize_multiline_comment( &mut self, ) -> Result<Option<Token>, TokenizerError>
fn consume_and_return( &mut self, t: Token, ) -> Result<Option<Token>, TokenizerError>
Auto Trait Implementations§
impl<'a> Freeze for Tokenizer<'a>
impl<'a> RefUnwindSafe for Tokenizer<'a>
impl<'a> Send for Tokenizer<'a>
impl<'a> Sync for Tokenizer<'a>
impl<'a> Unpin for Tokenizer<'a>
impl<'a> UnwindSafe for Tokenizer<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more