summaryrefslogtreecommitdiffstats
path: root/Parser/listnode.c
diff options
context:
space:
mode:
Diffstat (limited to 'Parser/listnode.c')
-rw-r--r--Parser/listnode.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/Parser/listnode.c b/Parser/listnode.c
index d431ae5..b5f8ad2 100644
--- a/Parser/listnode.c
+++ b/Parser/listnode.c
@@ -1,8 +1,7 @@
/* List a node on a file */
-#include "Python.h"
-#include "pycore_pystate.h"
+#include "pgenheaders.h"
#include "token.h"
#include "node.h"
@@ -16,22 +15,20 @@ PyNode_ListTree(node *n)
listnode(stdout, n);
}
+static int level, atbol;
+
static void
listnode(FILE *fp, node *n)
{
- PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
-
- interp->parser.listnode.level = 0;
- interp->parser.listnode.atbol = 1;
+ level = 0;
+ atbol = 1;
list1node(fp, n);
}
static void
list1node(FILE *fp, node *n)
{
- PyInterpreterState *interp;
-
- if (n == NULL)
+ if (n == 0)
return;
if (ISNONTERMINAL(TYPE(n))) {
int i;
@@ -39,26 +36,25 @@ list1node(FILE *fp, node *n)
list1node(fp, CHILD(n, i));
}
else if (ISTERMINAL(TYPE(n))) {
- interp = _PyInterpreterState_GET_UNSAFE();
switch (TYPE(n)) {
case INDENT:
- interp->parser.listnode.level++;
+ ++level;
break;
case DEDENT:
- interp->parser.listnode.level--;
+ --level;
break;
default:
- if (interp->parser.listnode.atbol) {
+ if (atbol) {
int i;
- for (i = 0; i < interp->parser.listnode.level; ++i)
+ for (i = 0; i < level; ++i)
fprintf(fp, "\t");
- interp->parser.listnode.atbol = 0;
+ atbol = 0;
}
if (TYPE(n) == NEWLINE) {
if (STR(n) != NULL)
fprintf(fp, "%s", STR(n));
fprintf(fp, "\n");
- interp->parser.listnode.atbol = 1;
+ atbol = 1;
}
else
fprintf(fp, "%s ", STR(n));