   # blocks, so it doesn't need to. ')' can close a single-line block,
   # but we need to make sure it's balanced.
   addImplicitIndentation: ->
+    
+    starter = indent = outdent = null
+    
+    condition = (token, i) ->
+      token[1] isnt ';' and token[0] in SINGLE_CLOSERS and
+      not (token[0] is 'ELSE' and starter not in ['IF', 'THEN'])
+      
+    action = (token, i) ->
+      @tokens.splice (if @tag(i - 1) is ',' then i - 1 else i), 0, outdent
+    
     @scanTokens (token, i, tokens) ->
       [tag] = token
       if tag is 'TERMINATOR' and @tag(i + 1) is 'THEN'

        indent.fromThen   = true if starter is 'THEN'
        indent.generated  = outdent.generated = true
        tokens.splice i + 1, 0, indent
        condition = (token, i) ->
          token[1] isnt ';' and token[0] in SINGLE_CLOSERS and
          not (token[0] is 'ELSE' and starter not in ['IF', 'THEN'])
        action = (token, i) ->
          @tokens.splice (if @tag(i - 1) is ',' then i - 1 else i), 0, outdent
        @detectEnd i + 2, condition, action
        tokens.splice i, 1 if tag is 'THEN'
        return 1

  # The lexer has tagged the opening parenthesis of an indexing operation call.
  # Match it with its paired close.
  closeOpenIndexes: ->
    
    condition = (token, i) -> 
      token[0] in [']', 'INDEX_END']
      
    action = (token, i) -> 
      token[0] = 'INDEX_END'
      
    @scanTokens (token, i) ->
      @detectEnd i + 1, condition, action if token[0] is 'INDEX_START'
      1
