(
tag: string | null,
anchor: string | null,
nodeIndent: number,
flowIndent: number,
)
| 1175 | return { tag, anchor, kind: "scalar", result }; |
| 1176 | } |
| 1177 | readBlockMapping( |
| 1178 | tag: string | null, |
| 1179 | anchor: string | null, |
| 1180 | nodeIndent: number, |
| 1181 | flowIndent: number, |
| 1182 | ): State | void { |
| 1183 | const result = {}; |
| 1184 | const overridableKeys = new Set<string>(); |
| 1185 | |
| 1186 | let allowCompact = false; |
| 1187 | let line: number; |
| 1188 | let pos: number; |
| 1189 | let keyTag = null; |
| 1190 | let keyNode = null; |
| 1191 | let valueNode = null; |
| 1192 | let atExplicitKey = false; |
| 1193 | let detected = false; |
| 1194 | |
| 1195 | if (anchor !== null) this.anchorMap.set(anchor, result); |
| 1196 | |
| 1197 | let ch = this.#scanner.peek(); |
| 1198 | |
| 1199 | while (ch !== 0) { |
| 1200 | const following = this.#scanner.peek(1); |
| 1201 | line = this.line; // Save the current line. |
| 1202 | pos = this.#scanner.position; |
| 1203 | |
| 1204 | // |
| 1205 | // Explicit notation case. There are two separate blocks: |
| 1206 | // first for the key (denoted by "?") and second for the value (denoted by ":") |
| 1207 | // |
| 1208 | if ((ch === QUESTION || ch === COLON) && isWhiteSpaceOrEOL(following)) { |
| 1209 | if (ch === QUESTION) { |
| 1210 | if (atExplicitKey) { |
| 1211 | this.storeMappingPair( |
| 1212 | result, |
| 1213 | overridableKeys, |
| 1214 | keyTag as string, |
| 1215 | keyNode, |
| 1216 | null, |
| 1217 | ); |
| 1218 | keyTag = null; |
| 1219 | keyNode = null; |
| 1220 | valueNode = null; |
| 1221 | } |
| 1222 | |
| 1223 | detected = true; |
| 1224 | atExplicitKey = true; |
| 1225 | allowCompact = true; |
| 1226 | } else if (atExplicitKey) { |
| 1227 | // i.e. 0x3A/* : */ === character after the explicit key. |
| 1228 | atExplicitKey = false; |
| 1229 | allowCompact = true; |
| 1230 | } else { |
| 1231 | throw this.#createError( |
| 1232 | "Cannot read block as explicit mapping pair is incomplete: a key node is missed or followed by a non-tabulated empty line", |
| 1233 | ); |
| 1234 | } |
no test coverage detected