[Python-ideas] Hooking between lexer and parser

Robert Collins robertc at robertcollins.net
Mon Jun 8 00:19:05 CEST 2015


On 6 June 2015 at 17:00, Nick Coghlan <ncoghlan at gmail.com> wrote:
> 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
> semantics.
>
> 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).

Let me just pimp https://pypi.python.org/pypi/Parsley here - I have
written languages in both Parsely (a simple packaging metadata
language) and its predecessor pymeta (in which I wrote pybars -
handlebars.js for python) - and both were good implementations of
OMeta, IMNSHO.

-Rob

-- 
Robert Collins <rbtcollins at hp.com>
Distinguished Technologist
HP Converged Cloud


More information about the Python-ideas mailing list