The custome exception EOF was not needed,
there is a built-in one called EOFError.
def tokenize(template):
- class EOF(Exception):
- pass
-
class UnclosedSection(Exception):
pass
def look(ahead=0, amount=1):
idx = current + ahead
if idx > len(template):
- raise EOF()
+ raise EOFError()
return template[idx:idx + amount]
size = 0
while look(size, 2) != l_del:
size += 1
- except EOF:
+ except EOFError:
yield ('literal', get(size))
return