Parsec Build Status

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).

Prelude> :m +Text.Parsec
Prelude Text.Parsec> let parenSet = char '(' >> many parenSet >> char ')'
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package bytestring-0.10.4.0 ... linking ... done.
Loading package mtl-2.1.3.1 ... linking ... done.
Loading package text-1.1.1.3 ... linking ... done.
Loading package parsec-3.1.5 ... linking ... done.
Prelude Text.Parsec> let parens = (many parenSet >> eof) <|> eof
Prelude Text.Parsec> parse parens "" "()"
Right ()
Prelude Text.Parsec> parse parens "" "()(())"
Right ()
Prelude Text.Parsec> parse parens "" "("
Left (line 1, column 2):
unexpected end of input
expecting "(" 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.

Changes

3.1.11

- Include `README.md` in package.

3.1.10

- Most types now have a `Typeable` instance. Some instances are dropped from
older versions of GHC (sorry about that!).
- The token-parser now rejects Unicode numeric escape sequences for characters
outside the Unicode range.
- The token-parser now loses less precision when parsing literal doubles.
- Documentation fixes and corrections.
- We no longer test parsec builds on GHC 7.4.

3.1.9

- Many and various updates to documentation and package description (inlcuding
the homepage links).
- Add an 'Eq' instance for 'ParseError'
- Fixed a regression from 3.1.6: 'runP' is again exported from module
Text.Parsec.

3.1.8

- Fix a regression from 3.1.6 related to exports from the main module.

3.1.7

- Fix a regression from 3.1.6 related to the reported position of error messages.
See bug #9 for details.
- Reset the current error position on success of 'lookAhead'.

3.1.6

- Export 'Text' instances from Text.Parsec
- Make Text.Parsec exports more visible
- Re-arrange Text.Parsec exports
- Add functions 'crlf' and 'endOfLine' to Text.Parsec.Char for handling
input streams that do not have normalized line terminators.
- Fix off-by-one error in Token.charControl

3.1.4 & 3.1.5

- Bump dependency on 'text'

3.1.3

