Skip to main content

TokenSource

Trait TokenSource 

Source
pub trait TokenSource {
    // Required methods
    fn next_token(
        &mut self,
        sink: &mut TokenSink<'_>,
    ) -> Result<TokenId, TokenStoreError>;
    fn line(&self) -> usize;
    fn column(&self) -> usize;
    fn source_name(&self) -> &str;

    // Provided methods
    fn source_text(&self) -> Option<Rc<str>> { ... }
    fn drain_errors(&mut self) -> Vec<TokenSourceError> { ... }
    fn report_error(&self, _error: &TokenSourceError) -> bool { ... }
    fn lexer_dfa_string(&self) -> String { ... }
}

Required Methods§

Source

fn next_token( &mut self, sink: &mut TokenSink<'_>, ) -> Result<TokenId, TokenStoreError>

Source

fn line(&self) -> usize

Source

fn column(&self) -> usize

Source

fn source_name(&self) -> &str

Provided Methods§

Source

fn source_text(&self) -> Option<Rc<str>>

Returns the source buffer once for ownership by the token store.

Source

fn drain_errors(&mut self) -> Vec<TokenSourceError>

Returns and clears diagnostics emitted while fetching tokens.

Source

fn report_error(&self, _error: &TokenSourceError) -> bool

Reports a buffered diagnostic through source-owned listeners.

Returns true when the source owns diagnostic reporting. The parser uses its own listeners as a fallback for token sources that return false.

Source

fn lexer_dfa_string(&self) -> String

Serializes lexer DFA cache state when the token source exposes one.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§