combine

Build Status Docs v1 Docs Gitter

An implementation of parser combinators for Rust, inspired by the Haskell library Parsec. As in Parsec the parsers are LL(1) by default but they can opt-in to arbitrary lookahead using the try combinator.

Example

```rust extern crate combine; use combine::{many, Parser}; use combine::char::letter;

let result = many(letter()).parse("hello world"); asserteq!(result, Ok(("hello".tostring(), " world"))); ```

Larger examples can be found in the tests and benches folders.

Links

Documentation and examples

crates.io

About

A parser combinator is, broadly speaking, a function which takes several parsers as arguments and returns a new parser, created by combining those parsers. For instance, the many parser takes one parser, p, as input and returns a new parser which applies p zero or more times. Thanks to the modularity that parser combinators gives it is possible to define parsers for a wide range of tasks without needing to implement the low level plumbing while still having the full power of Rust when you need it.

The library adheres to semantic versioning.

If you end up trying it I welcome any feedback from your experience with it. I am usually reachable within a day by opening an issue, sending an email or posting a message on gitter.

FAQ

Why does my errors contain inscrutable positions?

Since combine aims to crate parsers with little to no overhead streams over &str and &[T] do not carry any extra position information but instead only rely on comparing the pointer of the buffer to check which Stream is further ahead than another Stream. To retrieve a better position, either call translate_position on the ParseError or wrap your stream with State.

Extra

There is an additional crate which has parsers to lex and parse programming languages in combine-language.

You can find older versions of combine (parser-combinators) here.

Contributing

The easiest way to contribute is to just open an issue about any problems you encounter using combine but if you are interested in adding something to the library here is a list of some of the easier things to work on to get started.

Breaking changes

Here is a list containing most of the breaking changes in older versions of combine (parser-combinators).

2.0.0-beta3

1.0.0

1.0.0-beta.3

1.0.0-beta.2

0.7.0

0.6.0

0.5.0

0.4.0

0.3.2 / 0.3.0

0.2.6

If you have trouble updating to a newer version feel free to open an issue and I can take a look.