o
    6dk                     @   s   d dl mZmZmZmZ d dlmZ d dlZd dlm	Z	 ddl
mZmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z! e"e#dZ$G dd	 d	e%Z&dS )
    )absolute_importdivisionprint_functionunicode_literals)OrderedDictN   )Lexer	NullToken)AstAliasAstAnnotationDefAstAnnotationRefAstAnnotationTypeDefAstAttrField
AstExampleAstExampleFieldAstExampleRefAstFieldAstNamespace	AstImportAstRouteDefAstStructDefAstStructPatchAstSubtypeField	AstTagRef
AstTypeRefAstUnionDefAstUnionPatchAstVoidFieldzstone.frontend.parserc                   @   s  e Zd ZdZejZedZdddZdd Z	dd	d
Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Z d7d8 Z!d9d: Z"d;d< Z#d=d> Z$d?d@ Z%dAdB Z&dCdD Z'dEdF Z(dGdH Z)dIdJ Z*dKdL Z+dMdN Z,dOdP Z-dQdR Z.dSdT Z/dUdV Z0dWdX Z1dYdZ Z2d[d\ Z3d]d^ Z4d_d` Z5dadb Z6dcdd Z7dedf Z8dgdh Z9didj Z:dkdl Z;dmdn Z<dodp Z=dqdr Z>dsdt Z?dudv Z@dwdx ZAdydz ZBd{d| ZCd}d~ ZDdd ZEdd ZFdd ZGdd ZHdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`dd ZadS )ParserFactorya  
    After instantiating a ParserFactory, call get_parser() to get an object
    with a parse() method. It so happens that the object is also a
    ParserFactory. The purpose of get_parser() is to reset the internal state
    of the fatory. The details for why these aren't cleanly separated have to
    do with the inability to separate out the yacc.yacc BNF definition parser
    from the class methods that implement the parser handling logic.

    Due to how ply.yacc works, the docstring of each parser method is a BNF
    rule. Comments that would normally be docstrings for each parser rule
    method are kept before the method definition.
    specFc                 C   s@   || _ tj| | j | j d| _t | _g | _d | _g | _d| _d S )N)moduledebugZwrite_tablesT)r!   yaccr   lexererrorspath
anony_defs	exhausted)selfr!    r)   lC:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\stone/frontend/parser.py__init__;   s   
zParserFactory.__init__c                 C   s   d| _ g | _d| _| S )z
        Returns a ParserFactory with the state reset so it can be used to
        parse again.

        :return: ParserFactory
        NF)r%   r&   r'   r(   r)   r)   r*   
get_parserH   s   zParserFactory.get_parserNc                 C   sr   | j rJ d|| _| jj|| j| jd}| jjddd D ]\}}| jd||| jf q|| j	 d| _ |S )z
        Args:
            data (str): Raw specification text.
            path (Optional[str]): Path to specification on filesystem. Only
                used to tag tokens with the file they originated from.
        z&Must call get_parser() to reset state.)r#   r!   Nr   T)
r'   r%   r"   parser#   r!   r$   insertextendr&   )r(   datar%   Zparsed_dataerr_msglinenor)   r)   r*   r/   T   s   zParserFactory.parsec                 C   s   | j | d S N)r#   test)r(   r2   r)   r)   r*   test_lexingg   s   zParserFactory.test_lexingc                 C   s   | j S )z'Whether the lexer or parser had errors.r$   r,   r)   r)   r*   got_errors_parsingj   s   z ParserFactory.got_errors_parsingc                 C   s   | j dd S )z
        If got_errors_parsing() returns True, call this to get the errors.

        Returns:
            list[tuple[msg: str, lineno: int, path: str]]
        Nr8   r,   r)   r)   r*   
