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

Function parseArithUnary

src/utils/bash/bashParser.ts:4264–4300  ·  view source on GitHub ↗
(
  P: ParseState,
  stop: string,
  mode: ArithMode,
)

Source from the content-addressed store, hash-verified

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

Callers 1

parseArithBinaryFunction · 0.85

Calls 7

skipBlanksFunction · 0.85
isArithStopFunction · 0.85
advanceFunction · 0.85
mkFunction · 0.85
isDigitFunction · 0.85
parseArithPostfixFunction · 0.85
peekFunction · 0.70

Tested by

no test coverage detected