Ë
    ?—Öj–‡  ã                   ó@  — d dl Z d dlZd dl m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mZmZmZ d dl m!Z!m"Z"  ejF                  e$«      Z% G d„ d«      Z& G d	„ d
e jN                  ¬«      Z( G d„ de(«      Z) G d„ de(e&«      Z* G d„ de(«      Z+ G d„ de(e&«      Z, G d„ de,«      Z- G d„ de(«      Z. G d„ de(«      Z/ G d„ de)«      Z0 G d„ de(«      Z1 G d„ de(«      Z2 G d „ d!e(«      Z3 G d"„ d#e(«      Z4 G d$„ d%e(«      Z5 G d&„ d'e(«      Z6 G d(„ d)e(«      Z7 G d*„ d+e,«      Z8 G d,„ d-e(«      Z9 G d.„ d/e(«      Z: G d0„ d1e,«      Z; G d2„ d3e(e jN                  ¬«      Z< G d4„ d5e<«      Z= G d6„ d7e(«      Z> G d8„ d9e,«      Z? G d:„ d;e<«      Z@y)<é    N)Úabstractmethod)Údeque)ÚInvalidTokenExceptionÚInvalidUpdateExpression)ÚExpressionAttributeÚExpressionAttributeNameÚExpressionAttributeValueÚExpressionPathDescenderÚExpressionSelectorÚExpressionValueOperatorÚUpdateExpressionÚUpdateExpressionAddActionÚUpdateExpressionAddActionsÚUpdateExpressionAddClauseÚUpdateExpressionDeleteActionÚUpdateExpressionDeleteActionsÚUpdateExpressionDeleteClauseÚUpdateExpressionFunctionÚUpdateExpressionGroupedValueÚUpdateExpressionPathÚUpdateExpressionRemoveActionÚUpdateExpressionRemoveActionsÚUpdateExpressionRemoveClauseÚUpdateExpressionSetActionÚUpdateExpressionSetActionsÚUpdateExpressionSetClauseÚUpdateExpressionValue)ÚExpressionTokenizerÚTokenc                   óL   — e Zd ZdZd„ Zd„ Zed„ «       Zeed„ «       «       Z	d„ Z
y)ÚNestableExpressionParserMixinad  
    For nodes that can be nested in themselves (recursive). Take for example UpdateExpression's grammar:

    UpdateExpression => UpdateExpressionClause*
    UpdateExpression => UpdateExpressionClause* UpdateExpression

    If we consider it of structure
    NestableExpression => TargetClause*
    NestableExpression => TargetClause* NestableExpression

    This pattern comes back multiple times. This Mixin adds re-usability for that type of pattern.

    This approach is taken since it allows to remain the ordering of the Nodes as how the corresponding tokens where
    in the originating expression.
    c                 ó"   — t        «       | _        y ©N)r   Útarget_clauses©Úselfs    ú^/var/www/photos/backend/venv/lib/python3.12/site-packages/moto/dynamodb/parsing/expressions.pyÚ__init__z&NestableExpressionParserMixin.__init__7   s   € Ü#›gˆÕó    c                 ó4  — | j                   }|j                  j                  }t        j	                  d||«        |di | j                  «       ¤Žj                  «       \  }}| j                  j                  |«       t        j	                  d|«       || _         y)úŽ

        Args:
            factory_class: The factory for the target clause e.g.  UpdateExpressionSetClauseParser

        Returns:

        zDMove token pos %s to continue parsing with specific factory class %sú)Continue where previous parsing ended: %sN© )	Ú	token_posÚ	__class__Ú__name__ÚloggerÚdebugÚ_initializer_argsÚ_parse_with_posr$   Úappend)r&   Úfactory_classÚposÚfcÚastr.   s         r'   Ú_parse_target_clausez2NestableExpressionParserMixin._parse_target_clause:   s‚   € ð �n‰nˆØ×$Ñ$×-Ñ-ˆÜ�‰ØRØØô	
ñ 'ÑB¨×)?Ñ)?Ó)AÑB×RÑRÓT‰ˆˆYØ×Ñ×"Ñ" 3Ô'Ü�‰Ð@À)ÔLØ"ˆ�r)   c                  ó   — y)zÜ
        Get the arguments of the initializer. This is implemented by the calling class. See ExpressionParser for an
        example.

        Returns:
            dict: A dictionary of the initializer arguments
        Nr-   r%   s    r'   r3   z/NestableExpressionParserMixin._initializer_argsP   ó   � r)   c                  ó   — y)zð
        Get the class of the Node that will be created that would be nested. For the example in the docstring this would
        be UpdateExpression

        Returns:
            class: The class of the Nodes that will be created.
        Nr-   ©Úclss    r'   Ú_nestable_classz-NestableExpressionParserMixin._nestable_classZ   r<   r)   c                 óš  — | j                   j                  }t        | j                  «      dkD  s
J d|› �«       ‚ | j	                  «       | j                  j                  «       g¬«      }t        | j                  «      dkD  rJ | j	                  «       | j                  j                  «       |g¬«      }t        | j                  «      dkD  rŒJ|S )a´  
        target_clauses has the nodes in order of encountering. Go through them backwards and build the tree bottom up.

        This way left-deep-descending traversal will process nodes in order.

        Continuing the example of an UpdateExpression:
            For example SET a=3 REMOVE b
                  UpdateExpression
                  /                           SET a=3        UpdateExpression
                                    |
                                 REMOVE b

        self.target_clauses looks like:  ( SET a=3 >> REMOVE b )
        Returns:
            moto.dynamodb.ast_nodes.Node: Node of an AST representing the Expression as produced by the factory.
        r   zNo nodes for ©Úchildren)r/   r0   Úlenr$   r@   Úpop)r&   ÚcnÚtarget_nodes      r'   Ú_create_nodez*NestableExpressionParserMixin._create_nodee   s»   € ð$ �^‰^×$Ñ$ˆÜ�4×&Ñ&Ó'¨!Ò+ÐA¨}¸R¸DÐ-AÓAÐ+Ø,�d×*Ñ*Ó,°t×7JÑ7J×7NÑ7NÓ7PÐ6QÔRˆÜ�$×%Ñ%Ó&¨Ò*Ø0˜$×.Ñ.Ó0Ø×-Ñ-×1Ñ1Ó3°[ÐAôˆKô �$×%Ñ%Ó&¨Ó*ð Ðr)   N)r0   Ú
__module__Ú__qualname__Ú__doc__r(   r:   r   r3   Úclassmethodr@   rH   r-   r)   r'   r!   r!   &   sF   „ ñò &ò#ð, ñó ðð Øñó ó ðór)   r!   c                   ó¾   — e Zd ZdZdd„Zd„ Zed„ «       Zed„ «       Z	eed„ «       «       Z
d„ Zd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚExpressionParserzAbstract classc                 ó    — || _         || _        y)zq

        Args:
            expression_token_list:
            token_pos(int): Location where parsing is
        N©Ú
