(state: ParserState, nodeIndent: number, props: NodeProperties)
| 857 | } |
| 858 | |
| 859 | function readFlowCollection (state: ParserState, nodeIndent: number, props: NodeProperties) { |
| 860 | const ch = state.input.charCodeAt(state.position) |
| 861 | const isMapping = ch === 0x7B/* { */ |
| 862 | const start = state.position |
| 863 | let readNext = true |
| 864 | |
| 865 | if (ch !== 0x5B/* [ */ && ch !== 0x7B/* { */) return false |
| 866 | |
| 867 | const terminator = isMapping ? 0x7D/* } */ : 0x5D/* ] */ |
| 868 | |
| 869 | if (isMapping) { |
| 870 | addMappingEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE_FLOW) |
| 871 | } else { |
| 872 | addSequenceEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE_FLOW) |
| 873 | } |
| 874 | |
| 875 | state.position++ |
| 876 | |
| 877 | while (state.input.charCodeAt(state.position) !== 0) { |
| 878 | skipFlowSeparationSpace(state, nodeIndent) |
| 879 | |
| 880 | let ch = state.input.charCodeAt(state.position) |
| 881 | |
| 882 | if (ch === terminator) { |
| 883 | state.position++ |
| 884 | addPopEvent(state) |
| 885 | return true |
| 886 | } else if (!readNext) { |
| 887 | throwError(state, 'missed comma between flow collection entries') |
| 888 | } else if (ch === 0x2C/* , */) { |
| 889 | throwError(state, "expected the node content, but found ','") |
| 890 | } |
| 891 | |
| 892 | let isPair = false |
| 893 | let isExplicitPair = false |
| 894 | |
| 895 | if (ch === 0x3F/* ? */ && isWsOrEol(state.input.charCodeAt(state.position + 1))) { |
| 896 | isPair = isExplicitPair = true |
| 897 | state.position += 1 |
| 898 | skipFlowSeparationSpace(state, nodeIndent) |
| 899 | } |
| 900 | |
| 901 | const entryLine = state.line |
| 902 | const entryStart = snapshotState(state) |
| 903 | |
| 904 | const keyWasRead = parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true) |
| 905 | skipFlowSeparationSpace(state, nodeIndent) |
| 906 | |
| 907 | ch = state.input.charCodeAt(state.position) |
| 908 | |
| 909 | if ((isMapping || isExplicitPair || state.line === entryLine) && ch === 0x3A/* : */) { |
| 910 | isPair = true |
| 911 | state.position++ |
| 912 | skipFlowSeparationSpace(state, nodeIndent) |
| 913 | if (!isMapping) { |
| 914 | restoreState(state, entryStart) |
| 915 | addMappingEvent(state, entryStart.position, NO_RANGE, NO_RANGE, NO_RANGE, NO_RANGE, COLLECTION_STYLE_FLOW) |
| 916 | if (!parseNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true)) { |
no test coverage detected
searching dependent graphs…