This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

28 rindas
732 B

  1. class GrammarError(Exception):
  2. pass
  3. class ParseError(Exception):
  4. pass
  5. class UnexpectedToken(ParseError):
  6. def __init__(self, token, expected, seq, index):
  7. self.token = token
  8. self.expected = expected
  9. self.line = getattr(token, 'line', '?')
  10. self.column = getattr(token, 'column', '?')
  11. context = ' '.join(['%r(%s)' % (t.value, t.type) for t in seq[index:index+5]])
  12. message = ("Unexpected token %r at line %s, column %s.\n"
  13. "Expected: %s\n"
  14. "Context: %s" % (token.value, self.line, self.column, expected, context))
  15. super(ParseError, self).__init__(message)
  16. def is_terminal(sym):
  17. return sym.isupper() or sym[0] == '$'