| Crates.io | parsell |
| lib.rs | parsell |
| version | 0.6.5 |
| created_at | 2016-02-05 19:10:15.098836+00 |
| updated_at | 2016-03-07 20:22:32.885537+00 |
| description | Parsell LL(1) streaming parser combinators |
| homepage | |
| repository | https://github.com/asajeffrey/parsell |
| max_upload_size | |
| id | 4089 |
| size | 147,824 |
The goal of this library is to provide parser combinators that:
It is based on:
Rustdoc | Video | Slides | Crate | CI
extern crate parsell;
use parsell::{character,Parser,UncommittedStr,StatefulStr};
use parsell::ParseResult::{Done,Continue};
#[allow(non_snake_case)]
fn main() {
// A sequence of alphanumerics, saved in a string buffer
let ALPHANUMERIC = character(char::is_alphanumeric);
let ALPHANUMERICS = ALPHANUMERIC.plus(String::new);
// If you provide unmatching input to the parser, you'll get back a None response:
match ALPHANUMERICS.init_str("!$?") {
None => (),
_ => panic!("Can't happen."),
}
// If you provide complete input to the parser, you'll get back a Done response:
match ALPHANUMERICS.init_str("abc123!") {
Some(Done(result)) => assert_eq!(result, "abc123"),
_ => panic!("Can't happen."),
}
// If you provide incomplete input to the parser, you'll get back a Continue response:
match ALPHANUMERICS.init_str("abc") {
Some(Continue(parsing)) => match parsing.more_str("123!") {
Done(result) => assert_eq!(result, "abc123"),
_ => panic!("Can't happen."),
},
_ => panic!("Can't happen."),
}
}
Example tested with Skeptic.