Re: best option for python lex/yacc?



On Jun 30, 1:47 am, m...@xxxxxxxxx wrote:
I'm porting a C lex/yacc based project, and would like to redo
it in python.

What's the best option for a python lex/yacc-like?  I've
googled a few things, but wanted to see the current concensus.

Many TIA!
Mark

--
Mark Harrison
Pixar Animation Studios

For a full list, see http://nedbatchelder.com/text/python-parsers.html

For lex/yacc-like's, PLY, Spark, simpleparse, or ANTLR are probably
the leaders.

If you consider using pyparsing, then *don't* just try to do a
straight transliteration from your existing lex/yacc implementation -
you will end up fighting some of pyparsing's basic concepts.

But if you already have this implemented and working in C, and given
that parsing usually is such a performance-sucking operation, why not
package the existing parser into a lib, and call it from python using
ctypes, or some similar technology for embedding C code in Python?

-- Paul
.



Relevant Pages

  • Re: py3k concerns. An example
    ... cross-version compatible single codebase for pyparsing. ... chance that you can support a wide range of versions ... Python 3.x codebases, as will anyone whose modules include exception ... There is a bit of code in Pyparsing that normalizes user ...
    (comp.lang.python)
  • ANN: pyparsing 1.5.1 released
    ... Here's what's new in Pyparsing 1.5.1: ... better compatibility with Python 2.3. ... is a file pyparsing_py3.py in the SourceForge Subversion repository. ... configuration file parser ...
    (comp.lang.python)
  • Re: py3k concerns. An example
    ... Apparently the promise of syntax compatibility in the 3.0a4 docs was ... As of a pyparsing release some time after ... I will only support Python 3.0 versions with any new features ... and produce 3.x code either at release or at install ...
    (comp.lang.python)
  • Re: store tag content with SGMLParser ... ?
    ... > Hi Python people! ... you could write a small SGML subset using pyparsing, ... With pyparsing, you don't have to define the ... more blah blah blah... ...
    (comp.lang.python)
  • Re: py3k concerns. An example
    ... If you don't like Python 3, ... develop and support modules for use by other Python users. ... supporter of pyparsing, I really can't just "not use" Py3 - ignoring ... fits trying to support both versions with a single code base. ...
    (comp.lang.python)