# HG changeset patch # User Atul Varma # Date 1271991811 25200 # Node ID 815520476fbb95b567218801928fadf88d2de4ba # Parent 30c1f55eff96842f7660409411c5976eca18533d accept '/' as a literal diff -r 30c1f55eff96 -r 815520476fbb jsscan.py --- a/jsscan.py Thu Apr 22 17:31:32 2010 -0700 +++ b/jsscan.py Thu Apr 22 20:03:31 2010 -0700 @@ -13,7 +13,7 @@ ) LITERALS = ('(){}[];.,:?' - '!=-+*&|<>') + '!=-+*&|<>/') def __init__(self, text): self.text = text @@ -29,30 +29,29 @@ while self.pos < len(self.text): found = None - if self.text[self.pos] in self.LITERALS: + for tokname, tokre in self.TOKENS.items(): + match = tokre.match(self.text, self.pos) + if match: + tokvalue = match.group(0) + found = (tokname, tokvalue, + (self.line, self.char)) + self.pos += len(tokvalue) + if tokre.flags & re.MULTILINE: + newlines = tokvalue.count('\n') + if newlines: + self.line += newlines + self.char = ((len(tokvalue) - 1) - + tokvalue.rfind('\n')) + else: + self.char += len(tokvalue) + else: + self.char += len(tokvalue) + continue + if found is None and self.text[self.pos] in self.LITERALS: found = ('literal', self.text[self.pos], (self.line, self.char)) self.pos += 1 self.char += 1 - else: - for tokname, tokre in self.TOKENS.items(): - match = tokre.match(self.text, self.pos) - if match: - tokvalue = match.group(0) - found = (tokname, tokvalue, - (self.line, self.char)) - self.pos += len(tokvalue) - if tokre.flags & re.MULTILINE: - newlines = tokvalue.count('\n') - if newlines: - self.line += newlines - self.char = ((len(tokvalue) - 1) - - tokvalue.rfind('\n')) - else: - self.char += len(tokvalue) - else: - self.char += len(tokvalue) - continue if found is not None: if found[0] not in ignore: yield found