token_listr.   )r&   Úexpression_token_listr.   s      r'   r(   zExpressionParser.__init__„   s   € ð 0ˆŒØ"ˆ�r)   c                 ó4   — | j                   | j                  dœS )N)rR   r.   rP   r%   s    r'   r3   z"ExpressionParser._initializer_argsŽ   s   € Ø)-¯©ÀtÇ~Á~ÑVÐVr)   c                  ó   — y)zÈ
        Start parsing the token_list from token_pos for the factory type.

        Returns:
            moto.dynamodb.ast_nodes.Node: AST which is root node of resulting abstract syntax tree
        Nr-   r%   s    r'   Ú_parsezExpressionParser._parse‘   r<   r)   c                 ó0   — |d uxr | j                  |«      S r#   )Ú_is_possible_start©r?   Útokens     r'   Úis_possible_startz"ExpressionParser.is_possible_startš   s   € à˜DÐ ÒB S×%;Ñ%;¸EÓ%BÐBr)   c                  ó   — y)z¬

        Args:
            token(moto.dynamodb.tokens.Token):

        Returns:
            bool: True if token is a possible start for entries processed by `cls`
        Nr-   rX   s     r'   rW   z#ExpressionParser._is_possible_startž   r<   r)   c                 ó:   — | j                  «       | j                  fS )a;  
        Start parsing the token_list from token_pos for the factory type and also return the resulting token_pos.

        Returns:
            (ast, token_pos): tuple of AST which is root node of resulting abstract syntax tree and token_pos is the
                              position in the tokenlist.
        )rU   r.   r%   s    r'   r4   z ExpressionParser._parse_with_posª   s   € ð �{‰{‹}˜dŸn™nÐ,Ð,r)   c                 ó"   — | j                  «       S r#   )rU   r%   s    r'   ÚparsezExpressionParser.parse´   s   € Ø�{‰{‹}Ðr)   c                 óV   — 	 | j                  «       j                  S # t        $ r Y yw xY w)zŒ
        Get the type of the next token to be processed

        Returns:
            str: Token type or None if no more next token
        N)Úget_next_tokenÚtypeÚAttributeErrorr%   s    r'   Úget_next_token_typez$ExpressionParser.get_next_token_type·   s.   € ð	Ø×&Ñ&Ó(×-Ñ-Ð-øÜò 	Ùð	úó   ‚ œ	(§(c                 óT   — 	 | j                   | j                     S # t        $ r Y yw xY w)zŒ
        Get the next token to be processed

        Returns:
            moto.dynamodb.tokens.Token: or None if no more next token
        N)rQ   r.   Ú
IndexErrorr%   s    r'   r`   zExpressionParser.get_next_tokenÃ   s,   € ð	Ø—?‘? 4§>¡>Ñ2Ð2øÜò 	Ùð	ús   ‚ ›	'¦'c                 óV   — 	 | j                  «       j                  S # t        $ r Y yw xY w)zˆ
        Get the value of the next token to be processed

        Returns:
            str: value or None if no more next token
        N)r`   Úvaluerb   r%   s    r'   Úget_next_token_valuez%ExpressionParser.get_next_token_valueÏ   s.   € ð	Ø×&Ñ&Ó(×.Ñ.Ð.øÜò 	Ùð	úrd   c                 óF   — | j                   t        | j                  «      k(  S )z>Return boolean indicating whether we are at end of the parsing)r.   rD   rQ   r%   s    r'   Ú	is_at_endzExpressionParser.is_at_endÛ   s   € à�~‰~¤ T§_¡_Ó!5Ñ5Ð5r)   c                 ó    — | j                   dk(  S )z@Return boolean indicating whether we are at start of the parsingr   )r.   r%   s    r'   Úis_at_startzExpressionParser.is_at_startß   s   € à�~‰~ Ñ"Ð"r)   c                 ón   — | j                   dkD  r&| j                  | j                   dz
     j                  S y)zCGet the last token that was correctly parsed or return empty stringr   é   Ú )r.   rQ   rh   r%   s    r'   Úget_last_token_valuez%ExpressionParser.get_last_token_valueã   s/   € à�>‰>˜AÒØ—?‘? 4§>¡>°AÑ#5Ñ6×<Ñ<Ð<àr)   c                 ón   — | j                   dkD  r&| j                  | j                   dz
     j                  S y)z@Get the last token type that was correctly parsed or return Noner   ro   N)r.   rQ   ra   r%   s    r'   Úget_last_token_typez$ExpressionParser.get_last_token_typeê   s/   € à�>‰>˜AÒØ—?‘? 4§>¡>°AÑ#5Ñ6×;Ñ;Ð;àr)   c                 ó°   — | j                   dkD  rG| j                  «       t        j                  k(  r&| j                  | j                   dz
     j
                  S y)zbGet the 2nd last token that was correctly parsed if last one was whitespace or return empty stringro   é   rp   )r.   rs   r   Ú
WHITESPACErQ   rh   r%   s    r'   Ú/get_2nd_last_token_value_if_last_was_whitespacez@ExpressionParser.get_2nd_last_token_value_if_last_was_whitespaceñ   sE   € à�>‰>˜AÒ $×":Ñ":Ó"<Ä×@PÑ@PÒ"PØ—?‘? 4§>¡>°AÑ#5Ñ6×<Ñ<Ð<àr)   c                 ón   — 	 | j                   | j                  dz      j                  S # t        $ r Y yw xY w)zWGet the token value after the one that is being parsed or empty string if non existent.ro   rp   )rQ   r.   rh   rf   r%   s    r'   Úget_following_token_valuez*ExpressionParser.get_following_token_valueø   s7   € ð	Ø—?‘? 4§>¡>°AÑ#5Ñ6×<Ñ<Ð<øÜò 	Ùð	úó   ‚%( ¨	4³4c                 ón   — 	 | j                   | j                  dz      j                  S # t        $ r Y yw xY w)zNGet the token type after the one that is being parsed or None if non existent.ro   N)rQ   r.   ra   rf   r%   s    r'   Úget_following_token_typez)ExpressionParser.get_following_token_typeÿ   s7   € ð	Ø—?‘? 4§>¡>°AÑ#5Ñ6×;Ñ;Ð;øÜò 	Ùð	úrz   c                 ó²   — | j                  «       t        j                  k(  r'	 | j                  | j                  dz      j
                  S y# t        $ r Y yw xY w)zfGet the 2nd following token that was correctly parsed if 1st one was whitespace or return empty stringru   rp   )r|   r   rv   rQ   r.   rh   rf   r%   s    r'   Ú9get_2nd_following_token_value_if_following_was_whitespacezJExpressionParser.get_2nd_following_token_value_if_following_was_whitespace  sU   € à×(Ñ(Ó*¬e×.>Ñ.>Ò>ðØ—‘ t§~¡~¸Ñ'9Ñ:×@Ñ@Ð@ð øô ò Ùðús   £%A
 Á
	AÁAc                 ó,  — 	 | j                  «       t        j                  k(  r8| xj                  dz  c_        | j                  «       t        j                  k(  rŒ7y y # t        $ r. | j                  dkD  sJ d«       ‚t
        j                  d«       Y y w xY w)Nro   r   z&We should always have positive indexesz%We are out of range so end is reached)rc   r   rv   r.   rf   r1   r2   r%   s    r'   Úskip_white_spacez!ExpressionParser.skip_white_space  s|   € ð	BØ×*Ñ*Ó,´×0@Ñ0@Ò@Ø—’ !Ñ#•ð ×*Ñ*Ó,´×0@Ñ0@Õ@øäò 	BØ—>‘> AÒ%ÐOÐ'OÓOÐ%Ü�L‰LÐ@ÖAð	Bús   ‚AA Á4BÂBc                 óŽ   — | j                  «       |k(  r"| j                  «       }| j                  «        |S | j                  «        y)zæ
        Maker sure the next token is of type `token_type` if not raise unexpected token
        Args:
            token_type: A token type

        Returns:
            str: The value if the token is of type `token_type`
        N)rc   ri   Úgoto_next_significant_tokenÚraise_unexpected_token)r&   Ú
token_typeÚtoken_values      r'   Úprocess_token_of_typez&ExpressionParser.process_token_of_type  sA   € ð ×#Ñ#Ó%¨Ò3Ø×3Ñ3Ó5ˆKØ×,Ñ,Ô.ØÐà×'Ñ'Õ)r)   c                 óN   — | xj                   dz  c_         | j                  «        y)z4Continue past current token and skip all whitespacesro   N)r.   r€   r%   s    r'   r‚   z,ExpressionParser.goto_next_significant_token(  s   € à�Š˜!Ñ�Ø×ÑÕr)   c                 ó  — | j                  «       rd}d}n| j                  «       x}}dj                  | j                  «       | j	                  «       || j                  «       | j                  «       g«      }t        ||«      ‚)Nz<EOF>rp   )rk   ri   Újoinrw   rq   ry   r~   r   )r&   Úproblematic_tokenÚproblematic_token_in_nearÚnears       r'   rƒ   z'ExpressionParser.raise_unexpected_token-  sƒ   € Ø�>‰>ÔØ 'ÐØ(*Ñ%à<@×<UÑ<UÓ<WÐWÐ%Ð(9à�w‰wà×DÑDÓFØ×)Ñ)Ó+Ø)Ø×.Ñ.Ó0Ø×NÑNÓPðó
ˆô $Ð$5°tÓ<Ð<r)   N)r   )r0   rI   rJ   rK   r(   r3   r   rU   rL   rZ   rW   r4   r^   rc   r`   ri   rk   rm   rq   rs   rw   ry   r|   r~   r€   r†   r‚   rƒ   r-   r)   r'   rN   rN   �   s¬   „ Ùó#òWð ñó ðð ñCó ðCð Øñó ó ðò-òò
ò
ò
ò6ò#òòòòòòòBò*ò  ó
=r)   rN   )Ú	metaclassc                   óT   ‡ — e Zd ZdZˆ fd„Zd„ Zd„ Zed„ «       Zed„ «       Z	d„ Z
ˆ xZS )ÚNestableBinExpressionParseras  
    For nodes that can be nested in themselves (recursive) but with an operation. Take for example
    UpdateExpressionValue's grammar:

    Value => Operand*
    Value => Operand* + Value
    Value => Operand* - Value

    If we consider it of structure
    NestableBinExpression => TargetClause*
    NestableBinExpression => TargetClause* BinOp NestableBinExpression

    This pattern comes back multiple times. This Mixin adds re-usability for that type of pattern.

    This approach is taken since it allows to remain the ordering of the Nodes as how the corresponding tokens where
    in the originating expression.
    c                 óB   •— t        ‰| �  |i |¤Ž t        «       | _        y r#   )Úsuperr(   r   Útarget_nodes©r&   ÚargsÚkwargsr/   s      €r'   r(   z$NestableBinExpressionParser.__init__T  s   ø€ Ü‰Ñ˜$Ð) &Ò)Ü!›GˆÕr)   c                 óÒ   —  |di | j                  «       ¤Žj                  «       \  }| _        | j                  j	                  |«       t
        j                  d| j                  «       y)r+   r,   Nr-   )r3   r4   r.   r’   r5   r1   r2   )r&   r6   r9   s      r'   r:   z0NestableBinExpressionParser._parse_target_clauseX  sY   € ñ ,ñ 
