Crates.io | muncher |
lib.rs | muncher |
version | 0.7.0 |
source | src |
created_at | 2020-02-06 18:41:31.322313 |
updated_at | 2021-08-27 23:09:31.868238 |
description | Easy to use char muncher for writing a lexer. |
homepage | |
repository | https://github.com/DevinR528/muncher |
max_upload_size | |
id | 205558 |
size | 30,723 |
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()
.
[dependencies]
muncher = "0.6"
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());