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

Function parseTestExtglobRhs

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

Source from the content-addressed store, hash-verified

3976// (with paren counting for @(a|b)); $(...)/${}/quoted → proper node types.
3977// Multiple parts become flat children of binary_expression per tree-sitter.
3978function parseTestExtglobRhs(P: ParseState): TsNode[] {
3979 skipBlanks(P.L)
3980 const parts: TsNode[] = []
3981 let segStart = P.L.b
3982 let segStartI = P.L.i
3983 let parenDepth = 0
3984 const flushSeg = () => {
3985 if (P.L.i > segStartI) {
3986 const text = P.src.slice(segStartI, P.L.i)
3987 // Pure number stays number; everything else is extglob_pattern
3988 const type = /^\d+$/.test(text) ? 'number' : 'extglob_pattern'
3989 parts.push(mk(P, type, segStart, P.L.b, []))
3990 }
3991 }
3992 while (P.L.i < P.L.len) {
3993 const c = peek(P.L)
3994 if (c === '\\' && P.L.i + 1 < P.L.len) {
3995 advance(P.L)
3996 advance(P.L)
3997 continue
3998 }
3999 if (c === '\n') break
4000 if (parenDepth === 0) {
4001 if (c === ']' && peek(P.L, 1) === ']') break
4002 if (c === ' ' || c === '\t') {
4003 let j = P.L.i
4004 while (j < P.L.len && (P.L.src[j] === ' ' || P.L.src[j] === '\t')) j++
4005 const nc = P.L.src[j] ?? ''
4006 const nc1 = P.L.src[j + 1] ?? ''
4007 if (
4008 (nc === ']' && nc1 === ']') ||
4009 (nc === '&' && nc1 === '&') ||
4010 (nc === '|' && nc1 === '|')
4011 ) {
4012 break
4013 }
4014 advance(P.L)
4015 continue
4016 }
4017 }
4018 // $ " ' must be parsed even inside @( ) extglob parens — parseDollarLike
4019 // consumes matching ) so parenDepth stays consistent.
4020 if (c === '$') {
4021 const c1 = peek(P.L, 1)
4022 if (
4023 c1 === '(' ||
4024 c1 === '{' ||
4025 isIdentStart(c1) ||
4026 SPECIAL_VARS.has(c1)
4027 ) {
4028 flushSeg()
4029 const exp = parseDollarLike(P)
4030 if (exp) parts.push(exp)
4031 segStart = P.L.b
4032 segStartI = P.L.i
4033 continue
4034 }
4035 }

Callers 1

parseTestBinaryFunction · 0.85

Calls 11

skipBlanksFunction · 0.85
advanceFunction · 0.85
isIdentStartFunction · 0.85
flushSegFunction · 0.85
parseDollarLikeFunction · 0.85
parseDoubleQuotedFunction · 0.85
nextTokenFunction · 0.85
leafFunction · 0.85
peekFunction · 0.70
hasMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected