Ë
    hKêj�Q  ã                   óª  — d Z ddlmZ ddlmZ ddlZddlZdZ ej                  e«      Z	d„ Z
er?d„ Z
ddlZ ej                  ej                  ¬«       e	j                  ej                  «        e«       Z G d	„ d
e«      Z G d„ de«      Zd„ Z G d„ de«      Z ej,                  dej.                  ej0                  z  ej2                  z  «      Zd„ Zy)u,  
Aho-Corasick string search algorithm in pure Python

Original Author: Wojciech MuÅ‚a, wojciech_mula@poczta.onet.pl
WWW            : http://0x80.pl
License        : public domain

This is the pure Python Aho-Corasick automaton from pyahocorasick modified for
use in the license_expression library for advanced tokenization:

 - add support for unicode strings.
 - case insensitive search using sequence of words and not characters
 - improve returned results with the actual start,end and matched string.
 - support returning non-matched parts of a string
é    )Údeque)ÚOrderedDictNFc                   ó   — y ©N© ©Úargss    úf/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/license_expression/_pyahocorasick.pyÚlogger_debugr   !   s   € Øó    c                  óX   — t         j                  dj                  d„ | D «       «      «      S )Nú c              3   ó^   K  — | ]%  }t        |t        «      xr |xs t        |«      –— Œ' y ­wr   )Ú
isinstanceÚstrÚrepr)Ú.0Úas     r
   ú	<genexpr>zlogger_debug.<locals>.<genexpr>(   s(   è ø€ Ò$WÈQ¤Z°´3Ó%7Ò%=¸AÒ%HÄÀaÃÓ%HÑ$Wùs   ‚+-)ÚloggerÚdebugÚjoinr   s    r
   r   r   '   s!   € Ü�|‰|˜CŸH™HÑ$WÐRVÔ$WÓWÓXÐXr   )Ústreamc                   ó(   — e Zd ZdZg d¢Zefd„Zd„ Zy)ÚTrieNodez2
    Node of the Trie/Aho-Corasick automaton.
    )ÚtokenÚoutputÚfailÚchildrenc                 óD   — || _         || _        t        | _        i | _        y r   )r   r   Únilr   r   )Úselfr   r   s      r
   Ú__init__zTrieNode.__init__:   s$   € àˆŒ
ð ˆŒô ˆŒ	ð ˆ�r   c                 ó~   — | j                   t        urd| j                  ›d| j                   ›d�S d| j                  z  S )Nz	TrieNode(z, ú)zTrieNode(%r))r   r!   r   ©r"   s    r
   Ú__repr__zTrieNode.__repr__J   s0   € Ø�;‰;œcÒ!Ø)-¯«°T·[³[ÐAÐAà! D§J¡JÑ.Ð.r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r!   r#   r'   r   r   r
   r   r   3   s   „ ñò 8€Ià%(ó ó /r   r   c                   ób   — e Zd ZdZd„ Zdd„Zd„ Zefd„Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zdd„Zdd„Zy)ÚTriez†
    A Trie and Aho-Corasick automaton. This behaves more or less like a mapping of
    key->value. This is the main entry point.
    c                 óP   — t        d«      | _        t        «       | _        d| _        y)z(
        Initialize a new Trie.
        Ú FN)r   ÚrootÚsetÚ_known_tokensÚ
_convertedr&   s    r
   r#   zTrie.__init__W   s$   € ô ˜R“LˆŒ	ô
 !›UˆÔð  ˆ�r   Nc                 ó   — | j                   rt        d«      ‚|rt        |t        «      syt	        |«      D �cg c]  }|j                  «       sŒ|‘Œ }}| j                  j                  |«       | j                  }|D ]  }	 |j                  |   }Œ ||xs |f|_        yc c}w # t        $ r t        |«      }||j                  |<   |}Y ŒOw xY w)a~  
        Add a new tokens_string and its associated value to the trie. If the
        tokens_string already exists in the Trie, its value is replaced with the
        provided value, typically a Token object. If a value is not provided,
        the tokens_string is used as value.

        A tokens_string is any string. It will be tokenized when added
        to the Trie.
        zQThis Trie has been converted to an Aho-Corasick automaton and cannot be modified.N)r4   Ú	Exceptionr   r   Ú
