( P: ParseState, stop: string, mode: ArithMode, )
| 4258 | } |
| 4259 | |
| 4260 | function parseArithUnary( |
| 4261 | P: ParseState, |
| 4262 | stop: string, |
| 4263 | mode: ArithMode, |
| 4264 | ): TsNode | null { |
| 4265 | skipBlanks(P.L) |
| 4266 | if (isArithStop(P, stop)) return null |
| 4267 | const c = peek(P.L) |
| 4268 | const c1 = peek(P.L, 1) |
| 4269 | // Prefix ++ -- |
| 4270 | if ((c === '+' && c1 === '+') || (c === '-' && c1 === '-')) { |
| 4271 | const s = P.L.b |
| 4272 | advance(P.L) |
| 4273 | advance(P.L) |
| 4274 | const op = mk(P, c + c1, s, P.L.b, []) |
| 4275 | const inner = parseArithUnary(P, stop, mode) |
| 4276 | if (!inner) return op |
| 4277 | return mk(P, 'unary_expression', op.startIndex, inner.endIndex, [op, inner]) |
| 4278 | } |
| 4279 | if (c === '-' || c === '+' || c === '!' || c === '~') { |
| 4280 | // In 'word'/'assign' mode (c-style for head), `-N` is a single number |
| 4281 | // literal per tree-sitter, not unary_expression. 'var' mode uses unary. |
| 4282 | if (mode !== 'var' && c === '-' && isDigit(c1)) { |
| 4283 | const s = P.L.b |
| 4284 | advance(P.L) |
| 4285 | while (isDigit(peek(P.L))) advance(P.L) |
| 4286 | return mk(P, 'number', s, P.L.b, []) |
| 4287 | } |
| 4288 | const s = P.L.b |
| 4289 | advance(P.L) |
| 4290 | const op = mk(P, c, s, P.L.b, []) |
| 4291 | const inner = parseArithUnary(P, stop, mode) |
| 4292 | if (!inner) return op |
| 4293 | return mk(P, 'unary_expression', op.startIndex, inner.endIndex, [op, inner]) |
| 4294 | } |
| 4295 | return parseArithPostfix(P, stop, mode) |
| 4296 | } |
| 4297 | |
| 4298 | function parseArithPostfix( |
| 4299 | P: ParseState, |
no test coverage detected