Elementary lex/yacc implementation in Python