ANN: pyparsing 1.5.6 released!

Paul McGuire ptmcg at
Fri Jul 1 08:10:10 CEST 2011

After about 10 months, there is a new release of pyparsing, version
1.5.6.  This release contains some small enhancements, some bugfixes,
and some new examples.

Most notably, this release includes the first public release of the
Verilog parser.  I have tired of restricting this parser for
commercial use, and so I am distributing it under the same license as
pyparsing, with the request that if you use it for commmercial use,
please make a commensurate donation to your local Red Cross.

Change summary:
- Cleanup of parse action normalizing code, to be more version-
  and robust in the face of future Python versions - much thanks to
  Raymond Hettinger for this rewrite!

- Removal of exception cacheing, addressing a memory leak condition
  in Python 3. Thanks to Michael Droettboom and the Cape Town PUG for
  their analysis and work on this problem!

- Fixed bug when using packrat parsing, where a previously parsed
  expression would duplicate subsequent tokens - reported by Frankie
  Ribery on stackoverflow, thanks!

- Added 'ungroup' helper method, to address token grouping done
  implicitly by And expressions, even if only one expression in the
  And actually returns any text - also inspired by stackoverflow
  discussion with Frankie Ribery!

- Fixed bug in srange, which accepted escaped hex characters of the
  form '\0x##', but should be '\x##'.  Both forms will be supported
  for backwards compatibility.

- Enhancement to countedArray, accepting an optional expression to be
  used for matching the leading integer count - proposed by Mathias on
  the pyparsing mailing list, good idea!

- Added the Verilog parser to the provided set of examples, under the
  MIT license.  While this frees up this parser for any use, if you
  yourself using it in a commercial purpose, please consider making a
  charitable donation as described in the parser's header.

- Added the excludeChars argument to the Word class, to simplify
  a word composed of all characters in a large range except for one or
  two. Suggested by JesterEE on the pyparsing wiki.

- Added optional overlap parameter to scanString, to return
  matches found in the source text.

- Updated oneOf internal regular expression generation, with improved
  parse time performance.

- Slight performance improvement in transformString, removing empty
  strings from the list of string fragments built while scanning the
  source text, before calling ''.join.  Especially useful when using
  transformString to strip out selected text.

- Enhanced form of using the "expr('name')" style of results naming,
  in lieu of calling setResultsName.  If name ends with an '*', then
  this is equivalent to

- Fixed up internal list flattener to use iteration instead of
  to avoid stack overflow when transforming large files.

- Added other new examples:
  . protobuf parser - parses Google's protobuf language
  . btpyparse - a BibTex parser contributed by Matthew Brett,
    with test suite (thanks, Matthew!)
  . - demo using trailing '*' for results

Download pyparsing 1.5.6 at,
or use 'easy_install pyparsing'. You can also access pyparsing's
epydoc documentation online at

The pyparsing Wiki is at

-- 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
- Verilog parser
- Google protobuf parser
- time expression parser/evaluator
- 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