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

Function show_spt_aux

tools/json-graph/src/jgf2spt.c:81–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81static void show_spt_aux(Node u, unsigned indent, FILE *fp)
82{
83 unsigned degree = outdegree(u);
84
85 if (debug) node_info(u);
86
87 assert(degree != 1);
88 if (degree == 0) {
89 jsmntok_t *type = node_attr_value(u, "node-type");
90 assert(type && string_eq(type, "Token"));
91
92 fprintf(fp, "%*s{", indent, "");
93 if (pprint) {
94 fputc('\n', fp);
95 indent += 2;
96 }
97 /* Fake line, leading, trailing: */
98 fprintf(fp, "%*s\"line\":", indent, "");
99 jsmntok_t *line = node_attr_value(u, "line");
100 if (line)
101 show(fp, line, 0);
102 else
103 fputs("2", fp);
104 fputc(',', fp);
105 if (pprint) fputc('\n', fp);
106 fprintf(fp, "%*s\"leading\":\" \",", indent, "");
107 if (pprint) fputc('\n', fp);
108 fprintf(fp, "%*s\"trailing\":\" \",", indent, "");
109 if (pprint) fputc('\n', fp);
110 fprintf(fp, "%*s\"token\":", indent, "");
111 show(fp, u->label, 1);
112 /* if identifier signal as leaf: */
113 type = node_attr_value(u, "type-rule-name");
114 if (type && string_eq(type, "Identifier")) {
115 fputc(',', fp);
116 if (pprint) fputc('\n', fp);
117 fprintf(fp, "%*s\"leaf\":true", indent, "");
118 /* if identifier used as variable signal as var: */
119 if (0) {
120 fputc(',', fp);
121 if (pprint) fputc('\n', fp);
122 fprintf(fp, "%*s\"var\":true", indent, "");
123 }
124 }
125 if (pprint) {
126 fputc('\n', fp);
127 indent -= 2;
128 }
129 fprintf(fp, "%*s}", indent, "");
130 }
131 else {
132 fprintf(fp, "%*s[", indent, "");
133 if (pprint) {
134 fputc('\n', fp);
135 indent += 2;
136 }
137 fprintf(fp, "%*s", indent, "");
138 show(fp, u->label, 1);

Callers 1

show_sptFunction · 0.85

Calls 5

outdegreeFunction · 0.85
node_infoFunction · 0.85
node_attr_valueFunction · 0.85
string_eqFunction · 0.85
showFunction · 0.85

Tested by

no test coverage detected