Struct hime_redist::tokens::TokenRepository
source · pub struct TokenRepository<'s, 't, 'a> {
pub terminals: &'a [Symbol<'s>],
pub text: &'a Text<'t>,
/* private fields */
}
Expand description
The proxy structure for a repository of matched tokens
Fields§
§terminals: &'a [Symbol<'s>]
The table of grammar terminals
text: &'a Text<'t>
The input text
Implementations§
source§impl<'s, 't, 'a> TokenRepository<'s, 't, 'a>
impl<'s, 't, 'a> TokenRepository<'s, 't, 'a>
sourcepub fn new(
terminals: &'a [Symbol<'s>],
text: &'a Text<'t>,
tokens: &'a TokenRepositoryImpl
) -> TokenRepository<'s, 't, 'a>
pub fn new( terminals: &'a [Symbol<'s>], text: &'a Text<'t>, tokens: &'a TokenRepositoryImpl ) -> TokenRepository<'s, 't, 'a>
Creates a new repository
sourcepub fn new_mut(
terminals: &'a [Symbol<'s>],
text: &'a Text<'t>,
tokens: &'a mut TokenRepositoryImpl
) -> TokenRepository<'s, 't, 'a>
pub fn new_mut( terminals: &'a [Symbol<'s>], text: &'a Text<'t>, tokens: &'a mut TokenRepositoryImpl ) -> TokenRepository<'s, 't, 'a>
Creates a new mutable repository
sourcepub fn iter(&self) -> TokenRepositoryIterator<'_, '_, '_> ⓘ
pub fn iter(&self) -> TokenRepositoryIterator<'_, '_, '_> ⓘ
Gets an iterator over the tokens
sourcepub fn add(&mut self, terminal: usize, index: usize, length: usize) -> usize
pub fn add(&mut self, terminal: usize, index: usize, length: usize) -> usize
Registers a new token in this repository
sourcepub fn get_tokens_count(&self) -> usize
pub fn get_tokens_count(&self) -> usize
Gets the number of tokens in this repository
sourcepub fn get_symbol_id_for(&self, index: usize) -> u32
pub fn get_symbol_id_for(&self, index: usize) -> u32
Gets the terminal’s identifier for the i-th token
sourcepub fn find_token_at(&self, index: usize) -> Option<Token<'_, '_, '_>>
pub fn find_token_at(&self, index: usize) -> Option<Token<'_, '_, '_>>
Gets the token (if any) that contains the specified index in the input text
Auto Trait Implementations§
impl<'s, 't, 'a> RefUnwindSafe for TokenRepository<'s, 't, 'a>
impl<'s, 't, 'a> Send for TokenRepository<'s, 't, 'a>
impl<'s, 't, 'a> Sync for TokenRepository<'s, 't, 'a>
impl<'s, 't, 'a> Unpin for TokenRepository<'s, 't, 'a>
impl<'s, 't, 'a> !UnwindSafe for TokenRepository<'s, 't, 'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more