[][src]Trait artichoke_backend::Parser

pub trait Parser {
    type Context;
    fn reset_parser(&mut self);
fn fetch_lineno(&self) -> usize;
fn add_fetch_lineno(
        &mut self,
        val: usize
    ) -> Result<usize, IncrementLinenoError>;
fn push_context(&mut self, context: Self::Context);
fn pop_context(&mut self) -> Option<Self::Context>;
fn peek_context(&self) -> Option<&Self::Context>; }

Manage parser state, active filename context, and line number metadata.

Parsers maintain a stack of Contexts which are modified as successive sources are parsed, for example as a set of nested requires.

Associated Types

type Context

Concrete type for parser context.

Loading content...

Required methods

fn reset_parser(&mut self)

Reset parser state to initial values.

fn fetch_lineno(&self) -> usize

Fetch the current line number from the parser state.

fn add_fetch_lineno(
    &mut self,
    val: usize
) -> Result<usize, IncrementLinenoError>

Increment line number and return the new value.

Errors

This function returns [IncrementLinenoError] if the increment results in an overflow of the internal parser line number counter.

fn push_context(&mut self, context: Self::Context)

Set the currently active context by modifying the parser stack.

fn pop_context(&mut self) -> Option<Self::Context>

Remove the current active context and return it.

fn peek_context(&self) -> Option<&Self::Context>

Return a reference to the currently active context.

Loading content...

Implementors

impl Parser for Artichoke[src]

type Context = Context

Loading content...