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

Function parseTestNegatablePrimary

src/utils/bash/bashParser.ts:3791–3819  ·  view source on GitHub ↗

* Parse `!`-negated or test-operator (`-f`) or parenthesized primary — but NOT * a binary comparison. Used as LHS of binary_expression so `! x =~ y` binds * `!` to `x` only, not the whole `x =~ y`.

(
  P: ParseState,
  closer: string,
)

Source from the content-addressed store, hash-verified

3789 * `!` to `x` only, not the whole `x =~ y`.
3790 */
3791function parseTestNegatablePrimary(
3792 P: ParseState,
3793 closer: string,
3794): TsNode | null {
3795 skipBlanks(P.L)
3796 const c = peek(P.L)
3797 if (c === '!') {
3798 const s = P.L.b
3799 advance(P.L)
3800 const bang = mk(P, '!', s, P.L.b, [])
3801 const inner = parseTestNegatablePrimary(P, closer)
3802 if (!inner) return bang
3803 return mk(P, 'unary_expression', bang.startIndex, inner.endIndex, [
3804 bang,
3805 inner,
3806 ])
3807 }
3808 if (c === '-' && isIdentStart(peek(P.L, 1))) {
3809 const s = P.L.b
3810 advance(P.L)
3811 while (isIdentChar(peek(P.L))) advance(P.L)
3812 const op = mk(P, 'test_operator', s, P.L.b, [])
3813 skipBlanks(P.L)
3814 const arg = parseTestPrimary(P, closer)
3815 if (!arg) return op
3816 return mk(P, 'unary_expression', op.startIndex, arg.endIndex, [op, arg])
3817 }
3818 return parseTestPrimary(P, closer)
3819}
3820
3821function parseTestBinary(P: ParseState, closer: string): TsNode | null {
3822 skipBlanks(P.L)

Callers 1

parseTestBinaryFunction · 0.85

Calls 7

skipBlanksFunction · 0.85
advanceFunction · 0.85
mkFunction · 0.85
isIdentStartFunction · 0.85
isIdentCharFunction · 0.85
parseTestPrimaryFunction · 0.85
peekFunction · 0.70

Tested by

no test coverage detected