get_errorsn   s   zParserFactory.get_errorsc                 C   s   g |d< dS )z!spec : NL
                | emptyr   Nr)   r(   pr)   r)   r*   p_spec_initz   s   zParserFactory.p_spec_initc                 C      |d g|d< dS )zFspec : namespace
                | import
                | definitionr   r   Nr)   r;   r)   r)   r*   p_spec_init_decl   s   zParserFactory.p_spec_init_declc                 C   "   |d |d< |d  |d  dS )zUspec : spec namespace
                | spec import
                | spec definitionr   r      Nappendr;   r)   r)   r*   p_spec_iter   s   zParserFactory.p_spec_iterc                 C      |d |d< dS )zspec : spec NLr   r   Nr)   r;   r)   r)   r*   p_spec_ignore_newline      z#ParserFactory.p_spec_ignore_newlinec                 C   rE   )a  definition : alias
                      | annotation
                      | annotation_type
                      | struct
                      | struct_patch
                      | union
                      | union_patch
                      | router   r   Nr)   r;   r)   r)   r*   p_definition   s   	zParserFactory.p_definitionc                 C   sV   |d dkr'd}t |dkr|d }t| j|d|d|d ||d< dS td)	zWnamespace : KEYWORD ID NL
                     | KEYWORD ID NL INDENT docsection DEDENTr   	namespaceN      rA   r   zExpected namespace keyword)lenr   r%   r4   lexpos
ValueError)r(   r<   docr)   r)   r*   p_namespace   s   zParserFactory.p_namespacec                 C   s(   t | j|d|d|d |d< dS )zimport : IMPORT ID NLr   rA   r   N)r   r%   r4   rM   r;   r)   r)   r*   p_import      (zParserFactory.p_importc                 C   s   |d dkrCt |dko|d du}t |dkr|d nd}t| j|d|d|d |d ||d	< |rA|d	 |d  dS dS td
)z{alias : KEYWORD ID EQ type_ref NL
                 | KEYWORD ID EQ type_ref NL INDENT annotation_ref_list docsection DEDENTr   alias      N   rA   rJ   r   zExpected alias keyword)rL   r
   r%   r4   rM   set_annotationsrN   )r(   r<   has_annotationsrO   r)   r)   r*   p_alias   s   "zParserFactory.p_aliasc                 C   rE   )zNL : NEWLINEr   r   Nr)   r;   r)   r)   r*   p_nl   rG   zParserFactory.p_nlc                 C   rE   )zNL : NL NEWLINEr   r   Nr)   r;   r)   r)   r*   p_nl_combine   rG   zParserFactory.p_nl_combinec                 C   rE   )zprimitive : BOOLEAN
                     | FLOAT
                     | INTEGER
                     | NULL
                     | STRINGr   r   Nr)   r;   r)   r)   r*   p_primitive   s   zParserFactory.p_primitivec                 C   rE   )z1pos_arg : primitive
                   | type_refr   r   Nr)   r;   r)   r)   r*   	p_pos_arg      zParserFactory.p_pos_argc                 C   r>   )zpos_args_list : pos_argr   r   Nr)   r;   r)   r)   r*   p_pos_args_list_create      z$ParserFactory.p_pos_args_list_createc                 C   r@   )z+pos_args_list : pos_args_list COMMA pos_argr   r      NrB   r;   r)   r)   r*   p_pos_args_list_extend      z$ParserFactory.p_pos_args_list_extendc                 C   s   |d |d i|d< dS )z;kw_arg : ID EQ primitive
                  | ID EQ type_refr   ra   r   Nr)   r;   r)   r)   r*   p_kw_arg   s   zParserFactory.p_kw_argc                 C   rE   )zkw_args : kw_argr   r   Nr)   r;   r)   r)   r*   	p_kw_args   rG   zParserFactory.p_kw_argsc                 C   s^   |d |d< |d D ]}||d v r#d| }| j ||d| jf q
|d |d  dS )zkw_args : kw_args COMMA kw_argr   r   ra   z-Keyword argument '%s' defined more than once.rA   N)r$   rC   r4   r%   update)r(   r<   keymsgr)   r)   r*   p_kw_args_update   s   zParserFactory.p_kw_args_updatec                 C   sv   t |dkr3|d dkr|d |d f|d< dS t|d tr)g |d f|d< dS |d i f|d< dS g i f|d< dS )zargs : LPAR pos_args_list COMMA kw_args RPAR
                | LPAR pos_args_list RPAR
                | LPAR kw_args RPAR
                | LPAR RPAR
                | emptyra   ,rA   rJ   r   N)rL   