Ø×$Ñ$Ó&ñ
ç
‰/Ó
ñ 	ˆˆTŒ^ð 	×Ñ× Ñ  Ô%Ü�‰Ð@À$Ç.Á.ÕQr)   c                 ó  — | j                  | j                  «       «       | j                  «       j                  | j	                  «       «      rª| j                  | j                  «       «       | j                  «       j                  | j	                  «       «      r | j                  | j                  «       «       n| j                  «        | j                  «       j                  | j	                  «       «      rŒª| j                  «       S r#   )r:   Ú_operand_factory_classÚ_binop_factory_classrZ   r`   rƒ   rH   r%   s    r'   rU   z"NestableBinExpressionParser._parseh  sÆ   € Ø×!Ñ! $×"=Ñ"=Ó"?Ô@Ø×'Ñ'Ó)×;Ñ;¸D×<OÑ<OÓ<QÔRØ×%Ñ% d×&?Ñ&?Ó&AÔBØ×*Ñ*Ó,×>Ñ>¸t×?RÑ?RÓ?TÔUØ×)Ñ)¨$×*EÑ*EÓ*GÕHà×+Ñ+Ô-ð ×'Ñ'Ó)×;Ñ;¸D×<OÑ<OÓ<QÕRð × Ñ Ó"Ð"r)   c                  ó   — y)z~
        Get the Parser class of the Operands for the Binary operations/actions.

        Returns:
            class:
        Nr-   r%   s    r'   r˜   z2NestableBinExpressionParser._operand_factory_classr  r<   r)   c                  ó   — y)z�
        Get a factory that gets the possible binary operation.

        Returns:
            class: A class extending ExpressionParser
        Nr-   r%   s    r'   r™   z0NestableBinExpressionParser._binop_factory_class{  r<   r)   c                 óB  — t        | j                  «      dk(  r%t        | j                  j                  «       g¬«      S t        | j                  j                  «       | j                  j                  «       | j                  j                  «       g¬«      }t        | j                  «      dk\  rXt        || j                  j                  «       | j                  j                  «       g¬«      }t        | j                  «      dk\  rŒXt        | j                  «      dk(  sJ ‚|S )aô  
        target_clauses has the nodes in order of encountering. Go through them forward and build the tree bottom up.
        For simplicity docstring will use Operand Node rather than the specific node

        This way left-deep-descending traversal will process nodes in order.

        Continuing the example of an UpdateExpressionValue:
            For example value => a + :val - :val2
                                  UpdateExpressionValue
                                  /            |                          UpdateExpressionValue     BinOp   Operand
                           /    |      |       |        |
        UpdateExpressionValue  BinOp Operand   -       :val2
               /                |       |
            Operand             +      :val
              |
              a

        self.target_nodes looks like: (  a >> + >> :val >> - >> :val2 )
        Returns:
            moto.dynamodb.ast_nodes.Node: Node of an AST representing the Expression as produced by the factory.
        ro   rB   ru   r   )rD   r’   r   Úpopleft)r&   rG   s     r'   rH   z(NestableBinExpressionParser._create_node„  sú   € ô. ˆt× Ñ Ó! QÒ&Ü(°4×3DÑ3D×3LÑ3LÓ3NÐ2OÔPÐPä/à×%Ñ%×-Ñ-Ó/Ø×%Ñ%×-Ñ-Ó/Ø×%Ñ%×-Ñ-Ó/ðôˆKô �d×'Ñ'Ó(¨AÒ-Ü3à#Ø×)Ñ)×1Ñ1Ó3Ø×)Ñ)×1Ñ1Ó3ðô�ô �d×'Ñ'Ó(¨AÓ-ô �t×(Ñ(Ó)¨QÒ.Ð.Ð.ØÐr)   )r0   rI   rJ   rK   r(   r:   rU   r   r˜   r™   rH   Ú__classcell__©r/   s   @r'   r�   r�   A  sE   ø„ ñô$$òRò #ð ñó ðð ñó ðö*r)   r�   c                   óz   ‡ — e Zd ZdZed„ «       Zed„ «       Zˆ fd„Zed„ «       Zd„ Z	d„ Z
