This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

28 linhas
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] == '$'