https://wiki.haskell.org/api.php?action=feedcontributions&user=Sri&feedformat=atomHaskellWiki - User contributions [en]2024-03-29T00:25:23ZUser contributionsMediaWiki 1.35.5https://wiki.haskell.org/index.php?title=Parsec&diff=63259Parsec2020-03-02T15:16:41Z<p>Sri: fix links for blog url changes</p>
<hr />
<div>{{Template:Stub}}<br />
<br />
[[Category:Compiler tools]]<br />
[[Category:Combinators]]<br />
[[Category:Packages]]<br />
[[Category:Libraries]]<br />
<br />
<br />
== Introduction ==<br />
Parsec is an industrial strength, monadic parser combinator library for<br />
Haskell. It can parse context-sensitive, infinite look-ahead grammars<br />
but it performs best on predictive (LL[1]) grammars. <br />
<br />
The latest stable release with Haddock documentation is available on [http://hackage.haskell.org/package/parsec Hackage] and development versions are [http://code.haskell.org/parsec3/ available via the Darcs repository].<br />
<br />
<br />
== Usage ==<br />
<br />
Parsec lets you construct parsers by combining higher-order<br />
[[Combinator]]s to create larger expressions. Combinator parsers are<br />
written and used within the same programming language as the rest of the<br />
program. The parsers are first-class citizens of the language, unlike<br />
[[Happy]] parsers, which must be generated via a preprocessor.<br />
<br />
An example for parsing a simple grammar of expressions can be found [http://www.haskell.org/haskellwiki/Parsing_expressions_and_statements here].<br />
<br />
Much more documentation can be found on [https://web.archive.org/web/20140528151730/http://legacy.cs.uu.nl/daan/parsec.html the parsec website].<br />
<br />
== Examples ==<br />
<br />
* [http://book.realworldhaskell.org/read/using-parsec.html "Using Parsec"] chapter on [http://book.realworldhaskell.org/ Real World Haskell]. (The JSON examples require revision to work under GHC 7.10.x, and possibly earlier versions. This 2008 publication would benefit from an updated edition.)<br />
<br />
* [http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing Write Yourself a Scheme in 48 Hours/Parsing]. Note, that where the example uses the read function, the Token module of Parsec could have been used, to handle numbers.<br />
<br />
See also the [http://packdeps.haskellers.com/reverse/parsec list of reverse dependencies for Parsec].<br />
<br />
== Parsec clones in other languages ==<br />
<br />
* PCL for OCaml [http://lprousnth.files.wordpress.com/2007/08/pcl.pdf] (PDF)<br />
* JParsec for Java [http://jparsec.codehaus.org/JParsec+Overview]<br />
* NParsec, JParsec ported to C# [http://jparsec.codehaus.org/NParsec+Tutorial]<br />
* Ruby Parsec, JParsec ported to Ruby [http://jparsec.codehaus.org/Ruby+Parsec]]<br />
* FParsec for F# [http://www.quanttec.com/fparsec/]<br />
* XParsec for F# [http://corsis.github.com/XParsec/] is a type-and-source-polymorphic, generalized and extensible parsec implementation in F# 3.0 which supports powerful domain-specific non-linear navigation combinators (such as for XML trees)<br />
* Parsec-Erlang [https://bitbucket.org/dmercer/parsec-erlang/], is a faithful reproduction of Parsec in Erlang (there is also an older toy Parsec-like parser that isn't monadic, nor does it give error messages: [http://www.engr.uconn.edu/~jeffm/Source/Erlang/])<br />
* AliceParsec for Alice ML [http://www.ps.uni-sb.de/alice/contribs.html]<br />
* Parsnip for C++ [http://parsnip-parser.sourceforge.net/]<br />
* A Nemerle port [http://kriomant.net/nparsec.zip] (Zip file)<br />
* Pysec for Python [http://www.valuedlessons.com/2008/02/pysec-monadic-combinatoric-parsing-in.html]<br />
* JSParsec for JavaScript: [http://code.google.com/p/jsparsec/]<br />
* Bennu JavaScript Parser Combinator Library: [https://github.com/mattbierner/bennu/]<br />
* ParsecJ for Java [https://github.com/jon-hanson/parsecj/] is implemented in a functional style based on the original Parsec papers.<br />
<br />
Interesting non-Parsec parser combinator libraries:<br />
* Parse::RecDescent for Perl [https://metacpan.org/module/Parse::RecDescent]<br />
* Spirit for C++ [http://boost-spirit.com/home/doc/]<br />
<br />
== Links == <br />
<br />
=== Docs ===<br />
<br />
* [http://research.microsoft.com/pubs/65201/parsec-paper-letter.pdf Parsec: Direct Style Monadic Parser Combinators For The Real World] (PDF)<br />
* [http://research.microsoft.com/en-us/um/people/daan/download/parsec/parsec.pdf Parsec, a fast combinator parser] (PDF)<br />
<br />
=== Blog articles ===<br />
<br />
* [https://magnus.therning.org/posts/2007-05-27-289-adventures-in-parsing.html Adventures in Parsing] by Magnus Therning <br />
* [https://magnus.therning.org/posts/2007-05-29-290-more-adventures-in-parsing.html More Adventures in Parsing]<br />
* [https://magnus.therning.org/posts/2007-06-03-295-adventures-in-parsing-part-3.html Adventures in Parsing, Part 3]<br />
* [https://magnus.therning.org/posts/2007-06-05-296-adventures-in-parsing-part-4.html Adventures in Parsing, Part 4]<br />
<br />
* [http://panicsonic.blogspot.com/2009/12/adventures-in-parsec.html Adventures in Parsec] by Antoine Latter<br />
<br />
* [http://blog.jakubarnold.cz/2014/08/10/parsing-css-with-parsec.html Parsing CSS with Parsec] by Jacub Arnold<br />
<br />
=== Other ===<br />
<br />
* [https://github.com/JakeWheat/intro_to_parsing Introduction to parsing with Haskell and Parsec]<br />
* [http://stackoverflow.com/questions/tagged/parsec Parsec] on Stack Overflow</div>Srihttps://wiki.haskell.org/index.php?title=Haskell_Quiz/Secret_Santas&diff=55614Haskell Quiz/Secret Santas2013-03-28T15:24:16Z<p>Sri: /* The problem */</p>
<hr />
<div>[[Category:Haskell Quiz|Secret Santas]]<br />
<br />
==The problem==<br />
<br />
* http://www.rubyquiz.com/quiz2.html ([http://web.archive.org/web/20130215052222/http://rubyquiz.com/quiz2.html Cached Version])<br />
<br />
==Solutions==<br />
<br />
* [[Haskell Quiz/Secret Santas/Solution Matthias|Matthias]]<br />
* [[Haskell Quiz/Secret Santas/Solution Kuklewicz|Kuklewicz]] - A backtracking solution<br />
* [[Haskell Quiz/Secret Santas/Solution Anton|Anton]]</div>Srihttps://wiki.haskell.org/index.php?title=Haskell_Quiz/Secret_Santas&diff=55613Haskell Quiz/Secret Santas2013-03-28T15:04:33Z<p>Sri: /* The problem */</p>
<hr />
<div>[[Category:Haskell Quiz|Secret Santas]]<br />
<br />
==The problem==<br />
<br />
* http://www.rubyquiz.com/quiz2.html<br />
* http://web.archive.org/web/20130215052222/http://rubyquiz.com/quiz2.html<br />
<br />
==Solutions==<br />
<br />
* [[Haskell Quiz/Secret Santas/Solution Matthias|Matthias]]<br />
* [[Haskell Quiz/Secret Santas/Solution Kuklewicz|Kuklewicz]] - A backtracking solution<br />
* [[Haskell Quiz/Secret Santas/Solution Anton|Anton]]</div>Sri