<s> from parsimonious . utils import StrAndRepr <EOL> class ParseError ( StrAndRepr , Exception ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , text , pos = - <NUM_LIT:1> , expr = None ) : <EOL> self . text = text <EOL> self . pos = pos <EOL> self . expr = expr <EOL> def __unicode__ ( self ) : <EOL> rule_name = ( ( u"<STR_LIT>" % self . expr . name ) if self . expr . name else <EOL> unicode ( self . expr ) ) <EOL> return u"<STR_LIT>" % ( <EOL> rule_name , <EOL> self . text [ self . pos : self . pos + <NUM_LIT:20> ] , <EOL> self . line ( ) , <EOL> self . column ( ) ) <EOL> def line ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . text . count ( '<STR_LIT:\n>' , <NUM_LIT:0> , self . pos ) + <NUM_LIT:1> <EOL> def column ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return self . pos - self . text . rindex ( '<STR_LIT:\n>' , <NUM_LIT:0> , self . pos ) <EOL> except ValueError : <EOL> return self . pos + <NUM_LIT:1> <EOL> class IncompleteParseError ( ParseError ) : <EOL> """<STR_LIT>""" <EOL> def __unicode__ ( self ) : <EOL> return u"<STR_LIT>" % ( <EOL> self . expr . name , <EOL> self . text [ self . pos : self . pos + <NUM_LIT:20> ] , <EOL> self . line ( ) , <EOL> self . column ( ) ) <EOL> class VisitationError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , exc , exc_class , node ) : <EOL> """<STR_LIT>""" <EOL> self . original_class = exc_class <EOL> super ( VisitationError , self ) . __init__ ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT:%s>' % <EOL> ( exc_class . __name__ , <EOL> exc , <EOL> node . prettily ( error = node ) ) ) <EOL> class BadGrammar ( StrAndRepr , Exception ) : <EOL> """<STR_LIT>""" <EOL> class UndefinedLabel ( BadGrammar ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , label ) : <EOL> self . label = label <EOL> def __unicode__ ( self ) : <EOL> return u'<STR_LIT>' % self . label </s>
