Glue is a parser combinator framework for parsing text based formats, it is easy to use and relatively fast too.
Use the test
method to see if your input matches a parser:
```rust use glue::prelude::*;
if take(1.., is(alphabetic)).test("foobar") { println!("One or more alphabetic characters found!"); } ```
Use the parse
method to extract information from your input:
```rust use glue::prelude::*;
assert_eq!(take(1.., is(alphabetic)).parse("foobar"), Ok(( ParserContext { input: "foobar", bounds: 0..6, }, "foobar" ))) ```
Write your own parser functions:
```rust use glue::prelude::*;
enum Token<'a> { Identifier(&'a str), }
fn identifier<'a>() -> impl Parser<'a, Token<'a>> { move |ctx| { take(1.., is(alphabetic)).parse(ctx) .map_result(|token| Token::Identifier(token)) } }
assert_eq!(identifier().parse("foobar"), Ok(( ParserContext { input: "foobar", bounds: 0..6, }, Token::Identifier("foobar") ))); ```
For more information, look in the [examples directory] in the [git repository].