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