compiler package vs parser
robin at NOSPAMreportlab.com
Thu Apr 16 23:11:53 CEST 2009
Kay Schluehr wrote:
> On 16 Apr., 11:41, Robin Becker <ro... at reportlab.com> wrote:
>> Is the compiler package actually supposed to be equivalent to the parser module?
> No. The parser module creates a concrete parse tree ( CST ) whereas
> the compiler package transforms this CST into an AST for subsequent
> computations. In more recent versions those CST -> AST transformations
> are performed by the runtime and the Python compiler uses those
> internally produced ASTs. The Python 2.6 API to ASTs is the ast module.
OK so I've been using the old compiler package to synthesize my trees,
but presumably there are equivalents in the ast module so I could
re-code my stuff to use the new module fairly easily. Presumably
compiling the ast trees should produce identical code.
On the other hand it seems as though there are at least three
generations of AST lying about with compiler, ast (and _ast in 2.5) so
multi version coding will be hard.
More information about the Python-list