source: trunk/include/python2.4/node.h @ 490

Last change on this file since 490 was 88, checked in by cxsong, 19 years ago

copied from /opt/rappture/include

File size: 850 bytes
Line 
1
2/* Parse tree node interface */
3
4#ifndef Py_NODE_H
5#define Py_NODE_H
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10typedef struct _node {
11    short               n_type;
12    char                *n_str;
13    int                 n_lineno;
14    int                 n_nchildren;
15    struct _node        *n_child;
16} node;
17
18PyAPI_FUNC(node *) PyNode_New(int type);
19PyAPI_FUNC(int) PyNode_AddChild(node *n, int type,
20                                      char *str, int lineno);
21PyAPI_FUNC(void) PyNode_Free(node *n);
22
23/* Node access functions */
24#define NCH(n)          ((n)->n_nchildren)
25       
26#define CHILD(n, i)     (&(n)->n_child[i])
27#define RCHILD(n, i)    (CHILD(n, NCH(n) + i))
28#define TYPE(n)         ((n)->n_type)
29#define STR(n)          ((n)->n_str)
30
31/* Assert that the type of a node is what we expect */
32#define REQ(n, type) assert(TYPE(n) == (type))
33
34PyAPI_FUNC(void) PyNode_ListTree(node *);
35
36#ifdef __cplusplus
37}
38#endif
39#endif /* !Py_NODE_H */
Note: See TracBrowser for help on using the repository browser.