Mercurial > cpython-lru_cache-weakref
diff Doc/lib/libparser.tex @ 12223:e82e82b3b9ad legacy-trunk
Merged changes from the 1.5.2p2 release.
(Very rough.)
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Mon, 03 Apr 2000 20:13:55 +0000 |
| parents | 17e12305973e |
| children | 3f06f4765ba4 |
line wrap: on
line diff
--- a/Doc/lib/libparser.tex Mon Apr 03 15:42:13 2000 +0000 +++ b/Doc/lib/libparser.tex Mon Apr 03 20:13:55 2000 +0000 @@ -1,5 +1,6 @@ -% libparser.tex -% +\section{\module{parser} --- + Access Python parse trees} + % Copyright 1995 Virginia Polytechnic Institute and State University % and Fred L. Drake, Jr. This copyright notice must be distributed on % all copies, but this document otherwise may be distributed as part @@ -7,10 +8,6 @@ % in any representation, either on paper or electronically. This % restriction does not affect other elements in a distributed package % in any way. -% - -\section{\module{parser} --- - Access Python parse trees} \declaremodule{builtin}{parser} \modulesynopsis{Access parse trees for Python source code.} @@ -166,7 +163,7 @@ \begin{funcdesc}{ast2list}{ast\optional{, line_info}} This function accepts an AST object from the caller in \var{ast} and returns a Python list representing the -equivelent parse tree. The resulting list representation can be used +equivalent parse tree. The resulting list representation can be used for inspection or the creation of a new parse tree in list form. This function does not fail so long as memory is available to build the list representation. If the parse tree will only be used for @@ -185,7 +182,7 @@ \begin{funcdesc}{ast2tuple}{ast\optional{, line_info}} This function accepts an AST object from the caller in \var{ast} and returns a Python tuple representing the -equivelent parse tree. Other than returning a tuple instead of a +equivalent parse tree. Other than returning a tuple instead of a list, this function is identical to \function{ast2list()}. If \var{line_info} is true, line number information will be @@ -238,7 +235,7 @@ \begin{funcdesc}{issuite}{ast} This function mirrors \function{isexpr()} in that it reports whether an AST object represents an \code{'exec'} form, commonly known as a -``suite.'' It is not safe to assume that this function is equivelent +``suite.'' It is not safe to assume that this function is equivalent to \samp{not isexpr(\var{ast})}, as additional syntactic fragments may be supported in the future. \end{funcdesc} @@ -274,9 +271,6 @@ \subsection{AST Objects \label{AST Objects}} -AST objects returned by \function{expr()}, \function{suite()} and -\function{sequence2ast()} have no methods of their own. - Ordered and equality comparisons are supported between AST objects. Pickling of AST objects (using the \refmodule{pickle} module) is also supported. @@ -326,7 +320,7 @@ While many useful operations may take place between parsing and bytecode generation, the simplest operation is to do nothing. For this purpose, using the \module{parser} module to produce an -intermediate data structure is equivelent to the code +intermediate data structure is equivalent to the code \begin{verbatim} >>> code = compile('a + 5', 'eval') @@ -335,7 +329,7 @@ 10 \end{verbatim} -The equivelent operation using the \module{parser} module is somewhat +The equivalent operation using the \module{parser} module is somewhat longer, and allows the intermediate internal parse tree to be retained as an AST object: @@ -474,7 +468,7 @@ By replacing the actual docstring with something to signify a variable component of the tree, we allow a simple pattern matching approach to -check any given subtree for equivelence to the general pattern for +check any given subtree for equivalence to the general pattern for docstrings. Since the example demonstrates information extraction, we can safely require that the tree be in tuple form rather than list form, allowing a simple variable representation to be
