(stop: (code: number) => boolean)
| 656 | // Reads a plain scalar up to `stop`, rejecting directive, tag, explicit key and |
| 657 | // block sequence indicators. |
| 658 | private readPlain(stop: (code: number) => boolean): string { |
| 659 | // YAML 1.2.2 §7.3.3: `-` starts a plain scalar only before a non-space character other |
| 660 | // than a flow indicator. Checked in the source, since folding and trimming hide a |
| 661 | // following space or line break; the end of the line is a line break. |
| 662 | if (this.peek() === "-") { |
| 663 | const next = this.line.charCodeAt(this.index + 1) |
| 664 | if (this.index + 1 >= this.line.length || isWhiteCode(next) || isFlowIndicatorCode(next)) this.fail(flowDashError) |
| 665 | } |
| 666 | const start = this.offset + this.index |
| 667 | const raw = this.readUntil(stop, true) |
| 668 | const text = trimWhite(foldFlowLines(raw)) |
| 669 | if (text.startsWith("%")) this.fail(directiveIndicatorError) |
| 670 | // YAML 1.2.2 §7.3.3: `?` directly before a `:` starts a plain scalar. Checked in the source, |
| 671 | // since the separating `:` is not part of the text. |
| 672 | if (isExplicitKey(text) && !(raw === "?" && this.peek() === ":")) this.fail(explicitKeyError) |
| 673 | // YAML 1.2.2 §7.3.3 (ns-plain-safe-in): a plain scalar in a flow collection cannot contain a |
| 674 | // flow indicator. `,`, `]` and `}` end it, and `[` or `{` inside it fails. |
| 675 | if (/[[{]/.test(text)) { |
| 676 | throw new SyntaxError(`A flow plain scalar cannot contain '[' or '{' at flow offset ${start}`) |
| 677 | } |
| 678 | return text |
| 679 | } |
| 680 | |
| 681 | private parseSequence(): Array<unknown> { |
| 682 | this.expect("[") |
no test coverage detected