https://wiki.haskell.org/api.php?action=feedcontributions&user=Rsimoes&feedformat=atomHaskellWiki - User contributions [en]2024-03-29T05:58:10ZUser contributionsMediaWiki 1.35.5https://wiki.haskell.org/index.php?title=Parsec&diff=43564Parsec2011-12-10T17:33:00Z<p>Rsimoes: + perl module</p>
<hr />
<div>[[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 [http://legacy.cs.uu.nl/daan/parsec.html the parsec website].<br />
<br />
{{Template:Stub}}<br />
<br />
<br />
== Examples ==<br />
<br />
* [http://book.realworldhaskell.org/read/using-parsec.html "Using Parsec"] chapter on [http://book.realworldhaskell.org/ Real World Haskell].<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 O'Caml http://lprousnth.files.wordpress.com/2007/08/pcl.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 />
* Parsec-Erlang, http://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 />
* Somewhere there is a Nemerle port<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 />
<br />
Interesting non-Parsec parser combinator libraries:<br />
* Parse::RecDescent for Perl https://metacpan.org/module/Parse::RecDescent<br />
* Spirit for C++ http://spirit.sourceforge.net/documentation.html<br />
<br />
<br />
== Links == <br />
<br />
=== Docs ===<br />
<br />
* [http://legacy.cs.uu.nl/daan/parsec.html on Parsec website]<br />
* [http://research.microsoft.com/en-us/um/people/daan/parsec.html on Microsoft] (content same as above)<br />
<br />
=== Blog articles ===<br />
<br />
* [http://therning.org/magnus/archives/289 Adventures in parsing] by Magnus Therning <br />
* [http://therning.org/magnus/archives/290 More adventures in parsing]<br />
* [http://therning.org/magnus/archives/295 Adventures in parsing, part 3]<br />
* [http://therning.org/magnus/archives/296 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 />
=== Other ===<br />
<br />
* [http://stackoverflow.com/questions/tagged/parsec Parsec] on Stack Overflow</div>Rsimoes