get_tokensÚstripr3   Úupdater1   r   ÚKeyErrorr   r   )r"   Útokens_stringÚvalueÚtÚtokensÚnoder   Úchilds           r
   ÚaddzTrie.adde   sÓ   € ð �?Š?ÜØcóð ñ ¤J¨}¼cÔ$BØä'¨Ó6ÖD˜¸!¿'¹'½)’!ÐDˆÐDð 	×Ñ×!Ñ! &Ô)à�y‰yˆØò 	ˆEðØ—}‘} UÑ+‘ð	ð % eÒ&<¨}Ð=ˆ�ùò# Eøô ò Ü  ›�Ø',�—‘˜eÑ$Ø’ðús   ¸B ÁB ÂB%Â%%CÃCc                 óî   — |rt        |t        «      syt        |«      D �cg c]  }|j                  «       sŒ|‘Œ }}| j                  }|D ]  }	 |j
                  |   }Œ |S c c}w # t        $ r Y  yw xY w)zÎ
        Return a node for this tokens_string or None if the trie does not
        contain the tokens_string. Private function retrieving a final node of
        the Trie for a given tokens_string.
        N)r   r   r7   r8   r1   r   r:   )r"   r;   r=   r>   r?   r   s         r
   Ú
__get_nodezTrie.__get_nodeŠ   s   € ñ ¤J¨}¼cÔ$BØä'¨Ó6ÖD˜¸!¿'¹'½)’!ÐDˆÐDØ�y‰yˆØò 	ˆEðØ—}‘} UÑ+‘ð	ð
 ˆùò Eøô
 ò Úðús   ¡A"·A"ÁA'Á'	A4Á3A4c                 óŠ   — | j                  |«      }t        }|r|j                  }|t        u r|t        u rt        |«      ‚|S |S )a   
        Return the output value found associated with a `tokens_string`. If
        there is no such tokens_string in the Trie, return the default value
        (other than nil). If `default` is not provided or is `nil`, raise a
        KeyError.
        )Ú_Trie__get_noder!   r   r:   )r"   r;   Údefaultr?   r   s        r
   ÚgetzTrie.getœ   sF   € ð �‰˜}Ó-ˆÜˆÙØ—[‘[ˆFà”S‰=Øœ#‰~Ü˜}Ó-Ð-à�àˆMr   c                 ó0   — d„ | j                  «       D «       S )z5
        Yield all keys stored in this trie.
        c              3   ó&   K  — | ]	  \  }}|–— Œ y ­wr   r   )r   ÚkeyÚ_s      r
   r   zTrie.keys.<locals>.<genexpr>´   s   è ø€ Ò/™˜˜Q”Ñ/ùó   ‚©Úitemsr&   s    r
   Úkeysz	Trie.keys°   s   € ñ 0 $§*¡*£,Ô/Ð/r   c                 ó0   — d„ | j                  «       D «       S )zL
        Yield all values associated with keys stored in this trie.
        c              3   ó&   K  — | ]	  \  }}|–— Œ y ­wr   r   )r   rK   r<   s      r
   r   zTrie.values.<locals>.<genexpr>º   s   è ø€ Ò3™(˜!˜U”Ñ3ùrL   rM   r&   s    r
   ÚvalueszTrie.values¶   s   € ñ 4 d§j¡j£lÔ3Ð3r   c                 óT   ‡‡— g Šˆˆfd„Š ‰| j                   g ¬«       t        ‰«      S )zF
        Yield tuple of all (key, value) stored in this trie.
        c                 ó(  •— || j                   gz   D �cg c]  }|sŒ|‘Œ	 }}| j                  t        ur-‰j                  | j                  d   | j                  d   f«       | j                  j                  «       D ]  }|| usŒ ‰||«       Œ yc c}w )z5
            Walk the trie, depth first.
            r   é   N)r   r   r!   Úappendr   rR   )r?   r>   r=   r@   rN   Úwalks       €€r
   rW   zTrie.items.<locals>.walkÂ   s�   ø€ ð "(¨4¯:©:¨,Ñ!6Ö<˜Aº!’aÐ<ˆFÐ<Ø�{‰{¤#Ñ%Ø—‘àŸ™ A™ØŸ™ A™ðôð Ÿ™×-Ñ-Ó/ò (�Ø Ò$Ù˜ Õ'ñ(ùò =s
   ”BœB)r>   )r1   Úiter)r"   rN   rW   s    @@r
   rN   z
