MCPcopy Create free account
hub / github.com/nodejs/node / scanBinaryOrOctalDigits

Function scanBinaryOrOctalDigits

test/fixtures/snapshot/typescript.js:11361–11398  ·  view source on GitHub ↗
(base)

Source from the content-addressed store, hash-verified

11359 return token = 79 /* SyntaxKind.Identifier */;
11360 }
11361 function scanBinaryOrOctalDigits(base) {
11362 var value = "";
11363 // For counting number of digits; Valid binaryIntegerLiteral must have at least one binary digit following B or b.
11364 // Similarly valid octalIntegerLiteral must have at least one octal digit following o or O.
11365 var separatorAllowed = false;
11366 var isPreviousTokenSeparator = false;
11367 while (true) {
11368 var ch = text.charCodeAt(pos);
11369 // Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator
11370 if (ch === 95 /* CharacterCodes._ */) {
11371 tokenFlags |= 512 /* TokenFlags.ContainsSeparator */;
11372 if (separatorAllowed) {
11373 separatorAllowed = false;
11374 isPreviousTokenSeparator = true;
11375 }
11376 else if (isPreviousTokenSeparator) {
11377 error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
11378 }
11379 else {
11380 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
11381 }
11382 pos++;
11383 continue;
11384 }
11385 separatorAllowed = true;
11386 if (!isDigit(ch) || ch - 48 /* CharacterCodes._0 */ >= base) {
11387 break;
11388 }
11389 value += text[pos];
11390 pos++;
11391 isPreviousTokenSeparator = false;
11392 }
11393 if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) {
11394 // Literal ends with underscore - not allowed
11395 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
11396 }
11397 return value;
11398 }
11399 function checkBigIntSuffix() {
11400 if (text.charCodeAt(pos) === 110 /* CharacterCodes.n */) {
11401 tokenValue += "n";

Callers 1

scanFunction · 0.85

Calls 2

isDigitFunction · 0.85
errorFunction · 0.70

Tested by

no test coverage detected