glue 0.3.1

Glue is a parser combinator library that is designed for parsing text based formats with speed and efficiency.
Documentation
glue-0.3.1 has been yanked.

Glue

Build Status Latest Version Documentation Minimum rustc version License:MIT lines of code

Glue is a parser combinator library that is designed for parsing text based formats with speed and efficiency.

Usage

use glue::prelude::*;

let input = Context::from("foobar");

match merge(one_or_more(is(alphabetic))).parse(input) {
    Ok((input, token)) => {
        println!("Found: {}", token.as_str());
    },
    Err(_) => {
        println!("Nothing found!");
    }
}

Writing your own parser functions

use glue::prelude::*;

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

fn identifier<'i>() -> impl Parser<'i, Token> {
    move |input: Context<'i>| {
        let (input, token) = merge(one_or_more(is(alphabetic))).parse(input)?;

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

let input = Context::from("foobar");

assert_eq!(identifier().parse(input), Ok((
    Context {
        input: "foobar",
        start: 6,
        end: 6,
    },
    Token::Identifier("foobar".into()),
)));