()
| 3398 | } |
| 3399 | |
| 3400 | function scanNumericLiteral() { |
| 3401 | var number, start, ch; |
| 3402 | |
| 3403 | ch = source[index]; |
| 3404 | assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'), |
| 3405 | 'Numeric literal must start with a decimal digit or a decimal point'); |
| 3406 | |
| 3407 | start = index; |
| 3408 | number = ''; |
| 3409 | if (ch !== '.') { |
| 3410 | number = source[index++]; |
| 3411 | ch = source[index]; |
| 3412 | |
| 3413 | // Hex number starts with '0x'. |
| 3414 | // Octal number starts with '0'. |
| 3415 | // Octal number in ES6 starts with '0o'. |
| 3416 | // Binary number in ES6 starts with '0b'. |
| 3417 | if (number === '0') { |
| 3418 | if (ch === 'x' || ch === 'X') { |
| 3419 | ++index; |
| 3420 | return scanHexLiteral(start); |
| 3421 | } |
| 3422 | if (ch === 'b' || ch === 'B') { |
| 3423 | ++index; |
| 3424 | return scanBinaryLiteral(start); |
| 3425 | } |
| 3426 | if (ch === 'o' || ch === 'O' || isOctalDigit(ch)) { |
| 3427 | return scanOctalLiteral(ch, start); |
| 3428 | } |
| 3429 | // decimal number starts with '0' such as '09' is illegal. |
| 3430 | if (ch && isDecimalDigit(ch.charCodeAt(0))) { |
| 3431 | throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); |
| 3432 | } |
| 3433 | } |
| 3434 | |
| 3435 | while (isDecimalDigit(source.charCodeAt(index))) { |
| 3436 | number += source[index++]; |
| 3437 | } |
| 3438 | ch = source[index]; |
| 3439 | } |
| 3440 | |
| 3441 | if (ch === '.') { |
| 3442 | number += source[index++]; |
| 3443 | while (isDecimalDigit(source.charCodeAt(index))) { |
| 3444 | number += source[index++]; |
| 3445 | } |
| 3446 | ch = source[index]; |
| 3447 | } |
| 3448 | |
| 3449 | if (ch === 'e' || ch === 'E') { |
| 3450 | number += source[index++]; |
| 3451 | |
| 3452 | ch = source[index]; |
| 3453 | if (ch === '+' || ch === '-') { |
| 3454 | number += source[index++]; |
| 3455 | } |
| 3456 | if (isDecimalDigit(source.charCodeAt(index))) { |
| 3457 | while (isDecimalDigit(source.charCodeAt(index))) { |
no test coverage detected