   # blocks, so it doesn't need to. ')' can close a single-line block,
   # but we need to make sure it's balanced.
   addImplicitIndentation: ->
-    @scanTokens (prev, token, post, i) =>
-      if token[0] is 'ELSE' and prev[0] isnt 'OUTDENT'
+    @scanTokens (token, i) =>
+      if token[0] is 'ELSE' and @tag(i - 1) isnt 'OUTDENT'
         @tokens.splice i, 0, @indentation(token)...
         return 2
       if token[0] is 'CATCH' and
           (@tokens[i + 2][0] is 'TERMINATOR' or @tokens[i + 2][0] is 'FINALLY')
         @tokens.splice i + 2, 0, @indentation(token)...
         return 4
-      if include(SINGLE_LINERS, token[0]) and post[0] isnt 'INDENT' and
-          not (token[0] is 'ELSE' and post[0] is 'IF')
+      if include(SINGLE_LINERS, token[0]) and @tag(i + 1) isnt 'INDENT' and
+          not (token[0] is 'ELSE' and @tag(i + 1) is 'IF')
         starter = token[0]
         [indent, outdent] = @indentation token
         indent.generated = outdent.generated = true

  ensureBalance: (pairs) ->
    levels   = {}
    openLine = {}
    @scanTokens (prev, token, post, i) =>
      for pair in pairs
        [open, close] = pair
        levels[open] or= 0

  # Some blocks occur in the middle of expressions -- when we're expecting
  # this, remove their trailing newlines.
  removeMidExpressionNewlines: ->
    @scanTokens (token, i) =>
      return 1 unless include(EXPRESSION_CLOSE, @tag(i + 1)) and token[0] is 'TERMINATOR'
      @tokens.splice i, 1
      return 0

  # The lexer has tagged the opening parenthesis of a method call. Match it with
  # its paired close.
  closeOpenCalls: ->
    @scanTokens (token, i) =>
      if token[0] is 'CALL_START'
        condition = (token, i) -> token[0] in [')', 'CALL_END']
        action    = (token, i) -> token[0] = 'CALL_END'
