paul@0 | 1 | """Package for parsing and compiling Python source code |
paul@0 | 2 | |
paul@0 | 3 | There are several functions defined at the top level that are imported |
paul@0 | 4 | from modules contained in the package. |
paul@0 | 5 | |
paul@0 | 6 | parse(buf, mode="exec") -> AST |
paul@0 | 7 | Converts a string containing Python source code to an abstract |
paul@0 | 8 | syntax tree (AST). The AST is defined in compiler.ast. |
paul@0 | 9 | |
paul@0 | 10 | parseFile(path) -> AST |
paul@0 | 11 | The same as parse(open(path)) |
paul@0 | 12 | |
paul@0 | 13 | walk(ast, visitor, verbose=None) |
paul@0 | 14 | Does a pre-order walk over the ast using the visitor instance. |
paul@0 | 15 | See compiler.visitor for details. |
paul@0 | 16 | |
paul@0 | 17 | compile(source, filename, mode, flags=None, dont_inherit=None) |
paul@0 | 18 | Returns a code object. A replacement for the builtin compile() function. |
paul@0 | 19 | |
paul@0 | 20 | compileFile(filename) |
paul@0 | 21 | Generates a .pyc file by compiling filename. |
paul@0 | 22 | """ |
paul@0 | 23 | |
paul@0 | 24 | import warnings |
paul@0 | 25 | |
paul@0 | 26 | warnings.warn("The compiler package is deprecated and removed in Python 3.x.", |
paul@0 | 27 | DeprecationWarning, stacklevel=2) |
paul@0 | 28 | |
paul@0 | 29 | from compiler.transformer import parse, parseFile |
paul@0 | 30 | from compiler.visitor import walk |
paul@0 | 31 | from compiler.pycodegen import compile, compileFile |