(value: string, parentIndent: number, allowIndentless: boolean)
| 1245 | } |
| 1246 | |
| 1247 | private parseValue(value: string, parentIndent: number, allowIndentless: boolean): unknown { |
| 1248 | const text = trimWhiteEnd(value) |
| 1249 | if (text.length === 0) return this.parseBlockValue(parentIndent, allowIndentless) |
| 1250 | if (text.startsWith("!")) throw new SyntaxError("Multiple tags on one node") |
| 1251 | if (isExplicitKey(text)) throw new SyntaxError(explicitKeyError) |
| 1252 | // YAML 1.2.2 §8.2.1: a block sequence never starts after a key or an anchor on the same line. |
| 1253 | if (isSequenceEntry(text)) { |
| 1254 | throw new SyntaxError("A block sequence cannot start on the same line as a mapping key or anchor") |
| 1255 | } |
| 1256 | const first = text.charCodeAt(0) |
| 1257 | if ((first === 124 || first === 62) && /^[|>](?:[1-9]?[+-]?|[+-]?[1-9]?)$/.test(text)) { |
| 1258 | return this.parseBlockScalar(text, parentIndent) |
| 1259 | } |
| 1260 | if (value.startsWith("\"") || value.startsWith("'")) return this.parseQuotedValue(value, parentIndent) |
| 1261 | if (text.startsWith("*")) { |
| 1262 | const name = trimWhite(text.slice(1)) |
| 1263 | if (!this.anchors.has(name)) throw new SyntaxError(`Unknown YAML alias '*${name}'`) |
| 1264 | return this.anchors.get(name) |
| 1265 | } |
| 1266 | // The untrimmed value keeps an escaped trailing space before a quoted line break. |
| 1267 | if (text.startsWith("[") || text.startsWith("{")) return this.parseFlowValue(value, parentIndent) |
| 1268 | return this.parsePlainValue(text, parentIndent) |
| 1269 | } |
| 1270 | |
| 1271 | // The node on the lines after a value that is empty on its own line. |
| 1272 | private parseBlockValue(parentIndent: number, allowIndentless: boolean): unknown { |
no test coverage detected