( P: ParseState, stop: string, mode: ArithMode, )
| 4155 | } |
| 4156 | |
| 4157 | function 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. */ |
| 4191 | function scanArithOp(P: ParseState): [string, number] | null { |
no test coverage detected