__init__.py 851 Bytes
Newer Older
Jeremy Hylton's avatar
Jeremy Hylton committed
1 2 3 4 5
"""Package for parsing and compiling Python source code

There are several functions defined at the top level that are imported
from modules contained in the package.

Jeremy Hylton's avatar
Jeremy Hylton committed
6
parse(buf, mode="exec") -> AST
Jeremy Hylton's avatar
Jeremy Hylton committed
7
    Converts a string containing Python source code to an abstract
Jeremy Hylton's avatar
Jeremy Hylton committed
8 9 10 11 12 13 14 15
    syntax tree (AST).  The AST is defined in compiler.ast.

parseFile(path) -> AST
    The same as parse(open(path))

walk(ast, visitor, verbose=None)
    Does a pre-order walk over the ast using the visitor instance.
    See compiler.visitor for details.
16

Jeremy Hylton's avatar
Jeremy Hylton committed
17
compile(source, filename, mode, flags=None, dont_inherit=None)
Tim Peters's avatar
Tim Peters committed
18
    Returns a code object.  A replacement for the builtin compile() function.
Jeremy Hylton's avatar
Jeremy Hylton committed
19 20

compileFile(filename)
Andrew M. Kuchling's avatar
Andrew M. Kuchling committed
21
    Generates a .pyc file by compiling filename.
Jeremy Hylton's avatar
Jeremy Hylton committed
22 23 24 25
"""

from transformer import parse, parseFile
from visitor import walk
Jeremy Hylton's avatar
Jeremy Hylton committed
26
from pycodegen import compile, compileFile