# Glue v0.8 <img src="https://gitlab.com/glue-for-rust/brands/raw/master/glue-512.png" align="right" width="128" height="128" />
Glue is a parser combinator framework for parsing text based formats, it is easy to use and relatively fast too.
## Usage
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::*;
#[derive(Debug, PartialEq)]
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].
[git repository]: https://gitlab.com/glue-for-rust/glue-rs
[examples directory]: https://gitlab.com/glue-for-rust/glue-rs/tree/master/examples