1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! Glue is a parser combinator framework that is designed for parsing text
//! based formats, it is easy to use and relatively efficient.
//!
//!
//! # Usage
//!
//! Use the `test` method to see if your input matches a parser:
//!
//! ```
//! 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:
//!
//! ```
//! # use glue::prelude::*;
//! assert_eq!(take(1.., is(alphabetic)).parse("foobar"), Ok((
//! ParserContext {
//! input: "foobar",
//! bounds: 0..6,
//! },
//! "foobar"
//! )))
//! ```
//!
//! Write your own parser functions:
//!
//! ```
//! # 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
// #[cfg(test)]
// mod book;
// #[doc(hidden)]