(
tag: string | null,
anchor: string | null,
nodeIndent: number,
)
| 872 | ); |
| 873 | } |
| 874 | readFlowCollection( |
| 875 | tag: string | null, |
| 876 | anchor: string | null, |
| 877 | nodeIndent: number, |
| 878 | ): State | void { |
| 879 | let ch = this.#scanner.peek(); |
| 880 | let terminator: number; |
| 881 | let isMapping = true; |
| 882 | let result = {}; |
| 883 | if (ch === LEFT_SQUARE_BRACKET) { |
| 884 | terminator = RIGHT_SQUARE_BRACKET; |
| 885 | isMapping = false; |
| 886 | result = []; |
| 887 | } else if (ch === LEFT_CURLY_BRACKET) { |
| 888 | terminator = RIGHT_CURLY_BRACKET; |
| 889 | } else { |
| 890 | return; |
| 891 | } |
| 892 | |
| 893 | if (anchor !== null) this.anchorMap.set(anchor, result); |
| 894 | |
| 895 | this.#scanner.next(); |
| 896 | ch = this.#scanner.peek(); |
| 897 | |
| 898 | let readNext = true; |
| 899 | let valueNode = null; |
| 900 | let keyNode = null; |
| 901 | let keyTag: string | null = null; |
| 902 | let isExplicitPair = false; |
| 903 | let isPair = false; |
| 904 | let following = 0; |
| 905 | let line = 0; |
| 906 | const overridableKeys = new Set<string>(); |
| 907 | while (ch !== 0) { |
| 908 | this.skipSeparationSpace(true, nodeIndent); |
| 909 | |
| 910 | ch = this.#scanner.peek(); |
| 911 | |
| 912 | if (ch === terminator) { |
| 913 | this.#scanner.next(); |
| 914 | const kind = isMapping ? "mapping" : "sequence"; |
| 915 | return { tag, anchor, kind, result }; |
| 916 | } |
| 917 | if (!readNext) { |
| 918 | throw this.#createError( |
| 919 | "Cannot read flow collection: missing comma between flow collection entries", |
| 920 | ); |
| 921 | } |
| 922 | |
| 923 | keyTag = keyNode = valueNode = null; |
| 924 | isPair = isExplicitPair = false; |
| 925 | |
| 926 | if (ch === QUESTION) { |
| 927 | following = this.#scanner.peek(1); |
| 928 | |
| 929 | if (isWhiteSpaceOrEOL(following)) { |
| 930 | isPair = isExplicitPair = true; |
| 931 | this.#scanner.next(); |
no test coverage detected