Struct Lexer

Source
pub struct Lexer<T>
where T: Read,
{ /* private fields */ }
Expand description

This structure holds the data of the actual lexer. It is expected that this structure can be mutated by the next_token function, which advances to the next token, and returns the term found by the lexer.

Implementations§

Source§

impl<T: Read> Lexer<T>

The lexer implementation allows to read the tokens from a given type implementing the Read trait. If an error occurs while reading, or EOT has been reached, the next_token function will return Error or EOT as its term.

Source

pub fn create(input: T) -> Self

Creates a new lexer from the given input, where input supports the Read trait.

Trait Implementations§

Source§

impl<T: Read> LexerBase for Lexer<T>

Source§

fn next_token(&mut self) -> Token

Finds the next token in a mutable self. If the next token can be found, returns it into Token. If the file or stream of data is found, the special term EOT is returned. If an error occurred of some sort, the special term Error is returned.

Source§

fn current_stream(&self) -> Option<String>

Returns the current stream’s name, if any (for example, the normal lexer does know this value)

Auto Trait Implementations§

§

impl<T> Freeze for Lexer<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Lexer<T>
where T: RefUnwindSafe,

§

impl<T> Send for Lexer<T>
where T: Send,

§

impl<T> Sync for Lexer<T>
where T: Sync,

§

impl<T> Unpin for Lexer<T>
where T: Unpin,

§

impl<T> UnwindSafe for Lexer<T>
where T: UnwindSafe,

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.

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, 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.