MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / parseCase

Function parseCase

source code/utils/bash/bashParser.ts:3324–3350  ·  view source on GitHub ↗
(P: ParseState, caseTok: Token)

Source from the content-addressed store, hash-verified

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

Callers 1

parseCommandFunction · 0.85

Calls 10

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

Tested by

no test coverage detected