Mercurial > cpython-lru_cache-weakref
annotate Parser/listnode.c @ 60174:255a401c19b0
(partially)
Merged revisions 79534,79537,79539,79558,79606 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79534 | florent.xicluna | 2010-03-31 23:21:54 +0200 (mer, 31 mar 2010) | 2 lines
Fix test for xml.etree when using a non-ascii path. And use check_warnings instead of catch_warnings.
........
r79537 | florent.xicluna | 2010-03-31 23:40:32 +0200 (mer, 31 mar 2010) | 2 lines
Fix typo
........
r79539 | florent.xicluna | 2010-04-01 00:01:03 +0200 (jeu, 01 avr 2010) | 2 lines
Replace catch_warnings with check_warnings when it makes sense. Use assertRaises context manager to simplify some tests.
........
r79558 | florent.xicluna | 2010-04-01 20:17:09 +0200 (jeu, 01 avr 2010) | 2 lines
#7092: Fix some -3 warnings, and fix Lib/platform.py when the path contains a double-quote.
........
r79606 | florent.xicluna | 2010-04-02 19:26:42 +0200 (ven, 02 avr 2010) | 2 lines
Backport some robotparser test and skip the test if the external resource is not available.
........
| author | Florent Xicluna <florent.xicluna@gmail.com> |
|---|---|
| date | Fri, 02 Apr 2010 18:52:12 +0000 |
| parents | 6f6f965c5e2d |
| children | fd25030223b0 |
| rev | line source |
|---|---|
| 145 | 1 |
| 6 | 2 /* List a node on a file */ |
| 3 | |
| 86 | 4 #include "pgenheaders.h" |
| 6 | 5 #include "token.h" |
| 6 #include "node.h" | |
| 7 | |
| 86 | 8 /* Forward */ |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
13256
diff
changeset
|
9 static void list1node(FILE *, node *); |
|
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
13256
diff
changeset
|
10 static void listnode(FILE *, node *); |
| 86 | 11 |
| 12 void | |
| 13659 | 13 PyNode_ListTree(node *n) |
| 86 | 14 { |
| 15 listnode(stdout, n); | |
| 16 } | |
| 17 | |
| 6 | 18 static int level, atbol; |
| 19 | |
|
1318
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
20 static void |
| 13659 | 21 listnode(FILE *fp, node *n) |
| 86 | 22 { |
| 23 level = 0; | |
| 24 atbol = 1; | |
| 25 list1node(fp, n); | |
| 26 } | |
| 27 | |
| 6 | 28 static void |
| 13659 | 29 list1node(FILE *fp, node *n) |
| 6 | 30 { |
| 31 if (n == 0) | |
| 32 return; | |
| 33 if (ISNONTERMINAL(TYPE(n))) { | |
| 34 int i; | |
| 35 for (i = 0; i < NCH(n); i++) | |
| 36 list1node(fp, CHILD(n, i)); | |
| 37 } | |
| 38 else if (ISTERMINAL(TYPE(n))) { | |
| 39 switch (TYPE(n)) { | |
| 40 case INDENT: | |
| 41 ++level; | |
| 42 break; | |
| 43 case DEDENT: | |
| 44 --level; | |
| 45 break; | |
| 46 default: | |
| 47 if (atbol) { | |
| 48 int i; | |
| 49 for (i = 0; i < level; ++i) | |
| 50 fprintf(fp, "\t"); | |
| 51 atbol = 0; | |
| 52 } | |
| 53 if (TYPE(n) == NEWLINE) { | |
| 54 if (STR(n) != NULL) | |
| 55 fprintf(fp, "%s", STR(n)); | |
| 56 fprintf(fp, "\n"); | |
| 57 atbol = 1; | |
| 58 } | |
| 59 else | |
| 60 fprintf(fp, "%s ", STR(n)); | |
| 61 break; | |
| 62 } | |
| 63 } | |
| 64 else | |
| 65 fprintf(fp, "? "); | |
| 66 } |
