def scan(self, source): self.current_symbol, self.current_position = source.getNextSymbol() self.start_position = deepcopy( self.current_position ) while True: if Symbol.isComment(self.current_symbol): self.scanComment(source) elif Symbol.isSeparator(self.current_symbol): self.scanSeperator(source) elif Symbol.isEof(self.current_symbol): return None else: return self.scanToken(source)
def testForEof(self): if Symbol.isEof(self.current_symbol): pos_str = self.positionToString(self.current_position) raise ScanException('Error scanning at %s.' % (pos_str) )