Skip to main content

LexedSource

Trait LexedSource 

Source
pub trait LexedSource<'a>: Iterator<Item = (Result<Token<'a>, String>, Span<'a>)> + Clone {
    // Provided methods
    fn report_errors(
        &self,
    ) -> impl Iterator<Item = Report<'a, (&'a str, ByteSpan)>> { ... }
    fn dump(&self, file_path: &Path) -> Result<()> { ... }
    fn process(self) -> IntoIter<(Result<Token<'a>, String>, Span<'a>)> { ... }
    fn tokens(self) -> impl Iterator<Item = SpannedToken<'a>> { ... }
}
Expand description

An iterator over syntactical tokens for a SystemVerilog source

Provided Methods§

Source

fn report_errors(&self) -> impl Iterator<Item = Report<'a, (&'a str, ByteSpan)>>

Generate error reports for any errors encountered in lexing

Source

fn dump(&self, file_path: &Path) -> Result<()>

Dump a representation of the lexed source to a file, for debugging

Source

fn process(self) -> IntoIter<(Result<Token<'a>, String>, Span<'a>)>

Process the lexing of the source, storing the result

While this does incur memory overhead, it avoid processing the source multiple times if cloned.

Source

fn tokens(self) -> impl Iterator<Item = SpannedToken<'a>>

Convert lexer results into tokens, turning errors into Token::Error

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a, T> LexedSource<'a> for T
where T: Iterator<Item = (Result<Token<'a>, String>, Span<'a>)> + Clone,