MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / parseCase

Function parseCase

src/utils/bash/bashParser.ts:3318–3344  ·  view source on GitHub ↗
(P: ParseState, caseTok: Token)

Source from the content-addressed store, hash-verified

3316}
3317
3318function 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
3346function parseCaseItem(P: ParseState): TsNode | null {
3347 skipBlanks(P.L)

Callers 1

parseCommandFunction · 0.85

Calls 11

leafFunction · 0.85
skipBlanksFunction · 0.85
parseWordFunction · 0.85
consumeKeywordFunction · 0.85
skipNewlinesFunction · 0.85
saveLexFunction · 0.85
nextTokenFunction · 0.85
restoreLexFunction · 0.85
parseCaseItemFunction · 0.85
mkFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected