Skip to content

Commit 193edf5

Browse files
committed
compiler: Capture compiler package from CPython git 2.7 branch.
The latest active commit is 994f04dbf576f4ebafb9de2bc6821e15cb0de0ea.
1 parent 63fd147 commit 193edf5

File tree

11 files changed

+6094
-0
lines changed

11 files changed

+6094
-0
lines changed

compiler/__init__.py

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

0 commit comments

Comments
 (0)