---

developerWorks: A Look at DParser for Python

“There are many Python parser libraries available. I have
discussed mx.TextTools, SimpleParse, and SPARK in this column and
covered PLY in my book (see Resources for links to these
documents). Offhand, I know of PyGgy, Yapps, PLEX, PyLR, PyParsing,
and TPG, and I have vague recollections of reading announcements of
a half dozen others. This is a category where users might be
frustrated, not by the dearth, but by the glut of high quality
libraries.

“What distinguishes DParser from all the others? Well, like PLY
and Spark, DParser for Python utilizes function documentation
strings to indicate its productions. This style lets you put action
code right inside a production for events that should occur when a
particular grammar rule is fulfilled; the production-in-docstring
style also lets you manipulate parse trees as parsing occurs. In
contrast to PLY or Spark, DParser itself is written in C, and is
thus likely to be considerably faster than pure-Python parsers.
DParser for Python is a fairly thin wrapper around an underlying C
library — callbacks into Python take some extra time, but the
basic parsing is at C speeds. For this article, however, I have not
attempted any specific benchmarks. So exactly how fast or slow
DParser is compared to other parsers is not something I can
directly comment on…”


Complete Story

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends, & analysis