Found in 2 comments on Hacker News
ramanujan · 2009-09-07 · Original thread
I would recommend pyparsing for this. There was an excellent article on it in Python Magazine a few months ago.

Some links:

1. O'Reilly mini-book on pyparsing (probably best single ref) http://oreilly.com/catalog/9780596514235/

2. Quick example of pyparsing http://eikke.com/pyparsing-introduction-bnf-to-code/

3. Main pyparsing page (i know it's not very aesthetically pleasing. The code is much better, I promise) http://pyparsing.wikispaces.com/

4. Links to more on pyparsing here http://pyparsing.wikispaces.com/Publications

Python Magazine is excellent, by the way. Definitely worth the purchase price as they include a zip file with code. (Mandatory disclaimer: I have no stake in it at all. Just found it very useful, that's all).

wilkes · 2008-12-19 · Original thread
I've really enjoyed using PyParsing. O'Reilly has a ShortCut book on it that is worthwhile. http://oreilly.com/catalog/9780596514235/

Fresh book recommendations delivered straight to your inbox every Thursday.