node.h 804 Bytes
Newer Older
1

Guido van Rossum's avatar
Guido van Rossum committed
2 3
/* Parse tree node interface */

4 5 6 7 8 9
#ifndef Py_NODE_H
#define Py_NODE_H
#ifdef __cplusplus
extern "C" {
#endif

Guido van Rossum's avatar
Guido van Rossum committed
10
typedef struct _node {
11
    short		n_type;
12
    char		*n_str;
13 14
    int			n_lineno;
    int			n_nchildren;
15
    struct _node	*n_child;
Guido van Rossum's avatar
Guido van Rossum committed
16 17
} node;

18 19
PyAPI_FUNC(node *) PyNode_New(int type);
PyAPI_FUNC(int) PyNode_AddChild(node *n, int type,
20
                                      char *str, int lineno);
21
PyAPI_FUNC(void) PyNode_Free(node *n);
Guido van Rossum's avatar
Guido van Rossum committed
22 23 24 25 26 27 28 29

/* Node access functions */
#define NCH(n)		((n)->n_nchildren)
#define CHILD(n, i)	(&(n)->n_child[i])
#define TYPE(n)		((n)->n_type)
#define STR(n)		((n)->n_str)

/* Assert that the type of a node is what we expect */
30
#define REQ(n, type) assert(TYPE(n) == (type))
Guido van Rossum's avatar
Guido van Rossum committed
31

32
PyAPI_FUNC(void) PyNode_ListTree(node *);
33 34 35 36 37

#ifdef __cplusplus
}
#endif
#endif /* !Py_NODE_H */