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