Mercurial > cpython-lru_cache-weakref
annotate Parser/listnode.c @ 1590:ac2e5cc29949 legacy-trunk
Added tests for missing host to open_http and open_gopher
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Mon, 18 Apr 1994 09:39:56 +0000 |
| parents | 7c3245c18677 |
| children | b724599401ff |
| rev | line source |
|---|---|
| 145 | 1 /*********************************************************** |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
2 Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
795
diff
changeset
|
3 Amsterdam, The Netherlands. |
| 145 | 4 |
| 5 All Rights Reserved | |
| 6 | |
| 7 Permission to use, copy, modify, and distribute this software and its | |
| 8 documentation for any purpose and without fee is hereby granted, | |
| 9 provided that the above copyright notice appear in all copies and that | |
| 10 both that copyright notice and this permission notice appear in | |
| 11 supporting documentation, and that the names of Stichting Mathematisch | |
| 12 Centrum or CWI not be used in advertising or publicity pertaining to | |
| 13 distribution of the software without specific, written prior permission. | |
| 14 | |
| 15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO | |
| 16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| 17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE | |
| 18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
| 19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
| 20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
| 21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
| 22 | |
| 23 ******************************************************************/ | |
| 24 | |
| 6 | 25 /* List a node on a file */ |
| 26 | |
| 86 | 27 #include "pgenheaders.h" |
| 6 | 28 #include "token.h" |
| 29 #include "node.h" | |
| 30 | |
| 86 | 31 /* Forward */ |
| 32 static void list1node PROTO((FILE *, node *)); | |
|
1391
7c3245c18677
* ceval.c, longobject.c, methodobject.c, listnode.c, arraymodule.c,
Guido van Rossum <guido@python.org>
parents:
1318
diff
changeset
|
33 static void listnode PROTO((FILE *, node *)); |
| 86 | 34 |
| 35 void | |
| 36 listtree(n) | |
| 37 node *n; | |
| 38 { | |
| 39 listnode(stdout, n); | |
| 40 } | |
| 41 | |
| 6 | 42 static int level, atbol; |
| 43 | |
|
1318
92e6a8cf14be
* pythonmain.c: -k option, usage message, more environment flags.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
44 static void |
| 86 | 45 listnode(fp, n) |
| 46 FILE *fp; | |
| 47 node *n; | |
| 48 { | |
| 49 level = 0; | |
| 50 atbol = 1; | |
| 51 list1node(fp, n); | |
| 52 } | |
| 53 | |
| 6 | 54 static void |
| 55 list1node(fp, n) | |
| 56 FILE *fp; | |
| 57 node *n; | |
| 58 { | |
| 59 if (n == 0) | |
| 60 return; | |
| 61 if (ISNONTERMINAL(TYPE(n))) { | |
| 62 int i; | |
| 63 for (i = 0; i < NCH(n); i++) | |
| 64 list1node(fp, CHILD(n, i)); | |
| 65 } | |
| 66 else if (ISTERMINAL(TYPE(n))) { | |
| 67 switch (TYPE(n)) { | |
| 68 case INDENT: | |
| 69 ++level; | |
| 70 break; | |
| 71 case DEDENT: | |
| 72 --level; | |
| 73 break; | |
| 74 default: | |
| 75 if (atbol) { | |
| 76 int i; | |
| 77 for (i = 0; i < level; ++i) | |
| 78 fprintf(fp, "\t"); | |
| 79 atbol = 0; | |
| 80 } | |
| 81 if (TYPE(n) == NEWLINE) { | |
| 82 if (STR(n) != NULL) | |
| 83 fprintf(fp, "%s", STR(n)); | |
| 84 fprintf(fp, "\n"); | |
| 85 atbol = 1; | |
| 86 } | |
| 87 else | |
| 88 fprintf(fp, "%s ", STR(n)); | |
| 89 break; | |
| 90 } | |
| 91 } | |
| 92 else | |
| 93 fprintf(fp, "? "); | |
| 94 } |
