2015-08-01 19:24:45 +03:00
|
|
|
|
# Megaparsec
|
2014-10-16 20:21:52 +04:00
|
|
|
|
|
2015-07-27 12:00:41 +03:00
|
|
|
|
[![License BSD3](https://img.shields.io/badge/license-BSD3-brightgreen.svg)](http://opensource.org/licenses/BSD-3-Clause)
|
2015-09-21 18:42:10 +03:00
|
|
|
|
[![Hackage](https://img.shields.io/hackage/v/megaparsec.svg?style=flat)](https://hackage.haskell.org/package/megaparsec)
|
2015-07-27 12:12:29 +03:00
|
|
|
|
[![Build Status](https://travis-ci.org/mrkkrp/megaparsec.svg?branch=master)](https://travis-ci.org/mrkkrp/megaparsec)
|
2015-08-02 10:33:26 +03:00
|
|
|
|
[![Coverage Status](https://coveralls.io/repos/mrkkrp/megaparsec/badge.svg?branch=master&service=github)](https://coveralls.io/github/mrkkrp/megaparsec?branch=master)
|
2014-10-16 20:21:52 +04:00
|
|
|
|
|
2015-08-01 19:24:45 +03:00
|
|
|
|
This is industrial-strength monadic parser combinator library. Megaparsec is
|
2015-09-21 20:26:25 +03:00
|
|
|
|
a fork of [Parsec](https://github.com/aslatter/parsec) library originally
|
|
|
|
|
written by Daan Leijen.
|
2014-10-16 20:21:52 +04:00
|
|
|
|
|
2015-08-17 20:08:17 +03:00
|
|
|
|
Megaparsec is different from Parsec in the following ways:
|
2014-10-16 20:21:52 +04:00
|
|
|
|
|
2015-08-17 20:08:17 +03:00
|
|
|
|
* Better error messages. We test our error messages using dense QuickCheck
|
|
|
|
|
tests. Good error messages are just as important for us as correct return
|
|
|
|
|
values of our parsers. Megaparsec will be especially useful if you write
|
|
|
|
|
compiler or interpreter for some language.
|
2014-10-16 20:21:52 +04:00
|
|
|
|
|
2015-08-17 20:08:17 +03:00
|
|
|
|
* Some quirks and “buggy features” (as well as plain bugs) of original
|
|
|
|
|
Parsec are fixed. There is no undocumented surprising stuff in Megaparsec.
|
2014-10-16 20:21:52 +04:00
|
|
|
|
|
2015-08-17 20:08:17 +03:00
|
|
|
|
* Better support for Unicode parsing in `Text.Megaparsec.Char`.
|
|
|
|
|
|
|
|
|
|
* Megaparsec has more powerful combinators and can parse languages where
|
|
|
|
|
indentation matters.
|
|
|
|
|
|
|
|
|
|
* Comprehensive QuickCheck test suite covering nearly 100% of our code.
|
2015-07-30 19:04:33 +03:00
|
|
|
|
|
2015-08-17 20:08:17 +03:00
|
|
|
|
* We have benchmarks to detect performance regressions.
|
2014-10-16 20:21:52 +04:00
|
|
|
|
|
2015-08-17 20:08:17 +03:00
|
|
|
|
* Better documentation, with 100% of functions covered, without typos and
|
|
|
|
|
obsolete information, with working examples. Megaparsec's documentation is
|
|
|
|
|
well-structured and doesn't contain things useless to end user.
|
|
|
|
|
|
|
|
|
|
* Megaparsec's code is clearer and doesn't contain “magic” found in original
|
2015-08-26 14:47:22 +03:00
|
|
|
|
Parsec.
|
2015-08-17 20:08:17 +03:00
|
|
|
|
|
2015-09-21 18:42:10 +03:00
|
|
|
|
## Megaparsec vs Parsec
|
|
|
|
|
|
|
|
|
|
There are good reasons to use Parsec:
|
|
|
|
|
|
2015-09-30 20:30:50 +03:00
|
|
|
|
* You need to work with legacy code or with older versions of GHC (< 7.8).
|
2015-09-21 18:42:10 +03:00
|
|
|
|
|
|
|
|
|
And that's it. In other cases you should prefer Megaparsec for your own
|
|
|
|
|
sake. If you think you have a reason to use Parsec other than listed here,
|
|
|
|
|
open an issue. We are glad to hear from you.
|
|
|
|
|
|
|
|
|
|
## Megaparsec vs Parsers
|
|
|
|
|
|
|
|
|
|
There is [parsers](https://hackage.haskell.org/package/parsers) package,
|
|
|
|
|
which is great. You can use it, but consider the following:
|
|
|
|
|
|
|
|
|
|
* It depends on *both* Attoparsec and Parsec, which means you always grab
|
|
|
|
|
useless code installing it. This is ridiculous, by the way, because this
|
|
|
|
|
package is supposed to be useful for parser builders, so they can write
|
|
|
|
|
basic core functionality and get the rest “for free”. But with these
|
|
|
|
|
useful functions you get two more parsers as dependencies.
|
|
|
|
|
|
|
|
|
|
* It currently has a bug in definition of `lookAhead` for various monad
|
|
|
|
|
transformers like `StateT`, etc. which is visible when you create
|
|
|
|
|
backtracking state via monad stack, not via built-in features. See #27.
|
|
|
|
|
|
|
|
|
|
We intended to use Parsers library in Megaparsec at some point, but aside
|
|
|
|
|
from already mentioned flaws the library has different conventions for
|
|
|
|
|
naming of things, different set of “core” functions, etc., different
|
|
|
|
|
approach to lexer. So it didn't happen, Megaparsec has minimal dependencies,
|
|
|
|
|
it is feature-rich and self-contained.
|
|
|
|
|
|
2014-10-16 20:21:52 +04:00
|
|
|
|
## Contributing
|
|
|
|
|
|
|
|
|
|
Issues (bugs, feature requests or otherwise feedback) may be reported in
|
2015-09-22 14:34:18 +03:00
|
|
|
|
[the GitHub issue tracker for this project](https://github.com/mrkkrp/megaparsec/issues).
|
2014-10-16 20:21:52 +04:00
|
|
|
|
|
2015-09-22 14:34:18 +03:00
|
|
|
|
Pull requests are also welcome (and yes, they will get attention and will be
|
2015-08-17 20:08:17 +03:00
|
|
|
|
merged quickly if they are good, we are progressive folks).
|
2014-10-16 20:21:52 +04:00
|
|
|
|
|
2015-08-26 14:47:22 +03:00
|
|
|
|
## Spread the Word
|
|
|
|
|
|
|
|
|
|
Many people still don't know about Megaparsec, you can help the project by
|
|
|
|
|
writing about it in a blog, creating a tutorial or something like that. This
|
|
|
|
|
is highly appreciated.
|
|
|
|
|
|
2014-10-16 20:21:52 +04:00
|
|
|
|
## License
|
|
|
|
|
|
2015-08-01 19:24:45 +03:00
|
|
|
|
Copyright © 2015 Megaparsec contributors<br>
|
2015-07-27 12:28:15 +03:00
|
|
|
|
Copyright © 2007 Paolo Martini<br>
|
2015-07-31 14:44:27 +03:00
|
|
|
|
Copyright © 1999–2000 Daan Leijen
|
2015-07-27 12:00:41 +03:00
|
|
|
|
|
|
|
|
|
Distributed under BSD3 license.
|