Parsing CONTEXT-FREE
in • No standard way to traverse the
Python
tree, but supports notation in the
grammar to make changes to the
generated the tree
• Includes library of rules for
common things like numbers and
ANTLR whitespace
• The most popular with many
grammars available ready to be
LRPARSING
used
• The grammar is defined with
• Supports Python, but also Java,
python expressions. Easy to
C#, JavaScript, etc.
understand for Python developers,
• Supports left-recursive rules
slightly harder to read
• The grammar has a clean format
• Includes supports to print the
(EBNF), that can be completely
parsing tree
separated by your code
• Comes with support for visitor
and listener pattern to traverse the
parsing tree in a standard way
PLY
• Mature (started in 2001) and
LARK basic tool
• The grammar is written with
• Implement two parsing Python code
algorithms: LALR(1) for speed and • Made for educational purposes:
Earley for power great support for diagnostics and
• The Earley algorithm supports error detection
left-recursive and even ambiguous
grammars. It can be slower than the
rest.
• The grammar has a clean format
(EBNF), completely separated by
your code
CONTEXT-FREE
PLYPLUS
• Built on top of PLY. It maintains
simplicity, but adds power
• The grammar has a clean format
(EBNF) but also supports notation
to make changes to the generated
the tree
• Includes functions to draw image
of parse tree
• Includes function to select nodes
using a CSS-selectors-like format
PYLERI
• Part of a family of parser
generators available in Python,
JavaScript, Python, C, etc.
• Simple tool
• The grammar is written with
Python expression in a class
PEG
ARPEGGIO • Supports the use of a visitor
• It supports grammars with
PYPEG
different formats: one in Python
expressions and the other in a clean
• The grammar is written in Python
PEG format
code, but you have to use a verbose
• It generates just the parse tree,
structure of classes and Python
but integrate support for a visitor
code
• Used as the basis of a tool to
• It can be used both for parsing
create DSL
and templating
• It does not output a parse tree,
CANOPY but a structure based on the
grammar
• Parser generator that supports
multiple languages: Python, Java,
JavaScript, Ruby TATSU
• The grammar is written in a clean
format (PEG). It supports the use of • The grammar uses a clean format
a notation to include actions that (EBNF-like). It includes notation to
are defined in the rest of your code manipulate the generated parse
tree
• Actions are written in your
PARSIMONIOUS Python code, not in the grammar
• It supports a visitor-like pattern
• Designed for speed • It supports left-recursive rule
• No-nonsense tool and no (experimental)
documentation • It includes tools to convert
The grammar is written in a clean ANTLR grammars in Tatsu grammars
format (PEG-like)
PEG
WAXEYE
• It supports Python, C, Ruby,
Scheme, etc.
• The grammar has a clean format
(PEG) that also supports notation
to simplify the generated parse tree
• It does not include a standard
way to traverse the parse tree
• It supports modular grammars
PARSER COMBINATORS
PARSEC.PY
A parser combinator inspired by
Parsec (the Haskell library)
PARSY
It supports building parsers both
combining standard combinator
functions and using a generator
function. Using generator function
makes easier to deal with complex
parsing problems
PYPARSING
• Stable and mature (14 years and
counting)
• Still not a great documentation
OTHER PARSING LIBRARIES
PYTHON
Python includes module to parse
Python code using the Python
interpreter itself. You get an
excellent Python parser, but it only
parses one thing
REPARSE
• A simple tool to combine regular
expressions to parse simple
formats, like dates
• Much better than just using
regular expression on your own,
still you cannot parse things like
programming languages with it
CONSTRUCT
• It provided specialized support to
parse binary data
• It is a cross between a DSL and a
parser combinator
I'VE GOT 5 SECONDS!
I NEED TO PARSE WHAT TO USE
EVERYTHING/NOT ANTLR
SURE
SIMPLE THINGS REPARSE
THINGS THAT PARSY
SEEMS SIMPLE
BINARY DATA CONSTRUCT
PYTHON PYTHON