Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Esrapy is an easy-to-use parsing library written entirely in python.

Project description

Esrapy can parse pretty much any context-free grammar, including left-recursive ones; can compile patterns (grammars) from textual or procedural descriptions; unifies parsing and tokenizing so tokenization can be contextual; has support for precedence (ambiguity resolution) and attributes (limited context-sensitivity); can return “first match” or a forrest of all possible parsings (for an ambiguous grammar); is very easy to use and results in very readable applications; and is only about 600 lines of code (not counting comments)–or only 450 if you don’t need the textual compiler. Esrapy works as a simple translator from a raw source text to a friendly(!) parse tree. Much of the emphasis in esrapy is in making the returned parse tree very easy to traverse.

Esrapy is not terribly fast, and may be a bit of a memory hog while it’s running (this may be an understatement). It’s probably most useful for language prototyping or small interactive applications where generality and ease of use are more important than speed. (I could be wrong about the speed–I haven’t run comparisons.) The parsing method it uses is somewhere between chart parsing and a packrat recursive descent.

There is a very short but complete example given on the home page which implements a five function (plus assignment) infix calculator with operator precedence. That should give you a quick idea for what it provides and how to use it (as well as how easy it is to use).

Project details

Release history Release notifications

This version


Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page