Trie.items¼   s)   ù€ ð ˆõ	(ñ" 	ˆT�Y‰Y˜rÕ"ä�E‹{Ðr   c                 ób   — | j                  |«      }|rt        |j                  t        k7  «      S y)zA
        Return True if the key is present in this trie.
        F)rE   Úboolr   r!   )r"   r;   r?   s      r
   ÚexistszTrie.exists×   s,   € ð �‰˜}Ó-ˆÙÜ˜Ÿ™¤sÑ*Ó+Ð+Ør   c                 ó:   — t        | j                  |«      du«      S )ze
        Return True if tokens_string is a prefix of any existing tokens_string in the trie.
        N)rZ   rE   )r"   r;   s     r
   Ú	is_prefixzTrie.is_prefixà   s   € ô �D—O‘O MÓ2¸$Ð>Ó?Ð?r   c                 ó¼  — t        «       }| j                  D ]y  }|| j                  j                  v r<| j                  j                  |   }| j                  |_        |j                  |«       ŒW| j                  | j                  j                  |<   Œ{ |rÁ|j                  «       }|j                  j                  «       D ]‘  }|j                  |«       |j                  }|j                  |j                  vr%|j                  }|j                  |j                  vrŒ%|j                  j                  |j                  | j                  «      |_        Œ“ |rŒÁd| _
        y)z²
        Convert this trie to an Aho-Corasick automaton.
        Note that this is an error to add new keys to a Trie once it has been
        converted to an Automaton.
        TN)r   r3   r1   r   r   rV   ÚpopleftrR   r   rG   r4   )r"   Úqueuer   r?   Úcurrent_nodeÚstates         r
   Úmake_automatonzTrie.make_automatonæ   s  € ô “ˆð
 ×'Ñ'ò 	6ˆEØ˜Ÿ	™	×*Ñ*Ñ*Ø—y‘y×)Ñ)¨%Ñ0�à ŸI™I�”	Ø—‘˜TÕ"à,0¯I©I�—	‘	×"Ñ" 5Ò)ð	6ñ Ø Ÿ=™=›?ˆLØ$×-Ñ-×4Ñ4Ó6ò F�Ø—‘˜TÔ"Ø$×)Ñ)�Ø—j‘j¨¯©Ñ6Ø!ŸJ™J�Eð —j‘j¨¯©Ò6à!ŸN™N×.Ñ.¨t¯z©z¸4¿9¹9ÓE�•	ðFò ð ˆ�r   c           	   #   óè  K  — |syt        |«      }| j                  }t        r!t        dt	        |«      «       t        d|«       d}|D �]  }|t        |«      z  }t        r+t        «        t        dt	        |«      «       t        d|«       |s"|j                  «       st        rt        d«       Œg|| j                  vr^| j                  }t        rt        d«       |r>t        |«      }||z
  d	z   }	t        |	|||	|d	z    d¬
«      }
t        rt        d|
«       |
–— ŒÓd}||j                  vr|j                  }||j                  vrŒ|j                  j                  || j                  «      }|}|t        ur˜|j                  t        urq|j                  \  }}t        rt        dt	        |«      t        |«      «       t        |«      }||z
  d	z   }	t        rt        d|	«       t        |	|||	|d	z    |«      –— d}|j                  }|t        urŒ˜|r�ŒÊ|s�ŒÎt        rt        d«       t        |«      }||z
  d	z   }	t        |	|||	|d	z    d«      }
