/** * @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper * @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos * @license BSD-3-Clause (see LICENSE in the root directory of this source tree) */ /** * @private */ export class CompositePrinterParser { constructor(printerParsers, optional) { this._printerParsers = printerParsers; this._optional = optional; } /** * Returns a copy of this printer-parser with the optional flag changed. * * @param {boolean} optional the optional flag to set in the copy * @return {CompositePrinterParser} the new printer-parser, not null */ withOptional(optional) { if (optional === this._optional) { return this; } return new CompositePrinterParser(this._printerParsers, optional); } print(context, buf) { const length = buf.length(); if (this._optional) { context.startOptional(); } try { for (let i=0; i