/* List a node on a file */#include "Python.h"#include "token.h"#include "node.h"/* Forward */static void list1node(FILE *, node *);static void listnode(FILE *, node *);voidPyNode_ListTree(node *n){listnode(stdout, n);}static int level, atbol;static voidlistnode(FILE *fp, node *n){level = 0;atbol = 1;list1node(fp, n);}static voidlist1node(FILE *fp, node *n){if (n == NULL)return;if (ISNONTERMINAL(TYPE(n))) {int i;for (i = 0; i < NCH(n); i++)list1node(fp, CHILD(n, i));}else if (ISTERMINAL(TYPE(n))) {switch (TYPE(n)) {case INDENT:++level;break;case DEDENT:--level;break;default:if (atbol) {int i;for (i = 0; i < level; ++i)fprintf(fp, "\t");atbol = 0;}if (TYPE(n) == NEWLINE) {if (STR(n) != NULL)fprintf(fp, "%s", STR(n));fprintf(fp, "\n");atbol = 1;}elsefprintf(fp, "%s ", STR(n));break;}}elsefprintf(fp, "? ");}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。