Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="lib.html" title='Python Library Reference' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="next" href="sgi.html" /> | |
13 | <link rel="prev" href="language.html" /> | |
14 | <link rel="parent" href="lib.html" /> | |
15 | <link rel="next" href="module-compiler.html" /> | |
16 | <meta name='aesop' content='information' /> | |
17 | <title>19. Python compiler package </title> | |
18 | </head> | |
19 | <body> | |
20 | <DIV CLASS="navigation"> | |
21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
23 | <tr> | |
24 | <td class='online-navigation'><a rel="prev" title="18.12 distutils " | |
25 | href="module-distutils.html"><img src='../icons/previous.png' | |
26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
27 | <td class='online-navigation'><a rel="parent" title="Python Library Reference" | |
28 | href="lib.html"><img src='../icons/up.png' | |
29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
30 | <td class='online-navigation'><a rel="next" title="19.1 The basic interface" | |
31 | href="module-compiler.html"><img src='../icons/next.png' | |
32 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
33 | <td align="center" width="100%">Python Library Reference</td> | |
34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
35 | href="contents.html"><img src='../icons/contents.png' | |
36 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
38 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
39 | <td class='online-navigation'><a rel="index" title="Index" | |
40 | href="genindex.html"><img src='../icons/index.png' | |
41 | border='0' height='32' alt='Index' width='32' /></A></td> | |
42 | </tr></table> | |
43 | <div class='online-navigation'> | |
44 | <b class="navlabel">Previous:</b> | |
45 | <a class="sectref" rel="prev" href="module-distutils.html">18.12 distutils </A> | |
46 | <b class="navlabel">Up:</b> | |
47 | <a class="sectref" rel="parent" href="lib.html">Python Library Reference</A> | |
48 | <b class="navlabel">Next:</b> | |
49 | <a class="sectref" rel="next" href="module-compiler.html">19.1 The basic interface</A> | |
50 | </div> | |
51 | <hr /></div> | |
52 | </DIV> | |
53 | <!--End of Navigation Panel--> | |
54 | ||
55 | <H1><A NAME="SECTION0021000000000000000000"></A><A NAME="compiler"></A> | |
56 | <BR> | |
57 | 19. Python compiler package | |
58 | </H1> | |
59 | ||
60 | <P> | |
61 | ||
62 | <P> | |
63 | The Python compiler package is a tool for analyzing Python source code | |
64 | and generating Python bytecode. The compiler contains libraries to | |
65 | generate an abstract syntax tree from Python source code and to | |
66 | generate Python bytecode from the tree. | |
67 | ||
68 | <P> | |
69 | The <tt class="module"><a href="module-compiler.html">compiler</a></tt> package is a Python source to bytecode | |
70 | translator written in Python. It uses the built-in parser and | |
71 | standard <tt class="module"><a href="module-parser.html">parser</a></tt> module to generated a concrete syntax | |
72 | tree. This tree is used to generate an abstract syntax tree (AST) and | |
73 | then Python bytecode. | |
74 | ||
75 | <P> | |
76 | The full functionality of the package duplicates the builtin compiler | |
77 | provided with the Python interpreter. It is intended to match its | |
78 | behavior almost exactly. Why implement another compiler that does the | |
79 | same thing? The package is useful for a variety of purposes. It can | |
80 | be modified more easily than the builtin compiler. The AST it | |
81 | generates is useful for analyzing Python source code. | |
82 | ||
83 | <P> | |
84 | This chapter explains how the various components of the | |
85 | <tt class="module"><a href="module-compiler.html">compiler</a></tt> package work. It blends reference material with | |
86 | a tutorial. | |
87 | ||
88 | <P> | |
89 | The following modules are part of the <tt class="module"><a href="module-compiler.html">compiler</a></tt> package: | |
90 | ||
91 | <P> | |
92 | <table class='synopsistable' valign='baseline'> | |
93 | <tr class='oddrow'> | |
94 | <td><b><tt class='module'><a href='module-compiler.html'>compiler</a></tt></b></td> | |
95 | <td> </td> | |
96 | <td class='synopsis'></td></tr> | |
97 | <tr><td><b><tt class='module'><a href='module-compiler.ast.html'>compiler.ast</a></tt></b></td> | |
98 | <td> </td> | |
99 | <td class='synopsis'></td></tr> | |
100 | <tr class='oddrow'> | |
101 | <td><b><tt class='module'><a href='module-compiler.visitor.html'>compiler.visitor</a></tt></b></td> | |
102 | <td> </td> | |
103 | <td class='synopsis'></td></tr> | |
104 | </table> | |
105 | ||
106 | <BR> | |
107 | <P> | |
108 | ||
109 | <DIV CLASS="navigation"> | |
110 | <div class='online-navigation'> | |
111 | <p></p><hr /> | |
112 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
113 | <tr> | |
114 | <td class='online-navigation'><a rel="prev" title="18.12 distutils " | |
115 | href="module-distutils.html"><img src='../icons/previous.png' | |
116 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
117 | <td class='online-navigation'><a rel="parent" title="Python Library Reference" | |
118 | href="lib.html"><img src='../icons/up.png' | |
119 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
120 | <td class='online-navigation'><a rel="next" title="19.1 The basic interface" | |
121 | href="module-compiler.html"><img src='../icons/next.png' | |
122 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
123 | <td align="center" width="100%">Python Library Reference</td> | |
124 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
125 | href="contents.html"><img src='../icons/contents.png' | |
126 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
127 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
128 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
129 | <td class='online-navigation'><a rel="index" title="Index" | |
130 | href="genindex.html"><img src='../icons/index.png' | |
131 | border='0' height='32' alt='Index' width='32' /></A></td> | |
132 | </tr></table> | |
133 | <div class='online-navigation'> | |
134 | <b class="navlabel">Previous:</b> | |
135 | <a class="sectref" rel="prev" href="module-distutils.html">18.12 distutils </A> | |
136 | <b class="navlabel">Up:</b> | |
137 | <a class="sectref" rel="parent" href="lib.html">Python Library Reference</A> | |
138 | <b class="navlabel">Next:</b> | |
139 | <a class="sectref" rel="next" href="module-compiler.html">19.1 The basic interface</A> | |
140 | </div> | |
141 | </div> | |
142 | <hr /> | |
143 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
144 | </DIV> | |
145 | <!--End of Navigation Panel--> | |
146 | <ADDRESS> | |
147 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
148 | </ADDRESS> | |
149 | </BODY> | |
150 | </HTML> |