combine-language 0.9.0

Extra parser combinators, useful for parsing programming languages.
docs.rs failed to build combine-language-0.9.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: combine-language-4.0.0

combine-language

This a crate providing an easy way of constructing parsers which can easily parse various programming languages. It has much of the same API as Text.Parsec.Token but are otherwise a bit different to fit in to the ownership model of rust. The crate is an extension of the combine crate.

Example

extern crate combine;
extern crate combine_language;
use combine::*;
use combine_language::*;
fn main() {
    let env = LanguageEnv::new(LanguageDef {
        ident: Identifier {
            start: letter(),
            rest: alpha_num(),
            reserved: ["if", "then", "else", "let", "in", "type"].iter().map(|x| (*x).into()).collect()
        },
        op: Identifier {
            start: satisfy(|c| "+-*/".chars().find(|x| *x == c).is_some()),
            rest: satisfy(|c| "+-*/".chars().find(|x| *x == c).is_some()),
            reserved: ["+", "-", "*", "/"].iter().map(|x| (*x).into()).collect()
        },
        comment_start: "/*",
        comment_end: "*/",
        comment_line: "//"
    });
    let id = env.identifier();//An identifier parser
    let integer = env.integer();//An integer parser
    let result = (id, integer).parse_state("this /* Skips comments */ 42");
    assert_eq!(result, Ok(((String::from("this"), 42), "")));
}

Links

Documention

combine

Unstable Features

  • range_stream Enables the range_stream feature in combine, allows some parsers exposed in this crate to be zero-copy