t        rt        d|
«       |
–— �Œ t        «        y­w)aS  
        Yield Token objects for matched strings by performing the Aho-Corasick
        search procedure.

        The Token start and end positions in the searched string are such that
        the matched string is "tokens_string[start:end+1]". And the start is
        computed from the end_index collected by the Aho-Corasick search
        procedure such that
        "start=end_index - n + 1" where n is the length of a matched string.

        The Token.value is an object associated with a matched string.

        For example:
        >>> a = Trie()
        >>> a.add('BCDEF')
        >>> a.add('CDE')
        >>> a.add('DEFGH')
        >>> a.add('EFGH')
        >>> a.add('KL')
        >>> a.make_automaton()
        >>> tokens_string = 'a bcdef ghij kl m'
        >>> strings = Token.sort(a.iter(tokens_string))
        >>> expected = [
        ...     Token(2, 6, u'bcdef', u'BCDEF'),
        ...     Token(13, 14, u'kl', u'KL')
        ... ]

        >>> strings == expected
        True

        >>> list(a.iter('')) == []
        True

        >>> list(a.iter(' ')) == []
        True
        NzTrie.iter() with:z tokens:éÿÿÿÿÚtoken_stringz end_posz  include_space skippedz  unmatchedrU   ©ÚstartÚendÚstringr<   z  unmatched tok:Fz type outputz   start_posTz  unmatched but known tokenz  unmatched tok 2:)r7   r1   ÚTRACEr   r   Úlenr8   r3   ÚTokenr   r   rG   r!   r   Útype)r"   r;   Úinclude_unmatchedÚinclude_spacer>   rb   Úend_posrf   ÚnÚ	start_posÚtokÚyieldedÚmatchÚmatched_stringÚoutput_values                  r
   rX   z	Trie.iter  s`  è ø€ ñJ Øä˜MÓ*ˆØ—	‘	ˆåÜÐ,¬d°=Ó.AÔBÜ˜ VÔ,àˆØ"ó =	ˆLØ”s˜<Ó(Ñ(ˆGÝÜ”Ü˜^¬T°,Ó-?Ô@Ü˜Z¨Ô1á ¨×);Ñ);Ô)=ÝÜ Ð!:Ô;Øà 4×#5Ñ#5Ñ5ØŸ	™	�ÝÜ  Ô/Ù$Ü˜LÓ)�AØ '¨!¡¨a¡�IÜØ'Ø#Ø,¨Y¸À1¹ÐEØ"ô	�Cõ Ü$Ð%7¸Ô=Ø’IØàˆGð  e§n¡nÑ4ØŸ
™
�ð  e§n¡nÒ4ð —N‘N×&Ñ& |°T·Y±YÓ?ˆEØˆEØœsÑ"Ø—<‘<¤sÑ*Ø38·<±<Ñ0�N LÝÜ$ ^´T¸,Ó5GÌÈnÓI]Ô^Ü˜NÓ+�AØ '¨!¡¨a¡�IÝÜ$ ^°YÔ?ÜØ! 7¨M¸)ÀgÐPQÁkÐ,RÐT`óò ð #�GØŸ
™
�ð œsÒ"ó Ó0ÝÜ Ð!>Ô?Ü˜Ó%�Ø# a™K¨!™O�	Ü˜I w°¸iÈ'ÐTUÉ+Ð0VÐX\Ó]�ÝÜ Ð!5°sÔ;Ø”	ð{=	ô~ 	�ùs    ‚EI2ÅCI2ÈI2ÈI2ÈAI2c                 óà   — | j                  |||¬«      }t        |«      }t        rt        d|«       |s*|D �cg c]  }|j                  j                  «       sŒ|‘Œ! }}t        |«      }|S c c}w )a`  
        Tokenize a string for matched and unmatched sub-sequences and yield non-
        overlapping Token objects performing a modified Aho-Corasick search
        procedure:

        - return both matched and unmatched sub-sequences.
        - do not return matches with positions that are contained or overlap with
          another match:
          - discard smaller matches contained in a larger match.
          - when there is overlap (but not containment), the matches are sorted by
            start and biggest length and then:
             - we return the largest match of two overlaping matches
             - if they have the same length, keep the match starting the earliest and
               return the non-overlapping portion of the other discarded match as a
               non-match.

        Each Token contains the start and end position, the corresponding string
        and an associated value object.

        For example:
        >>> a = Trie()
        >>> a.add('BCDEF')
        >>> a.add('CDE')
        >>> a.add('DEFGH')
        >>> a.add('EFGH')
        >>> a.add('KL')
        >>> a.make_automaton()
        >>> string = 'a bcdef ghij kl'
        >>> tokens = list(a.tokenize(string, include_space=True))

        >>> expected = [
        ...     Token(0, 0, u'a', None),
        ...     Token(1, 1, u' ', None),
        ...     Token(2, 6, u'bcdef', u'BCDEF'),
        ...     Token(7, 7, u' ', None),
        ...     Token(8, 11, u'ghij', None),
        ...     Token(12, 12, u' ', None),
        ...     Token(13, 14, u'kl', u'KL')
        ... ]
        >>> tokens == expected
        True
        )ro   rp   ztokenize.tokens:)rX   Úlistrk   r   rj   r8   Úfilter_overlapping)r"   rj   ro   rp   r>   r=   s         r
   ÚtokenizezTrie.tokenizey  si   € ðV —‘˜6Ð5FÐVc�ÓdˆÜ�f“ˆÝÜÐ+¨VÔ4ÙØ!'Ö<˜A¨1¯8©8¯>©>Õ+;’aÐ<ˆFÐ<Ü# FÓ+ˆØˆùò =s   ¸A+ÁA+r   )FF)TF)r(   r)   r*   r+   r#   rA   rE   r!   rG   rO   rR   rN   r[   r]   rc   rX   r|   r   r   r
   r.   r.   Q   sM   „ ñò
 ó#>òJð$ *-ó ò(0ò4òò6ò@ò óDoôb2r   r.   c                 óø  — t         j                  | «      } d}|t        | «      dz
  k  rÑ|dz   }|t        | «      k  r§| |   }| |   }t        d||||«       |j	                  |«      rt        d|«       np||v rt        d|«       | |= ŒY|j                  |«      r7t        |«      t        |«      k\  rt        d|«       | |= Œ‘t        d|«       | |= n|dz  }|t        | «      k  rŒ§|dz  }|t        | «      dz
  k  rŒÑ| S )a{  
    Return a new list from an iterable of `tokens` discarding contained and
    overlaping Tokens using these rules:

    - skip a token fully contained in another token.
    - keep the biggest, left-most token of two overlapping tokens and skip the other

    For example:
    >>> tokens = [
    ...     Token(0, 0, 'a'),
    ...     Token(1, 5, 'bcdef'),
    ...     Token(2, 4, 'cde'),
    ...     Token(3, 7, 'defgh'),
    ...     Token(4, 7, 'efgh'),
    ...     Token(8, 9, 'ij'),
    ...     Token(10, 13, 'klmn'),
    ...     Token(11, 15, 'lmnop'),
    ...     Token(16, 16, 'q'),
    ... ]

    >>> expected = [
    ...     Token(0, 0, 'a'),
    ...     Token(1, 5, 'bcdef'),
    ...     Token(8, 9, 'ij'),
    ...     Token(11, 15, 'lmnop'),
    ...     Token(16, 16, 'q'),
    ... ]

    >>> filtered = list(filter_overlapping(tokens))
    >>> filtered == expected
    True
    r   rU   zcurr_tok, i, next_tok, j:z  break to nextz  del next_tok contained:z  del next_tok smaller overlap:z  del curr_tok smaller overlap:)rm   Úsortrl   r   Úis_afterÚoverlap)r>   ÚiÚjÚcurr_tokÚnext_toks        r
   r{   r{   ®  s   € ôB �Z‰Z˜Ó€Fð 	
€AØ
Œc�&‹k˜A‰oÒ
Ø�‰EˆØ”#�f“+ŠoØ˜a‘yˆHØ˜a‘yˆHäÐ4°hÀÀ8ÈQÔOà× Ñ  Ô*ÜÐ.°Ô9Øð ˜8Ñ#ÜÐ8¸(ÔCØ˜1�IØð ×Ñ Ô)Ü�x“=¤C¨£MÒ1Ü Ð!BÀHÔMØ˜q˜	Øä Ð!BÀHÔMØ˜q˜	ØØ�‰FˆAð7 ”#�f“+‹oð8 	
ˆQ‰ˆð= Œc�&‹k˜A‰oÓ
ð> €Mr   c                   ób   — e Zd ZdZdZdd„Zd„ Zd„ Zd„ Zd„ Z	d	„ Z
ed
„ «       Zd„ Zd„ Zd„ Zd„ Zy)rm   a0  
    A Token is used to track the tokenization an expression with its
    start and end as index position in the original string and other attributes:

    - `start` and `end` are zero-based index in the original string S such that
         S[start:end+1] will yield `string`.
    - `string` is the matched substring from the original string for this Token.
    - `value` is the corresponding object for this token as one of:
      - a LicenseSymbol object
      - a "Keyword" object (and, or, with, left and right parens)
      - None if this is a space.
    rg   Nc                 ó<   — || _         || _        || _        || _        y r   rg   )r"   rh   ri   rj   r<   s        r
   r#   zToken.__init__
  s   € ØˆŒ
