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

Function parseArithTernary

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

Source from the content-addressed store, hash-verified

4155}
4156
4157function parseArithTernary(
4158 P: ParseState,
4159 stop: string,
4160 mode: ArithMode,
4161): TsNode | null {
4162 const cond = parseArithBinary(P, stop, 0, mode)
4163 if (!cond) return null
4164 skipBlanks(P.L)
4165 if (peek(P.L) === '?') {
4166 const qs = P.L.b
4167 advance(P.L)
4168 const q = mk(P, '?', qs, P.L.b, [])
4169 const t = parseArithBinary(P, ':', 0, mode)
4170 skipBlanks(P.L)
4171 let colon: TsNode
4172 if (peek(P.L) === ':') {
4173 const cs = P.L.b
4174 advance(P.L)
4175 colon = mk(P, ':', cs, P.L.b, [])
4176 } else {
4177 colon = mk(P, ':', P.L.b, P.L.b, [])
4178 }
4179 const f = parseArithTernary(P, stop, mode)
4180 const last = f ?? colon
4181 const kids: TsNode[] = [cond, q]
4182 if (t) kids.push(t)
4183 kids.push(colon)
4184 if (f) kids.push(f)
4185 return mk(P, 'ternary_expression', cond.startIndex, last.endIndex, kids)
4186 }
4187 return cond
4188}
4189
4190/** Scan next arithmetic binary operator; returns [text, length] or null. */
4191function 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
mkFunction · 0.85
peekFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected