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§
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§
Sourcefn source_text(&self) -> Option<Rc<str>>
fn source_text(&self) -> Option<Rc<str>>
Returns the source buffer once for ownership by the token store.
Sourcefn drain_errors(&mut self) -> Vec<TokenSourceError>
fn drain_errors(&mut self) -> Vec<TokenSourceError>
Returns and clears diagnostics emitted while fetching tokens.
Sourcefn report_error(&self, _error: &TokenSourceError) -> bool
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.
Sourcefn lexer_dfa_string(&self) -> String
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".