FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpython/Parser/listnode.c at 3.5 · python/cpython · GitHub
python
cpython
Repository navigation
Code
Issues
5k+
(5k+)
Pull requests
2.4k
(2.4k)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpython
/
Parser
/
listnode.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
66 lines (59 loc) · 1.25 KB
Breadcrumbs
cpython
/
Parser
/
listnode.c
Copy path
File metadata and controls
66 lines (59 loc) · 1.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* List a node on a file */
#include
"pgenheaders.h"
#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
int
level
,
atbol
;
static
void
listnode
(
FILE
*
fp
,
node
*
n
)
{
level
=
0
;
atbol
=
1
;
list1node
(
fp
,
n
);
}
static
void
list1node
(
FILE
*
fp
,
node
*
n
)
{
if
(
n
==
0
)
return
;
if
(
ISNONTERMINAL
(
TYPE
(
n
))) {
int
i
;
for
(
i
=
0
;
i
<
NCH
(
n
);
i
++
)
list1node
(
fp
,
CHILD
(
n
,
i
));
}
else
if
(
ISTERMINAL
(
TYPE
(
n
))) {
switch
(
TYPE
(
n
)) {
case
INDENT
:
++
level
;
break
;
case
DEDENT
:
--
level
;
break
;
default
:
if
(
atbol
) {
int
i
;
for
(
i
=
0
;
i
<
level
;
++
i
)
fprintf
(
fp
,
"\t"
);
atbol
=
0
;
}
if
(
TYPE
(
n
)
==
NEWLINE
) {
if
(
STR
(
n
)
!=
NULL
)
fprintf
(
fp
,
"%s"
,
STR
(
n
));
fprintf
(
fp
,
"\n"
);
atbol
=
1
;
}
else
fprintf
(
fp
,
"%s "
,
STR
(
n
));
break
;
}
}
else
fprintf
(
fp
,
"? "
);
}
Back
|
FazBrowse Home
|
New Git URL