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

Function fxGetNextNumberX

xs/sources/xsLexical.c:494–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

492}
493
494void fxGetNextNumberX(txParser* parser)
495{
496 txString p = parser->buffer;
497 txString q = p + parser->bufferSize;
498 int c;
499 fxGetNextCharacter(parser);
500 p = fxGetNextDigits(parser, fxGetNextDigitsX, p, q, 1);
501 c = parser->character;
502 if (p == q) {
503 fxReportMemoryError(parser, parser->states[2].line, "number overflow");
504 }
505 if (c == 'n')
506 fxGetNextCharacter(parser);
507 if (fxIsIdentifierFirst(parser->character)) {
508 fxReportParserError(parser, parser->states[2].line, "invalid number");
509 }
510 *p = 0;
511 q = parser->buffer;
512 if (c == 'n') {
513 parser->states[2].bigint.data = fxNewParserChunk(parser, fxBigIntMaximumX(mxPtrDiff(p - q)));
514 fxBigIntParseX(&parser->states[2].bigint, q, mxPtrDiff(p - q));
515 parser->states[2].token = XS_TOKEN_BIGINT;
516 }
517 else {
518 txNumber n = 0;
519 while ((c = *q++)) {
520 if (('0' <= c) && (c <= '9'))
521 n = (n * 16) + (c - '0');
522 else if (('a' <= c) && (c <= 'f'))
523 n = (n * 16) + (10 + c - 'a');
524 else
525 n = (n * 16) + (10 + c - 'A');
526 }
527 fxGetNextNumber(parser, n);
528 }
529}
530
531void fxGetNextRegExp(txParser* parser, txU4 c)
532{

Callers 2

fxGetNextTokenAuxFunction · 0.85
fxGetNextTokenJSONFunction · 0.85

Calls 9

fxGetNextCharacterFunction · 0.85
fxGetNextDigitsFunction · 0.85
fxReportMemoryErrorFunction · 0.85
fxIsIdentifierFirstFunction · 0.85
fxReportParserErrorFunction · 0.85
fxNewParserChunkFunction · 0.85
fxBigIntMaximumXFunction · 0.85
fxBigIntParseXFunction · 0.85
fxGetNextNumberFunction · 0.85

Tested by

no test coverage detected