Struct peel::Peel
[−]
[src]
pub struct Peel<D> { pub graph: StableGraph<Parser<D>, ()>, pub root: Option<NodeIndex>, pub data: Option<D>, // some fields omitted }
The main peeling structure
Fields
graph: StableGraph<Parser<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<D> Peel<D>
[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: Parsable<D> + 'static,
T: Parsable<D> + '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 remove(&mut self, node: NodeIndex) -> Option<Parser<D>>
Remove a parser from the graph and return if existing.
fn link_nodes(&mut self, edges: &[(NodeIndex, NodeIndex)])
Link multiple nodes together
fn link_new_parser<T>(&mut self, left: NodeIndex, parser: T) -> NodeIndex where
T: Parsable<D> + 'static,
T: Parsable<D> + 'static,
Create a new parser and link it with the provided node
fn traverse<'a>(
&mut self,
input: &'a [u8],
result: ParserResultVec
) -> PeelResult<'a>
&mut self,
input: &'a [u8],
result: ParserResultVec
) -> PeelResult<'a>
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 continue_traverse<'a>(
&mut self,
input: &'a [u8],
result: ParserResultVec
) -> PeelResult<'a>
&mut self,
input: &'a [u8],
result: ParserResultVec
) -> PeelResult<'a>
Continue the traversal from the last processed node. This can be useful if you want to continue traversal after an incomplete parsing.
fn create_dot_file(&mut self) -> Result<(), PeelError>
Create a graphviz graph.dot
file representation in the current directory
fn display_error(&self, input: &[u8], res: IResult<&[u8], ParserResult>)
Display an error from a parser