ØˆŒØˆŒØˆ�
r   c                 óV   — | j                   j                  d| j                  «       z  z   S )Nz+(%(start)r, %(end)r, %(string)r, %(value)r))Ú	__class__r(   Úas_dictr&   s    r
   r'   zToken.__repr__  s)   € à�N‰N×#Ñ#Ð&SÐVZ×VbÑVbÓVdÑ&dÑdð	
r   c           
      ój   — t        | j                  D �cg c]  }|t        | |«      f‘Œ c}«      S c c}w r   )r   r,   Úgetattr)r"   Úss     r
   r‰   zToken.as_dict  s+   € Ü¸4¿>¹>ÖJ°a˜Q¤¨¨aÓ 0Ò1ÒJÓKÐKùÒJs   ”0c                 ó:   — | j                   | j                  z
  dz   S )NrU   ©ri   rh   r&   s    r
   Ú__len__zToken.__len__  s   € Ø�x‰x˜$Ÿ*™*Ñ$ qÑ(Ð(r   c                 óú   — t        |t        «      xrj | j                  |j                  k(  xrO | j                  |j                  k(  xr4 | j                  |j                  k(  xr | j
                  |j
                  k(  S r   )r   rm   rh   ri   rj   r<   ©r"   Úothers     r
   Ú__eq__zToken.__eq__  sg   € Ü˜%¤Ó'ò 
Ø�J‰J˜%Ÿ+™+Ñ%ò *Ø—‘˜EŸI™IÑ%ò*à—‘˜uŸ|™|Ñ+ò*ð —
‘
˜eŸk™kÑ)ð		
r   c                 ót   — | j                   | j                  | j                  | j                  f}t	        |«      S r   )rh   ri   rj   r<   Úhash)r"   Útups     r
   Ú__hash__zToken.__hash__#  s*   € Ø�j‰j˜$Ÿ(™( D§K¡K°·±Ð;ˆÜ�C‹yÐr   c                 ó"   — d„ }t        ||¬«      S )a  
        Return a new sorted sequence of tokens given a sequence of tokens. The
        primary sort is on start and the secondary sort is on longer lengths.
        Therefore if two tokens have the same start, the longer token will sort
        first.

        For example:
        >>> tokens = [Token(0, 0), Token(5, 5), Token(1, 1), Token(2, 4), Token(2, 5)]
        >>> expected = [Token(0, 0), Token(1, 1), Token(2, 5), Token(2, 4), Token(5, 5)]
        >>> expected == Token.sort(tokens)
        True
        c                 ó2   — | j                   t        | «       fS r   )rh   rl   )rŒ   s    r
   rJ   zToken.sort.<locals>.key6  s   € à—‘Ü�Q“�ðð r   )rJ   )Úsorted)Úclsr>   rJ   s      r
   r~   z
