haskell/parsec

Name: parsec

Owner: Haskell

Description: A monadic parser combinator library

Created: 2014-03-23 20:46:26.0

Updated: 2018-03-28 21:55:21.0

Pushed: 2018-03-04 09:17:20.0

Homepage: https://hackage.haskell.org/package/parsec

Size: 344

Language: Haskell

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Parsec Build Status

Please refer to the package description on Hackage for more information.

A monadic parser combinator library, written by Daan Leijen. Parsec is designed from scratch as an industrial-strength parser library. It is simple, safe, well documented, has extensive libraries, good error messages, and is fast.

Some links:

By analyzing Parsec's reverse dependencies on Hackage we can find open source project that make use of Parsec. For example bibtex, ConfigFile, csv and hjson.

Getting started

This requires a working version of cabal and ghci, which are part of any modern installation of Haskell, such as Haskell Platform.

First install Parsec.

cabal install parsec

Below we show how a very simple parser that tests matching parentheses was made from GHCI (the interactive GHC environment), which we started with the ghci command).

ude> :m +Text.Parsec
ude Text.Parsec> let parenSet = char '(' >> many parenSet >> char ')' :: Parsec String () Char
ing package transformers-0.3.0.0 ... linking ... done.
ing package array-0.5.0.0 ... linking ... done.
ing package deepseq-1.3.0.2 ... linking ... done.
ing package bytestring-0.10.4.0 ... linking ... done.
ing package mtl-2.1.3.1 ... linking ... done.
ing package text-1.1.1.3 ... linking ... done.
ing package parsec-3.1.5 ... linking ... done.
ude Text.Parsec> let parens = (many parenSet >> eof) <|> eof
ude Text.Parsec> parse parens "" "()"
t ()
ude Text.Parsec> parse parens "" "()(())"
t ()
ude Text.Parsec> parse parens "" "("
 (line 1, column 2):
pected end of input
cting "(" or ")"

The Right () results indicate successes: the parentheses matched. The Left [...] result indicates a parse failure, and is detailed with an error message.

For a more thorough introduction to Parsec we recommend the links at the top of this README file.

Contributing

Issues (bugs, feature requests or otherwise feedback) may be reported in the Github issue tracker for this project.

Pull-requests are also welcome.

License

See the LICENSE file in the repository.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.