MCPcopy Create free account
hub / github.com/IBM/Project_CodeNet / main

Function main

tools/json-graph/src/jsonml2jgf.c:363–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361}
362
363int main(int argc, char *argv[])
364{
365 extern char *optarg;
366 extern int opterr;
367 extern int optind;
368 int option;
369 char const *opt_str = "cdho:stvw";
370 char usage_str[80];
371
372 char *outfile = 0;
373 enum { CSV, JSON, JSONL, XML, RAW } mode = CSV;
374 int output_tokens = 0;
375
376 sprintf(usage_str, "usage: %%s [ -%s ] [ FILE ]\n", opt_str);
377
378 /* Process arguments: */
379 while ((option = getopt(argc, argv, opt_str)) != EOF) {
380 switch (option) {
381
382 case 'c':
383 keep_comments = 1;
384 break;
385
386 case 'd':
387 debug = verbose = 1;
388 break;
389
390 case 'h':
391fputs(
392"Reads a JsonML file and constructs a JSON-Graph from its tree structure.\n"
393"If the JsonML represents a (abstract) syntax tree, e.g. generated by scrML\n"
394"then this program can also output a token stream instead.\n\n", stdout);
395fprintf(stderr, usage_str, basename(argv[0]));
396fputs(
397"\nCommand line options are:\n"
398"-c : keep comments in the token output stream.\n"
399"-d : print debug info to stderr; implies -v.\n"
400"-h : print just this text to stderr and stop.\n"
401"-o<file> : name for output file (instead of stdout).\n"
402"-s : enable a special start token specifying the filename.\n"
403"-t : output the tokens instead of a graph.\n"
404"-v : print action summary to stderr.\n"
405"-w : suppress all warning messages.\n",
406 stderr);
407 return 0;
408
409 case 'm':
410 if (!strcmp(optarg, "csv"))
411 mode = CSV;
412 else if (!strcmp(optarg, "json"))
413 mode = JSON;
414 else if (!strcmp(optarg, "jsonl"))
415 mode = JSONL;
416 else if (!strcmp(optarg, "xml"))
417 mode = XML;
418 else if (!strcmp(optarg, "raw"))
419 mode = RAW;
420 else {

Callers

nothing calls this directly

Calls 3

jsonml_parseFunction · 0.85
show_tokensFunction · 0.85
graph_show_jgfFunction · 0.85

Tested by

no test coverage detected