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

Function fxParseJSONValue

xs/sources/xsJSON.c:594–641  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

592}
593
594void fxParseJSONValue(txMachine* the, txJSONParser* theParser)
595{
596 if (theParser->token == XS_JSON_TOKEN_LEFT_BRACE)
597 fxParseJSONObject(the, theParser);
598 else if (theParser->token == XS_JSON_TOKEN_LEFT_BRACKET)
599 fxParseJSONArray(the, theParser);
600 else {
601 switch (theParser->token) {
602 case XS_JSON_TOKEN_FALSE:
603 mxPushBoolean(0);
604 break;
605 case XS_JSON_TOKEN_TRUE:
606 mxPushBoolean(1);
607 break;
608 case XS_JSON_TOKEN_NULL:
609 mxPushNull();
610 break;
611 case XS_JSON_TOKEN_INTEGER:
612 mxPushInteger(theParser->integer);
613 break;
614 case XS_JSON_TOKEN_NUMBER:
615 mxPushNumber(theParser->number);
616 break;
617 case XS_JSON_TOKEN_STRING:
618 mxPushString(theParser->string->value.string);
619 break;
620 default:
621 mxPushUndefined();
622 mxSyntaxError("%ld: invalid value", theParser->line);
623 break;
624 }
625 if (theParser->sourceFlag) {
626 txSlot* value = the->stack;
627 txSlot* list;
628 txSlot* slot;
629 mxPushList();
630 list = the->stack;
631 slot = list->value.list.first = fxNewSlot(the);
632 slot->kind = XS_DATA_VIEW_KIND;
633 slot->value.dataView.offset = theParser->sourceOffset;
634 slot->value.dataView.size = theParser->sourceSize;
635 slot = slot->next = list->value.list.last = fxNewSlot(the);
636 slot->kind = value->kind;
637 slot->value = value->value;
638 }
639 fxParseJSONToken(the, theParser);
640 }
641}
642
643void fxReviveJSON(txMachine* the, txJSONParser* theParser, txSlot* reviver)
644{

Callers 3

fxParseJSONFunction · 0.70
fxParseJSONArrayFunction · 0.70
fxParseJSONObjectFunction · 0.70

Calls 4

fxNewSlotFunction · 0.85
fxParseJSONObjectFunction · 0.70
fxParseJSONArrayFunction · 0.70
fxParseJSONTokenFunction · 0.70

Tested by

no test coverage detected