public Parser waitStatement() {
        if (waitStatementParser == null) {
           FutureParser future = scoped("waitStatement");
           waitStatementParser = future;
           future.setParser(
               choice(
                   sequence(
                       token("WAIT"),
                       optional(
                           token("FOR")
                       ),
                       threadPointer(),
                       optional(
                           sequence(
                               token("RETURNING"),
                               optional(
                                   token("INTO")
                               ),
                               identifier()
                           )
                       ),
                       optional(
                           sequence(
                               token("STATUS"),
                               optional(
                                   token("IS")
                               ),
                               identifier()
                           )
                       ),
                       optional(
                           onException()
                       ),
                       optional(
                           notOnException()
                       ),
                       optional(
                           token("END-WAIT")
                       )
                   ),
                   sequence(
                       token("WAIT"),
                       optional(
                           token("FOR")
                       ),
                       eventPointer()
                   )
               )
           );
        }

        return waitStatementParser;
    }