d„ Zed	efd
„«       Zˆ xZS )ÚUpdateExpressionParserz-
    Parser to create update expressions
    c                 ó.   — t         t        t        t        gS r#   )ÚUpdateExpressionSetClauseParserÚUpdateExpressionAddClauseParserÚ"UpdateExpressionDeleteClauseParserÚ"UpdateExpressionRemoveClauseParserr>   s    r'   Ú_sub_factoriesz%UpdateExpressionParser._sub_factories¶  s   € ô ,Ü+Ü.Ü.ð	
ð 	
r)   c                  ó   — y r#   r-   rX   s     r'   rW   z)UpdateExpressionParser._is_possible_start¿  s   € àr)   c                 óN   •— t        ‰| �  |i |¤Ž t        j                  | «       y r#   ©r‘   r(   r!   r“   s      €r'   r(   zUpdateExpressionParser.__init__Ã  ó#   ø€ Ü‰Ñ˜$Ð) &Ò)Ü%×.Ñ.¨tÕ4r)   c                 ó   — t         S r#   )r   r>   s    r'   r@   z&UpdateExpressionParser._nestable_classÇ  s   € äÐr)   c                 ó$   — | j                  |«      S r#   )r:   )r&   r6   s     r'   Ú_parse_expression_clausez/UpdateExpressionParser._parse_expression_clauseË  s   € Ø×(Ñ(¨Ó7Ð7r)   c                 ó’   — | j                  «       D ]4  }|j                  | j                  «       «      sŒ#| j                  |«        y y)NTF)r§   rZ   r`   r®   )r&   Úsub_factorys     r'   Ú_parse_by_a_subfactoryz-UpdateExpressionParser._parse_by_a_subfactoryÎ  sG   € Ø×.Ñ.Ó0ò 	ˆKØ×,Ñ,¨T×-@Ñ-@Ó-BÕCØ×-Ñ-¨kÔ:Ùð	ð r)   c                 óÔ   — 	 | j                  «        | j                  «       r&t        j                  d«       	 | j                  «       S | j	                  «       rŒX| j                  «        Œh)zy
        Update Expression is the top-most node therefore it is expected to end up at the end of the expression.
        zEnd reached)r€   rk   r1   r2   r±   rƒ   rH   r%   s    r'   rU   zUpdateExpressionParser._parseÕ  s_   € ð Ø×!Ñ!Ô#Ø�~‰~ÔÜ—‘˜]Ô+Øð × Ñ Ó"Ð"ð ×,Ñ,Ô.Øà×+Ñ+Ô-ð r)   Úreturnc                 óX   — t        j                  |«      } | |«      j                  «       S r#   )r   Ú	make_listr^   )r?   Úexpression_strrQ   s      r'   ÚmakezUpdateExpressionParser.makeå  s%   € ä(×2Ñ2°>ÓBˆ
Ù�:‹×$Ñ$Ó&Ð&r)   )r0   rI   rJ   rK   rL   r§   rW   r(   r@   r®   r±   rU   r   r·   rž   rŸ   s   @r'   r¡   r¡   ±  st   ø„ ñð ñ
ó ð
ð ñó ðô5ð ñ ó ð ò8òò#ð  ð'Ð%5ò 'ó ô'r)   r¡   c                   ó&   — e Zd ZdZed„ «       Zd„ Zy)r£   z5
    UpdateExpressionSetClause => SET SetActions
    c                 óz   — |j                   t        j                  k(  xr |j                  j	                  «       dk(  S )NÚSET©ra   r   Ú	ATTRIBUTErh   ÚupperrX   s     r'   rW   z2UpdateExpressionSetClauseParser._is_possible_startð  ó,   € à�z‰zœUŸ_™_Ñ,ÒM°·±×1BÑ1BÓ1DÈÑ1MÐMr)   c                 óÜ   — | j                  | j                  «       «      sJ ‚| j                  «        t        di | j	                  «       ¤Žj                  «       \  }| _        t        |g¬«      S ©NrB   r-   )rZ   r`   r‚   Ú UpdateExpressionSetActionsParserr3   r4   r.   r   ©r&   r9   s     r'   rU   z&UpdateExpressionSetClauseParser._parseô  óf   € Ø×%Ñ% d×&9Ñ&9Ó&;Ô<Ð<Ð<Ø×(Ñ(Ô*Ü>ñ 
Ø×$Ñ$Ó&ñ
ç
‰/Ó
ñ 	ˆˆTŒ^ô )°3°%Ô8Ð8r)   N©r0   rI   rJ   rK   rL   rW   rU   r-   r)   r'   r£   r£   ë  s"   „ ñð ñNó ðNó9r)   r£   c                   ól   ‡ — e Zd ZdZˆ fd„Zed„ «       Zeed„ «       «       Zeed„ «       «       Z	d„ Z
ˆ xZS )ÚUpdateExpressionActionsParserú$
    UpdateExpressionSetActions
    c                 óN   •— t        ‰| �  |i |¤Ž t        j                  | «       y r#   rª   r“   s      €r'   r(   z&UpdateExpressionActionsParser.__init__  r«   r)   c                 óR   — | j                  «       j                  }t        |› d�«      ‚)Nz( cannot be identified by the next token.)r@   r0   ÚRuntimeError)r?   rY   rF   s      r'   rW   z0UpdateExpressionActionsParser._is_possible_start  s)   € à× Ñ Ó"×+Ñ+ˆÜ˜b˜TÐ!IÐJÓKÐKr)   c                 ó   — t         S r#   ©r   r>   s    r'   r@   z-UpdateExpressionActionsParser._nestable_class  s
   € ô *Ð)r)   c                  ó   — y)zCReturns the parser for the query part that creates the nested nodesNr-   r>   s    r'   Ú_nested_expression_parser_classz=UpdateExpressionActionsParser._nested_expression_parser_class  r<   r)   c                 óâ  — | j                  «        | j                  «       j                  | j                  «       «      r°| j	                  | j                  «       «       | j                  «        | j                  «       t        j                  k(  r1| j                  «        | j                  «       r| j                  «        nn.| j                  «       j                  | j                  «       «      rŒ°t        | j                  «      dk(  r[| j                  «       j                  }| j                  «       j                  }t        j!                  d||«       | j                  «        | j#                  «       S )z¥
        UpdateExpressionSetActions is inside the expression so it can be followed by others. Process SetActions one by
        one until no more SetAction.
        r   z#Didn't encounter a single %s in %s.)r€   rÎ   rZ   r`   r:   rc   r   ÚCOMMAr‚   rk   rƒ   rD   r$   r@   r0   r1   r2   rH   )r&   ÚncÚnepcs      r'   rU   z$UpdateExpressionActionsParser._parse  s   € ð
 	×ÑÔà×2Ñ2Ó4×FÑFØ×ÑÓ!ô
