def to_lines(self):
        """Generates lines of Lua source based on the parser output.

        Yields:
          Lines of Lua code.
        """
        self._pos = 0

        linebuf = []
        last_was_newline = False
        for chunk in self.walk():
            if self._args.get('ignore_tokens'):
                # Clean up extraneous spacing.
                if chunk == '\n':
                    if last_was_newline:
                        chunk = ''
                    last_was_newline = True
                else:
                    last_was_newline = False
            parts = chunk.split('\n')
            while len(parts) > 1:
                linebuf.append(parts.pop(0))
                yield ''.join(linebuf) + '\n'
                linebuf.clear()
            linebuf.append(parts.pop(0))

        # Write the last line and any trailing spaces, as lines.
        last = ''.join(linebuf) + self._get_code_for_spaces(None)
        parts = last.split('\n')
        for i in range(len(parts)-1):
            yield parts[i] + '\n'
        if parts[-1]:
            yield parts[-1]
dataset/ETHPy150Open dansanderson/picotool/pico8/lua/lua.py/LuaASTEchoWriter.to_lines/original