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