diff options
author | German M. Bravo <german.mb@deipi.com> | 2013-08-16 09:45:43 -0500 |
---|---|---|
committer | German M. Bravo <german.mb@deipi.com> | 2013-08-16 09:45:43 -0500 |
commit | c6d2a8adfbeef4fceb2b776e993140ae51217fe4 (patch) | |
tree | 4291219fceb4af68963c3d8da5fddd0b9b3d30fb | |
parent | 47e804b3913c3b2cd4f0bb3a588b7189e586b894 (diff) | |
download | pyscss-c6d2a8adfbeef4fceb2b776e993140ae51217fe4.tar.gz |
Debugging prints improved
-rw-r--r-- | scss/_native.py | 16 | ||||
-rw-r--r-- | scss/src/scanner.c | 4 | ||||
-rwxr-xr-x | scss/src/scanner.py | 15 |
3 files changed, 24 insertions, 11 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 diff --git a/scss/src/scanner.c b/scss/src/scanner.c index 25504a2..ca74ba7 100644 --- a/scss/src/scanner.c +++ b/scss/src/scanner.c @@ -197,7 +197,7 @@ _Scanner_scan(Scanner *self, Pattern *restrictions, int restrictions_sz) if (skip) { continue; #ifdef DEBUG - fprintf(stderr, "\tSkipping!\n"); + fprintf(stderr, "\tSkipping %s!\n", repr(regex->tok)); #endif } } @@ -209,7 +209,7 @@ _Scanner_scan(Scanner *self, Pattern *restrictions, int restrictions_sz) &best_token )) { #ifdef DEBUG - fprintf(stderr, "\tMatch OK! %s: %s at pos %d\n", repr(regex->tok), repr(regex->expr), self->pos); + fprintf(stderr, "Match OK! %s: %s at pos %d\n", repr(regex->tok), repr(regex->expr), self->pos); #endif break; } diff --git a/scss/src/scanner.py b/scss/src/scanner.py index a2463ec..777fd67 100755 --- a/scss/src/scanner.py +++ b/scss/src/scanner.py @@ -135,15 +135,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 @@ -202,7 +208,6 @@ class Scanner(object): self.pos = token[0] - class _Scanner_a(Scanner): patterns = None _patterns = PATTERNS |