
Ka¸2c      s‡     d  Z  7 d  9 d Z : d Z A d f  d „  ƒ  YZ ¤ d e f d „  ƒ  YZ À d e f d „  ƒ  YZ Ô d	 e f d
 „  ƒ  YZ d S(   sË  Object-oriented interface to the parser module.

This module exports four classes which together provide an interface
to the parser module.  Together, the three classes represent two ways
to create parsed representations of Python source and the two starting
data types (source text and tuple representations).  Each class
provides interfaces which are identical other than the constructors.
The constructors are described in detail in the documentation for each
class and the remaining, shared portion of the interface is documented
below.  Briefly, the classes provided are:

AST
    Defines the primary interface to the AST objects and supports creation
    from the tuple representation of the parse tree.

ExpressionAST
    Supports creation of expression constructs from source text.

SuiteAST
    Supports creation of statement suites from source text.

FileSuiteAST
    Convenience subclass of the `SuiteAST' class; loads source text of the
    suite from an external file.

Common Methods
--------------

Aside from the constructors, several methods are provided to allow
access to the various interpretations of the parse tree and to check
conditions of the construct represented by the parse tree.

ast()
    Returns the corresponding `parser.ASTType' object.

code()
    Returns the compiled code object.

filename()
    Returns the name of the associated source file, if known.

isExpression()
    Returns true value if parse tree represents an expression, or a false
    value otherwise.

isSuite()
    Returns true value if parse tree represents a suite of statements, or
    a false value otherwise.

text()
    Returns the source text, or None if not available.

tuple()
    Returns the tuple representing the parse tree.
s   $Revision: 1.2 $sü   Copyright (c) 1995, 1996 by Fred L. Drake, Jr.

This software may be used and distributed freely for any purpose provided
that this notice is included unchanged on any and all copies.  The author
does not warrant or guarantee this software in any way.
s   ASTc     sÃ   A d  Z  I d  J k Z K e Z M e Z N e Z O e Z P d Z Q e Z S d „  Z	 d d d „ Z
 m d d „ Z x d „  Z „ d „  Z ‰ d „  Z Ž d	 „  Z ˜ d
 „  Z  d „  Z RS(   sa  Base class for Abstract Syntax Tree objects.

    Creates an Abstract Syntax Tree based on the tuple representation
    of the parse tree.  The parse tree can represent either an
    expression or a suite; which will be recognized automatically.
    This base class provides all of the query methods for subclass
    objects defined in this module.
    s   unknownc   s‡   S \ d  ] t  | ƒ t  f  ƒ j	 o ^ t d ‚ n ` | |  _ a |  i i | ƒ |  _ b |  i i |  i ƒ o d p d |  _	 d S(   s+  Create an `AST' instance from a tuple-tree representation.

	tuple
	    The tuple tree to convert.

	The tuple-tree may represent either an expression or a suite; the
	type will be determined automatically.  Line number information may
	optionally be present for any subset of the terminal tokens.
	s(   Base AST class requires tuple parameter.s
   expressions   suiteN(
   s   types   tuples	   TypeErrors   selfs   _tupls   _ps	   tuple2asts   _asts   isexprs   _type(   s   selfs   tuples   /usr/lib/python1.4/AST.pys   __init__c   s'   d j d  k |  i i |  i | ƒ Sd S(   s¥   Returns a fresh list representing the parse tree.

	line_info
	    If true, includes line number information for terminal tokens in
	    the output data structure,
	N(   s   selfs   _ps   ast2lists   _asts	   line_info(   s   selfs	   line_infos   /usr/lib/python1.4/AST.pys   listi    c   sM   m s d  t |  i t j o" u |  i i |  i | ƒ |  _ n v |  i Sd S(   s¢   Returns the tuple representing the parse tree.

	line_info
	    If true, includes line number information for terminal tokens in
	    the output data structure,
	N(   s   selfs   _tupls   Nones   _ps	   ast2tuples   _asts	   line_info(   s   selfs	   line_infos   /usr/lib/python1.4/AST.pys   tuplec   sE   x  d  € |  i o  |  i i |  i ƒ |  _ n ‚ |  i Sd S(   s
  Returns the compiled code object.

	The code object returned by this method may be passed to the
	exec statement if `AST.isSuite()' is true or to the eval()
	function if `AST.isExpression()' is true.  All the usual rules
	regarding execution of code objects apply.
	N(   s   selfs   _codes   _ps
   compileasts   _ast(   s   selfs   /usr/lib/python1.4/AST.pys   codec   s   „ † d  ‡ |  i Sd S(   s4   Returns the corresponding `parser.ASTType' object.
	N(   s   selfs   _ast(   s   selfs   /usr/lib/python1.4/AST.pys   astc   s   ‰ ‹ d  Œ t  Sd S(   s8   Returns the name of the source file if known, or None.
	N(   s   None(   s   selfs   /usr/lib/python1.4/AST.pys   filenamec   s   Ž • d  – |  i Sd S(   só   Returns the source text, or None if not available.

	If the instance is of class `AST', None is returned since no
	source text is available.  If of class `ExpressionAST' or
	`SuiteAST', the source text passed to the constructor is
	returned.
	N(   s   selfs   _text(   s   selfs   /usr/lib/python1.4/AST.pys   textc   s   ˜ š d  › |  i d j Sd S(   s?   Determine if `AST' instance represents a suite of statements.
	s   suiteN(   s   selfs   _type(   s   selfs   /usr/lib/python1.4/AST.pys   isSuitec   s    Ÿ d    |  i d j Sd S(   s7   Determine if `AST' instance represents an expression.
	s
   expressionN(   s   selfs   _type(   s   selfs   /usr/lib/python1.4/AST.pys   isExpression(   s   __doc__s   parsers   _ps   Nones   _texts   _codes   _asts   _types   _tupls   __init__s   lists   tuples   codes   asts   filenames   texts   isSuites   isExpression(    s   /usr/lib/python1.4/AST.pys   ASTs   SuiteASTc     s?   ¤ d  Z  « d  ¬ d Z ® d „  Z ¹ d „  Z ¼ d „  Z RS(   s+  Statement suite parse tree representation.

    This subclass of the `AST' base class represents statement suites
    parsed from the source text of a Python suite.  If the source text
    does not represent a parsable suite of statements, the appropriate
    exception is raised by the parser.
    s   suitec   s^   ® ³ d  ´ t  | ƒ t  d ƒ j	 o µ t d ‚ n ¶ | |  _ · |  i i | ƒ |  _ d S(   sM   Initialize a `SuiteAST' from source text.

	text
	    Source text to parse.
	s    s(   SuiteAST requires source text parameter.N(   s   types   texts	   TypeErrors   selfs   _texts   _ps   suites   _ast(   s   selfs   texts   /usr/lib/python1.4/AST.pys   __init__c   s   ¹ º d Sd  S(   Ni   (    (   s   selfs   /usr/lib/python1.4/AST.pys   isSuitec   s   ¼ ½ d Sd  S(   Ni    (    (   s   selfs   /usr/lib/python1.4/AST.pys   isExpression(   s   __doc__s   _types   __init__s   isSuites   isExpression(    s   /usr/lib/python1.4/AST.pys   SuiteASTs   FileSuiteASTc     s*   À d  Z  Å d  Æ d „  Z Ï d „  Z RS(   s°   Representation of a python source file syntax tree.

    This provides a convenience wrapper around the `SuiteAST' class to
    load the source text from an external file.
    c   s9   Æ Ë d  Ì | |  _ Í t i |  t | ƒ i ƒ  ƒ d S(   s_   Initialize a `SuiteAST' from a source file.

	fileName
	    Name of the external source file.
	N(   s   fileNames   selfs	   _fileNames   SuiteASTs   __init__s   opens   read(   s   selfs   fileNames   /usr/lib/python1.4/AST.pys   __init__c   s   Ï Ð |  i Sd  S(   N(   s   selfs	   _fileName(   s   selfs   /usr/lib/python1.4/AST.pys   filename(   s   __doc__s   __init__s   filename(    s   /usr/lib/python1.4/AST.pys   FileSuiteASTs   ExpressionASTc     s?   Ô d  Z  Û d  Ü d Z Þ d „  Z é d „  Z ì d „  Z RS(   s.  Expression parse tree representation.

    This subclass of the `AST' base class represents expression
    constructs parsed from the source text of a Python expression.  If
    the source text does not represent a parsable expression, the
    appropriate exception is raised by the Python parser.
    s
   expressionc   s^   Þ ã d  ä t  | ƒ t  d ƒ j	 o å t d ‚ n æ | |  _ ç |  i i | ƒ |  _ d S(   sR   Initialize an expression AST from source text.

	text
	    Source text to parse.
	s    s-   ExpressionAST requires source text parameter.N(   s   types   texts	   TypeErrors   selfs   _texts   _ps   exprs   _ast(   s   selfs   texts   /usr/lib/python1.4/AST.pys   __init__c   s   é ê d Sd  S(   Ni    (    (   s   selfs   /usr/lib/python1.4/AST.pys   isSuitec   s   ì í d Sd  S(   Ni   (    (   s   selfs   /usr/lib/python1.4/AST.pys   isExpression(   s   __doc__s   _types   __init__s   isSuites   isExpression(    s   /usr/lib/python1.4/AST.pys   ExpressionASTN(   s   __doc__s   __version__s   __copyright__s   ASTs   SuiteASTs   FileSuiteASTs   ExpressionAST(    s   /usr/lib/python1.4/AST.pys   ?