public Parser writeStatement() {
        if (writeStatementParser == null) {
           FutureParser future = scoped("writeStatement");
           writeStatementParser = future;
           future.setParser(
               sequence(
                   token("WRITE"),
                   recordName(),
                   optional(
                       sequence(
                           token("FROM"),
                           choice(
                               identifier(),
                               literal()
                           )
                       )
                   ),
                   optional(
                       sequence(
                           choice(
                               token("AFTER"),
                               token("BEFORE")
                           ),
                           optional(
                               choice(
                                   token("ADVANCING"),
                                   token("POSITIONING")
                               )
                           ),
                           choice(
                               sequence(
                                   choice(
                                       identifier(),
                                       integer(),
                                       zero()
                                   ),
                                   optional(
                                       choice(
                                           token("LINE"),
                                           token("LINES")
                                       )
                                   )
                               ),
                               mnemonicName(),
                               token("PAGE"),
                               token("TAB"),
                               token("FORMFEED")
                           )
                       )
                   ),
                   optional(
                       sequence(
                           optional(
                               token("AT")
                           ),
                           choice(
                               token("END-OF-PAGE"),
                               token("EOP")
                           ),
                           nestedStatements()
                       )
                   ),
                   optional(
                       sequence(
                           token("NOT"),
                           optional(
                               token("AT")
                           ),
                           choice(
                               token("END-OF-PAGE"),
                               token("EOP")
                           ),
                           nestedStatements()
                       )
                   ),
                   optional(
                       retryPhrase()
                   ),
                   optional(
                       sequence(
                           optional(
                               token("WITH")
                           ),
                           optional(
                               token("NO")
                           ),
                           token("LOCK")
                       )
                   ),
                   optional(
                       sequence(
                           token("INVALID"),
                           optional(
                               token("KEY")
                           ),
                           nestedStatements()
                       )
                   ),
                   optional(
                       sequence(
                           token("NOT"),
                           token("INVALID"),
                           optional(
                               token("KEY")
                           ),
                           nestedStatements()
                       )
                   ),
                   optional(
                       token("END-WRITE")
                   )
               )
           );
        }

        return writeStatementParser;
    }