Recursive descent parsing library based on functional combinators
Parser combinators are just higher-order functions that take parsers as their arguments and return them as result values. Parser combinators are:
- First-class values
- Extremely composable
- Tend to make the code quite compact
- Resemble the readable notation of xBNF grammars
Parsers made with funcparserlib are pure-Python LL(*) parsers. It means that it’s very easy to write them without thinking about look-aheads and all that hardcore parsing stuff. But the recursive descent parsing is a rather slow method compared to LL(k) or LR(k) algorithms.
So the primary domain for funcparserlib is parsing little languages or external DSLs (domain specific languages).
The library itself is very small. Its source code is only 0.5 KLOC, with lots of comments included. It features the longest parsed prefix error reporting, as well as a tiny lexer generator for token position tracking.
- The funcparserlib Tutorial is a good starting point
- Nested Brackets Mini-HOWTO is a shorter intro
- Parsing Stages Illustrated (with pictures!) for a general view
- Examples in ./examples directory
- GraphViz DOT parser
- JSON parser
- The source code is quite straightforward and well-documented
What’s New in 0.3.5
A maintenance release.
- Python 2.4 compatibility
- More readable terminal names for error reporting
- Fixed wrong token positions in lexer error messages