     levels = 0
     loop
       token = @tokens[i]
-      return action token, i if levels is 0 and condition token, i
-      return action token, i - 1 if not token or levels < 0
+      return action.call this, token, i     if levels is 0 and condition.call this, token, i
+      return action.call this, token, i - 1 if not token or levels < 0
       levels += 1 if include EXPRESSION_START, token[0]
       levels -= 1 if include EXPRESSION_END, token[0]
       i += 1

          (@tokens[i + 2][0] is 'TERMINATOR' or @tokens[i + 2][0] is 'FINALLY')
        @tokens.splice i + 2, 0, @indentation(token)...
        return 4
      return 1 unless include(SINGLE_LINERS, token[0]) and
        post[0] isnt 'INDENT' and
        not (token[0] is 'ELSE' and post[0] is 'IF')
      starter = token[0]
      [indent, outdent] = @indentation token
      indent.generated = outdent.generated = true
      @tokens.splice i + 1, 0, indent
      idx = i + 1
      parens = 0
      loop
        idx += 1
        tok = @tokens[idx]
        pre = @tokens[idx - 1]
        if (not tok or
            (include(SINGLE_CLOSERS, tok[0]) and tok[1] isnt ';' and parens is 0) or
            (tok[0] is ')' and parens is 0)) and
            not (tok[0] is 'ELSE' and starter not in ['IF', 'THEN'])
          insertion = if pre[0] is "," then idx - 1 else idx
          @tokens.splice insertion, 0, outdent
          break
        parens += 1 if tok[0] is '('
        parens -= 1 if tok[0] is ')'
      return 1 unless token[0] is 'THEN'
      @tokens.splice i, 1
      return 0

  # Ensure that all listed pairs of tokens are correctly balanced throughout
  # the course of the token stream.

      if prev and prev.spaced and include(IMPLICIT_FUNC, prev[0]) and include(IMPLICIT_CALL, token[0]) and
          not (token[0] is '!' and (post[0] in ['IN', 'OF']))
        @tokens.splice i, 0, ['CALL_START', '(', token[2]]
        condition = (token, i) ->
          [before, prev] = @tokens.slice(i - 2, i + 1)
          (not token.generated and @tokens[i - 1][0] isnt ',' and include(IMPLICIT_END, token[0]) and
            not (token[0] is 'INDENT' and (include(IMPLICIT_BLOCK, prev[0]) or before[0] is 'CLASS'))) or
            token[0] is 'PROPERTY_ACCESS' and prev[0] is 'OUTDENT'
        action = (token, i) ->
          idx = if token[0] is 'OUTDENT' then i + 1 else i
          @tokens.splice idx, 0, ['CALL_END', ')', token[2]]
        @detectEnd i + 1, condition, action
