Message256543
"The fact that ast combines strings and does not maintain the original syntax of the document means that original syntax information is lost and a writer walking the abstract syntax tree is unable to reproduce the original syntax of the document."
You should take a look at the RedBaron project which implements a Python parser, provide a high-level representation of the code *and* allow to regenerates the Python code without loosing the indentation, comment, or anything else.
https://redbaron.readthedocs.org/en/latest/
"To achieve this, [RedBaron] is based on Baron a lossless AST for Python that guarantees the operation
fst_to_code(code_to_fst(source_code)) == source_code." |
|
Date |
User |
Action |
Args |
2015-12-16 21:58:20 | vstinner | set | recipients:
+ vstinner, brett.cannon, georg.brandl, ncoghlan, benjamin.peterson, r.david.murray, SilentGhost, myronww |
2015-12-16 21:58:20 | vstinner | set | messageid: <1450303100.03.0.851455531903.issue25886@psf.upfronthosting.co.za> |
2015-12-16 21:58:20 | vstinner | link | issue25886 messages |
2015-12-16 21:58:19 | vstinner | create | |
|