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