#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

#142 in Parser tooling

Download history 112/week @ 2023-11-20 927/week @ 2023-11-27 415/week @ 2023-12-04 612/week @ 2023-12-11 300/week @ 2023-12-18 187/week @ 2023-12-25 342/week @ 2024-01-01 413/week @ 2024-01-08 333/week @ 2024-01-15 409/week @ 2024-01-22 417/week @ 2024-01-29 564/week @ 2024-02-05 1710/week @ 2024-02-12 1110/week @ 2024-02-19 1115/week @ 2024-02-26 1971/week @ 2024-03-04

5,921 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