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

Function parseCase

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

Source from the content-addressed store, hash-verified

3320}
3321
3322function 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
3350function parseCaseItem(P: ParseState): TsNode | null {
3351 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.85
pushMethod · 0.45

Tested by

no test coverage detected