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