
V}Oc           @   s"  d  Z  d d l m Z d e f d     YZ d e f d     YZ d e f d     YZ d	 e f d
     YZ d e f d     YZ d e f d     YZ	 d e f d     YZ
 d e
 f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d S(   s   ANTLR3 exception hierarchyi(   t   INVALID_TOKEN_TYPEt   BacktrackingFailedc           B   s   e  Z d  Z RS(   s0   @brief Raised to signal failed backtrack attempt(   t   __name__t
   __module__t   __doc__(    (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR   $   s   t   RecognitionExceptionc           B   s8   e  Z d  Z d d  Z d   Z d   Z e e  Z RS(   s  @brief The root of the ANTLR exception hierarchy.

    To avoid English-only error messages and to generally make things
    as flexible as possible, these exceptions are not created with strings,
    but rather the information necessary to generate an error.  Then
    the various reporting methods in Parser and Lexer can be overridden
    to generate a localized error message.  For example, MismatchedToken
    exceptions are built with the expected token type.
    So, don't expect getMessage() to return anything.

    Note that as of Java 1.4, you can access the stack trace, which means
    that you can compute the complete trace of rules from the start symbol.
    This gives you considerable context information with which to generate
    useful error messages.

    ANTLR generates code that throws exceptions upon recognition error and
    also generates code to catch these exceptions in each rule.  If you
    want to quit upon first error, you can turn off the automatic error
    handling mechanism using rulecatch action, but you still need to
    override methods mismatch and recoverFromMismatchSet.
    
    In general, the recognition exceptions can track where in a grammar a
    problem occurred and/or what was the expected input.  While the parser
    knows its state (such as current input symbol and line info) that
    state can change before the exception is reported so current token index
    is computed and stored at exception time.  From this info, you can
    perhaps print an entire line of input not just a single token, for example.
    Better to just say the recognizer had a problem and then let the parser
    figure out a fancy report.
    
    c         C   sp  t  j |   d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _	 t
 |  _ | d  k	 rl| |  _ | j   |  _ d d l m } m } d d l m } t |  j |  r |  j j d  |  _ |  j j |  _ |  j j	 |  _	 n  t |  j |  r|  j |  j  qlt |  j |  rT|  j j d  |  _ |  j j |  _ |  j j	 |  _	 ql|  j j d  |  _ n  d  S(   Ni(   t   TokenStreamt
   CharStream(   t   TreeNodeStreami   (   t	   Exceptiont   __init__t   Nonet   inputt   indext   tokent   nodet   ct   linet   charPositionInLinet   Falset   approximateLineInfot   antlr3.streamsR   R   t   antlr3.treeR   t
   isinstancet   LTt$   extractInformationFromTreeNodeStreamt   LA(   t   selfR   R   R   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR
   K   s2    									c         C   s  d d l  m } m } d d l m } | j d  |  _ | j } | j |  j  } | d  k	 r%| |  _
 | j d k r
d } | j |  } x | d  k	 r| j |  }	 |	 d  k	 r |	 j d k r |	 j |  _ |	 j |  _ t |  _ Pn  | d 8} | j |  } q Wq| j |  _ | j |  _ n t |  j |  r||  j j |  _ |  j j |  _ t |  j |  r|  j j
 |  _
 qn< | j |  j  }
 | j |  j  } | d |
 d |  |  _
 d  S(   Ni(   t   Treet
   CommonTree(   t   CommonTokeni   i    t   typet   text(   R   R   R   t   antlr3.tokensR   R   R   t   adaptort   getTokenR   R   R   R   t   TrueR   R   t   getTypet   getText(   R   t   nodesR   R   R   R"   t   payloadt   it	   priorNodet   priorPayloadR   R    (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR      s:    			
c         C   su   d d l  m } d d l m } t |  j |  r< |  j j St |  j |  rj |  j j } | j	 |  j
  S|  j Sd S(   s=   Return the token type or char of the unexpected input elementi(   R   (   R   N(   R   R   R   R   R   R   R   R   t   treeAdaptorR%   R   R   (   R   R   R   R"   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyt   getUnexpectedType   s    
N(	   R   R   R   R   R
   R   R-   t   propertyt   unexpectedType(    (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR   *   s
   =	)	t   MismatchedTokenExceptionc           B   s&   e  Z d  Z d   Z d   Z e Z RS(   s/   @brief A mismatched char or Token or tree node.c         C   s   t  j |  |  | |  _ d  S(   N(   R   R
   t	   expecting(   R   R1   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR
      s    c         C   s   d |  j    |  j f S(   Ns    MismatchedTokenException(%r!=%r)(   R-   R1   (   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyt   __str__   s    (   R   R   R   R
   R2   t   __repr__(    (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR0      s   		t   UnwantedTokenExceptionc           B   s&   e  Z d  Z d   Z d   Z e Z RS(   s*   An extra token while parsing a TokenStreamc         C   s   |  j  S(   N(   R   (   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyt   getUnexpectedToken   s    c         C   sV   d |  j  } |  j  t k r% d } n  |  j d  k rB d d  | f Sd |  j j | f S(   Ns   , expected %st    s"   UnwantedTokenException(found=%s%s)(   R1   R    R   R   R    (   R   t   exp(    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR2      s    	(   R   R   R   R5   R2   R3   (    (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR4      s   			t   MissingTokenExceptionc           B   s/   e  Z d  Z d   Z d   Z d   Z e Z RS(   so   
    We were expecting a token but it's not found.  The current token
    is actually what we wanted next.
    c         C   s    t  j |  | |  | |  _ d  S(   N(   R0   R
   t   inserted(   R   R1   R   R9   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR
      s    c         C   s   |  j  S(   N(   R1   (   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyt   getMissingType   s    c         C   sV   |  j  d  k	 r5 |  j d  k	 r5 d |  j  |  j j f S|  j d  k	 rR d |  j j Sd S(   Ns(   MissingTokenException(inserted %r at %r)s   MissingTokenException(at %r)R8   (   R9   R   R   R    (   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR2      s    (   R   R   R   R
   R:   R2   R3   (    (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR8      s
   				t   MismatchedRangeExceptionc           B   s&   e  Z d  Z d   Z d   Z e Z RS(   s?   @brief The next token does not match a range of expected types.c         C   s&   t  j |  |  | |  _ | |  _ d  S(   N(   R   R
   t   at   b(   R   R<   R=   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR
     s    	c         C   s   d |  j    |  j |  j f S(   Ns,   MismatchedRangeException(%r not in [%r..%r])(   R-   R<   R=   (   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR2     s    (   R   R   R   R
   R2   R3   (    (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR;     s   		t   MismatchedSetExceptionc           B   s&   e  Z d  Z d   Z d   Z e Z RS(   s=   @brief The next token does not match a set of expected types.c         C   s   t  j |  |  | |  _ d  S(   N(   R   R
   R1   (   R   R1   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR
     s    c         C   s   d |  j    |  j f S(   Ns$   MismatchedSetException(%r not in %r)(   R-   R1   (   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR2     s    (   R   R   R   R
   R2   R3   (    (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR>     s   		t   MismatchedNotSetExceptionc           B   s   e  Z d  Z d   Z e Z RS(   s/   @brief Used for remote debugger deserializationc         C   s   d |  j    |  j f S(   Ns!   MismatchedNotSetException(%r!=%r)(   R-   R1   (   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR2   '  s    (   R   R   R   R2   R3   (    (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR?   $  s   	t   NoViableAltExceptionc           B   s&   e  Z d  Z d   Z d   Z e Z RS(   s4   @brief Unable to decide which alternative to choose.c         C   s/   t  j |  |  | |  _ | |  _ | |  _ d  S(   N(   R   R
   t   grammarDecisionDescriptiont   decisionNumbert   stateNumber(   R   RA   RB   RC   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR
   1  s    		c         C   s   d |  j  |  j f S(   Ns   NoViableAltException(%r!=[%r])(   R/   RA   (   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR2   ;  s    (   R   R   R   R
   R2   R3   (    (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR@   .  s   	
	t   EarlyExitExceptionc           B   s   e  Z d  Z d   Z RS(   s>   @brief The recognizer did not match anything for a (..)+ loop.c         C   s   t  j |  |  | |  _ d  S(   N(   R   R
   RB   (   R   RB   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR
   E  s    (   R   R   R   R
   (    (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyRD   B  s   t   FailedPredicateExceptionc           B   s&   e  Z d  Z d   Z d   Z e Z RS(   s  @brief A semantic predicate failed during validation.

    Validation of predicates
    occurs when normally parsing the alternative just like matching a token.
    Disambiguating predicate evaluation occurs when we hoist a predicate into
    a prediction decision.
    c         C   s&   t  j |  |  | |  _ | |  _ d  S(   N(   R   R
   t   ruleNamet   predicateText(   R   R   RF   RG   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR
   T  s    	c         C   s   d |  j  d |  j d S(   Ns   FailedPredicateException(s   ,{s   }?)(   RF   RG   (   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR2   [  s    (   R   R   R   R
   R2   R3   (    (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyRE   K  s   		t   MismatchedTreeNodeExceptionc           B   s&   e  Z d  Z d   Z d   Z e Z RS(   s;   @brief The next tree mode does not match the expected type.c         C   s   t  j |  |  | |  _ d  S(   N(   R   R
   R1   (   R   R1   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR
   c  s    c         C   s   d |  j    |  j f S(   Ns#   MismatchedTreeNodeException(%r!=%r)(   R-   R1   (   R   (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyR2   h  s    (   R   R   R   R
   R2   R3   (    (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyRH   `  s   		N(   R   t   antlr3.constantsR    R	   R   R   R0   R4   R8   R;   R>   R?   R@   RD   RE   RH   (    (    (    sZ   /afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/antlr3/exceptions.pyt   <module>   s    
	