summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Parser/listnode.c
diff options
context:
space:
mode:
authororivej <[email protected]>2022-02-10 16:44:49 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:44:49 +0300
commit718c552901d703c502ccbefdfc3c9028d608b947 (patch)
tree46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/tools/python3/src/Parser/listnode.c
parente9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff)
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Parser/listnode.c')
-rw-r--r--contrib/tools/python3/src/Parser/listnode.c110
1 files changed, 55 insertions, 55 deletions
diff --git a/contrib/tools/python3/src/Parser/listnode.c b/contrib/tools/python3/src/Parser/listnode.c
index c806b98e48c..e8844e8a685 100644
--- a/contrib/tools/python3/src/Parser/listnode.c
+++ b/contrib/tools/python3/src/Parser/listnode.c
@@ -1,71 +1,71 @@
-
-/* List a node on a file */
-
+
+/* List a node on a file */
+
#include "Python.h"
#include "pycore_interp.h" // PyInterpreterState.parser
#include "pycore_pystate.h" // _PyInterpreterState_GET()
-#include "token.h"
-#include "node.h"
-
-/* Forward */
-static void list1node(FILE *, node *);
-static void listnode(FILE *, node *);
-
-void
-PyNode_ListTree(node *n)
-{
- listnode(stdout, n);
-}
-
-static void
-listnode(FILE *fp, node *n)
-{
+#include "token.h"
+#include "node.h"
+
+/* Forward */
+static void list1node(FILE *, node *);
+static void listnode(FILE *, node *);
+
+void
+PyNode_ListTree(node *n)
+{
+ listnode(stdout, n);
+}
+
+static void
+listnode(FILE *fp, node *n)
+{
PyInterpreterState *interp = _PyInterpreterState_GET();
interp->parser.listnode.level = 0;
interp->parser.listnode.atbol = 1;
- list1node(fp, n);
-}
-
-static void
-list1node(FILE *fp, node *n)
-{
+ list1node(fp, n);
+}
+
+static void
+list1node(FILE *fp, node *n)
+{
PyInterpreterState *interp;
- 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))) {
+ 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))) {
interp = _PyInterpreterState_GET();
- switch (TYPE(n)) {
- case INDENT:
+ switch (TYPE(n)) {
+ case INDENT:
interp->parser.listnode.level++;
- break;
- case DEDENT:
+ break;
+ case DEDENT:
interp->parser.listnode.level--;
- break;
- default:
+ break;
+ default:
if (interp->parser.listnode.atbol) {
- int i;
+ int i;
for (i = 0; i < interp->parser.listnode.level; ++i)
- fprintf(fp, "\t");
+ fprintf(fp, "\t");
interp->parser.listnode.atbol = 0;
- }
- if (TYPE(n) == NEWLINE) {
- if (STR(n) != NULL)
- fprintf(fp, "%s", STR(n));
- fprintf(fp, "\n");
+ }
+ if (TYPE(n) == NEWLINE) {
+ if (STR(n) != NULL)
+ fprintf(fp, "%s", STR(n));
+ fprintf(fp, "\n");
interp->parser.listnode.atbol = 1;
- }
- else
- fprintf(fp, "%s ", STR(n));
- break;
- }
- }
- else
- fprintf(fp, "? ");
-}
+ }
+ else
+ fprintf(fp, "%s ", STR(n));
+ break;
+ }
+ }
+ else
+ fprintf(fp, "? ");
+}