(
indent: number,
first?: { readonly text: string; readonly separator: number; readonly line: Line }
)
| 1099 | |
| 1100 | // `first` is the entry on a sequence item's line, parsed once the mapping counts toward the depth. |
| 1101 | private parseMapping( |
| 1102 | indent: number, |
| 1103 | first?: { readonly text: string; readonly separator: number; readonly line: Line } |
| 1104 | ): YamlRecord { |
| 1105 | this.enterCollection() |
| 1106 | const mapping = new MappingBuilder(this.merges) |
| 1107 | if (first !== undefined) this.parseMappingEntry(mapping, first.text, first.separator, indent, first.line) |
| 1108 | while (true) { |
| 1109 | this.skipIgnored() |
| 1110 | const line = this.lineAt(this.index) |
| 1111 | if (line === undefined || line.indent < indent) break |
| 1112 | if (line.indent > indent) this.fail(line, `Unexpected indentation of ${line.indent} spaces`) |
| 1113 | if (isExplicitKey(line.text)) this.fail(line, explicitKeyError) |
| 1114 | const separator = line.separator |
| 1115 | if (separator === -1) break |
| 1116 | this.index++ |
| 1117 | this.parseMappingEntry(mapping, line.text, separator, indent, line) |
| 1118 | } |
| 1119 | this.depth-- |
| 1120 | return mapping.output |
| 1121 | } |
| 1122 | |
| 1123 | private parseMappingEntry( |
| 1124 | mapping: MappingBuilder, |
no test coverage detected