Token.sort'  s   € ò	ô �f #Ô&Ð&r   c                 ó4   — | j                   |j                  kD  S )aJ  
        Return True if this token is after the other token.

        For example:
        >>> Token(1, 2).is_after(Token(5, 6))
        False
        >>> Token(5, 6).is_after(Token(5, 6))
        False
        >>> Token(2, 3).is_after(Token(1, 2))
        False
        >>> Token(5, 6).is_after(Token(3, 4))
        True
        ©rh   ri   r‘   s     r
   r   zToken.is_after>  s   € ð �z‰z˜EŸI™IÑ%Ð%r   c                 ó4   — | j                   |j                  k  S r   rŽ   r‘   s     r
   Ú	is_beforezToken.is_beforeN  s   € Ø�x‰x˜%Ÿ+™+Ñ%Ð%r   c                 ój   — | j                   |j                   k  xr |j                  | j                  k  S )aa  
        Return True if this token contains the other token.

        For example:
        >>> Token(5, 7) in Token(5, 7)
        True
        >>> Token(6, 8) in Token(5, 7)
        False
        >>> Token(6, 6) in Token(4, 8)
        True
        >>> Token(3, 9) in Token(4, 8)
        False
        >>> Token(4, 8) in Token(3, 9)
        True
        r�   r‘   s     r
   Ú__contains__zToken.__contains__Q  s)   € ð  �z‰z˜UŸ[™[Ñ(ÒB¨U¯Y©Y¸$¿(¹(Ñ-BÐBr   c                 óž   — | j                   }| j                  }||j                   cxk  xr |k  nc xs ||j                  cxk  xr |k  S c S )a‚  
        Return True if this token and the other token overlap.

        For example:
        >>> Token(1, 2).overlap(Token(5, 6))
        False
        >>> Token(5, 6).overlap(Token(5, 6))
        True
        >>> Token(4, 5).overlap(Token(5, 6))
        True
        >>> Token(4, 5).overlap(Token(5, 7))
        True
        >>> Token(4, 5).overlap(Token(6, 7))
        False
        r�   )r"   r’   rh   ri   s       r
   r€   zToken.overlapc  sC   € ð  —
‘
ˆØ�h‰hˆØ˜Ÿ™Ö+¨Ô+ÒK°¸%¿)¹)Ö1JÀsÑ1JÐKÑ1JÐKr   )r0   N)r(   r)   r*   r+   r,   r#   r'   r‰   r�   r“   r—   Úclassmethodr~   r   rŸ   r¡   r€   r   r   r
   rm   rm   õ  sW   „ ñð€Ióò