ð ×%Ñ% d×&JÑ&JÓ&LÔMØ×!Ñ!Ô#Ø×'Ñ'Ó)¬U¯[©[Ò8Ø×0Ñ0Ô2Ø—>‘>Ô#à×/Ñ/Õ1àð ×2Ñ2Ó4×FÑFØ×ÑÓ!õ
ô ˆt×"Ñ"Ó# qÒ(Ø×%Ñ%Ó'×0Ñ0ˆBØ×7Ñ7Ó9×BÑBˆDÜ�L‰LÐ>ÀÀDÔIØ×'Ñ'Ô)à× Ñ Ó"Ð"r)   )r0   rI   rJ   rK   r(   rL   rW   r   r@   rÎ   rU   rž   rŸ   s   @r'   rÆ   rÆ   þ  sb   ø„ ñô5ð ñLó ðLð Øñ*ó ó ð*ð ØñRó ó ðRö#r)   rÆ   c                   ó0   — e Zd ZdZed„ «       Zed„ «       Zy)rÁ   rÇ   c                 ó   — t         S r#   )ÚUpdateExpressionSetActionParserr>   s    r'   rÎ   z@UpdateExpressionSetActionsParser._nested_expression_parser_class8  ó   € ä.Ð.r)   c                 ó   — t         S r#   rÌ   r>   s    r'   r@   z0UpdateExpressionSetActionsParser._nestable_class<  ó   € ä)Ð)r)   N©r0   rI   rJ   rK   rL   rÎ   r@   r-   r)   r'   rÁ   rÁ   3  ó/   „ ñð ñ/ó ð/ð ñ*ó ñ*r)   rÁ   c                   ó&   — e Zd ZdZed„ «       Zd„ Zy)rÕ   z“
    SetAction => Path = Value

    So we create an UpdateExpressionSetAction Node that has 2 children. Left child Path and right child Value.
    c                 ó,   — t         j                  |«      S r#   ©ÚUpdateExpressionPathParserrZ   rX   s     r'   rW   z2UpdateExpressionSetActionParser._is_possible_startH  ó   € ä)×;Ñ;¸EÓBÐBr)   c                 óX  — t        di | j                  «       ¤Žj                  «       \  }| _        | j	                  «        | j                  t        j                  «       | j	                  «        t        di | j                  «       ¤Žj                  «       \  }| _        t        ||g¬«      S )as  
        UpdateExpressionSetActionParser only gets called when expecting a SetAction. So we should be aggressive on
        raising invalid Tokens.  We can thus do the following:
          1) Process path
          2) skip whitespace if there are any
          3) Process equal-sign token
          4) skip whitespace if there are any
          3) Process value

        rB   r-   )
rÞ   r3   r4   r.   r€   r†   r   Ú
EQUAL_SIGNÚUpdateExpressionValueParserr   ©r&   Úpathrh   s      r'   rU   z&UpdateExpressionSetActionParser._parseL  s›   € ô  :ñ  
Ø×$Ñ$Ó&ñ 
ç
‰/Ó
ñ 	ˆˆdŒnð 	×ÑÔØ×"Ñ"¤5×#3Ñ#3Ô4Ø×ÑÔÜ ;ñ !
Ø×$Ñ$Ó&ñ!
ç
‰/Ó
ñ 	ˆˆtŒ~ô )°4¸°-Ô@Ð@r)   NrÄ   r-   r)   r'   rÕ   rÕ   A  s#   „ ñð ñCó ðCóAr)   rÕ   c                   óh   ‡ — e Zd ZdZˆ fd„Zed„ «       Zd„ Zd„ Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zd„ Zd„ Zˆ xZS )rÞ   zð
    Paths are selectors within items to specify a part within an Item. DynamoDB does not impose much restrictions on the
    data it stores but it does store more strict restrictions on how they are represented in UpdateExpression's.

    c                 ó2   •— t        ‰| �  |i |¤Ž g | _        y r#   )r‘   r(   Ú
path_nodesr“   s      €r'   r(   z#UpdateExpressionPathParser.__init__j  s   ø€ Ü‰Ñ˜$Ð) &Ò)Øˆ�r)   c                 ó¸   — |j                   t        j                  k(  ry|j                   t        j                  k(  r|j                  j                  «       dk7  r	 yy)z­
        Args:
            token(Token): the token to be checked

        Returns:
            bool: Whether the token could be the start of an UpdateExpressionPath
        TÚREMOVEF)ra   r   ÚATTRIBUTE_NAMEr¼   rh   r½   rX   s     r'   rW   z-UpdateExpressionPathParser._is_possible_startn  sF   € ð �:‰:œ×-Ñ-Ò-ØØ�Z‰Zœ5Ÿ?™?Ò*¨u¯{©{×/@Ñ/@Ó/BÀhÒ/NØ;ØØr)   c                 ó"   — | j                  «       S r#   )Úprocess_pathr%   s    r'   rU   z!UpdateExpressionPathParser._parse~  s   € Ø× Ñ Ó"Ð"r)   c                 óN   — | j                  «        t        | j                  ¬«      S ©NrB   )Ú
