MCPcopy Index your code
hub / github.com/IBM/Project_CodeNet / jgf_parse

Function jgf_parse

tools/json-graph/src/jgflib.c:444–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442}
443
444Graph jgf_parse(void)
445{
446 int ntokens;
447 jsmntok_t *tokens = parse(&ntokens);
448
449 /* Collect all information in internal graph data structure: */
450 Graph graph = graph_create();
451
452 if (debug)
453 fprintf(stderr, "(D): Parsing the JSON-Graph...\n");
454
455 /* token cursor: */
456 jsmntok_t *token = tokens;
457
458 /* input must be an object: */
459 expect(token, JSMN_OBJECT); /* ^{ ... } */
460 /* look for graph key: */
461 token = lookfor_value_of_key(token, "graph");
462 /* value must be an object: */
463 expect(token, JSMN_OBJECT); /* { "graph": ^{ ... }} */
464 int keys = token->size; /* this many keys */
465 token++;
466 /* Consider all keys of "graph" object: */
467 while (keys--) {
468 expect(token, JSMN_STRING); /* { "graph": { ^"?": ... }} */
469
470 /* Handle predefined keys: */
471
472 if (string_eq(token, "directed")) {
473 /* FIXME: required */
474 token++;
475 expect_bool(token);
476 graph->directed = (input[token->start] == 't');
477 token++;
478 continue;
479 }
480
481 if (string_eq(token, "version")) {
482 /* FIXME: required and value "1.0" */
483 token++;
484 expect(token, JSMN_STRING);
485 graph->version = token;
486 token++;
487 continue;
488 }
489
490 if (string_eq(token, "type")) {
491 token++;
492 expect(token, JSMN_STRING);
493 graph->type = token;
494 token++;
495 continue;
496 }
497
498 if (string_eq(token, "root")) {
499 token++;
500 expect_nodeid(token);
501 graph->root = token;

Callers 2

mainFunction · 0.85
mainFunction · 0.85

Calls 15

parseFunction · 0.85
graph_createFunction · 0.85
expectFunction · 0.85
lookfor_value_of_keyFunction · 0.85
string_eqFunction · 0.85
expect_boolFunction · 0.85
expect_nodeidFunction · 0.85
node_createFunction · 0.85
node_add_attrFunction · 0.85
attr_createFunction · 0.85
skipFunction · 0.85
node_addFunction · 0.85

Tested by

no test coverage detected