summaryrefslogtreecommitdiff
path: root/scss/_native.py
diff options
context:
space:
mode:
Diffstat (limited to 'scss/_native.py')
-rw-r--r--scss/_native.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/scss/_native.py b/scss/_native.py
index f04b914..6d7960f 100644
--- a/scss/_native.py
+++ b/scss/_native.py
@@ -3,6 +3,8 @@
from scss.cssdefs import SEPARATOR
import re
+DEBUG = False
+
# TODO copied from __init__
_nl_num_re = re.compile(r'\n.+' + SEPARATOR, re.MULTILINE)
_blocks_re = re.compile(r'[{},;()\'"\n]')
@@ -187,15 +189,21 @@ class Scanner(object):
# Search the patterns for a match, with earlier
# tokens in the list having preference
best_pat_len = 0
- for p, regexp in self.patterns:
+ for tok, regex in self.patterns:
+ if DEBUG:
+ print("\tTrying %s: %s at pos %d -> %s" % (repr(tok), repr(regex.pattern), self.pos, repr(self.input)))
# First check to see if we're restricting to this token
- if restrict and p not in restrict and p not in self.ignore:
+ if restrict and tok not in restrict and tok not in self.ignore:
+ if DEBUG:
+ print "\tSkipping %s!" % repr(tok)
continue
- m = regexp.match(self.input, self.pos)
+ m = regex.match(self.input, self.pos)
if m:
# We got a match
- best_pat = p
+ best_pat = tok
best_pat_len = len(m.group(0))
+ if DEBUG:
+ print("Match OK! %s: %s at pos %d" % (repr(tok), repr(regex.pattern), self.pos))
break
# If we didn't find anything, raise an error