ยปCore Development>Code coverage>Parser/listnode.c

Python code coverage for Parser/listnode.c

#countcontent
1n/a
2n/a/* List a node on a file */
3n/a
4n/a#include "pgenheaders.h"
5n/a#include "token.h"
6n/a#include "node.h"
7n/a
8n/a/* Forward */
9n/astatic void list1node(FILE *, node *);
10n/astatic void listnode(FILE *, node *);
11n/a
12n/avoid
13n/aPyNode_ListTree(node *n)
14n/a{
15n/a listnode(stdout, n);
16n/a}
17n/a
18n/astatic int level, atbol;
19n/a
20n/astatic void
21n/alistnode(FILE *fp, node *n)
22n/a{
23n/a level = 0;
24n/a atbol = 1;
25n/a list1node(fp, n);
26n/a}
27n/a
28n/astatic void
29n/alist1node(FILE *fp, node *n)
30n/a{
31n/a if (n == 0)
32n/a return;
33n/a if (ISNONTERMINAL(TYPE(n))) {
34n/a int i;
35n/a for (i = 0; i < NCH(n); i++)
36n/a list1node(fp, CHILD(n, i));
37n/a }
38n/a else if (ISTERMINAL(TYPE(n))) {
39n/a switch (TYPE(n)) {
40n/a case INDENT:
41n/a ++level;
42n/a break;
43n/a case DEDENT:
44n/a --level;
45n/a break;
46n/a default:
47n/a if (atbol) {
48n/a int i;
49n/a for (i = 0; i < level; ++i)
50n/a fprintf(fp, "\t");
51n/a atbol = 0;
52n/a }
53n/a if (TYPE(n) == NEWLINE) {
54n/a if (STR(n) != NULL)
55n/a fprintf(fp, "%s", STR(n));
56n/a fprintf(fp, "\n");
57n/a atbol = 1;
58n/a }
59n/a else
60n/a fprintf(fp, "%s ", STR(n));
61n/a break;
62n/a }
63n/a }
64n/a else
65n/a fprintf(fp, "? ");
66n/a}