#lexer #parse #token #munch

muncher

Easy to use char muncher for writing a lexer

5 unstable releases

0.7.0 Aug 27, 2021
0.6.2 Aug 20, 2021
0.6.1 Jun 6, 2020
0.6.0 Apr 8, 2020
0.5.0 Feb 6, 2020

#164 in Parser tooling

Download history 1038/week @ 2024-03-14 4044/week @ 2024-03-21 1645/week @ 2024-03-28 3036/week @ 2024-04-04 2220/week @ 2024-04-11 3619/week @ 2024-04-18 4459/week @ 2024-04-25 493/week @ 2024-05-02 201/week @ 2024-05-09 195/week @ 2024-05-16 78/week @ 2024-05-23 51/week @ 2024-05-30 29/week @ 2024-06-06 36/week @ 2024-06-13 34/week @ 2024-06-20 10/week @ 2024-06-27

113 downloads per month
Used in 5 crates

MIT/Apache

30KB
608 lines

Muncher

Rust Stable Latest Version

About

An easy-to-use string muncher that allows easy tokenization when writing a parser. Muncher has peek and fork capabilities, so you can look ahead and behind when needed. If lexing braces, Muncher has a built-in brace matching stack accessed from Muncher::brace_stack().

Use

[dependencies]
muncher = "0.6"

Examples

use muncher::Muncher;

let input = "hello\nworld";
let mut m = Muncher::new(input);

let hello = m.eat_until(|c| c == &'\n').collect::<String>();
assert_eq!(m.peek(), Some(&'\n'));
assert!(m.eat_eol());

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps