Crate nom_packrat
source ·Expand description
nom-packrat
is an extension of nom to apply “Packrat Parsing”.
Examples
The following example show a quick example.
use nom::character::complete::char;
use nom::IResult;
use nom_packrat::{init, packrat_parser, storage};
// Declare storage used by packrat_parser
storage!(String);
// Apply packrat_parser by custom attribute
#[packrat_parser]
pub fn parser(s: &str) -> IResult<&str, String> {
let (s, x) = char('a')(s)?;
Ok((s, x.to_string()))
}
fn main() {
let input = "a";
// Initialize before parsing
init!();
let result = parser(input);
println!("{:?}", result);
}
Macros
- Initialize packrat storage
- Declare packrat storage
Structs
Traits
Attribute Macros
- Custom attribute for packrat parser