[ANN] pyparsing 1.5.3 released

Paul McGuire ptmcg at austin.rr.com
Fri Jun 25 07:03:04 CEST 2010

I'm happy to announce that a new release of pyparsing is now
version 1.5.3.  It has been almost a year and a half since 1.5.2 was
released, but pyparsing has remained pretty stable.

I believe I have cleaned up the botch-job I made in version 1.5.2 of
trying to support both Python 2.x and Python 3.x.  This new release
will handle it by:
- providing version-specific binary installers for Windows users
- use version-adaptive code in the source distribution to use the
  correct version of pyparsing.py for the current Python distribution

This release also includes a number of small bug-fixes, plus some
interesting new examples.

Here is the high-level summary of what's new in pyparsing 1.5.3:

- ======= NOTE:  API CHANGE!!!!!!! ===============
  With this release, and henceforward, the pyparsing module is
  imported as "pyparsing" on both Python 2.x and Python 3.x versions.

- Fixed up setup.py to auto-detect Python version and install the
  correct version of pyparsing - suggested by Alex Martelli,
  thanks, Alex! (and my apologies to all those who struggled with
  those spurious installation errors caused by my earlier

- Fixed bug on Python3 when using parseFile, getting bytes instead of
  a str from the input file.

- Fixed subtle bug in originalTextFor, if followed by
  significant whitespace (like a newline) - discovered by
  Francis Vidal, thanks!

- Fixed very sneaky bug in Each, in which Optional elements were
  not completely recognized as optional - found by Tal Weiss, thanks
  for your patience.

- Fixed off-by-1 bug in line() method when the first line of the
  input text was an empty line. Thanks to John Krukoff for submitting
  a patch!

- Fixed bug in transformString if grammar contains Group expressions,
  thanks to patch submitted by barnabas79, nice work!

- Fixed bug in originalTextFor in which trailing comments or
  ignored text got slurped in with the matched expression.  Thanks to
  michael_ramirez44 on the pyparsing wiki for reporting this just in
  time to get into this release!

- Added better support for summing ParseResults, see the new example,

- Added support for composing a Regex using a compiled RE object;
  thanks to my new colleague, Mike Thornton!

- In version 1.5.2, I changed the way exceptions are raised in order
  to simplify the stacktraces reported during parsing.  An anonymous
  user posted a bug report on SF that this behavior makes it difficult
  to debug some complex parsers, or parsers nested within parsers. In
  this release I've added a class attribute
  with a default value of False. If you set this to True, pyparsing
  report stacktraces using the pre-1.5.2 behavior.

- Some interesting new examples, including a number of parsers related
  to parsing C source code:

  . pymicko.py, a MicroC compiler submitted by Zarko Zivanov.
    (Note: this example is separately licensed under the GPLv3,
    and requires Python 2.6 or higher.)  Thank you, Zarko!

  . oc.py, a subset C parser, using the BNF from the 1996 Obfuscated C

  . select_parser.py, a parser for reading SQLite SELECT statements,
    as specified at http://www.sqlite.org/lang_select.html; this goes
    into much more detail than the simple SQL parser included in
    source code

  . stateMachine2.py, a modified version of stateMachine.py submitted
    by Matt Anderson, that is compatible with Python versions 2.7 and
    above - thanks so much, Matt!

  . excelExpr.py, a *simplistic* first-cut at a parser for Excel
    expressions, which I originally posted on comp.lang.python in
    2010; beware, this parser omits many common Excel cases (addition
    numbers represented as strings, references to named ranges)

  . cpp_enum_parser.py, a nice little parser posted my Mark Tolonen on
    comp.lang.python in August, 2009 (redistributed here with Mark's
    permission).  Thanks a bunch, Mark!

  . partial_gene_match.py, a sample I posted to Stackoverflow.com,
    implementing a special variation on Literal that does "close"
    up to a given number of allowed mismatches.  The application was
    find matching gene sequences, with allowance for one or two

  . tagCapture.py, a sample showing how to use a Forward placeholder
    enforce matching of text parsed in a previous expression.

  . matchPreviousDemo.py, simple demo showing how the
    helper method is used to match a previously parsed token.

Download pyparsing 1.5.3 at http://sourceforge.net/projects/pyparsing/.
can also access pyparsing's epydoc documentation online at

The pyparsing Wiki is at http://pyparsing.wikispaces.com.

-- Paul

Pyparsing is a pure-Python class library for quickly developing
recursive-descent parsers.  Parser grammars are assembled directly in
the calling Python code, using classes such as Literal, Word,
OneOrMore, Optional, etc., combined with operators '+', '|', and '^'
for And, MatchFirst, and Or.  No separate code-generation or external
files are required.  Pyparsing can be used in many cases in place of
regular expressions, with shorter learning curve and greater
readability and maintainability.  Pyparsing comes with a number of
parsing examples, including:
- "Hello, World!" (English, Korean, Greek, and Spanish(new))
- chemical formulas
- configuration file parser
- web page URL extractor
- 5-function arithmetic expression parser
- subset of CORBA IDL
- chess portable game notation
- simple SQL parser
- Mozilla calendar file parser
- EBNF parser/compiler
- Python value string parser (lists, dicts, tuples, with nesting)
  (safe alternative to eval)
- HTML tag stripper
- S-expression parser
- macro substitution preprocessor

More information about the Python-announce-list mailing list