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>;
}
Expand description
Manage parser state, active filename context, and line number metadata.
Parsers maintain a stack of Context
s which are modified as successive
sources are parsed, for example as a set of nested require
s.
Required Associated Types
Required Methods
fn reset_parser(&mut self) -> Result<(), Self::Error>
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>
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.
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.
Set the currently active context by modifying the parser stack.
Errors
If the parser state is inaccessible, an error is returned.
Remove the current active context and return it.
Errors
If the parser state is inaccessible, an error is returned.