[Python-ideas] Hooking between lexer and parser

Nick Coghlan ncoghlan at gmail.com
Sat Jun 6 07:00:03 CEST 2015

On 6 June 2015 at 12:21, Neil Girdhar <mistersheik at gmail.com> wrote:
> I'm curious what other people will contribute to this discussion as I think
> having no great parsing library is a huge hole in Python.  Having one would
> definitely allow me to write better utilities using Python.

The design of *Python's* grammar is deliberately restricted to being
parsable with an LL(1) parser. There are a great many static analysis
and syntax highlighting tools that are able to take advantage of that
simplicity because they only care about the syntax, not the full

Anyone actually doing their *own* parsing of something else *in*
Python, would be better advised to reach for PLY
(https://pypi.python.org/pypi/ply ). PLY is the parser underlying
https://pypi.python.org/pypi/pycparser, and hence the highly regarded
CFFI library, https://pypi.python.org/pypi/cffi

Other notable parsing alternatives folks may want to look at include
https://pypi.python.org/pypi/lrparsing and
http://pythonhosted.org/pyparsing/ (both of which allow you to use
Python code to define your grammar, rather than having to learn a
formal grammar notation).


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list