isinstancedictr;   r)   r)   r*   p_args  s   zParserFactory.p_argsc                 C   s   |d dk|d< dS )z(nullable : Q
                    | emptyr   ?r   Nr)   r;   r)   r)   r*   p_field_nullable     zParserFactory.p_field_nullablec              	   C   s8   t | j|d|d|d |d |d dd|d< dS )ztype_ref : ID args nullabler   rA   ra   Nr%   r4   rM   nameargsnullablensr   r   r%   r4   rM   r;   r)   r)   r*   
p_type_ref  s   zParserFactory.p_type_refc              	   C   s<   t | j|d|d|d |d |d |d d|d< dS )z"type_ref : ID DOT ID args nullabler   ra   rJ   rK   rq   r   Nrv   r;   r)   r)   r*   p_foreign_type_ref$  s   z ParserFactory.p_foreign_type_refc                 C   6   t | j|d|d|d |d |d d|d< dS )ziannotation_type : ANNOTATION_TYPE ID NL                               INDENT docsection field_list DEDENTr   rA   rK   rT   )r%   r4   rM   rr   rO   paramsr   N)r   r%   r4   rM   r;   r)   r)   r*   p_annotation_type>  s   zParserFactory.p_annotation_typec                 C   s0   t |dkr|d |d d dkf|d< dS dS )zbenumerated_subtypes : uniont NL INDENT subtypes_list DEDENT
                               | emptyrA   rJ   r   r   unionNrL   r;   r)   r)   r*   p_enumerated_subtypesc  s    z#ParserFactory.p_enumerated_subtypesc                 C      |  | dS )zwstruct : STRUCT ID inheritance NL                      INDENT docsection enumerated_subtypes field_list examples DEDENTNmake_structr;   r)   r)   r*   p_structi     zParserFactory.p_structc                 C   r   )zxanony_def : STRUCT empty inheritance NL                 INDENT docsection enumerated_subtypes field_list examples DEDENTNr   r;   r)   r)   r*   p_anony_structn  r   zParserFactory.p_anony_structc                 C   sH   t | j|d|d|d |d |d |d |d |d d	|d	< d S )
Nr   rA   ra   rT   rU   rV   	   )	r%   r4   rM   rr   extendsrO   subtypesfieldsexamplesr   )r   r%   r4   rM   r;   r)   r)   r*   r   s  s   zParserFactory.make_structc                 C   ry   )zCstruct_patch : PATCH STRUCT ID NL INDENT field_list examples DEDENTr   ra   rT   rU   )r%   r4   rM   rr   r   r   r   N)r   r%   r4   rM   r;   r)   r)   r*   p_struct_patch  s   zParserFactory.p_struct_patchc                 C   sH   |d r"|d j rd}| j||d| jf dS |d |d< dS dS )z=inheritance : EXTENDS type_ref
                       | emptyr   rA   zReference cannot be nullable.r   N)rt   r$   rC   r4   r%   r(   r<   rh   r)   r)   r*   p_inheritance  s   
