diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-09-17 21:02:51 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-09-17 21:02:51 (GMT) |
commit | 9dca36432e4526da9c5885e86782e7dfa5432c42 (patch) | |
tree | a30bc1744590e05b731eb077d1d261b544270ccf /Lib/compiler/__init__.py | |
parent | c8ed18a4e3756f0cccbcddd10323ef536ad003ec (diff) | |
download | cpython-9dca36432e4526da9c5885e86782e7dfa5432c42.zip cpython-9dca36432e4526da9c5885e86782e7dfa5432c42.tar.gz cpython-9dca36432e4526da9c5885e86782e7dfa5432c42.tar.bz2 |
API change:
compile() becomes replacement for builtin compile()
compileFile() generates a .pyc from a .py
both are exported in __init__
compiler.parse() gets optional second argument to specify compilation
mode, e.g. single, eval, exec
Add AbstractCompileMode as parent class and Module, Expression, and
Interactive as concrete subclasses. Each corresponds to a compilation
mode.
THe AbstractCompileMode instances in turn delegate to CodeGeneration
subclasses specialized for their particular functions --
ModuleCodeGenerator, ExpressionCodeGeneration,
InteractiveCodeGenerator.
Diffstat (limited to 'Lib/compiler/__init__.py')
-rw-r--r-- | Lib/compiler/__init__.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/compiler/__init__.py b/Lib/compiler/__init__.py index 13855f9..97d9c76 100644 --- a/Lib/compiler/__init__.py +++ b/Lib/compiler/__init__.py @@ -3,7 +3,7 @@ There are several functions defined at the top level that are imported from modules contained in the package. -parse(buf) -> AST +parse(buf, mode="exec") -> AST Converts a string containing Python source code to an abstract syntax tree (AST). The AST is defined in compiler.ast. @@ -14,11 +14,14 @@ walk(ast, visitor, verbose=None) Does a pre-order walk over the ast using the visitor instance. See compiler.visitor for details. -compile(filename) +compile(source, filename, mode, flags=None, dont_inherit=None) + Returns a code object. A replacement for the builtin compile() function. + +compileFile(filename) Generates a .pyc file by compilining filename. """ from transformer import parse, parseFile from visitor import walk -from pycodegen import compile +from pycodegen import compile, compileFile |