def as_statements(lines: Iterator[str]) -> Iterator[str]:
lines = (l.strip() for l in lines if l)<EOL>lines = (l for l in lines if l and not l.startswith('<STR_LIT>'))<EOL>parts = []<EOL>for line in lines:<EOL><INDENT>parts.append(line.rstrip('<STR_LIT:;>'))<EOL>if line.endswith('<STR_LIT:;>'):<EOL><INDENT>yield '<STR_LIT:U+0020>'.join(parts)<EOL>parts.clear()<EOL><DEDENT><DEDENT>if parts:<EOL><INDENT>yield '<STR_LIT:U+0020>'.join(parts)<EOL><DEDENT>
Create an iterator that transforms lines into sql statements.

    Statements within the lines must end with ";"
    The last statement will be included even if it does not end in ';'

    >>> list(as_statements(['select * from', '-- comments are filtered', 't;']))
    ['select * from t']

    >>> list(as_statements(['a;', 'b', 'c;', 'd', ' ']))
    ['a', 'b c', 'd']