def _get_code_for_spaces(self, node):
        """Calculates the formatted text for the space and comment tokens that
        prefix the node.

        Args:
          node: The Node with possible space and comment tokens in its range.

        Returns:
          A string representing the minified spaces.
        """
        start_pos = self._pos
        strs = []
        while (((node is None and len(self._tokens) < self._pos) or
                (node is not None and self._pos < node.end_pos)) and
               (isinstance(self._tokens[self._pos], lexer.TokSpace) or
                isinstance(self._tokens[self._pos], lexer.TokNewline) or
                isinstance(self._tokens[self._pos], lexer.TokComment))):
            strs.append(self._tokens[self._pos].code)
            self._pos += 1
        spaces = ''.join(strs)

        # Normalize space characters.
        spaces = re.sub(r'\t', ' ', spaces)
        spaces = re.sub(r'\r\n', '\n', spaces)
        spaces = re.sub(r'\n\r', '\n', spaces)
        spaces = re.sub(r'\r', '\n', spaces)

        # Delete trailing whitespace.
        spaces = re.sub(r' +\n', '\n', spaces)

        # If a comment is on the same line as previous, separate it by two
        # spaces.
        if start_pos != 0:
            spaces = re.sub(r'^ *--', '  --', spaces)

        # If a comment is on its own line, indent it at the indent level.
        spaces = re.sub(r'\n *--',
                        '\n' + ' ' * self._indent_mult * self._indent + '--',
                        spaces)
        if start_pos == 0:
            spaces = re.sub(r'^ *--', '--', spaces)

        # If next non-space is on its own line, indent it at the indent level.
        spaces = re.sub(r'\n *$', '\n' + ' ' * self._indent_mult * self._indent,
                        spaces)
        if start_pos == 0:
            spaces = re.sub(r'^ *$', '', spaces)

        # Collapse regions of 2+ consecutive newlines to 2 newlines.
        # TODO: two blank lines before function defs? classes?
        spaces = re.sub(r'\n\n+', '\n\n', spaces)

        # Remove excess trailing whitespace at end of file.
        if self._pos == len(self._tokens):
            spaces = re.sub(r'[ \n]+$', '\n', spaces)

        # TODO: same-line spacing patterns:
        # - one space before and after binop
        # - one space before unop, no space after (except "not")
        # - no space inside parens or braces
        # - no space to left of comma or semicolon; one space after
        # - no space around colons (for methods)
        # - no "empty" semicolon statements; non-empty semicolon should be
        #    adjacent to its statement
        # - block starts on a new line; 'end' always on its own line

        return spaces
dataset/ETHPy150Open dansanderson/picotool/pico8/lua/lua.py/LuaFormatterWriter._get_code_for_spaces/swapped operands of `<`