pub trait LexerCache<L: Language> {
// Required methods
fn set_lex_output(&mut self, output: LexOutput<L>);
fn get_token(&self, index: usize) -> Option<Token<L::TokenType>>;
fn count_tokens(&self) -> usize;
fn has_tokens(&self) -> bool;
// Provided method
fn get_tokens(&self) -> Option<&[Token<L::TokenType>]> { ... }
}Expand description
Cache trait for lexical results.
This trait defines the interface for caching and accessing lexical analysis results. It provides methods for storing and retrieving token information from previous lexical analysis operations.
Required Methods§
Sourcefn set_lex_output(&mut self, output: LexOutput<L>)
fn set_lex_output(&mut self, output: LexOutput<L>)
Sets the lexed output in the cache.
§Arguments
output- The output from lexical analysis, including tokens and diagnostics
Sourcefn count_tokens(&self) -> usize
fn count_tokens(&self) -> usize
Gets the total number of tokens in the cache.
§Returns
The number of cached tokens, or 0 if no tokens are cached
Sourcefn has_tokens(&self) -> bool
fn has_tokens(&self) -> bool
Checks if the cache contains any tokens.
§Returns
true if the cache contains tokens, false otherwise