parse_pathr   rç   r%   s    r'   rì   z'UpdateExpressionPathParser.process_path�  s   € Ø�‰ÔÜ#¨T¯_©_Ô=Ð=r)   c                 ó¨   — | j                  «        | j                  «       r2| j                  «        | j                  «        | j                  «       rŒ1yy)a  
        A path is comprised of:
          - Attribute: the name of an attribute as how it is stored which has no special characters
          - ATTRIBUTE_NAME: A placeholder that has no special characters except leading # to refer to attributes that
                            have a name that is not allowed in an UpdateExpression)
          - DOT's: These are used to decent in a nested structure. When a DOT is in a path expression it is never part
                   of an attribute name but always means to descent into a MAP. We will call each descend a patch
                   chain
          - SELECTORs: E.g.: [1] These are used to select an element in ordered datatypes like a list.

        Whitespaces can be between all these elements that build a path. For SELECTORs it is also allowed to have
        whitespaces between brackets and numbers but the number cannot be split up with spaces

        Attributes and attribute_names must be separated with DOT's.
        Returns:
            UpdateExpressionPath:
        N)Úparse_path_chainÚ"is_next_token_start_of_patch_chainÚprocess_dotr%   s    r'   rï   z%UpdateExpressionPathParser.parse_path…  sB   € ð$ 	×ÑÔØ×5Ñ5Ô7Ø×ÑÔØ×!Ñ!Ô#ð ×5Ñ5×7r)   c                 óD   — | j                  «       t        j                  k(  S r#   )rc   r   ÚDOTr%   s    r'   rò   z=UpdateExpressionPathParser.is_next_token_start_of_patch_chainœ  s   € Ø×'Ñ'Ó)¬U¯Y©YÑ6Ð6r)   c                 ój   — | j                   j                  t        «       «       | j                  «        y r#   )rç   r5   r
   r‚   r%   s    r'   ró   z&UpdateExpressionPathParser.process_dotŸ  s$   € Ø�‰×ÑÔ6Ó8Ô9Ø×(Ñ(Õ*r)   c                 óÈ   — | j                  «        | j                  «        | j                  «       r2| j                  «        | j                  «        | j                  «       rŒ1y y r#   )Ú#process_attribute_identifying_tokenr€   Úis_next_token_start_of_selectorÚprocess_selectorr%   s    r'   rñ   z+UpdateExpressionPathParser.parse_path_chain£  sL   € Ø×0Ñ0Ô2Ø×ÑÔØ×2Ñ2Ô4Ø×!Ñ!Ô#Ø×!Ñ!Ô#ð ×2Ñ2×4r)   c                 ó”  — | j                  «       t        j                  k(  r3| j                  j	                  t        | j                  «       «      «       nd| j                  «       t        j                  k(  r3| j                  j	                  t        | j                  «       «      «       n| j                  «        | j                  «        y r#   )rc   r   r¼   rç   r5   r   ri   rê   r   rƒ   r‚   r%   s    r'   rø   z>UpdateExpressionPathParser.process_attribute_identifying_tokenª  sˆ   € Ø×#Ñ#Ó%¬¯©Ò8Ø�O‰O×"Ñ"Ô#6°t×7PÑ7PÓ7RÓ#SÕTØ×%Ñ%Ó'¬5×+?Ñ+?Ò?Ø�O‰O×"Ñ"Ô#:¸4×;TÑ;TÓ;VÓ#WÕXà×'Ñ'Ô)à×(Ñ(Õ*r)   c                 óD   — | j                  «       t        j                  k(  S r#   )rc   r   ÚOPEN_SQUARE_BRACKETr%   s    r'   rù   z:UpdateExpressionPathParser.is_next_token_start_of_selector´  s   € Ø×'Ñ'Ó)¬U×-FÑ-FÑFÐFr)   c                 ó  — | j                  t        j                  «       | j                  t        j                  «      }| j                  t        j                  «       | j
                  j                  t        |«      «       y)a  
        Process the selector is only called when a selector must be processed. So do the following actions:
         - skip opening bracket
         - skip optional spaces
         - read numeric literal
         - skip optional spaces
         - pass closing bracket
        N)r†   r   rý   ÚNUMBERÚCLOSE_SQUARE_BRACKETrç   r5   r   )r&   Úselector_values     r'   rú   z+UpdateExpressionPathParser.process_selector·  sX   € ð 	×"Ñ"¤5×#<Ñ#<Ô=Ø×3Ñ3´E·L±LÓAˆØ×"Ñ"¤5×#=Ñ#=Ô>Ø�‰×ÑÔ1°.ÓAÕBr)   )r0   rI   rJ   rK   r(   rL   rW   rU   rì   rï   rò   ró   rñ   rø   rù   rú   rž   rŸ   s   @r'   rÞ   rÞ   c  sP   ø„ ñôð ñó ðò#ò>ò$ò.7ò+ò$ò+òGöCr)   rÞ   c                   ó(   — e Zd Zed„ «       Zd„ Zd„ Zy)râ   c                 ó,   — t         j                  |«      S r#   )ÚUpdateExpressionOperandParserrZ   rX   s     r'   rW   z.UpdateExpressionValueParser._is_possible_startÇ  s   € ä,×>Ñ>¸uÓEÐEr)   c                 ó   — t         S r#   )r  r%   s    r'   r˜   z2UpdateExpressionValueParser._operand_factory_classË  s   € Ü,Ð,r)   c                 ó   — t         S r#   )Ú#UpdateExpressionValueOperatorParserr%   s    r'   r™   z0UpdateExpressionValueParser._binop_factory_classÎ  s   € Ü2Ð2r)   N)r0   rI   rJ   rL   rW   r˜   r™   r-   r)   r'   râ   râ   Æ  s    „ ØñFó ðFò-ó3r)   râ   c                   ó&   — e Zd ZdZd„ Zed„ «       Zy)Ú"UpdateExpressionGroupedValueParserz—
    A grouped value is an Update Expression value clause that is surrounded by round brackets. Each Operand can be
    a grouped value by itself.
    c                 óô   — | j                  t        j                  «       t        di | j	                  «       ¤Žj                  «       \  }| _        | j                  t        j                  «       t        |¬«      S rÀ   )	r†   r   ÚOPEN_ROUND_BRACKETrâ   r3   r4   r.   ÚCLOSE_ROUND_BRACKETr   )r&   rh   s     r'   rU   z)UpdateExpressionGroupedValueParser._parseØ  sc   € Ø×"Ñ"¤5×#;Ñ#;Ô<Ü ;ñ !
Ø×$Ñ$Ó&ñ!
ç
‰/Ó
ñ 	ˆˆtŒ~ð 	×"Ñ"¤5×#<Ñ#<Ô=Ü+°UÔ;Ð;r)   c                 ó<   — |j                   t        j                  k(  S r#   )ra   r   r  rX   s     r'   rW   z5UpdateExpressionGroupedValueParser._is_possible_startà  s   € à�z‰zœU×5Ñ5Ñ5Ð5r)   N©r0   rI   rJ   rK   rU   rL   rW   r-   r)   r'   r	  r	  Ò  s    „ ñò
<ð ñ6ó ñ6r)   r	  c                   óR   — e Zd Zej                  ej
                  gZed„ «       Zd„ Z	y)r  c                 ó2   — |j                   | j                  v S r#   )ra   ÚOPERATION_TOKENSrX   s     r'   rW   z6UpdateExpressionValueOperatorParser._is_possible_startè  s   € à�z‰z˜S×1Ñ1Ð1Ð1r)   c                 óx   — | j                  «       }|| j                  v sJ ‚| j                  «        t        |«      S r#   )ri   r  r‚   r   )r&   Úoperation_values     r'   rU   z*UpdateExpressionValueOperatorParser._parseì  s;   € Ø×3Ñ3Ó5ˆØ $×"7Ñ"7Ñ7Ð7Ð7Ø×(Ñ(Ô*Ü& Ó7Ð7r)   N)
r0   rI   rJ   r   Ú	PLUS_SIGNÚ
MINUS_SIGNr  rL   rW   rU   r-   r)   r'   r  r  å  s.   „ ØŸ™¨×)9Ñ)9Ð:Ðàñ2ó ð2ó8r)   r  c                   ó6   — e Zd ZdZed„ «       Zed„ «       Zd„ Zy)r  z‹
    Grammar
    Operand* => AttributeValue
    Operand* => UpdateExpressionFunction
    Operand* => Path
    Operand* => GroupedValue
    c                 ó.   — t         t        t        t        gS r#   )Ú$UpdateExpressionAttributeValueParserÚUpdateExpressionFunctionParserrÞ   r	  r>   s    r'   r§   z,UpdateExpressionOperandParser._sub_factoriesü  s   € ô 1Ü*Ü&Ü.ð	
