[][src]Trait artichoke::prelude::Parser

pub trait Parser {
    type Context;
    type Error;
    pub fn reset_parser(&mut self) -> Result<(), Self::Error>;
pub fn fetch_lineno(&self) -> Result<usize, Self::Error>;
pub fn add_fetch_lineno(&mut self, val: usize) -> Result<usize, Self::Error>;
pub fn push_context(
        &mut self,
        context: Self::Context
    ) -> Result<(), Self::Error>;
pub fn pop_context(&mut self) -> Result<Option<Self::Context>, Self::Error>;
pub 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[src]

Concrete type for parser context.

type Error[src]

Error type for Parser APIs.

Loading content...

Required methods

pub fn reset_parser(&mut self) -> Result<(), Self::Error>[src]

Reset parser state to initial values.

Errors

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

pub fn fetch_lineno(&self) -> Result<usize, Self::Error>[src]

Fetch the current line number from the parser state.

Errors

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

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

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.

pub fn push_context(
    &mut self,
    context: Self::Context
) -> Result<(), Self::Error>
[src]

Set the currently active context by modifying the parser stack.

Errors

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

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

Remove the current active context and return it.

Errors

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

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

Return a reference to the currently active context.

Errors

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

Loading content...

Implementors

impl Parser for Artichoke[src]

type Context = Context

type Error = Error

Loading content...