Struct peel::Peel
[−]
[src]
pub struct Peel<R, V, D> { pub graph: StableGraph<ParserBox<R, V, D>, ()>, pub root: Option<NodeIndex>, pub data: Option<D>, }
The main peeling structure
Fields
graph: StableGraph<ParserBox<R, V, D>, ()>
The memory arena of the tree
root: Option<NodeIndex>
The first node added will be the root
data: Option<D>
Additional data for which can be shared accross the parsers
Methods
impl<R, V, D> Peel<R, V, D> 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) -> NodeIndex where T: Parser<D, Result=R, Variant=V> + Send + Sync + 'static
Create a new boxed Parser and return a corresponding Node
fn link(&mut self, left: NodeIndex, right: NodeIndex)
Append the second node to the first one within the current tree structure
fn link_new_parser<T>(&mut self, left: NodeIndex, parser: T) -> NodeIndex where T: Parser<D, Result=R, Variant=V> + Send + Sync + 'static
Create a new parser and link it with the provided node
fn traverse(&mut 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(&mut self,
node_id: NodeIndex,
input: &[u8],
result: Vec<R>)
-> PeelResult<Vec<R>>
node_id: NodeIndex,
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 create_dot_file(&mut self) -> PeelResult<()>
Create a graphviz graph.dot
file representation in the current directory
fn display_error(&self, input: &[u8], res: IResult<&[u8], R>)
Display an error from a parser