
    ?d                     8    d Z d Zd Zd Zd Zd Zd Zd Zd Zy	)
a  PyParser-related utilities.

This module collects various utilities related to the parse trees produced by
the pyparser.

  GetLogicalLine: produces a list of tokens from the logical lines within a
    range.
  GetTokensInSubRange: produces a sublist of tokens from a current token list
    within a range.
  GetTokenIndex: Get the index of a token.
  GetNextTokenIndex: Get the index of the next token after a given position.
  GetPrevTokenIndex: Get the index of the previous token before a given
    position.
  TokenStart: Convenience function to return the token's start as a tuple.
  TokenEnd: Convenience function to return the token's end as a tuple.
c                     t        |      }t        |      }g }| D ]X  }|j                  |kD  r |S |j                  |k  s|j                  |k\  s4|j	                  t        |j                  |             Z |S )zDGet a list of tokens within the node's range from the logical lines.)
TokenStartTokenEndstartendextendGetTokensInSubRangetokens)logical_linesnoder   r   r	   lines         >/usr/lib/python3/dist-packages/yapf/pyparser/pyparser_utils.pyGetLogicalLiner       sv    
T
%#& <dzzC 
- zzUdhh#omm'T:;	< 
-    c                     t        |      }t        |      }g }| D ]7  }|j                  |j                  f}||k\  s!||k  s'|j	                  |       9 |S )z-Get a subset of tokens representing the node.)r   r   linenocolumnappend)r	   r   r   r   tokens_in_rangetok	tok_ranges          r   r   r   /   s_    
T
%#/ "cSZZ(IEi#oS!"
 
r   c                 h    t        |       D ]$  \  }}|j                  |j                  f|k(  s"|c S  y)z"Get the index of the token at pos.N	enumerater   r   r	   posindextokens       r   GetTokenIndexr   =   9    ' leUell#s*l 
r   c                 h    t        |       D ]$  \  }}|j                  |j                  f|k\  s"|c S  y)z*Get the index of the next token after pos.Nr   r   s       r   GetNextTokenIndexr!   F   r   r   c                 z    t        |       D ]-  \  }}|dkD  s|j                  |j                  f|k\  s(|dz
  c S  y)z/Get the index of the previous token before pos.       Nr   r   s       r   GetPrevTokenIndexr%   O   sD    ' leUqyellELL1S8QY 
r   c                 2    | j                   | j                  fS N)r   
col_offsetr   s    r   r   r   X   s    
++t	''r   c                 2    | j                   | j                  fS r'   )
end_linenoend_col_offsetr)   s    r   r   r   \   s    
//4..	//r   c                 F    dd l }t        |j                  | dd             y )Nr#   T   )include_attributesindent)astprintdump)r   r1   s     r   AstDumpr4   e   s    $q9:r   N)	__doc__r   r   r   r!   r%   r   r   r4    r   r   <module>r7      s2   $(0;r   