Skip to main content

ListenerWrapper

Trait ListenerWrapper 

Source
pub trait ListenerWrapper {
    // Required method
    fn get_log_mut(&mut self) -> &mut impl Logger;

    // Provided methods
    fn switch(
        &mut self,
        call: Call,
        nt: u16,
        alt_id: u16,
        t_data: Option<Vec<String>>,
    ) { ... }
    fn check_abort_request(&self) -> Terminate { ... }
    fn abort(&mut self) { ... }
    fn report(&mut self, span_opt: Option<&PosSpan>, msg: LogMsg) { ... }
    fn push_span(&mut self, span: PosSpan) { ... }
    fn is_stack_empty(&self) -> bool { ... }
    fn is_stack_t_empty(&self) -> bool { ... }
    fn is_stack_span_empty(&self) -> bool { ... }
    fn hook(&mut self, token: u16, text: &str, span: &PosSpan) -> u16 { ... }
    fn intercept_token(&mut self, token: u16, text: &str, span: &PosSpan) -> u16 { ... }
}

Required Methods§

Source

fn get_log_mut(&mut self) -> &mut impl Logger

Gets access to the listener’s log to report possible errors and information about the parsing.

Provided Methods§

Source

fn switch( &mut self, call: Call, nt: u16, alt_id: u16, t_data: Option<Vec<String>>, )

Calls the listener to execute Enter, Loop, Exit, and End actions.

Source

fn check_abort_request(&self) -> Terminate

Checks if the listener requests an abort (wrapper pass-through). This method is called at the end of each parser iteration. If an error is too difficult to recover from, the listener can set a flag that tells to return a Terminate::Abort on the next call, and implement this method to return the appropriate status.

In that case, the parser

Source

fn abort(&mut self)

Aborts the parsing.

Source

fn report(&mut self, span_opt: Option<&PosSpan>, msg: LogMsg)

Reports a message (note, info, warning, or error). The default behaviour adds the message to the log.

Source

fn push_span(&mut self, span: PosSpan)

Pushes a location span onto the (optional) span stack

Source

fn is_stack_empty(&self) -> bool

Checks that the stack is empty (the parser only checks that the stack is empty after successfully parsing a text)

Source

fn is_stack_t_empty(&self) -> bool

Checks that the stack_t is empty (the parser only checks that the stack is empty after successfully parsing a text)

Source

fn is_stack_span_empty(&self) -> bool

Checks that the stack_span is empty (the parser only checks that the stack is empty after successfully parsing a text)

Source

fn hook(&mut self, token: u16, text: &str, span: &PosSpan) -> u16

Allows to dynamically translate a token in the listener (wrapper pass-through)

Source

fn intercept_token(&mut self, token: u16, text: &str, span: &PosSpan) -> u16

Allows to intercept any token in the listener (wrapper pass-through)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§