Skip to main content

lex_stream

Function lex_stream 

Source
pub fn lex_stream<I: CharStream, L: TokenSource>(
    input: I,
    lexer: impl FnOnce(I) -> L,
) -> CommonTokenStream<L>
Expand description

Lexes a caller-provided character stream without constructing a parser.

Unlike lex, this accepts any CharStream, including a named InputStream or a byte-oriented crate::ByteStream.

number_of_source_errors() reports buffered lexer diagnostics. After iterating tokens(), drain_source_errors() retrieves those diagnostics.

ยงPanics

Panics if buffering returns an crate::TokenStoreError. Call CommonTokenStream::try_new with the constructed lexer to handle that error instead.