Trait vhdl_lang::TokenAccess

source ·
pub trait TokenAccess {
    // Required methods
    fn get_token(&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§

source

fn get_token(&self, id: TokenId) -> &Token

Get a token by its ID

source

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

Provided Methods§

source

fn get_pos(&self, id: TokenId) -> &SrcPos

Get a token’s position by its ID

source

fn get_span(&self, start_id: TokenId, end_id: TokenId) -> SrcPos

Get a span where the beginning of that span is the beginning of the token indexed by start_id and the end is the end of the token indexed by end_id

Implementations on Foreign Types§

source§

impl TokenAccess for Vec<Token>

source§

fn get_token(&self, id: TokenId) -> &Token

source§

fn get_token_slice(&self, start_id: TokenId, end_id: TokenId) -> &[Token]

source§

impl TokenAccess for [Token]

source§

fn get_token(&self, id: TokenId) -> &Token

source§

fn get_token_slice(&self, start_id: TokenId, end_id: TokenId) -> &[Token]

Implementors§