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

Function parseArithPrimary

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

Source from the content-addressed store, hash-verified

4319}
4320
4321function parseArithPrimary(
4322 P: ParseState,
4323 stop: string,
4324 mode: ArithMode,
4325): TsNode | null {
4326 skipBlanks(P.L)
4327 if (isArithStop(P, stop)) return null
4328 const c = peek(P.L)
4329 if (c === '(') {
4330 const s = P.L.b
4331 advance(P.L)
4332 const open = mk(P, '(', s, P.L.b, [])
4333 // Parenthesized expression may contain comma-separated exprs
4334 const inners = parseArithCommaList(P, ')', mode)
4335 skipBlanks(P.L)
4336 let close: TsNode
4337 if (peek(P.L) === ')') {
4338 const cs = P.L.b
4339 advance(P.L)
4340 close = mk(P, ')', cs, P.L.b, [])
4341 } else {
4342 close = mk(P, ')', P.L.b, P.L.b, [])
4343 }
4344 return mk(P, 'parenthesized_expression', open.startIndex, close.endIndex, [
4345 open,
4346 ...inners,
4347 close,
4348 ])
4349 }
4350 if (c === '"') {
4351 return parseDoubleQuoted(P)
4352 }
4353 if (c === '$') {
4354 return parseDollarLike(P)
4355 }
4356 if (isDigit(c)) {
4357 const s = P.L.b
4358 while (isDigit(peek(P.L))) advance(P.L)
4359 // Hex: 0x1f
4360 if (
4361 P.L.b - s === 1 &&
4362 c === '0' &&
4363 (peek(P.L) === 'x' || peek(P.L) === 'X')
4364 ) {
4365 advance(P.L)
4366 while (isHexDigit(peek(P.L))) advance(P.L)
4367 }
4368 // Base notation: BASE#DIGITS e.g. 2#1010, 16#ff
4369 else if (peek(P.L) === '#') {
4370 advance(P.L)
4371 while (isBaseDigit(peek(P.L))) advance(P.L)
4372 }
4373 return mk(P, 'number', s, P.L.b, [])
4374 }
4375 if (isIdentStart(c)) {
4376 const s = P.L.b
4377 while (isIdentChar(peek(P.L))) advance(P.L)
4378 const nc = peek(P.L)

Callers 1

parseArithPostfixFunction · 0.85

Calls 14

skipBlanksFunction · 0.85
isArithStopFunction · 0.85
advanceFunction · 0.85
mkFunction · 0.85
parseArithCommaListFunction · 0.85
parseDoubleQuotedFunction · 0.85
parseDollarLikeFunction · 0.85
isDigitFunction · 0.85
isHexDigitFunction · 0.85
isBaseDigitFunction · 0.85
isIdentStartFunction · 0.85
isIdentCharFunction · 0.85

Tested by

no test coverage detected