Trait Context

Source
pub trait Context<'i, I: Input + ?Sized, S: State, TK>: Default {
    // Required methods
    fn state(&self) -> S;
    fn set_state(&mut self, state: S);
    fn position(&self) -> usize;
    fn set_position(&mut self, position: usize);
    fn location(&self) -> Location;
    fn set_location(&mut self, location: Location);
    fn range(&self) -> Range<usize>;
    fn set_range(&mut self, range: Range<usize>);
    fn token_ahead(&self) -> Option<&Token<'i, I, TK>>;
    fn set_token_ahead(&mut self, token: Token<'i, I, TK>);
    fn layout_ahead(&self) -> Option<&'i I>;
    fn set_layout_ahead(&mut self, layout: Option<&'i I>);
}
Expand description

Lexer/Parser context is used to keep the state. It provides necessary information to parsers and actions.

Required Methods§

Source

fn state(&self) -> S

The current parser state.

Source

fn set_state(&mut self, state: S)

Source

fn position(&self) -> usize

An absolute position in the input sequence

The input must be indexable type.

Source

fn set_position(&mut self, position: usize)

Source

fn location(&self) -> Location

A span in the input sequence, possibly in line-column style.

Source

fn set_location(&mut self, location: Location)

Source

fn range(&self) -> Range<usize>

A span in the input sequence

Source

fn set_range(&mut self, range: Range<usize>)

Source

fn token_ahead(&self) -> Option<&Token<'i, I, TK>>

Next token recognized in the input at the current parsing location

Source

fn set_token_ahead(&mut self, token: Token<'i, I, TK>)

Source

fn layout_ahead(&self) -> Option<&'i I>

A layout before the token ahead

Source

fn set_layout_ahead(&mut self, layout: Option<&'i I>)

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§

Source§

impl<'i, I, S, TK> Context<'i, I, S, TK> for LRContext<'i, I, S, TK>
where I: Input + ?Sized, S: State,

Source§

impl<'i, S, I, TK> Context<'i, I, S, TK> for GssHead<'i, I, S, TK>
where I: Input + ?Sized, S: State,