- Fix a regression introduced in 3.1.2 related to positions reported by error messages.
Depends on:
Used by 874 packages:
abacate, abcnotation, ace, acme-lolcat, adblock2privoxy, adhoc-network, aeson-extra, aeson-parsec-picky, aeson-qq, AGI, aip, air-extra, algebra-dag, algebra-sql, alms, alpha, ampersand, amrun, anansi, anatomy, Annotations, Ansi2Html, antfarm, apiary-purescript, app-settings, arbtt, arcgrid, arguedit, arx, arxiv, assembler, atndapi, atomo, atp-haskell, attoparsec-parsec, Aurochs, aws-sdk, b9, bamboo, bamboo-theme-mini-html5, Barracuda, baskell, batchd, bbdb, bein, bencode, bert, bibdb, bibtex, bidirectionalization-combined, billeksah-forms, billeksah-main, billeksah-main-static, billeksah-pane, billeksah-services, bio, bioace, Biobase, BioHMM, biophd, bio-sequence, bird, Blogdown, BlogLiterately, bond, boolexpr, brain-bleep, Bravo, bricks, buchhaltung, buster, buster-gtk, c0parser, cabal2doap, cabal-debian, cabal-graphdeps, cabal-macosx, cake3, calculator, caldims, caledon, cantor, CarneadesDSL, casui, cedict, cg, cgen, cgi, chatter, chitauri, chuchu, chunks, citeproc-hs, citeproc-hs-pandoc-filter, clafer, claferIG, CLASE, clckwrks-cli, clevercss, clippings, clr-inline, ClustalParser, cmathml3, cmdtheline, cmv, cnc-spec-compiler, codec-libevent, codec-rpm, codo-notation, combinatorial-problems, Combinatorrent, competition, compiler-warnings, ConfigFile, ConfigFileTH, Configger, config-manager, config-parser, conjure, console-program, copilot-libraries, copilot-theorem, core, CoreErlang, cparsing, CPL, criterion, CSPM-Frontend, csv, dapi, darcs, darcs-beta, darcs-buildpackage, darcs-cabalized, DarcsHelpers, darcswatch, dash-haskell, dataflow, datalog, dates, dawdle, DBlimited, dbus, dbus-core, dbus-qq, dcpu16, ddc-base, ddc-core, dead-simple-json, debian, dedukti, deiko-config, deka, deka-tests, dfsbuild, diagrams-contrib, diagrams-haddock, dice, dictparser, diplomacy, diplomacy-server, disassembler, DisTract, diversity, docopt, doctemplates, docvim, doi, dom-selector, dotfs, dson, dson-parsec, Dung, easyjson, ebnf-bff, ecma262, egison, egison-quote, egison-tutorial, ehs, Elm, elm-compiler, elm-repl, email, Emping, epub-tools, Eq, erd, ersatz, EtaMOO, exference, extcore, fadno-xml, fasta, fdo-trash, FerryCore, Feval, fig, file-command-qq, filestore, fillit, flat-tex, flight-igc, Flippi, flite, flo, flow2dot, fltkhs, fluffy-parser, Folly, formal, format, forml, fptest, fquery, free-theorems-seq, fsmActions, ftphs, funcons-tools, Gamgine, Ganymede, Genbank, GenI, geniconvert, gentlemark, ggtsTC, ghc-core-html, ghc-events-analyze, ghci-history-parser, ghc-imported-from, ghc-man-completion, ghc-pkg-autofix, ginger, ginsu, git-checklist, gitHUD, gitit, gitlib-cmdline, glambda, GLM, gmndl, goatee, goatee-gtk, gopherbot, grammar-combinators, graph-rewriting-cl, graph-rewriting-lambdascope, graph-rewriting-ski, graph-rewriting-ww, graph-utils, grm, GroteTrap, gsmenu, GuiHaskell, hackage-security, hackage-server, hack-contrib-press, HackMail, hackport, haggis, hail, hails, hakaru, hako, hakyll, hakyll-contrib-links, hakyll-shortcode, HandsomeSoup, HAppS-Server, happstack-helpers, happstack-server, happstack-util, happs-tutorial, haquery, harchive, harpy, hascat-lib, hascat-system, Haschoo, HasGP, Hashell, haskeem, haskell-brainfuck, haskell-gettext, haskell-lsp, haskell-platform-test, haskell-reflect, haskellscrabble, HaskellTorrent, haskelm, haskhol-core, hask-home, haskintex, haskore, hastily, HaTeX, hatex-guide, HaTeX-meta, hatt, hawitter, haxparse, Hayoo, hbayes, hbro, hbro-contrib, HDBC-postgresql, hdigest, hdo, Hedi, helisp, helium, hellnet, herbalizer, here, heredocs, her-lexer-parsec, hesh, hesql, heterocephalus, hexpr, hexquote, hfoil, hg-buildpackage, hgdbmi, hgeometry, hgom, hi, hiccup, hifi, highlighting-kate, hipe, hist-pl-transliter, hit, hjpath, hjs, hjson, HJVM, HLearn-classification, hledger, hledger-lib, hledger-web, hLLVM, hmarkup, hmatrix-static, hmeap, hmeap-utils, hmk, hmt, hmumps, hol, Holumbus-Searchengine, HostAndPort, hourglass-fuzzy-parsing, hpaco-lib, HPath, hpc-tracer, hpdft, hpodder, hprotoc, hprotoc-fork, hpuz, hpyrg, hquery, hsc3-rw, hScraper, hsdip, Hsed, hsemail, hsemail-ns, HSFFIG, hs-gizapp, hsini, hs-java, hs-logo, hsmisc, Hsmtlib, hsnock, hsoptions, hsshellscript, hssqlppp, HStringTemplate, htoml, HTTP, http-encodings, http-monad, hugs2yc, hunch, hunit-parsec, HUnit-Plus, hunp, hunt-searchengine, husk-scheme, husky, huttons-razor, hxt, hxt-css, hxt-curl, hxt-filter, hxt-http, hxt-regex-xmlschema, hxt-relaxng, hxt-xpath, hxt-xslt, hybrid, hydrogen-parsing, hydrogen-prelude-parsec, hydrogen-syntax, hydrogen-util, i18n, iCalendar, ideas, ideas-math, ihaskell, ihaskell-parsec, imbib, imparse, implicit, inch, indentation, indentation-parsec, indentparser, IndentParser, indents, infernu, infer-upstream, inline-c, internetmarke, iptables-helpers, iptadmin, ipython-kernel, ircbot, iso8583-bitmaps, iteratee-parsec, ivor, ivory-bitdata, ixshader, iyql, jmacro, JsContracts, json, json2, JSON-Combinator, JSONParser, json-qq, kaleidoscope, katt, katydid, kdesrc-build-extra, keyword-args, khph, kicad-data, kif-parser, Konf, kontrakcja-templates, laborantin-hs, labyrinth, labyrinth-server, lambda2js, lambdaBase, lambdabot-core, lambdabot-haskell-plugins, lambdabot-misc-plugins, lambda-calculator, LambdaCalculator, LambdaPrettyQuote, LambdaShell, language-asn1, language-bash, language-boogie, language-dockerfile, language-dot, language-ecmascript, language-ecmascript-analysis, language-eiffel, language-fortran, language-glsl, language-go, language-java, language-java-classfile, language-mixal, language-pig, language-puppet, language-qux, language-sh, language-slice, language-typescript, language-webidl, ldif, leksah, leksah-server, lentil, lhae, libGenI, liquid-fixpoint, liquidhaskell, lispparser, lit, live-sequencer, llsd, llvm-general, llvm-general-pure, llvm-pretty, load-env, log2json, logic-classes, logplex-parse, lojban, lol-calculus, lol-typing, L-seed, LslPlus, ltk, luthor, lvmlib, maccatcher, mackerel-client, maclight, mappy, marvin-interpolate, mathista, maxsharing, mbox-tools, mbox-utility, mediawiki2latex, melody, MFlow, mi, microc, microstache, midi-utils, mighttpd, mighttpd2, mikrokosmos, miniforth, ministg, MissingH, ml-w, modelicaparser, modulo, mohws, monadiccp, MonadLab, mongoDB, mprover, mps, msh, msu, MTGBuilder, mud, multifocal, multipart, multipart-names, multipath, music-score, mustache, mustache2hs, mustache-haskell, mvclient, namelist, nanoAgda, natural-sort, neat, neat-interpolation, needle, netcore, netease-fm, netrc, nettle-openflow, network-dbus, network-hans, network-uri, nextstep-plist, nicify-lib, nixfromnpm, nntp, noise, numeric-ode, numeric-prelude, nymphaea, octopus, ofx, onama, only, open-pandoc, openssh-github-keys, optimusprime, orchid, org2anki, orgmode, os-release, ottparse-pretty, panda, pandoc, pandoc-citeproc, paragon, parco-parsec, parsec3-numbers, parsec-extra, parsec-free, parsec-numbers, parsec-numeric, parsec-parsers, parsec-permutation, parsec-pratt, parsec-tagsoup, ParsecTools, parsec-trace, parsec-utils, parsedate, parse-dimacs, parseerror-eq, parsely, ParserFunction, parsergen, parsers, pb-next, peg, penn-treebank, penny, penny-bin, penny-lib, period, pgm, phoityne, phoityne-vscode, photoname, phybin, pi-calculus, picologic, pi-forall, piki, pisigma, platinum-parsing, PlslTools, pngload, pngload-fixed, polar-configfile, polyseq, postgrest, postmaster, preprocessor-tools, press, pretty-simple, primula-bot, prof2dot, prolog, Proper, protobuf-simple, protocol-buffers, proto-lens, prove-everywhere-server, psc-ide, pseudo-boolean, Pugs, Pup-Events-Client, Pup-Events-Demo, Pup-Events-Server, purescript, puzzle-draw, pxsl-tools, quantities, QuickPlot, quoridor-hs, radium, radium-formula-parser, range, rdf4h, really-simple-xml-parser, record-syntax, redHandlers, reflex-jsx, regexchar, regex-deriv, regex-dfa, regexdot, regex-parsec, regex-pderiv, regex-tdfa, regex-tdfa-rc, regex-xmlschema, relative-date, repl, repl-toolkit, repo-based-blog, resolve, RESTng, riak-protobuf, RJson, rlglue, rl-satton, rlwe-challenges, RNAdesign, RNAlien, roshask, roundtrip-string, rpf, rsagl, rsagl-math, rss2irc, ruff, ruin, rws, salvia-protocol, SBench, scan, s-cargot, scc, scholdoc, scholdoc-citeproc, scholdoc-texmath, scion-browser, Scurry, scyther-proof, sdf2p1-parser, secd, SelectSequencesFromMSA, semver-range, serokell-util, sfnt2woff, sgf, shakespeare, ShellCheck, shelltestrunner, show-please, shqq, sifflet, sifflet-lib, simgi, simple-config, simple-eval, simple-nix, simple-pascal, simple-sql-parser, simple-stacked-vm, sindre, sitepipe, smallcaps, SmtLib, snaplet-mongoDB, snippet-extractor, snm, snorkels, sphinxesc, splitter, spoonutil, sprinkles, sqlite-simple-errors, srcinst, sshd-lint, stackage-cabal, stagen, stdata, steambrowser, StockholmAlignment, StrappedTemplates, subleq-toolchain, super-user-spark, SVGFonts, SVGPath, syfco, sylvia, system-uuid, tableaux, Tablify, taffybar, tagset-positional, tagsoup-parsec, tagsoup-selection, tak, tamarin-prover, tamarin-prover-term, tamarin-prover-theory, tamarin-prover-utils, tasty-integrate, Taxonomy, TaxonomyTools, tempered, template-hsml, templatepg, template-toolkit, term-rewriting, tex2txt, texmath, text-format-heavy, text-json-qq, text-render, text-xml-qq, th-typegraph, tidal, time-w3c, tkhs, todos, Top, toysolver, tpdb, transformations, TransformeR, tree-diff, treemap-html, treemap-html-tools, tsparse, tttool, turtle-options, twentefp, twentefp-number, twidge, twiml, twine, txt-sushi, typedquery, typed-wire, typescript-docs, uAgda, UMM, units-parser, uni-util, uri, urn, urxml, vcswrapper, ViennaRNAParser, vimeta, vintage-basic, vision, visualize-cbn, VKHS, vty, vty-examples, WashNGo, WebBits, WebBits-Html, WeberLogic, webidl, web-mongrel2, Webrexp, web-routes, web-routes-boomerang, web-routes-regular, web-routes-th, webserver, while-lang-parser, whiskers, WikimediaParser, windowslive, wtk-gtk, WURFL, wxcore, wxdirect, wyvern, xhaskell-library, xhb, xlsx-templater, xml-hamlet, xmlhtml, xml-parsec, XMLParser, xmobar, XMPP, yabi-muno, yamlkeysdiff, yeshql, yesod-bin, yesod-core, yes-precure5-command, yices, yi-core, yocto, Yocto, yql, yst, yuuko, yu-utils, yxdb-utils, zampolit
comments powered byDisqus