
June 13, 2015
11:09 a.m.
On Sat, Jun 13, 2015 at 1:39 AM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
You might find this interesting https://github.com/Psycojoker/baron
The introduction states "Baron is a Full Syntax Tree (FST) library for Python. By opposition to an AST which drops some syntax information in the process of its creation (like empty lines, comments, formatting), a FST keeps everything and guarantees the operation fst_to_code(code_to_fst(source_code)) == source_code.".
There's one like this in the stdlib too! It's in lib2to3 and even preserves comments and whitespace. It's used as the basis for the 2to3 fixers. -- --Guido van Rossum (python.org/~guido)