glue 0.7.2

Glue is a parser combinator framework for parsing text based formats, it is easy to use and relatively fast too.
Documentation

Glue v0.7

Glue is a parser combinator framework for parsing text based formats, it is easy to use and relatively fast too.

Usage

use glue::prelude::*;

fn main() {
    match take(1.., is(alphabetic)).parse((), "foobar") {
        Ok((_, result, _)) => {
            println!("Found: {}", result);
        }
        Err(_) => {
            println!("Nothing found!");
        }
    }
}

Writing your own parser functions

use glue::prelude::*;

#[derive(Debug, PartialEq)]
enum Token {
    Identifier(String),
}

fn identifier<I: Parsable>() -> impl Parser<I, Token> {
    move |input: I| {
        let (token, input) = take(1.., is(alphabetic)).parse((), input)?;

        Ok(((), Token::Identifier(token.into()), input))
    }
}

fn main() {
    assert_eq!(
        identifier().parse((), "foobar"),
        Ok(((), Token::Identifier("foobar".into()), ""))
    );
}

Pretty human readable error messages

Glue does the hard work of implementing error messages for you, have a look at this example which created the following message:

   1 │ foo xxx
   · │       ┃
   · ┢━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
   · ┃ Unexpected 'xxx'                                                       ┃
   · ┃ Expected bar                                                           ┃
   · ┃ At 1:7 of path/to/file                                                 ┃
     ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

For more information see the examples directory in the git repository.