Parsec: A parser combinator library in Python


What’s the ?

A universal Python parser combinator library inspired by Parsec library of Haskell.

Parser combinator is a technique to implement a parser. A parser combinator is a function (higher-order function) that accepts several parsers as arguments and return a new parser as result. Parser combinators enable a recursive descent parsing strategy, this parsing technique facilitates modular piecewise construction and testing. Parser combinators can be used to combine basic parsers to construct parsers for more complex rules, and parser built using combinators are straightforward to construct, readable, modular, well-structured and easily maintainable.

The parsec package is a famous monadic parser combinator library in Haskell. Now, the parsec is a parser combinator library implemented in Python, providing Python developers an easy and elegant approach to build a complex but efficient parser.

Let’s go ahead to see the MAGIC of parser combinators!


The design of parsec’s API was inspired by Parsec library of Haskell.

Simple parser primitives

For more details about this library, see it’s documentation at

Usage and Contributor Guide

This project is open-source under The MIT License and you may use, distribute and modify this code with out limitation. The source code can be found at the site hosted on github.

  • You can install this library using pip with the following command:

    pip install parsec

    or download it from Pypi and then install manually.

  • Looking for specific information? Try the detailed documentation.

  • Report bugs with in our Issue tracker.

  • Contribute your code to help me improve this library with Pull Request.