Crates.io | p-arse |
lib.rs | p-arse |
version | 0.0.1 |
source | src |
created_at | 2021-12-27 19:58:55.177862 |
updated_at | 2021-12-27 19:58:55.177862 |
description | the inelegant parser |
homepage | |
repository | https://github.com/micouy/p-arse |
max_upload_size | |
id | 503858 |
size | 44,656 |
p-( ㅅ )
— the inelegant parserp-arse
is a PEG parser library focused on readability and type safety • it follows the syntax from the original paper as closely as possible • the parsers are point-free (they're (mostly) variables, not functions), as opposed to nom
's parsers which are functions or compositions of functions • this encourages the user to bind and name many intermediate parsers • it is similar to pest
in this regard
warning: the project is in an early stage
let parse_hex_dd = |s: &str| {
u8::from_str_radix(s, 16).unwrap()
};
let construct_color = |(r, g, b)| Color { r, g, b };
let hex_d = ('0'.to('9')).or('a'.to('f'));
let hex_dd = (hex_d, hex_d).maps(parse_hex_dd);
let color = ("#", hex_dd, hex_dd, hex_dd).r0().map(construct_color);
let (color, _tail) = color.p_arse("#defec8").unwrap();
check out other examples • i've some replicated examples from the other parser libaries, i.e. nom
's hex color (mine), pest
's ident list (mine) and pom
's json (mine)
add docs
add verbose error messages
allow access to the string slice captured by the parser (its children's captures concatenated) (kinda works, except where .rn()
is used)