Trait vhdl_lang::TokenAccess
source · pub trait TokenAccess {
// Required methods
fn get_token(&self, id: TokenId) -> Option<&Token>;
fn index(&self, id: TokenId) -> &Token;
fn get_token_slice(&self, start_id: TokenId, end_id: TokenId) -> &[Token];
// Provided methods
fn get_pos(&self, id: TokenId) -> &SrcPos { ... }
fn get_span(&self, start_id: TokenId, end_id: TokenId) -> SrcPos { ... }
}
Expand description
A type that conforms to TokenAccess
can be indexed using a TokenId
.
Convenience methods exist to directly get the SrcPos
for a given TokenId
or a span starting at a certain token and ending at another.
Types such as Vec
and array
implement TokenAccess
Required Methods§
fn index(&self, id: TokenId) -> &Token
sourcefn get_token_slice(&self, start_id: TokenId, end_id: TokenId) -> &[Token]
fn get_token_slice(&self, start_id: TokenId, end_id: TokenId) -> &[Token]
Get a slice of tokens by using a start ID and an end ID