[−][src]Crate nom_tracable
nom-tracable
is an extension of nom to trace parser.
Examples
The following example show a quick example.
use nom::branch::*; use nom::character::complete::*; use nom::IResult; use nom_locate::LocatedSpanEx; use nom_tracable::{tracable_parser, TracableInfo}; // Input type must implement trait Tracable // nom_locate::LocatedSpanEx<T, TracableInfo> implements it. type Span<'a> = LocatedSpanEx<&'a str, TracableInfo>; // Apply tracable_parser by custom attribute #[tracable_parser] pub fn term(s: Span) -> IResult<Span, String> { let (s, x) = char('1')(s)?; Ok((s, x.to_string())) } #[test] fn test() { // Configure trace setting let info = TracableInfo::new().forward(true).backward(true); let ret = term(LocatedSpanEx::new_extra("1", info)); assert_eq!("\"1\"", format!("{:?}", ret.unwrap().1)); }
Re-exports
pub use nom_tracable_macros::tracable_parser; |
Structs
TracableInfo | Struct to have trace configuration. |
Traits
HasTracableInfo | Trait to indicate |
Tracable |
Functions
backward_trace | Function to display backward trace.
This is inserted by |
custom_trace | Function to display custom trace. |
forward_trace | Function to display forward trace.
This is inserted by |