()
| 858 | } |
| 859 | |
| 860 | function scanNumericLiteral() { |
| 861 | var number, start, ch; |
| 862 | |
| 863 | ch = source[index]; |
| 864 | assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'), |
| 865 | 'Numeric literal must start with a decimal digit or a decimal point'); |
| 866 | |
| 867 | start = index; |
| 868 | number = ''; |
| 869 | if (ch !== '.') { |
| 870 | number = source[index++]; |
| 871 | ch = source[index]; |
| 872 | |
| 873 | // Hex number starts with '0x'. |
| 874 | // Octal number starts with '0'. |
| 875 | if (number === '0') { |
| 876 | if (ch === 'x' || ch === 'X') { |
| 877 | ++index; |
| 878 | return scanHexLiteral(start); |
| 879 | } |
| 880 | if (isOctalDigit(ch)) { |
| 881 | if (isImplicitOctalLiteral()) { |
| 882 | return scanOctalLiteral(start); |
| 883 | } |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | while (isDecimalDigit(source.charCodeAt(index))) { |
| 888 | number += source[index++]; |
| 889 | } |
| 890 | ch = source[index]; |
| 891 | } |
| 892 | |
| 893 | if (ch === '.') { |
| 894 | number += source[index++]; |
| 895 | while (isDecimalDigit(source.charCodeAt(index))) { |
| 896 | number += source[index++]; |
| 897 | } |
| 898 | ch = source[index]; |
| 899 | } |
| 900 | |
| 901 | if (ch === 'e' || ch === 'E') { |
| 902 | number += source[index++]; |
| 903 | |
| 904 | ch = source[index]; |
| 905 | if (ch === '+' || ch === '-') { |
| 906 | number += source[index++]; |
| 907 | } |
| 908 | if (isDecimalDigit(source.charCodeAt(index))) { |
| 909 | while (isDecimalDigit(source.charCodeAt(index))) { |
| 910 | number += source[index++]; |
| 911 | } |
| 912 | } else { |
| 913 | throwError({}, Messages.UnexpectedToken, 'ILLEGAL'); |
| 914 | } |
| 915 | } |
| 916 | |
| 917 | if (isIdentifierStart(source.charCodeAt(index))) { |
no test coverage detected