Skip to main content

ErrorContext

Trait ErrorContext 

Source
pub trait ErrorContext {
    // Required methods
    fn symbol_name(&self, id: SymbolId) -> &str;
    fn state_symbol(&self, state: usize) -> SymbolId;
    fn state_items(&self, state: usize) -> &[(u16, u8)];
    fn rule_rhs(&self, rule: usize) -> &[u32];
}
Expand description

Trait for providing error context (symbol names, state/rule info).

Implemented by CompiledTable, ErrorInfo, and the generated parser’s error_info() static.

Required Methods§

Source

fn symbol_name(&self, id: SymbolId) -> &str

Get the name for a symbol ID.

Source

fn state_symbol(&self, state: usize) -> SymbolId

Get the accessing symbol for a state (the symbol shifted/reduced to enter it).

Source

fn state_items(&self, state: usize) -> &[(u16, u8)]

Get active LR items for a state. Each pair is (rule_index, dot_position): the dot position is how far into the rule’s RHS the parser has progressed.

Source

fn rule_rhs(&self, rule: usize) -> &[u32]

Get the RHS symbol IDs for a rule (each ID indexes into symbol_name).

Implementors§