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

Function parseArithTernary

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

Source from the content-addressed store, hash-verified

4151}
4152
4153function parseArithTernary(
4154 P: ParseState,
4155 stop: string,
4156 mode: ArithMode,
4157): TsNode | null {
4158 const cond = parseArithBinary(P, stop, 0, mode)
4159 if (!cond) return null
4160 skipBlanks(P.L)
4161 if (peek(P.L) === '?') {
4162 const qs = P.L.b
4163 advance(P.L)
4164 const q = mk(P, '?', qs, P.L.b, [])
4165 const t = parseArithBinary(P, ':', 0, mode)
4166 skipBlanks(P.L)
4167 let colon: TsNode
4168 if (peek(P.L) === ':') {
4169 const cs = P.L.b
4170 advance(P.L)
4171 colon = mk(P, ':', cs, P.L.b, [])
4172 } else {
4173 colon = mk(P, ':', P.L.b, P.L.b, [])
4174 }
4175 const f = parseArithTernary(P, stop, mode)
4176 const last = f ?? colon
4177 const kids: TsNode[] = [cond, q]
4178 if (t) kids.push(t)
4179 kids.push(colon)
4180 if (f) kids.push(f)
4181 return mk(P, 'ternary_expression', cond.startIndex, last.endIndex, kids)
4182 }
4183 return cond
4184}
4185
4186/** Scan next arithmetic binary operator; returns [text, length] or null. */
4187function scanArithOp(P: ParseState): [string, number] | null {

Callers 3

parseArithExprFunction · 0.85
parseArithCommaListFunction · 0.85
parseArithPrimaryFunction · 0.85

Calls 6

parseArithBinaryFunction · 0.85
skipBlanksFunction · 0.85
advanceFunction · 0.85
peekFunction · 0.70
mkFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected