()
| 10919 | return result + text.substring(start, pos); |
| 10920 | } |
| 10921 | function scanNumber() { |
| 10922 | var start = pos; |
| 10923 | var mainFragment = scanNumberFragment(); |
| 10924 | var decimalFragment; |
| 10925 | var scientificFragment; |
| 10926 | if (text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) { |
| 10927 | pos++; |
| 10928 | decimalFragment = scanNumberFragment(); |
| 10929 | } |
| 10930 | var end = pos; |
| 10931 | if (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */) { |
| 10932 | pos++; |
| 10933 | tokenFlags |= 16 /* TokenFlags.Scientific */; |
| 10934 | if (text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) |
| 10935 | pos++; |
| 10936 | var preNumericPart = pos; |
| 10937 | var finalFragment = scanNumberFragment(); |
| 10938 | if (!finalFragment) { |
| 10939 | error(ts.Diagnostics.Digit_expected); |
| 10940 | } |
| 10941 | else { |
| 10942 | scientificFragment = text.substring(end, preNumericPart) + finalFragment; |
| 10943 | end = pos; |
| 10944 | } |
| 10945 | } |
| 10946 | var result; |
| 10947 | if (tokenFlags & 512 /* TokenFlags.ContainsSeparator */) { |
| 10948 | result = mainFragment; |
| 10949 | if (decimalFragment) { |
| 10950 | result += "." + decimalFragment; |
| 10951 | } |
| 10952 | if (scientificFragment) { |
| 10953 | result += scientificFragment; |
| 10954 | } |
| 10955 | } |
| 10956 | else { |
| 10957 | result = text.substring(start, end); // No need to use all the fragments; no _ removal needed |
| 10958 | } |
| 10959 | if (decimalFragment !== undefined || tokenFlags & 16 /* TokenFlags.Scientific */) { |
| 10960 | checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* TokenFlags.Scientific */)); |
| 10961 | return { |
| 10962 | type: 8 /* SyntaxKind.NumericLiteral */, |
| 10963 | value: "" + +result // if value is not an integer, it can be safely coerced to a number |
| 10964 | }; |
| 10965 | } |
| 10966 | else { |
| 10967 | tokenValue = result; |
| 10968 | var type = checkBigIntSuffix(); // if value is an integer, check whether it is a bigint |
| 10969 | checkForIdentifierStartAfterNumericLiteral(start); |
| 10970 | return { type: type, value: tokenValue }; |
| 10971 | } |
| 10972 | } |
| 10973 | function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) { |
| 10974 | if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) { |
| 10975 | return; |
no test coverage detected
searching dependent graphs…