Struct peel::Peel
[−]
[src]
pub struct Peel<R, V> { pub arena: Arena<ParserBox<R, V>>, pub root: Option<NodeId>, }
The main peeling structure
Fields
arena: Arena<ParserBox<R, V>>
The memory arena of the tree
root: Option<NodeId>
The first node added will be the root
Methods
impl<R, V> Peel<R, V> where V: Display
[src]
fn new() -> Self
Create a new empty Peel
instance
fn set_log_level(&mut self, level: LogLevel)
Set the global log level for reporting
fn new_parser<T>(&mut self, parser: T) -> NodeId where T: Parser<Result=R, Variant=V> + Send + Sync + 'static
Create a new boxed Parser and return a corresponding Node
fn link(&mut self, left: NodeId, right: NodeId)
Append the second node to the first one within the current tree structure
fn link_new_parser<T>(&mut self, left: NodeId, parser: T) -> NodeId where T: Parser<Result=R, Variant=V> + Send + Sync + 'static
Create a new parser and link it with the provided node
fn traverse(&self, input: &[u8], result: Vec<R>) -> PeelResult<Vec<R>>
Convenient function for recursive traversal with the root as starting point
Errors
When no tree root was found or the first parser already fails.
fn traverse_recursive(&self,
start_node: NodeId,
input: &[u8],
result: Vec<R>)
-> PeelResult<Vec<R>>
start_node: NodeId,
input: &[u8],
result: Vec<R>)
-> PeelResult<Vec<R>>
Do parsing until all possible paths failed. This is equivalent in finding the deepest possible parsing result within the tree. The result will be assembled together in the given result vector, which will be returned at the end.
Errors
When the first parser already fails.
fn display_error(&self, input: &[u8], res: IResult<&[u8], (R, ParserState)>)
Display an error from a parser