Skip to main content

Lexer

Struct Lexer 

Source
pub struct Lexer<'a> { /* private fields */ }
Expand description

Logos-based lexer that converts source text into tokens.

Implementations§

Source§

impl<'a> LogosLexer<'a>

Source

pub fn new(source: &'a str) -> Self

Create a new lexer for the given source text with a fresh interner.

Uses the default file ID. For multi-file compilation, use with_file_id.

Source

pub fn with_interner(source: &'a str, interner: ThreadedRodeo) -> Self

Create a new lexer with an existing interner.

Source

pub fn with_file_id(source: &'a str, file_id: FileId) -> Self

Create a new lexer with a specific file ID.

Source

pub fn with_interner_and_file_id( source: &'a str, interner: ThreadedRodeo, file_id: FileId, ) -> Self

Create a new lexer with both an existing interner and a specific file ID.

Source

pub fn tokenize(self) -> CompileResult<(Vec<Token>, ThreadedRodeo)>

Tokenize the entire source, returning all tokens and the interner.

Auto Trait Implementations§

§

impl<'a> !Freeze for LogosLexer<'a>

§

impl<'a> !RefUnwindSafe for LogosLexer<'a>

§

impl<'a> Send for LogosLexer<'a>

§

impl<'a> Sync for LogosLexer<'a>

§

impl<'a> Unpin for LogosLexer<'a>

§

impl<'a> UnsafeUnpin for LogosLexer<'a>

§

impl<'a> UnwindSafe for LogosLexer<'a>

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.