diff options
| author | orivej <[email protected]> | 2022-02-10 16:45:01 +0300 |
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:01 +0300 |
| commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
| tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/tools/python3/src/Parser/listnode.c | |
| parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Parser/listnode.c')
| -rw-r--r-- | contrib/tools/python3/src/Parser/listnode.c | 110 |
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 e8844e8a685..c806b98e48c 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, "? "); +} |
