   stack: []
   debt:  {}
   (debt[key]: 0) for key, val of INVERSES
-  this.scan_tokens (prev, token, post, i) =>
+  @scan_tokens (prev, token, post, i) =>
     tag: token[0]
     inv: INVERSES[token[0]]
     # Push openers onto the stack.

          # Unexpected close, insert correct close, adding to the debt.
          debt[mtag] += 1
          val: if mtag is 'INDENT' then match[1] else INVERSES[mtag]
          this.tokens.splice(i, 0, [INVERSES[mtag], val])
          return 1
    else
      return 1

re::scan_tokens: (block) ->
  i: 0
  while true
    break unless @tokens[i]
    move: block(@tokens[i - 1], @tokens[i], @tokens[i + 1], i)
    i += move
  true

# Massage newlines and indentations so that comments don't have to be
# correctly indented, or appear on their own line.
re::adjust_comments: ->
  @scan_tokens (prev, token, post, i) =>
    return 1 unless token[0] is 'COMMENT'
    before: @tokens[i - 2]
    after:  @tokens[i + 2]
    if before and after and
        ((before[0] is 'INDENT' and after[0] is 'OUTDENT') or
        (before[0] is 'OUTDENT' and after[0] is 'INDENT')) and
        before[1] is after[1]
      @tokens.splice(i + 2, 1)
      @tokens.splice(i - 2, 1)
      return 0
    else if prev and prev[0] is 'TERMINATOR' and after[0] is 'INDENT'
      @tokens.splice(i + 2, 1)
      @tokens[i - 1]: after
      return 1
    else if prev and prev[0] isnt 'TERMINATOR' and prev[0] isnt 'INDENT' and prev[0] isnt 'OUTDENT'
      @tokens.splice(i, 0, ['TERMINATOR', "\n", prev[2]])
      return 2
    else
      return 1
