diff options
author | Eevee (Alex Munroe) <eevee.git@veekun.com> | 2014-09-02 19:29:55 -0700 |
---|---|---|
committer | Eevee (Alex Munroe) <eevee.git@veekun.com> | 2014-09-02 19:29:55 -0700 |
commit | 16bcfbbac6da460faaaa6ebc9cfaf75a3aa8aa78 (patch) | |
tree | c2b516819c972d3a178b343d4b849c9db151fe10 /scss/grammar | |
parent | d5c7a81a47acdff00cd553bb42bc07b128fa9fe4 (diff) | |
download | pyscss-16bcfbbac6da460faaaa6ebc9cfaf75a3aa8aa78.tar.gz |
Make scanner errors slightly more friendly to read.
Diffstat (limited to 'scss/grammar')
-rw-r--r-- | scss/grammar/scanner.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/scss/grammar/scanner.py b/scss/grammar/scanner.py index 5aee227..9fae657 100644 --- a/scss/grammar/scanner.py +++ b/scss/grammar/scanner.py @@ -4,9 +4,11 @@ from __future__ import print_function from __future__ import unicode_literals from collections import deque - import re +from scss.errors import SassSyntaxError + + DEBUG = False @@ -136,11 +138,8 @@ class Parser(object): Returns the token type for lookahead; if there are any args then the list of args is the set of token types to allow """ - try: - tok = self._scanner.token(self._pos, types) - return tok[2] - except SyntaxError: - return None + tok = self._scanner.token(self._pos, types) + return tok[2] def _scan(self, type): """ @@ -234,10 +233,7 @@ except ImportError: # If we didn't find anything, raise an error if best_pat is None: - msg = "Bad token found" - if restrict: - msg = "Bad token found while trying to find one of the restricted tokens: %s" % (", ".join(repr(r) for r in restrict)) - raise SyntaxError("SyntaxError[@ char %s: %s]" % (repr(self.pos), msg)) + raise SassSyntaxError(self.input, self.pos, restrict) # If we found something that isn't to be ignored, return it if best_pat in self.ignore: |