ASPN ActiveState Programmer Network
  ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups | Web Services
SEARCH
advanced | search help

Reference
ActivePython 2.4
Python Documentation
Library Reference
Front Matter
Contents
1. Introduction
2. Built-In Objects
3. Python Runtime Services
4. String Services
5. Miscellaneous Services
6. Generic Operating System Services
7. Optional Operating System Services
8. Unix Specific Services
9. The Python Debugger
10. The Python Profiler
11. Internet Protocols and Support
12. Internet Data Handling
13. Structured Markup Processing Tools
14. Multimedia Services
15. Cryptographic Services
16. Graphical User Interfaces with Tk
17. Restricted Execution
18. Python Language Services
19. Python compiler package
19.1 The basic interface
19.2 Limitations
19.3 Python Abstract Syntax
19.4 Using Visitors to Walk ASTs
19.5 Bytecode Generation
20. SGI IRIX Specific Services
21. SunOS Specific Services
22. MS Windows Specific Services
A. Undocumented Modules
B. Reporting Bugs
C. History and License
Module Index
Index
About this document ...

MyASPN >> Reference >> ActivePython 2.4 >> Python Documentation >> Library Reference
ActivePython 2.4 documentation


19. Python compiler package

The Python compiler package is a tool for analyzing Python source code and generating Python bytecode. The compiler contains libraries to generate an abstract syntax tree from Python source code and to generate Python bytecode from the tree.

The compiler package is a Python source to bytecode translator written in Python. It uses the built-in parser and standard parser module to generated a concrete syntax tree. This tree is used to generate an abstract syntax tree (AST) and then Python bytecode.

The full functionality of the package duplicates the builtin compiler provided with the Python interpreter. It is intended to match its behavior almost exactly. Why implement another compiler that does the same thing? The package is useful for a variety of purposes. It can be modified more easily than the builtin compiler. The AST it generates is useful for analyzing Python source code.

This chapter explains how the various components of the compiler package work. It blends reference material with a tutorial.

The following modules are part of the compiler package:

compiler  
compiler.ast  
compiler.visitor  

See About this document... for information on suggesting changes.

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState 2004 All rights reserved