[][src]Trait artichoke_core::parser::Parser

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

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.

type Error

Error type for Parser APIs.

Loading content...

Required methods

fn reset_parser(&mut self) -> Result<(), Self::Error>

Reset parser state to initial values.

Errors

If the parser state is inaccessible, an error is returned.

fn fetch_lineno(&self) -> Result<usize, Self::Error>

Fetch the current line number from the parser state.

Errors

If the parser state is inaccessible, an error is returned.

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

Increment line number and return the new value.

Errors

If the parser state is inaccessible, an error is returned.

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) -> Result<(), Self::Error>

Set the currently active context by modifying the parser stack.

Errors

If the parser state is inaccessible, an error is returned.

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

Remove the current active context and return it.

Errors

If the parser state is inaccessible, an error is returned.

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

Return a reference to the currently active context.

Errors

If the parser state is inaccessible, an error is returned.

Loading content...

Implementors

Loading content...