python-2.7.11/Include/node.h Source File

node.h
Go to the documentation of this file.
1 
2 /* Parse tree node interface */
3 
4 #ifndef Py_NODE_H
5 #define Py_NODE_H
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 typedef struct _node {
11  short n_type;
12  char *n_str;
13  int n_lineno;
16  struct _node *n_child;
17 } node;
18 
19 PyAPI_FUNC(node *) PyNode_New(int type);
20 PyAPI_FUNC(int) PyNode_AddChild(node *n, int type,
21  char *str, int lineno, int col_offset);
22 PyAPI_FUNC(void) PyNode_Free(node *n);
23 PyAPI_FUNC(Py_ssize_t) _PyNode_SizeOf(node *n);
24 
25 /* Node access functions */
26 #define NCH(n) ((n)->n_nchildren)
27 
28 #define CHILD(n, i) (&(n)->n_child[i])
29 #define RCHILD(n, i) (CHILD(n, NCH(n) + i))
30 #define TYPE(n) ((n)->n_type)
31 #define STR(n) ((n)->n_str)
32 
33 /* Assert that the type of a node is what we expect */
34 #define REQ(n, type) assert(TYPE(n) == (type))
35 
36 PyAPI_FUNC(void) PyNode_ListTree(node *);
37 
38 #ifdef __cplusplus
39 }
40 #endif
41 #endif /* !Py_NODE_H */
size_t n
Definition: longobject.h:93
int n_nchildren
Definition: node.h:15
int type
Definition: node.h:20
PyAPI_FUNC(node *) PyNode_New(int type)
Definition: node.h:10
int n_col_offset
Definition: node.h:14
short n_type
Definition: node.h:11
Py_intptr_t Py_ssize_t
Definition: pyport.h:185
int char int int col_offset
Definition: node.h:20
int char * str
Definition: node.h:20
struct _node * n_child
Definition: node.h:16
struct _node node
int n_lineno
Definition: node.h:13
char * n_str
Definition: node.h:12
int char int lineno
Definition: node.h:20