Trait rustemo::Context

source ·
pub trait Context<'i, I: Input + ?Sized, S: State, TK> {
    // 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>)

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,