Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | #ifndef Py_NODE_H |
2 | #define Py_NODE_H | |
3 | #ifdef __cplusplus | |
4 | extern "C" { | |
5 | #endif | |
6 | ||
7 | typedef struct _node { | |
8 | short n_type; | |
9 | char *n_str; | |
10 | int n_lineno; | |
11 | int n_nchildren; | |
12 | struct _node *n_child; | |
13 | } node; | |
14 | ||
15 | PyAPI_FUNC(node *) PyNode_New(int type); | |
16 | PyAPI_FUNC(int) PyNode_AddChild(node *n, int type, | |
17 | char *str, int lineno); | |
18 | PyAPI_FUNC(void) PyNode_Free(node *n); | |
19 | ||
20 | /* Node access functions */ | |
21 | #define NCH(n) ((n)->n_nchildren) | |
22 | ||
23 | #define CHILD(n, i) (&(n)->n_child[i]) | |
24 | #define RCHILD(n, i) (CHILD(n, NCH(n) + i)) | |
25 | #define TYPE(n) ((n)->n_type) | |
26 | #define STR(n) ((n)->n_str) | |
27 | ||
28 | /* Assert that the type of a node is what we expect */ | |
29 | #define REQ(n, type) assert(TYPE(n) == (type)) | |
30 | ||
31 | PyAPI_FUNC(void) PyNode_ListTree(node *); | |
32 | ||
33 | #ifdef __cplusplus | |
34 | } | |
35 | #endif | |
36 | #endif /* !Py_NODE_H */ |