ð 	
r)   c                 óH   ‡— t        ˆfd„| j                  «       D «       «      S )Nc              3   ó@   •K  — | ]  }|j                  ‰«      –— Œ y ­wr#   )rZ   )Ú.0ÚparserrY   s     €r'   ú	<genexpr>zCUpdateExpressionOperandParser._is_possible_start.<locals>.<genexpr>  s   øè ø€ ÒV°v�6×+Ñ+¨E×2ÑVùs   ƒ)Úanyr§   rX   s    `r'   rW   z0UpdateExpressionOperandParser._is_possible_start  s   ø€ äÓVÀ×ASÑASÓAUÔVÓVÐVr)   c                 óì   — | j                  «       D ]Q  }|j                  | j                  «       «      sŒ# |di | j                  «       ¤Žj	                  «       \  }| _        |c S  | j                  «        y ©Nr-   )r§   rZ   r`   r3   r4   r.   rƒ   )r&   ÚfactoryÚnodes      r'   rU   z$UpdateExpressionOperandParser._parse	  sr   € Ø×*Ñ*Ó,ò 	ˆGØ×(Ñ(¨×)<Ñ)<Ó)>Õ?Ù'.ñ (Ø×,Ñ,Ó.ñ(ç!‘/Ó#ñ %��d”nð ’ð	ð 	×#Ñ#Õ%r)   N)r0   rI   rJ   rK   rL   r§   rW   rU   r-   r)   r'   r  r  ó  s6   „ ñð ñ
ó ð
ð ñWó ðWó&r)   r  c                   ó"   — e Zd Zd„ Zed„ «       Zy)r  c                 óV   — t        | j                  t        j                  «      «      }|S r#   )r	   r†   r   ÚATTRIBUTE_VALUE)r&   Ú
attr_values     r'   rU   z+UpdateExpressionAttributeValueParser._parse  s(   € Ü-Ø×&Ñ&¤u×'<Ñ'<Ó=ó
ˆ
ð Ðr)   c                 ó<   — |j                   t        j                  k(  S r#   )ra   r   r&  rX   s     r'   rW   z7UpdateExpressionAttributeValueParser._is_possible_start  s   € à�z‰zœU×2Ñ2Ñ2Ð2r)   N©r0   rI   rJ   rU   rL   rW   r-   r)   r'   r  r    s   „ òð ñ3ó ñ3r)   r  c                   ó"   — e Zd Zd„ Zed„ «       Zy)Ú*UpdateExpressionAttributeValueOrPathParserc                 ó  — t         j                  | j                  «       «      r1t        di | j                  «       ¤Žj	                  «       \  }| _        |S t        di | j                  «       ¤Žj	                  «       \  }| _        |S r!  )r  rZ   r`   r3   r4   r.   rÞ   )r&   rY   s     r'   rU   z1UpdateExpressionAttributeValueOrPathParser._parse   s‡   € Ü/×AÑAØ×ÑÓ!ô
ô %Iñ %Ø×(Ñ(Ó*ñ%ç‰oÓñ "ˆE�4”>ð ˆô %?ñ %Ø×(Ñ(Ó*ñ%ç‰oÓñ "ˆE�4”>ð ˆr)   c                 óh   — t        t        j                  |«      t        j                  |«      g«      S r#   )r  r  rZ   rÞ   rX   s     r'   rW   z=UpdateExpressionAttributeValueOrPathParser._is_possible_start-  s0   € ää4×FÑFÀuÓMÜ*×<Ñ<¸UÓCðó
ð 	
r)   Nr)  r-   r)   r'   r+  r+    s   „ òð ñ
ó ñ
r)   r+  c                   ó8   — e Zd ZdZeegeegdœZed„ «       Z	d„ Z
y)r  z@
    A helper to process a function of an Update Expression
    )Úif_not_existsÚlist_appendc                 óŠ   — |j                   t        j                  k(  r&|j                  | j                  j                  «       v S y)zÍ
        Check whether a token is supposed to be a function
        Args:
            token(Token): the token to check

        Returns:
            bool: True if token is the start of a function.
        F)ra   r   r¼   rh   Ú	FUNCTIONSÚkeysrX   s     r'   rW   z1UpdateExpressionFunctionParser._is_possible_startE  s3   € ð �:‰:œŸ™Ò(Ø—;‘; #§-¡-×"4Ñ"4Ó"6Ð6Ð6àr)   c                 ój  — | j                  «       }|| j                  j                  «       vrt        |«      ‚| j	                  «        | j                  t        j                  «       |g}| j                  |   }t        |«      D ]ƒ  \  }} |di | j                  «       ¤Žj                  «       \  }| _        |j                  |«       |dz   t        |«      k  sŒU| j                  «        | j                  t        j                  «       Œ… | j                  t        j                   «       t#        |¬«      S )Nro   rB   r-   )ri   r2  r3  r   r‚   r†   r   r  Ú	enumerater3   r4   r.   r5   rD   r€   rÐ   r  r   )r&   Úfunction_nameÚfunction_elementsÚfunction_argumentsÚiÚfunc_elem_factoryÚ	func_elems          r'   rU   z%UpdateExpressionFunctionParser._parseT  s  € Ø×1Ñ1Ó3ˆØ §¡× 3Ñ 3Ó 5Ñ5ä)¨-Ó8Ð8Ø×(Ñ(Ô*Ø×"Ñ"¤5×#;Ñ#;Ô<Ø*˜OÐØ!Ÿ^™^¨MÑ:ÐÜ$-Ð.@Ó$Aò 	8Ñ ˆAÐ Ù(9ñ )Ø×(Ñ(Ó*ñ)ç‰oÓñ &ˆI�t”~ð ×$Ñ$ YÔ/Ø�1‰u”sÐ-Ó.Ó.Ø×%Ñ%Ô'Ø×*Ñ*¬5¯;©;Õ7ð	8ð 	×"Ñ"¤5×#<Ñ#<Ô=Ü'Ð1BÔCÐCr)   N)r0   rI   rJ   rK   rÞ   r+  r  r2  rL   rW   rU   r-   r)   r'   r  r  7  s@   „ ñð 'Ø6ð
ð 6Ð7TÐUñ€Ið ñó ðóDr)   r  c                   ó&   — e Zd ZdZd„ Zed„ «       Zy)r¦   z>
    UpdateExpressionRemoveClause => REMOVE RemoveActions
    c                 óÜ   — | j                  | j                  «       «      sJ ‚| j                  «        t        di | j	                  «       ¤Žj                  «       \  }| _        t        |g¬«      S rÀ   )rZ   r`   r‚   Ú#UpdateExpressionRemoveActionsParserr3   r4   r.   r   rÂ   s     r'   rU   z)UpdateExpressionRemoveClauseParser._parsen  óf   € Ø×%Ñ% d×&9Ñ&9Ó&;Ô<Ð<Ð<Ø×(Ñ(Ô*ÜAñ 
Ø×$Ñ$Ó&ñ
ç
‰/Ó
ñ 	ˆˆTŒ^ô ,°c°UÔ;Ð;r)   c                 óz   — |j                   t        j                  k(  xr |j                  j	                  «       dk(  S )zREMOVE is not a keywordré   r»   rX   s     r'   rW   z5UpdateExpressionRemoveClauseParser._is_possible_startw  s.   € ð �z‰zœUŸ_™_Ñ,ÒP°·±×1BÑ1BÓ1DÈÑ1PÐPr)   Nr  r-   r)   r'   r¦   r¦   i  s"   „ ñò<ð ñQó ñQr)   r¦   c                   ó0   — e Zd ZdZed„ «       Zed„ «       Zy)r>  rÇ   c                 ó   — t         S r#   )Ú"UpdateExpressionRemoveActionParserr>   s    r'   rÎ   zCUpdateExpressionRemoveActionsParser._nested_expression_parser_class‚  ó   € ä1Ð1r)   c                 ó   — t         S r#   )r   r>   s    r'   r@   z3UpdateExpressionRemoveActionsParser._nestable_class†  ó   € ä,Ð,r)   NrÙ   r-   r)   r'   r>  r>  }  ó/   „ ñð ñ2ó ð2ð ñ-ó ñ-r)   r>  c                   ó&   — e Zd ZdZed„ «       Zd„ Zy)rC  z–
    RemoveAction => Path = Value

    So we create an UpdateExpressionSetAction Node that has 2 children. Left child Path and right child Value.
    c                 ó,   — t         j                  |«      S r#   rÝ   rX   s     r'   rW   z5UpdateExpressionRemoveActionParser._is_possible_start’  rß   r)   c                 óš   — t        di | j                  «       ¤Žj                  «       \  }| _        | j	                  «        t        |g¬«      S )a
  
        UpdateExpressionRemoveActionParser only gets called when expecting a RemoveAction. So we should be aggressive on
        raising invalid Tokens.  We can thus do the following:
          1) Process path
          2) skip whitespace if there are any

        rB   r-   )rÞ   r3   r4   r.   r€   r   )r&   rä   s     r'   rU   z)UpdateExpressionRemoveActionParser._parse–  sK   € ô  :ñ  
Ø×$Ñ$Ó&ñ 
ç
‰/Ó
ñ 	ˆˆdŒnð 	×ÑÔÜ+°d°VÔ<Ð<r)   NrÄ   r-   r)   r'   rC  rC  ‹  s"   „ ñð ñCó ðCó=r)   rC  c                   ó"   — e Zd Zd„ Zed„ «       Zy)r¤   c                 óÜ   — | j                  | j                  «       «      sJ ‚| j                  «        t        di | j	                  «       ¤Žj                  «       \  }| _        t        |g¬«      S rÀ   )rZ   r`   r‚   Ú UpdateExpressionAddActionsParserr3   r4   r.   r   rÂ   s     r'   rU   z&UpdateExpressionAddClauseParser._parse¦  rÃ   r)   c                 óz   — |j                   t        j                  k(  xr |j                  j	                  «       dk(  S )NÚADDr»   rX   s     r'   rW   z2UpdateExpressionAddClauseParser._is_possible_start¯  r¾   r)   Nr)  r-   r)   r'   r¤   r¤   ¥  s   „ ò9ð ñNó ñNr)   r¤   c                   ó0   — e Zd ZdZed„ «       Zed„ «       Zy)rM  rÇ   c                 ó   — t         S r#   )ÚUpdateExpressionAddActionParserr>   s    r'   rÎ   z@UpdateExpressionAddActionsParser._nested_expression_parser_class¹  rÖ   r)   c                 ó   — t         S r#   )r   r>   s    r'   r@   z0UpdateExpressionAddActionsParser._nestable_class½  rØ   r)   NrÙ   r-   r)   r'   rM  rM  ´  rÚ   r)   rM  c                   ó   — e Zd Zd„ Zy)ÚUpdateExpressionPathValueParserc                 ó  — t        di | j                  «       ¤Žj                  «       \  }| _        | j	                  «        t        di | j                  «       ¤Žj                  «       \  }| _        | j	                  «        ||gS )a¹  
        UpdateExpressionAddActionParser only gets called when expecting an AddAction. So we should be aggressive on
        raising invalid Tokens.  We can thus do the following:
          1) Process path
          2) skip whitespace if there are any
          3) Process a value
          4) skip whitespace if there are any

        Returns:
            [path, value]: A list containing the Path node and the AttributeValue nodes
        r-   )rÞ   r3   r4   r.   r€   r  rã   s      r'   Ú_parse_path_and_valuez5UpdateExpressionPathValueParser._parse_path_and_valueÃ  s‚   € ô  :ñ  
