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

Function parseTestNegatablePrimary

src/utils/bash/bashParser.ts:3787–3815  ·  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

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

Callers 1

parseTestBinaryFunction · 0.85

Calls 7

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

Tested by

no test coverage detected