File: //opt/alt/python27/lib64/python2.7/site-packages/guppy/gsl/DottedTree.pyc
�
;�Pc           @   ss   d  Z  d e f d �  �  YZ d d d �  �  YZ d �  Z d �  Z d �  Z d �  Z d	 se e d
 k ro e �  n  d S(
   s�  
Handling of tree structures given in a special 'dotted' syntax.
This represents trees of nodes with strings as tags,
in a readable and writable and easy to parse syntax.
There are two main functions, unparse_sexpr and parse_string.
When parsing, the result is by default given in 'sexpr' format:
each node is a tuple of the form
    (tag, ) or (tag, node) or (tag, node, node) ...
The following invariant is intended to hold for every node x, 
    parse_string(unparse_sexpr(x)) == x
Currently the following invariant has been tested for some strings:
    unparse_sexpr(parse_string(s)).strip() == s.strip()
[It only holds on stripped results but may be fixed sometime.]
t   Nodec           B   s)   e  Z d Z d �  Z d �  Z d �  Z RS(   t   tagt   childrent   indexc         C   s   | |  _  | |  _ | |  _ d  S(   N(   R   R   R   (   t   selfR   R   R   (    (    sG   /opt/alt/python27/lib64/python2.7/site-packages/guppy/gsl/DottedTree.pyt   __init__   s    		c         C   s0   |  j  f t g  |  j D] } | j �  ^ q � S(   N(   R   t   tupleR   t   as_sexpr(   R   t   c(    (    sG   /opt/alt/python27/lib64/python2.7/site-packages/guppy/gsl/DottedTree.pyR   !   s    c         C   s#   d |  j  j |  j |  j |  j f S(   Ns   %s(%r, %r, %r)(   t	   __class__t   __name__R   R   R   (   R   (    (    sG   /opt/alt/python27/lib64/python2.7/site-packages/guppy/gsl/DottedTree.pyt   __repr__$   s
    	(   R   R   R   (   R
   t
   __module__t	   __slots__R   R   R   (    (    (    sG   /opt/alt/python27/lib64/python2.7/site-packages/guppy/gsl/DottedTree.pyR       s   		t   _GLUECLAMP_c           B   s�   e  Z d Z d Z d Z d Z d �  Z d �  Z e Z d d � Z
 d d � Z d d	 � Z d d
 � Z
 d �  Z d �  Z d
 �  Z RS(   s   _parent.FileIO:IOt   nodet   dotchart   .s   \c         C   s   | f t  | � S(   N(   R   (   R   R   R   t	   lineindex(    (    sG   /opt/alt/python27/lib64/python2.7/site-packages/guppy/gsl/DottedTree.pyt
   node_sexprI   s    c         C   s   t  | t | � | � S(   N(   R    R   (   R   R   R   R   (    (    sG   /opt/alt/python27/lib64/python2.7/site-packages/guppy/gsl/DottedTree.pyt	   node_nodeT   s    c         C   s   |  j  |  j j | � | � S(   N(   t   parse_stringt   IOt	   read_file(   R   t   filet   src(    (    sG   /opt/alt/python27/lib64/python2.7/site-packages/guppy/gsl/DottedTree.pyt
   parse_fileY   s    c         C   s�  |  j  } |  j } g  } | }	 xU y | j �  \ } }
 Wn t k
 rQ d  }
 Pn X|
 j | � sq | j |
 � q! Pq! Wx[ t | � D]M \ } } | j | | � s� | j | | | � r� | t | � | | <q� q� W| d g k r� d } n d j	 | � } x� |
 d  k sDt |
 � | k sD|
 | | k sD|
 j | | d � r`| |
 |  j
 | | |	 � f St |
 � | d k r�|
 | d | k r�| d  k r�t d � q�| j d | � n  |  j
 | d |
 | d g | | | � \ } }
 }
 | j |
 � q� Wd  S(   Nt    s   
i   s   Level must increase with 1 max(   R   t	   quotechart   nextt
   StopIterationt   Nonet
   startswitht   appendt	   enumeratet   lent   joinR   t   SyntaxErrort   errort
   parse_iter(   R   t   posR   R   t   itR   R   R   R   t	   firstlineR   t   it   tt   child(    (    sG   /opt/alt/python27/lib64/python2.7/site-packages/guppy/gsl/DottedTree.pyR'