Track value constructs that may legally span lines so bracket-shaped string * content and nested arrays cannot be mistaken for sibling table headers.
(line: string, state: TomlLexState)
| 189 | /** Track value constructs that may legally span lines so bracket-shaped string |
| 190 | * content and nested arrays cannot be mistaken for sibling table headers. */ |
| 191 | function scanTomlLine(line: string, state: TomlLexState): void { |
| 192 | for (let i = 0; i < line.length;) { |
| 193 | if (state.multilineString !== null) { |
| 194 | const end = findMultilineStringEnd(line, i, state.multilineString); |
| 195 | if (end === -1) return; |
| 196 | i = end + state.multilineString.length; |
| 197 | state.multilineString = null; |
| 198 | continue; |
| 199 | } |
| 200 | |
| 201 | if (line[i] === '#') return; |
| 202 | |
| 203 | const multiline = line.startsWith('"""', i) |
| 204 | ? '"""' |
| 205 | : line.startsWith("'''", i) |
| 206 | ? "'''" |
| 207 | : null; |
| 208 | if (multiline !== null) { |
| 209 | state.multilineString = multiline; |
| 210 | i += multiline.length; |
| 211 | continue; |
| 212 | } |
| 213 | |
| 214 | const ch = line[i]!; |
| 215 | if (ch === '"' || ch === "'") { |
| 216 | i = skipSingleLineString(line, i, ch); |
| 217 | continue; |
| 218 | } |
| 219 | if (ch === '[') state.arrayDepth++; |
| 220 | else if (ch === ']' && state.arrayDepth > 0) state.arrayDepth--; |
| 221 | else if (ch === '{') state.inlineTableDepth++; |
| 222 | else if (ch === '}' && state.inlineTableDepth > 0) state.inlineTableDepth--; |
| 223 | i++; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | function findMultilineStringEnd( |
| 228 | line: string, |
no test coverage detected