Ø×$Ñ$Ó&ñ 
ç
‰/Ó
ñ 	ˆˆdŒnð 	×ÑÔÜ Dñ !
Ø×$Ñ$Ó&ñ!
ç
‰/Ó
ñ 	ˆˆtŒ~ð 	×ÑÔØ�eˆ}Ðr)   N)r0   rI   rJ   rW  r-   r)   r'   rU  rU  Â  s   „ ór)   rU  c                   ó"   — e Zd Zed„ «       Zd„ Zy)rR  c                 ó,   — t         j                  |«      S r#   rÝ   rX   s     r'   rW   z2UpdateExpressionAddActionParser._is_possible_startÛ  rß   r)   c                 ó6   — t        | j                  «       ¬«      S rî   )r   rW  r%   s    r'   rU   z&UpdateExpressionAddActionParser._parseß  s   € Ü(°$×2LÑ2LÓ2NÔOÐOr)   N©r0   rI   rJ   rL   rW   rU   r-   r)   r'   rR  rR  Ú  s   „ ØñCó ðCóPr)   rR  c                   ó"   — e Zd Zd„ Zed„ «       Zy)r¥   c                 óÜ   — | j                  | j                  «       «      sJ ‚| j                  «        t        di | j	                  «       ¤Žj                  «       \  }| _        t        |g¬«      S rÀ   )rZ   r`   r‚   Ú#UpdateExpressionDeleteActionsParserr3   r4   r.   r   rÂ   s     r'   rU   z)UpdateExpressionDeleteClauseParser._parseä  r?  r)   c                 óz   — |j                   t        j                  k(  xr |j                  j	                  «       dk(  S )NÚDELETEr»   rX   s     r'   rW   z5UpdateExpressionDeleteClauseParser._is_possible_startí  s,   € à�z‰zœUŸ_™_Ñ,ÒP°·±×1BÑ1BÓ1DÈÑ1PÐPr)   Nr)  r-   r)   r'   r¥   r¥   ã  s   „ ò<ð ñQó ñQr)   r¥   c                   ó0   — e Zd ZdZed„ «       Zed„ «       Zy)r^  rÇ   c                 ó   — t         S r#   )Ú"UpdateExpressionDeleteActionParserr>   s    r'   rÎ   zCUpdateExpressionDeleteActionsParser._nested_expression_parser_class÷  rD  r)   c                 ó   — t         S r#   )r   r>   s    r'   r@   z3UpdateExpressionDeleteActionsParser._nestable_classû  rF  r)   NrÙ   r-   r)   r'   r^  r^  ò  rG  r)   r^  c                   ó"   — e Zd Zed„ «       Zd„ Zy)rc  c                 ó,   — t         j                  |«      S r#   rÝ   rX   s     r'   rW   z5UpdateExpressionDeleteActionParser._is_possible_start  rß   r)   c                 ó6   — t        | j                  «       ¬«      S rî   )r   rW  r%   s    r'   rU   z)UpdateExpressionDeleteActionParser._parse  s   € Ü+°T×5OÑ5OÓ5QÔRÐRr)   Nr[  r-   r)   r'   rc  rc     s   „ ØñCó ðCóSr)   rc  )AÚabcÚloggingr   Úcollectionsr   Úmoto.dynamodb.exceptionsr   r   Úmoto.dynamodb.parsing.ast_nodesr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Úmoto.dynamodb.parsing.tokensr   r   Ú	getLoggerr0   r1   r!   ÚABCMetarN   r�   r¡   r£   rÆ   rÁ   rÕ   rÞ   râ   r	  r  r  r  r+  r  r¦   r>  rC  r¤   rM  rU  rR  r¥   r^  rc  r-   r)   r'   ú<module>rp     sÎ  ðã 
Û Ý Ý ç S÷÷ ÷ ÷ ÷ ÷ ñ ÷2 Dà	ˆ×	Ñ	˜8Ó	$€÷Xñ Xôv}= §¡õ }=ô@mÐ"2ô mô`7'Ð-Ð/Lô 7'ôt9Ð&6ô 9ô&2#Ð$4Ð6Sô 2#ôj*Ð'Dô *ôAÐ&6ô AôD`CÐ!1ô `CôF	3Ð"=ô 	3ô6Ð)9ô 6ô&8Ð*:ô 8ô&Ð$4ô &ô@	3Ð+;ô 	3ô
Ð1Aô 
ô0/DÐ%5ô /DôdQÐ)9ô Qô(-Ð*Gô -ô=Ð)9ô =ô4NÐ&6ô Nô*Ð'Dô *ôÐ&6À#Ç+Á+õ ô0PÐ&Eô PôQÐ)9ô Qô-Ð*Gô -ôSÐ)Hõ Sr)   