Glue is a parser combinator library that is designed for parsing text based formats with speed and efficiency.
```rust use glue::prelude::*;
let input = Context::from("foobar");
match merge(oneormore(is(alphabetic))).parse(input) { Ok((input, token)) => { println!("Found: {}", token.asstr()); }, Err() => { println!("Nothing found!"); } } ```
```rust use glue::prelude::*;
enum Token { Identifier(String), }
fn identifier<'i>() -> impl Parser<'i, Token> { move |input: Context<'i>| { let (input, token) = merge(oneormore(is(alphabetic))).parse(input)?;
Ok((input, Token::Identifier(token.into())))
}
}
let input = Context::from("foobar");
assert_eq!(identifier().parse(input), Ok(( Context { input: "foobar", start: 6, end: 6, }, Token::Identifier("foobar".into()), ))); ```