ò
Lò)ò
òð ñ'ó ð'ò,&ò &òCó$Lr   rm   zV
    (?P<text>[^\s\(\)]+)
     |
    (?P<space>\s+)
     |
    (?P<parens>[\(\)])
    c                 ót   — t         j                  | j                  «       «      D �cg c]  }|sŒ|‘Œ	 c}S c c}w )zG
    Return an iterable of strings splitting on spaces and parens.
    )Ú
_tokenizerÚsplitÚlower)r;   rv   s     r
   r7   r7   …  s.   € ô  *×/Ñ/°×0CÑ0CÓ0EÓFÖP�eÊ%ŠEÒPÐPùÒPs   ¦5®5)r+   Úcollectionsr   r   ÚloggingÚrerk   Ú	getLoggerr(   r   r   ÚsysÚbasicConfigÚstdoutÚsetLevelÚDEBUGÚobjectr!   r   r.   r{   rm   ÚcompileÚVERBOSEÚ	MULTILINEÚUNICODEr¥   r7   r   r   r
   ú<module>r¶      sÜ   ðñõ  Ý #Û Û 	à€à	ˆ×	Ñ	˜8Ó	$€ò	ñ 	òYó à€G×Ñ˜sŸz™zÕ*Ø
‡O�O�G—M‘MÔ"ñ ƒh€ô/ˆvô /ô<Zˆ6ô Zòz
DôN@LˆFô @LðH ˆR�Z‰Zðð ‡J�J�—‘Ñ §
¡
Ñ*ó	€
óQr   