mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Remove "ast" aliases from the parser module.
This commit is contained in:
parent
4dcce175e2
commit
30704ea0db
3 changed files with 17 additions and 32 deletions
|
@ -30,11 +30,6 @@ the code forming the application. It is also faster.
|
|||
Syntax Tree (AST) generation and compilation stage, using the :mod:`ast`
|
||||
module.
|
||||
|
||||
The :mod:`parser` module exports the names documented here also with "st"
|
||||
replaced by "ast"; this is a legacy from the time when there was no other
|
||||
AST and has nothing to do with the AST found in Python 2.5. This is also the
|
||||
reason for the functions' keyword arguments being called *ast*, not *st*.
|
||||
|
||||
There are a few things to note about this module which are important to making
|
||||
use of the data structures created. This is not a tutorial on editing the parse
|
||||
trees for Python code, but some examples of using the :mod:`parser` module are
|
||||
|
@ -170,9 +165,9 @@ executable code objects. Parse trees may be extracted with or without line
|
|||
numbering information.
|
||||
|
||||
|
||||
.. function:: st2list(ast[, line_info])
|
||||
.. function:: st2list(st[, line_info])
|
||||
|
||||
This function accepts an ST object from the caller in *ast* and returns a
|
||||
This function accepts an ST object from the caller in *st* and returns a
|
||||
Python list representing the 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
|
||||
|
@ -188,9 +183,9 @@ numbering information.
|
|||
This information is omitted if the flag is false or omitted.
|
||||
|
||||
|
||||
.. function:: st2tuple(ast[, line_info])
|
||||
.. function:: st2tuple(st[, line_info])
|
||||
|
||||
This function accepts an ST object from the caller in *ast* and returns a
|
||||
This function accepts an ST object from the caller in *st* and returns a
|
||||
Python tuple representing the equivalent parse tree. Other than returning a
|
||||
tuple instead of a list, this function is identical to :func:`st2list`.
|
||||
|
||||
|
@ -199,7 +194,7 @@ numbering information.
|
|||
information is omitted if the flag is false or omitted.
|
||||
|
||||
|
||||
.. function:: compilest(ast[, filename='<syntax-tree>'])
|
||||
.. function:: compilest(st[, filename='<syntax-tree>'])
|
||||
|
||||
.. index::
|
||||
builtin: exec
|
||||
|
@ -208,7 +203,7 @@ numbering information.
|
|||
The Python byte compiler can be invoked on an ST object to produce code objects
|
||||
which can be used as part of a call to the built-in :func:`exec` or :func:`eval`
|
||||
functions. This function provides the interface to the compiler, passing the
|
||||
internal parse tree from *ast* to the parser, using the source file name
|
||||
internal parse tree from *st* to the parser, using the source file name
|
||||
specified by the *filename* parameter. The default value supplied for *filename*
|
||||
indicates that the source was an ST object.
|
||||
|
||||
|
@ -233,22 +228,22 @@ determine if an ST was created from source code via :func:`expr` or
|
|||
:func:`suite` or from a parse tree via :func:`sequence2st`.
|
||||
|
||||
|
||||
.. function:: isexpr(ast)
|
||||
.. function:: isexpr(st)
|
||||
|
||||
.. index:: builtin: compile
|
||||
|
||||
When *ast* represents an ``'eval'`` form, this function returns true, otherwise
|
||||
When *st* represents an ``'eval'`` form, this function returns true, otherwise
|
||||
it returns false. This is useful, since code objects normally cannot be queried
|
||||
for this information using existing built-in functions. Note that the code
|
||||
objects created by :func:`compilest` cannot be queried like this either, and
|
||||
are identical to those created by the built-in :func:`compile` function.
|
||||
|
||||
|
||||
.. function:: issuite(ast)
|
||||
.. function:: issuite(st)
|
||||
|
||||
This function mirrors :func:`isexpr` in that it reports whether an ST object
|
||||
represents an ``'exec'`` form, commonly known as a "suite." It is not safe to
|
||||
assume that this function is equivalent to ``not isexpr(ast)``, as additional
|
||||
assume that this function is equivalent to ``not isexpr(st)``, as additional
|
||||
syntactic fragments may be supported in the future.
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue