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

Function fxGetNextNumberE

xs/sources/xsLexical.c:389–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

387}
388
389void fxGetNextNumberE(txParser* parser, int dot)
390{
391 txString p = parser->buffer;
392 txString q = p + parser->bufferSize;
393 txString r = NULL;
394 int c;
395 if (dot) {
396 if (p < q) *p++ = '.';
397 }
398 p = fxGetNextDigits(parser, fxGetNextDigitsE, p, q, 0);
399 if (dot)
400 r = p;
401 else if (parser->character == '.') {
402 dot = 1;
403 if (p < q) *p++ = '.';
404 fxGetNextCharacter(parser);
405 p = fxGetNextDigits(parser, fxGetNextDigitsE, p, q, 0);
406 r = p;
407 }
408 c = parser->character;
409 if ((c == 'e') || (c == 'E')) {
410 if (dot) {
411 if (p == r) {
412 if (p < q) *p++ = '0';
413 }
414 }
415 else {
416 dot = 1;
417 if (p < q) *p++ = '.';
418 if (p < q) *p++ = '0';
419 }
420 if (p < q) *p++ = (char)c;
421 fxGetNextCharacter(parser);
422 c = parser->character;
423 if ((c == '+') || (c == '-')) {
424 if (p < q) *p++ = (char)c;
425 fxGetNextCharacter(parser);
426 c = parser->character;
427 }
428 p = fxGetNextDigits(parser, fxGetNextDigitsE, p, q, 1);
429 c = parser->character;
430 }
431 if (p == q) {
432 fxReportMemoryError(parser, parser->states[2].line, "number overflow");
433 }
434 if (c == 'n')
435 fxGetNextCharacter(parser);
436 if (fxIsIdentifierFirst(parser->character)) {
437 fxReportParserError(parser, parser->states[2].line, "invalid number");
438 }
439 *p = 0;
440 q = parser->buffer;
441 if (c == 'n') {
442 if (dot == 0) {
443 parser->states[2].bigint.data = fxNewParserChunk(parser, fxBigIntMaximum(mxPtrDiff(p - q)));
444 fxBigIntParse(&parser->states[2].bigint, q, mxPtrDiff(p - q), 0);
445 parser->states[2].token = XS_TOKEN_BIGINT;
446 }

Callers 2

fxGetNextTokenAuxFunction · 0.85
fxGetNextTokenJSONFunction · 0.85

Calls 10

fxGetNextDigitsFunction · 0.85
fxGetNextCharacterFunction · 0.85
fxReportMemoryErrorFunction · 0.85
fxIsIdentifierFirstFunction · 0.85
fxReportParserErrorFunction · 0.85
fxNewParserChunkFunction · 0.85
fxBigIntMaximumFunction · 0.85
fxBigIntParseFunction · 0.85
fxGetNextNumberFunction · 0.85
fxStringToNumberFunction · 0.85

Tested by

no test coverage detected