zParserFactory.p_inheritancec                 C   s"   |d dur|d g|d< dS dS )z>subtypes_list : subtype_field
                         | emptyr   Nr   r)   r;   r)   r)   r*   !p_enumerated_subtypes_list_create  s   z/ParserFactory.p_enumerated_subtypes_list_createc                 C   r@   )z+subtypes_list : subtypes_list subtype_fieldr   r   rA   NrB   r;   r)   r)   r*   !p_enumerated_subtypes_list_extend  rc   z/ParserFactory.p_enumerated_subtypes_list_extendc                 C   .   t | j|d|d|d |d |d< dS )zsubtype_field : ID type_ref NLr   rA   r   N)r   r%   r4   rM   r;   r)   r)   r*   p_enumerated_subtype_field      z(ParserFactory.p_enumerated_subtype_fieldc                 C   s*   |d du rg |d< dS |d g|d< dS )z0field_list : field
                      | emptyr   Nr   r)   r;   r)   r)   r*   p_field_list_create  s   z!ParserFactory.p_field_list_createc                 C   r@   )zfield_list : field_list fieldr   r   rA   NrB   r;   r)   r)   r*   p_field_list_extend  rc   z!ParserFactory.p_field_list_extendc                 C   s:   |d rt |d tr|d |d< dS |d |d< dS dS )zfdefault_option : EQ primitive
                          | EQ tag_ref
                          | emptyr   rA   r   N)rk   r   r;   r)   r)   r*   p_default_option  s
   zParserFactory.p_default_optionc                 C   s  t |dko|d du}t |dko|d du}t |dko#|d du}t| j|d|d|d |d |d< |d	 durV|d	 tu rM|d d n	|d |d	  |ra|d |d  |rl|d |d  |r|d j	|d _	| j
|d  dS dS )
zfield : ID type_ref default_option NL                     INDENT annotation_ref_list docsection anony_def_option DEDENT
                 | ID type_ref default_option NLrK   rT   NrU   rV   r   rA   r   ra   )rL   r   r%   r4   rM   r	   set_defaultrW   set_docrr   r&   rC   )r(   r<   rX   Zhas_docstringZhas_anony_defr)   r)   r*   p_field  s$    zParserFactory.p_fieldc                 C   rE   )z@anony_def_option : anony_def
                            | emptyr   r   Nr)   r;   r)   r)   r*   p_anony_def_option  r^   z ParserFactory.p_anony_def_optionc                 C   (   t | j|d|d|d |d< dS )ztag_ref : IDr   r   N)r   r%   r4   rM   r;   r)   r)   r*   	p_tag_ref  rR   zParserFactory.p_tag_refc              	   C   s   t |dk r&|d \}}t| j|d|d|d |d d|||d< dS |d \}}t| j|d|d|d |d	 |d |||d< dS )
zcannotation : ANNOTATION ID EQ ID args NL
                      | ANNOTATION ID EQ ID DOT ID args NLrV   rK   r   rA   rJ   Nr   rU   rT   )rL   r   r%   r4   rM   )r(   r<   rs   kwargsr)   r)   r*   p_annotation  s   &*zParserFactory.p_annotationc                 C   s*   |d dur|d g|d< dS d|d< dS )zKannotation_ref_list : annotation_ref
                               | emptyr   Nr   r)   r;   r)   r)   r*   p_annotation_ref_list_create  s   z*ParserFactory.p_annotation_ref_list_createc                 C   r@   )z8annotation_ref_list : annotation_ref_list annotation_refr   r   rA   NrB   r;   r)   r)   r*   p_annotation_ref_list_extend  rc   z*ParserFactory.p_annotation_ref_list_extendc                 C   sd   t |dk rt| j|d|d|d d|d< dS t| j|d|d|d |d |d< dS )zEannotation_ref : AT ID NL
                          | AT ID DOT ID NLrK   r   rA   Nr   rJ   )rL   r   r%   r4   rM   r;   r)   r)   r*   p_annotation_ref  s   *.zParserFactory.p_annotation_refc                 C   r   )zeunion : uniont ID inheritance NL                         INDENT docsection field_list examples DEDENTN
make_unionr;   r)   r)   r*   p_union  r   zParserFactory.p_unionc                 C   r   )zlanony_def : uniont empty inheritance NL                         INDENT docsection field_list examples DEDENTNr   r;   r)   r)   r*   p_anony_union  r   zParserFactory.p_anony_unionc                 C   sT   t | j|d d |d d |d |d |d |d |d |d d dkd		|d< d S )
Nr   rA   ra   rT   rU   rV   r   union_closed)	r%   r4   rM   rr   r   rO   r   r   closed)r   r%   r;   r)   r)   r*   r     s   

