Skip to main content

Tokenizer

Struct Tokenizer 

Source
struct Tokenizer<'input, 'db> {
    db: &'db dyn Db,
    anchor: Anchor<'db>,
    input: &'input str,
    chars: Peekable<CharIndices<'input>>,
    tokens: Vec<Token<'input, 'db>>,
    kws: &'static Map<String, Keyword>,
    input_offset: Offset,
    error_start: Option<usize>,
    skipped_accum: Option<Skipped>,
}

Fields§

§db: &'db dyn Db§anchor: Anchor<'db>§input: &'input str§chars: Peekable<CharIndices<'input>>§tokens: Vec<Token<'input, 'db>>§kws: &'static Map<String, Keyword>§input_offset: Offset§error_start: Option<usize>§skipped_accum: Option<Skipped>

Implementations§

Source§

impl<'input, 'db> Tokenizer<'input, 'db>

Source

fn tokenize(self) -> Vec<Token<'input, 'db>>

Source

fn accumulate_skipped(&mut self, skipped: Skipped)

Source

fn clear_accumulated(&mut self, index: usize) -> Option<Skipped>

Clears various accumulated state in prep for a new token being issued (or the final token). Returns the Skipped value that should be used for the next token issued (if any). Reports errors for any invalid characters seen thus far.

Source

fn span(&self, start: usize, end: usize) -> Span<'db>

Source

fn comment(&mut self, index: usize)

Source

fn identifier(&mut self, start: usize, ch: char)

Source

fn integer(&mut self, start: usize, ch: char)

Source

fn escape_sequence(&mut self, backslash_offset: usize, content: &mut String)

Process an escape sequence after consuming \. backslash_offset is the byte index of the \ character.

Source

fn emit_string_literal( &mut self, span: Span<'db>, skipped: Option<Skipped>, content: String, quote_len: usize, raw: bool, )

Emit a string literal token with the given span and processed content.

quote_len is the number of quote characters in the delimiter (1 for ", 3 for """). When the raw source content begins with a newline, multiline dedenting is applied: the raw content is dedented and escape sequences are re-processed on the result, replacing the content that was built during scanning.

Source

fn emit_unterminated_string( &mut self, start: usize, skipped: Option<Skipped>, content: String, message: &str, )

Emit tokens for an unterminated string literal: a literal token with whatever content was accumulated, plus an error token. No multiline dedenting is applied since the string is malformed.

Source

fn string_literal(&mut self, start: usize)

Source

fn triple_quoted_string_literal( &mut self, start: usize, skipped: Option<Skipped>, )

Lex a triple-quoted string literal. Called after the opening """ has been consumed. Scans until the closing """ is found.

Source

fn delimited(&mut self, start: usize, delim: Delimiter, close: char)

Source

fn ops(&mut self, start: usize, ch: char)

Auto Trait Implementations§

§

impl<'input, 'db> Freeze for Tokenizer<'input, 'db>

§

impl<'input, 'db> !RefUnwindSafe for Tokenizer<'input, 'db>

§

impl<'input, 'db> !Send for Tokenizer<'input, 'db>

§

impl<'input, 'db> !Sync for Tokenizer<'input, 'db>

§

impl<'input, 'db> Unpin for Tokenizer<'input, 'db>

§

impl<'input, 'db> UnsafeUnpin for Tokenizer<'input, 'db>

§

impl<'input, 'db> !UnwindSafe for Tokenizer<'input, 'db>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Lookup<T> for T

§

fn into_owned(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T