             
             switch state {
             case (_, .keyword("FILTER"), .lparen), (_, .keyword("BIND"), .lparen), (_, .keyword("HAVING"), .lparen):
-                pstate.registerForClose {
-                    s in
-                    outputArray.append((t, .newline(pstate.indentLevel)))
-                }
+                pstate.registerForClose()
             default:
                 break
             }

                pstate.openBraces -= 1
                pstate.indentLevel -= 1
                pstate.inSemicolon  = false
            }
            
            //                let value = t.value() as! String

        // swiftlint:disable:next nesting
        struct NestingCallback {
            let level: [Int]
        }
        
        var indentLevel: Int   = 0
        var inSemicolon: Bool  = false
        var openParens: Int    = 0
//        {
//            didSet { checkCallbacks() }
//        }
        var openBraces: Int    = 0
//        {
//            didSet { checkCallbacks() }
//        }
        var openBrackets: Int  = 0
//        {
//            didSet { checkCallbacks() }
//        }
        var callbackStack: [NestingCallback] = []
//        mutating func checkCallbacks() {
//            let currentLevel = [openBraces, openBrackets, openParens]
//            //        println("current level: \(currentLevel)")
//            if let top = callbackStack.last {
//                //            println("-----> callback set for level: \(top.level)")
//                if top.level == currentLevel {
//                    //                println("*** MATCHED")
//                    top.code(self)
//                    callbackStack.removeLast()
//                }
//            }
//        }
        
        mutating func checkBookmark() -> Bool {
            let currentLevel = [openBraces, openBrackets, openParens]
            if let top = callbackStack.last {
                if top.level == currentLevel {
                    callbackStack.removeLast()
                    return true
                }
            }
            return false
        }
        
        mutating func registerForClose() {
            let currentLevel = [openBraces, openBrackets, openParens]
            let cb = NestingCallback(level: currentLevel)
            callbackStack.append(cb)
        }
    }