zParserFactory.make_unionc              	   C   sH   t | j|d d |d d |d |d |d |d d dkd|d< d	S )
zBunion_patch : PATCH uniont ID NL INDENT field_list examples DEDENTrA   r   ra   rT   rU   r   r   )r%   r4   rM   rr   r   r   r   N)r   r%   r;   r)   r)   r*   p_union_patch'  s   

zParserFactory.p_union_patchc                 C   s"   |d | d|df|d< dS )z/uniont : UNION
                  | UNION_CLOSEDr   r   N)r4   rM   r;   r)   r)   r*   p_uniont2  s   "zParserFactory.p_uniontc                 C   sx   t | j|d|d|d |d< t|dkr8|d dur'|d |d  |d dur:|d |d  dS dS dS )zSfield : ID NL
                 | ID NL INDENT annotation_ref_list docsection DEDENTr   r   ra   rJ   NrK   )r   r%   r4   rM   rL   rW   r   r;   r)   r)   r*   p_field_void7  s   $zParserFactory.p_field_voidc                 C   s   t | j|d|d|d |d |d g|d R  |d< t|dkra|d |d  |d	 rct }|d	 D ]}|j|v rOd
|j }| j	||j|jf |
|j q8|d |d	  dS dS dS )zroute : ROUTE route_name route_version route_io route_deprecation NL                         INDENT docsection attrssection DEDENT
                 | ROUTE route_name route_version route_io route_deprecation NLr   rA   ra   rK   rJ   r   rU   rV   r   z&Attribute '%s' defined more than once.N)r   r%   r4   rM   rL   r   setrr   r$   rC   add	set_attrs)r(   r<   keysattrrh   r)   r)   r*   p_routeO  s   <

zParserFactory.p_routec                 C   s0   |d r|d |d  |d< dS |d |d< dS )zroute_name : ID route_pathrA   r   r   Nr)   r;   r)   r)   r*   p_route_name_  s   zParserFactory.p_route_namec                 C   rE   )z/route_path : PATH
                      | emptyr   r   Nr)   r;   r)   r)   r*   p_route_path_suffixf  r^   z!ParserFactory.p_route_path_suffixc                 C   sR   t |dkr#|d dkrd}| j||d| jf |d |d< dS d|d< dS )z>route_version : COLON INTEGER
                         | emptyrA   r   z,Version number should be a positive integer.r   N)rL   r$   rC   r4   r%   r   r)   r)   r*   p_route_versionk  s   zParserFactory.p_route_versionc                 C   sD   t |dkr|d |d |d f|d< dS |d |d df|d< dS )zsroute_io : LPAR type_ref COMMA type_ref RPAR
                    | LPAR type_ref COMMA type_ref COMMA type_ref RPARrT   rA   rJ   r   Nr}   r;   r)   r)   r*   
