1) Is there anything is the standard library that does the equivalent of import symbol,token def decode_ast(ast): if token.ISTERMINAL(ast[0]): return (token.tok_name[ast[0]], ast[1]) else: return (symbol.sym_name[ast[0]],)+tuple(map(decode_ast,ast[1:])) so that, eg: >>> pprint.pprint(decode.decode_ast(parser.expr("0").totuple())) ('eval_input', ('testlist', ('test', ('and_test', ('not_test', ('comparison', ('expr', ('xor_expr', ('and_expr', ('shift_expr', ('arith_expr', ('term', ('factor', ('power', ('atom', ('NUMBER', '0'))))))))))))))), ('NEWLINE', ''), ('ENDMARKER', '')) ? Should there be? (Especially if it was a bit better written). ... and Greg's just said everything else I wanted to! Cheers, M. -- please realize that the Common Lisp community is more than 40 years old. collectively, the community has already been where every clueless newbie will be going for the next three years. so relax, please. -- Erik Naggum, comp.lang.lisp
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4