(P: ParseState, caseTok: Token)
| 3320 | } |
| 3321 | |
| 3322 | function parseCase(P: ParseState, caseTok: Token): TsNode { |
| 3323 | const caseKw = leaf(P, 'case', caseTok) |
| 3324 | const kids: TsNode[] = [caseKw] |
| 3325 | skipBlanks(P.L) |
| 3326 | const word = parseWord(P, 'arg') |
| 3327 | if (word) kids.push(word) |
| 3328 | skipBlanks(P.L) |
| 3329 | consumeKeyword(P, 'in', kids) |
| 3330 | skipNewlines(P) |
| 3331 | while (true) { |
| 3332 | skipBlanks(P.L) |
| 3333 | skipNewlines(P) |
| 3334 | const save = saveLex(P.L) |
| 3335 | const t = nextToken(P.L, 'arg') |
| 3336 | if (t.type === 'WORD' && t.value === 'esac') { |
| 3337 | kids.push(leaf(P, 'esac', t)) |
| 3338 | break |
| 3339 | } |
| 3340 | if (t.type === 'EOF') break |
| 3341 | restoreLex(P.L, save) |
| 3342 | const item = parseCaseItem(P) |
| 3343 | if (!item) break |
| 3344 | kids.push(item) |
| 3345 | } |
| 3346 | const last = kids[kids.length - 1]! |
| 3347 | return mk(P, 'case_statement', caseKw.startIndex, last.endIndex, kids) |
| 3348 | } |
| 3349 | |
| 3350 | function parseCaseItem(P: ParseState): TsNode | null { |
| 3351 | skipBlanks(P.L) |
no test coverage detected