David Beazley has written up a pure-python Lex/YACC module called... Python Lex/YACC (or PLY). If you haven't worked with YACC-type parsers before, you might want to look at my implicit multiplication notes.