AlkantarClanX12

Your IP : 3.149.23.124


Current Path : /proc/self/root/opt/alt/python33/lib64/python3.3/lib2to3/pgen2/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python33/lib64/python3.3/lib2to3/pgen2/__pycache__/parse.cpython-33.pyo

�
��fuc@sFdZddlmZGdd�de�ZGdd�de�ZdS(u�Parser engine for the grammar tables generated by pgen.

The grammar table must be loaded first.

See Parser/parser.c in the Python distribution for additional info on
how this parsing engine works.

i(utokencBs&|EeZdZdZdd�ZdS(u
ParseErroru(Exception to signal the parser is stuck.cCsHtj|d||||f�||_||_||_||_dS(Nu!%s: type=%r, value=%r, context=%r(u	Exceptionu__init__umsgutypeuvalueucontext(uselfumsgutypeuvalueucontext((u8/opt/alt/python33/lib64/python3.3/lib2to3/pgen2/parse.pyu__init__s			uParseError.__init__N(u__name__u
__module__u__qualname__u__doc__u__init__(u
__locals__((u8/opt/alt/python33/lib64/python3.3/lib2to3/pgen2/parse.pyu
ParseErrorsu
ParseErrorcBst|EeZdZdZddd�Zddd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�ZdS(uParseru5Parser engine.

    The proper usage sequence is:

    p = Parser(grammar, [converter])  # create instance
    p.setup([start])                  # prepare for parsing
    <for each input token>:
        if p.addtoken(...):           # parse a token; may raise ParseError
            break
    root = p.rootnode                 # root of abstract syntax tree

    A Parser instance may be reused by calling setup() repeatedly.

    A Parser instance contains state pertaining to the current token
    sequence, and should not be used concurrently by different threads
    to parse separate token sequences.

    See driver.py for how to get input tokens by tokenizing a file or
    string.

    Parsing is complete when addtoken() returns True; the root of the
    abstract syntax tree can then be retrieved from the rootnode
    instance variable.  When a syntax error occurs, addtoken() raises
    the ParseError exception.  There is no error recovery; the parser
    cannot be used after a syntax error was reported (but it can be
    reinitialized by calling setup()).

    cCs"||_|pdd�|_dS(u�Constructor.

        The grammar argument is a grammar.Grammar instance; see the
        grammar module for more information.

        The parser is not ready yet for parsing; you must call the
        setup() method to get it started.

        The optional convert argument is a function mapping concrete
        syntax tree nodes to abstract syntax tree nodes.  If not
        given, no conversion is done and the syntax tree produced is
        the concrete syntax tree.  If given, it must be a function of
        two arguments, the first being the grammar (a grammar.Grammar
        instance), and the second being the concrete syntax tree node
        to be converted.  The syntax tree is converted from the bottom
        up.

        A concrete syntax tree node is a (type, value, context, nodes)
        tuple, where type is the node type (a token or symbol number),
        value is None for symbols and a string for tokens, context is
        None or an opaque value used for error reporting (typically a
        (lineno, offset) pair), and nodes is a list of children for
        symbols, and None for tokens.

        An abstract syntax tree node may be anything; this is entirely
        up to the converter function.

        cSs|S(N((ugrammarunode((u8/opt/alt/python33/lib64/python3.3/lib2to3/pgen2/parse.pyu<lambda>Wsu!Parser.__init__.<locals>.<lambda>N(ugrammaruconvert(uselfugrammaruconvert((u8/opt/alt/python33/lib64/python3.3/lib2to3/pgen2/parse.pyu__init__9s	uParser.__init__cCsk|dkr|jj}n|ddgf}|jj|d|f}|g|_d|_t�|_dS(u�Prepare for parsing.

        This *must* be called before starting to parse.

        The optional argument is an alternative start symbol; it
        defaults to the grammar's start symbol.

        You can use a Parser instance to parse any number of programs;
        each time you call setup() the parser is reset to an initial
        state determined by the (implicit or explicit) start symbol.

        iN(uNoneugrammarustartudfasustackurootnodeusetu
used_names(uselfustartunewnodeu
stackentry((u8/opt/alt/python33/lib64/python3.3/lib2to3/pgen2/parse.pyusetupYs
	uParser.setupcCs�|j|||�}x�|jd\}}}|\}}	||}
x_|
D]\}}|jj|\}
}||kr�|j||||�|}xV||d|fgkr�|j�|js�dS|jd	\}}}|\}}	q�Wd
S|
dkrK|jj|
}|\}}||krM|j	|
|jj|
||�PqMqKqKWd|f|
kr�|j�|js�t
d|||��q�qt
d|||��qdS(u<Add a token; return True iff this is the end of the program.iiiutoo much inputu	bad inputNi����Ti����F(uclassifyustackugrammarulabelsushiftupopuTrueuFalseudfasupushu
ParseError(uselfutypeuvalueucontextuilabeludfaustateunodeustatesufirstuarcsuiunewstateutuvuitsdfau	itsstatesuitsfirst((u8/opt/alt/python33/lib64/python3.3/lib2to3/pgen2/parse.pyuaddtokenqs:

	 
	uParser.addtokencCs�|tjkrG|jj|�|jjj|�}|dk	rG|Sn|jjj|�}|dkr�t	d|||��n|S(u&Turn a token into a label.  (Internal)u	bad tokenN(
utokenuNAMEu
used_namesuaddugrammarukeywordsugetuNoneutokensu
ParseError(uselfutypeuvalueucontextuilabel((u8/opt/alt/python33/lib64/python3.3/lib2to3/pgen2/parse.pyuclassify�suParser.classifyc	Csw|jd\}}}|||df}|j|j|�}|dk	r]|dj|�n|||f|jd<dS(uShift a token.  (Internal)iNi����i����i����(ustackuNoneuconvertugrammaruappend(	uselfutypeuvalueunewstateucontextudfaustateunodeunewnode((u8/opt/alt/python33/lib64/python3.3/lib2to3/pgen2/parse.pyushift�suParser.shiftc	Cs[|jd\}}}|d|gf}|||f|jd<|jj|d|f�dS(uPush a nonterminal.  (Internal)iiNi����i����(ustackuNoneuappend(	uselfutypeunewdfaunewstateucontextudfaustateunodeunewnode((u8/opt/alt/python33/lib64/python3.3/lib2to3/pgen2/parse.pyupush�suParser.pushcCs�|jj�\}}}|j|j|�}|dk	r�|jrl|jd\}}}|dj|�q�||_|j|j_ndS(uPop a nonterminal.  (Internal)iNi����i����(ustackupopuconvertugrammaruNoneuappendurootnodeu
used_names(uselfupopdfaupopstateupopnodeunewnodeudfaustateunode((u8/opt/alt/python33/lib64/python3.3/lib2to3/pgen2/parse.pyupop�s		u
Parser.popN(u__name__u
__module__u__qualname__u__doc__uNoneu__init__usetupuaddtokenuclassifyushiftupushupop(u
__locals__((u8/opt/alt/python33/lib64/python3.3/lib2to3/pgen2/parse.pyuParsers 0	uParserN(u__doc__uutokenu	Exceptionu
ParseErroruobjectuParser(((u8/opt/alt/python33/lib64/python3.3/lib2to3/pgen2/parse.pyu<module>s