p_route_iov  s   zParserFactory.p_route_ioc                 C   s>   t |dkrd|d |d f|d< dS |d rd|d< dS dS )	zroute_deprecation : DEPRECATED
                             | DEPRECATED BY route_name route_version
                             | emptyrK   Tra   rJ   r   r   )TNNNr}   r;   r)   r)   r*   p_route_deprecation~  s
   z!ParserFactory.p_route_deprecationc                 C   s   |d r|d |d< dS dS )zQattrssection : ATTRS NL INDENT attr_fields DEDENT
                        | emptyr   rJ   r   Nr)   r;   r)   r)   r*   p_attrs_section  s   zParserFactory.p_attrs_sectionc                 C   r>   )zattr_fields : attr_fieldr   r   Nr)   r;   r)   r)   r*   p_attr_fields_create  r`   z"ParserFactory.p_attr_fields_createc                 C   r@   )z$attr_fields : attr_fields attr_fieldr   r   rA   NrB   r;   r)   r)   r*   p_attr_fields_add  rc   zParserFactory.p_attr_fields_addc                 C   d   |d t u rt| j|d|d|d d|d< dS t| j|d|d|d |d |d< dS )zHattr_field : ID EQ primitive NL
                      | ID EQ tag_ref NLra   r   Nr   )r	   r   r%   r4   rM   r;   r)   r)   r*   p_attr_field  s    zParserFactory.p_attr_fieldc                 C   s    |d dur|d |d< dS dS )z7docsection : docstring NL
                      | emptyr   Nr   r)   r;   r)   r)   r*   p_docsection  s   zParserFactory.p_docsectionc                 C   s&   d dd |d dD |d< dS )zdocstring : STRING
c                 S   s   g | ]}|  qS r)   )rstrip).0liner)   r)   r*   
<listcomp>  s    z4ParserFactory.p_docstring_string.<locals>.<listcomp>r   r   N)joinsplitr;   r)   r)   r*   p_docstring_string  s   &z ParserFactory.p_docstring_stringc                 C   s4   t  |d< |d dur|d |d |d j< dS dS )z.examples : example
                    | emptyr   r   N)r   labelr;   r)   r)   r*   p_examples_create  s   
zParserFactory.p_examples_createc                 C   st   |d |d< |d j |d v r-|d |d j  }| jd|j |jf |d j|d jf |d |d |d j < dS )zexamples : examples exampler   r   rA   z3Example with label '%s' already defined on line %d.N)r   r$   rC   r4   r%   )r(   r<   Zexisting_exr)   r)   r*   p_examples_add  s   
zParserFactory.p_examples_addc              
   C   s   t |dkrPt }|d D ]!}|j|v r(| jd|d |jf |d| jf ||j qt| j|d|	d|d |d t
dd |d D |d	< d
S t| j|d|	d|d d
t
 |d	< d
S )zbexample : KEYWORD ID NL INDENT docsection example_fields DEDENT
                   | KEYWORD ID NLrJ   rT   z:Example with label '%s' defines field '%s' more than once.rA   r   rK   c                 s   s    | ]}|j |fV  qd S r5   )rr   )r   fr)   r)   r*   	<genexpr>  s    z*ParserFactory.p_example.<locals>.<genexpr>r   N)rL   r   rr   r$   rC   r4   r%   r   r   rM   r   )r(   r<   Zseen_fieldsZexample_fieldr)   r)   r*   	p_example  s&   
  zParserFactory.p_examplec                 C   r>   )zexample_fields : example_fieldr   r   Nr)   r;   r)   r)   r*   p_example_fields_create  r`   z%ParserFactory.p_example_fields_createc                 C   r@   )z-example_fields : example_fields example_fieldr   r   rA   NrB   r;   r)   r)   r*   p_example_fields_add  rc   z"ParserFactory.p_example_fields_addc                 C   r   )zyexample_field : ID EQ primitive NL
                         | ID EQ ex_list NL
                         | ID EQ ex_map NLra   r   Nr   )r	   r   r%   r4   rM   r;   r)   r)   r*   p_example_field  s    zParserFactory.p_example_fieldc                 C   r   )z0example_field : ID EQ NL INDENT ex_map NL DEDENTr   rK   r   N)r   r%   r4   rM   r;   r)   r)   r*   p_example_multiline  r   z!ParserFactory.p_example_multilinec                 C   sF   t | j|d|d|d t| j|d|d|d |d< dS )zexample_field : ID EQ ID NLr   ra   r   N)r   r%   r4   rM   r   r;   r)   r)   r*   p_example_field_ref  s   $z!ParserFactory.p_example_field_refc                 C   s(   |d du rg |d< dS |d |d< dS )zVex_list : LBRACKET ex_list_items RBRACKET
                   | LBRACKET empty RBRACKETrA   Nr   r)   r;   r)   r)   r*   	p_ex_list  s   zParserFactory.p_ex_listc                 C   s(   |d t u rd|d< dS |d |d< dS )zex_list_item : primitiver   Nr   r	   r;   r)   r)   r*   p_ex_list_item_primitive  s   z&ParserFactory.p_ex_list_item_primitivec                 C   r   )zex_list_item : IDr   r   Nr   r%   r4   rM   r;   r)   r)   r*   p_ex_list_item_id  rR   zParserFactory.p_ex_list_item_idc                 C   rE   )zex_list_item : ex_listr   r   Nr)   r;   r)   r)   r*   p_ex_list_item_list!  rG   z!ParserFactory.p_ex_list_item_listc                 C   r>   )zex_list_items : ex_list_itemr   r   Nr)   r;   r)   r)   r*   p_ex_list_items_create%  r`   z$ParserFactory.p_ex_list_items_createc                 C   r@   )z0ex_list_items : ex_list_items COMMA ex_list_itemr   r   ra   NrB   r;   r)   r)   r*   p_ex_list_items_extend)  rc   z$ParserFactory.p_ex_list_items_extendc                 C      |d pi |d< dS )zKex_map : LBRACE ex_map_pairs RBRACE
                  | LBRACE empty RBRACErA   r   Nr)   r;   r)   r)   r*   p_ex_map2  rp   zParserFactory.p_ex_mapc                 C   r   )z7ex_map : LBRACE NL INDENT ex_map_pairs NL DEDENT RBRACErJ   r   Nr)   r;   r)   r)   r*   p_ex_map_multiline7  s   z ParserFactory.p_ex_map_multilinec                 C   s    |d t krdn|d |d< dS )zex_map_elem : primitiver   Nr   r   r;   r)   r)   r*   p_ex_map_elem_primitive;  s    z%ParserFactory.p_ex_map_elem_primitivec                 C   rE   )z5ex_map_elem : ex_map
                       | ex_listr   r   Nr)   r;   r)   r)   r*   p_ex_map_elem_composit?  r^   z$ParserFactory.p_ex_map_elem_compositc                 C   r   )zex_map_elem : IDr   r   Nr   r;   r)   r)   r*   p_ex_map_elem_idD  rR   zParserFactory.p_ex_map_elem_idc              	   C   sb   z|d |d i|d< W dS  t y0   dt|d  }| j||d| jf i |d< Y dS w )z+ex_map_pair : ex_map_elem COLON ex_map_elemr   ra   r   z6%s is an invalid hash key because it cannot be hashed.rA   N)	TypeErrorreprr$   rC   r4   r%   r   r)   r)   r*   p_ex_map_pairH  s   zParserFactory.p_ex_map_pairc                 C   rE   )zex_map_pairs : ex_map_pair r   r   Nr)   r;   r)   r)   r*   p_ex_map_pairs_createQ  rG   z#ParserFactory.p_ex_map_pairs_createc                 C   r@   )z-ex_map_pairs : ex_map_pairs COMMA ex_map_pairr   r   ra   Nrf   r;   r)   r)   r*   p_ex_map_pairs_extendU  rc   z#ParserFactory.p_ex_map_pairs_extendc                 C   r@   )z0ex_map_pairs : ex_map_pairs COMMA NL ex_map_pairr   r   rJ   Nr   r;   r)   r)   r*   p_ex_map_pairs_multilineZ  rc   z&ParserFactory.p_ex_map_pairs_multilinec                 C   s   dS )zempty :Nr)   r;   r)   r)   r*   p_emptyc  s    zParserFactory.p_emptyc                 C   sV   |d usJ dt d|j|j|j | jd|jt|jdf |j| j	f d S )Nz"Unknown error, please report this.zUnexpected %s(%r) at line %dzUnexpected %s with value %s.u)
loggerr!   typevaluer4   r$   rC   r   lstripr%   )r(   tokenr)   r)   r*   p_errorg  s   zParserFactory.p_error)Fr5   )b__name__
__module____qualname____doc__r   tokensstrstartr+   r-   r/   r7   r9   r:   r=   r?   rD   rF   rH   rP   rQ   rY   rZ   r[   r\   r]   r_   rb   rd   re   ri   rm   ro   rw   rx   r{   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r)   r)   r)   r*   r   '   s    

		%


				r   )'
__future__r   r   r   r   collectionsr   loggingZply.yaccr"   r#   r   r	   astr
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   	getLoggerr   r   objectr   r)   r)   r)   r*   <module>   s    X