glue/
lib.rs

1//! Glue is a parser combinator framework that is designed for parsing text
2//! based formats, it is easy to use and relatively efficient.
3//!
4//!
5//! # Usage
6//!
7//! Use the `test` method to see if your input matches a parser:
8//!
9//! ```
10//! use glue::prelude::*;
11//!
12//! if take(1.., is(alphabetic)).test("foobar") {
13//!     println!("One or more alphabetic characters found!");
14//! }
15//! ```
16//!
17//! Use the `parse` method to extract information from your input:
18//!
19//! ```
20//! # use glue::prelude::*;
21//! assert_eq!(take(1.., is(alphabetic)).parse("foobar"), Ok((
22//!     ParserContext {
23//!         input: "foobar",
24//!         bounds: 0..6,
25//!     },
26//!     "foobar"
27//! )))
28//! ```
29//!
30//! Write your own parser functions:
31//!
32//! ```
33//! # use glue::prelude::*;
34//! #[derive(Debug, PartialEq)]
35//! enum Token<'a> {
36//!     Identifier(&'a str),
37//! }
38//!
39//! fn identifier<'a>() -> impl Parser<'a, Token<'a>> {
40//!     move |ctx| {
41//!         take(1.., is(alphabetic)).parse(ctx)
42//!             .map_result(|token| Token::Identifier(token))
43//!     }
44//! }
45//!
46//! assert_eq!(identifier().parse("foobar"), Ok((
47//!     ParserContext {
48//!         input: "foobar",
49//!         bounds: 0..6,
50//!     },
51//!     Token::Identifier("foobar")
52//! )));
53//! ```
54//!
55//! For more information, look in the [examples directory] in the [git repository].
56//!
57//! [git repository]: https://gitlab.com/glue-for-rust/glue-rs
58//! [examples directory]: https://gitlab.com/glue-for-rust/glue-rs/tree/master/examples
59#![doc(html_logo_url = "https://gitlab.com/glue-for-rust/brands/raw/master/glue-512.png")]
60#![doc(html_favicon_url = "https://gitlab.com/glue-for-rust/brands/raw/master/glue-512.png")]
61pub mod characters;
62pub mod combinators;
63pub mod types;
64
65// #[cfg(test)]
66// mod book;
67
68// #[doc(hidden)]
69pub mod prelude {
70    pub use crate::characters::*;
71    pub use crate::combinators::*;
72    pub use crate::types::*;
73}