* 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, )
| 3789 | * `!` to `x` only, not the whole `x =~ y`. |
| 3790 | */ |
| 3791 | function 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 | |
| 3821 | function parseTestBinary(P: ParseState, closer: string): TsNode | null { |
| 3822 | skipBlanks(P.L) |
no test coverage detected