GithubHelp home page GithubHelp logo

skade / combine Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marwes/combine

0.0 3.0 0.0 1.12 MB

A parser combinator library for Rust

Home Page: https://marwes.github.io/combine/combine/index.html

License: MIT License

Rust 100.00%

combine's Introduction

combine

Build Status Coverage Status Gitter

(Previously named parser-combinators)

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 lookahed using the try combinator.

##Example

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

let result = many(letter()).parse("hello world");
assert_eq!(result, Ok(("hello".to_string(), " world")));

Larger examples can be found in the examples 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 is almost stable but a few parts of the internals may still change before 1.0. After that the library will adhere to semantic versioning.

If you end up trying it I welcome any feedback from your experience with it. I am usually reachable within a dat by opening an issue or sending an email. I am also testing gitter for smaller questions.

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 intersted in adding something to the library here is a list of some of the easier things to work on to get started.

  • Add additional parsers There is a list of parsers which aren't implemented here but if you have a suggestion for another parser just leave a suggestion on the issue itself.
  • Add additional examples More examples for using combine will always be useful!
  • Add and improve the docs Not the fanciest of work but one cannot overstate the importance of good documentation.

Breaking changes

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

1.0.0

  • &[T] streams has had the Item type changed from &T to T and requires a T: Copy bound.

1.0.0-beta.3

  • Error::Unexpected holds an Info<T, R> instead of just a T to make it consitent with the other variants.

1.0.0-beta.2

  • Info<T> and Error<T> has had their signatures changed to Info<T, R> and Error<T, R>. Info has a new variant which is specified by R and defines the type for range errors. ParseError<T: Positioner> has been changed to ParseError<S: Stream> (S is the stream type of the parser).
  • If you were using ParseResult from primitives you should no longer specify the item type of the stream.

0.7.0

  • Stream::uncons changed its signature to allow it to return errors. Return Error::end_of_input() instead of () if you implemented Stream.

0.6.0

  • Addition of Parser::parse_lazy, should not break anything but I can't say for certain.

0.5.0

  • any_char -> any, uncons_char -> uncons
  • Introduction of the Positioner trait which needs to be implemented on an custom token types.
  • satisfy is moved to the combinators module and made generic, might cause type inference issues.

0.4.0

  • any_char is no longer a free function but returns a parser when called as all parser functions (and its called any after 0.5.0)
  • Cow is replaced by Info in the error messages.

0.3.2 / 0.3.0

  • Added variant to Error which can hold any kind of ::std::error::Error
  • choice_vec and choice_slice is replaced by just choice

0.2.6

  • Iterators cannot directly be used as streams but must be wrapped using from_iter function

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

combine's People

Contributors

marwes avatar hugoduncan avatar aochagavia avatar hawkw avatar

Watchers

Florian Gilcher avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.