MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxGetNextNumberO

Function fxGetNextNumberO

xs/sources/xsLexical.c:454–492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452}
453
454void fxGetNextNumberO(txParser* parser, int c, int legacy)
455{
456 txString p = parser->buffer;
457 txString q = p + parser->bufferSize;
458 if (legacy) {
459 p = fxGetNextDigitsD(parser, p, q, &legacy);
460 if (parser->character == '_')
461 fxReportParserError(parser, parser->states[2].line, "invalid number");
462 if (parser->character == 'n')
463 fxReportParserError(parser, parser->states[2].line, "invalid number");
464 }
465 else {
466 fxGetNextCharacter(parser);
467 legacy = 8;
468 p = fxGetNextDigits(parser, fxGetNextDigitsO, p, q, 1);
469 }
470 c = parser->character;
471 if (p == q) {
472 fxReportMemoryError(parser, parser->states[2].line, "number overflow");
473 }
474 if (c == 'n')
475 fxGetNextCharacter(parser);
476 if (fxIsIdentifierFirst(parser->character)) {
477 fxReportParserError(parser, parser->states[2].line, "invalid number");
478 }
479 *p = 0;
480 q = parser->buffer;
481 if (c == 'n') {
482 parser->states[2].bigint.data = fxNewParserChunk(parser, fxBigIntMaximumO(mxPtrDiff(p - q)));
483 fxBigIntParseO(&parser->states[2].bigint, q, mxPtrDiff(p - q));
484 parser->states[2].token = XS_TOKEN_BIGINT;
485 }
486 else {
487 txNumber n = 0;
488 while ((c = *q++))
489 n = (n * legacy) + (c - '0');
490 fxGetNextNumber(parser, n);
491 }
492}
493
494void fxGetNextNumberX(txParser* parser)
495{

Callers 2

fxGetNextTokenAuxFunction · 0.85
fxGetNextTokenJSONFunction · 0.85

Calls 10

fxGetNextDigitsDFunction · 0.85
fxReportParserErrorFunction · 0.85
fxGetNextCharacterFunction · 0.85
fxGetNextDigitsFunction · 0.85
fxReportMemoryErrorFunction · 0.85
fxIsIdentifierFirstFunction · 0.85
fxNewParserChunkFunction · 0.85
fxBigIntMaximumOFunction · 0.85
fxBigIntParseOFunction · 0.85
fxGetNextNumberFunction · 0.85

Tested by

no test coverage detected