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

Function parseCasePatternSegmented

src/utils/bash/bashParser.ts:3521–3559  ·  view source on GitHub ↗
(P: ParseState)

Source from the content-addressed store, hash-verified

3519// [extglob_pattern, string, extglob_pattern]. Bare segments → extglob_pattern
3520// if they have */?, else word. Stops at ) | space tab newline outside quotes.
3521function parseCasePatternSegmented(P: ParseState): TsNode[] {
3522 const parts: TsNode[] = []
3523 let segStart = P.L.b
3524 let segStartI = P.L.i
3525 const flushSeg = (): void => {
3526 if (P.L.i > segStartI) {
3527 const t = P.src.slice(segStartI, P.L.i)
3528 const type = /[*?]/.test(t) ? 'extglob_pattern' : 'word'
3529 parts.push(mk(P, type, segStart, P.L.b, []))
3530 }
3531 }
3532 while (P.L.i < P.L.len) {
3533 const c = peek(P.L)
3534 if (c === '\\' && P.L.i + 1 < P.L.len) {
3535 advance(P.L)
3536 advance(P.L)
3537 continue
3538 }
3539 if (c === '"') {
3540 flushSeg()
3541 parts.push(parseDoubleQuoted(P))
3542 segStart = P.L.b
3543 segStartI = P.L.i
3544 continue
3545 }
3546 if (c === "'") {
3547 flushSeg()
3548 const tok = nextToken(P.L, 'arg')
3549 parts.push(leaf(P, 'raw_string', tok))
3550 segStart = P.L.b
3551 segStartI = P.L.i
3552 continue
3553 }
3554 if (c === ')' || c === '|' || c === ' ' || c === '\t' || c === '\n') break
3555 advance(P.L)
3556 }
3557 flushSeg()
3558 return parts
3559}
3560
3561function parseFunction(P: ParseState, fnTok: Token): TsNode {
3562 const fnKw = leaf(P, 'function', fnTok)

Callers 1

parseCasePatternFunction · 0.85

Calls 7

advanceFunction · 0.85
flushSegFunction · 0.85
parseDoubleQuotedFunction · 0.85
nextTokenFunction · 0.85
leafFunction · 0.85
peekFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected