Trait rusty_lr::Callback

source ·
pub trait Callback<Term, NonTerm> {
    type Error;

    // Required methods
    fn shift_and_goto(
        &mut self,
        rules: &[ProductionRule<Term, NonTerm>],
        states: &[State<Term, NonTerm>],
        state_stack: &[usize],
        term: &Term,
    ) -> Result<(), Self::Error>;
    fn shift_and_goto_nonterm(
        &mut self,
        rules: &[ProductionRule<Term, NonTerm>],
        states: &[State<Term, NonTerm>],
        state_stack: &[usize],
        nonterm: &NonTerm,
    ) -> Result<(), Self::Error>;
    fn reduce(
        &mut self,
        rules: &[ProductionRule<Term, NonTerm>],
        states: &[State<Term, NonTerm>],
        state_stack: &[usize],
        rule: usize,
    ) -> Result<(), Self::Error>;
}
Expand description

callback trait for tracing parser actions

Required Associated Types§

source

type Error

Error type returned by callback

Required Methods§

source

fn shift_and_goto( &mut self, rules: &[ProductionRule<Term, NonTerm>], states: &[State<Term, NonTerm>], state_stack: &[usize], term: &Term, ) -> Result<(), Self::Error>

this is called after the shift of terminal symbol and state transition the actual state-transition of DFA is managed by parser if you are tyring to track the state transition with this method, you must also consider reduce method, which pop N states from the state stack, where N is the number of tokens of the reduced rule

source

fn shift_and_goto_nonterm( &mut self, rules: &[ProductionRule<Term, NonTerm>], states: &[State<Term, NonTerm>], state_stack: &[usize], nonterm: &NonTerm, ) -> Result<(), Self::Error>

this is called after the shift of non-terminal symbol and state transition the actual state-transition of DFA is managed by parser if you are tyring to track the state transition with this method, you must also consider reduce method, which pop N states from the state stack, where N is the number of tokens of the reduced rule

source

fn reduce( &mut self, rules: &[ProductionRule<Term, NonTerm>], states: &[State<Term, NonTerm>], state_stack: &[usize], rule: usize, ) -> Result<(), Self::Error>

this is called after poping N states from the state stack, where N is the number of tokens of the reduced rule production rule matched and reduce

Implementors§

source§

impl<Term, NonTerm> Callback<Term, NonTerm> for DefaultCallback

§

type Error = u8