yield Token(typ, val, line, mo.start() - line_start)
pos = mo.end()
mo = get_token(s, pos)
if pos != len(s):
    raise RuntimeError('Unexpected character %r on line %d' % (s[pos], line))
statements = """
    IF quantity THEN
        total := total + price * quantity;
        tax := price * 0.05;
    ENDIF;
"""
for token in tokenize(statements):
    pass
Efficiently match multiple regexes in Python