PageRenderTime 185ms CodeModel.GetById 85ms app.highlight 2ms RepoModel.GetById 97ms app.codeStats 0ms

/Include/node.h

http://unladen-swallow.googlecode.com/
C++ Header | 40 lines | 28 code | 9 blank | 3 comment | 1 complexity | 0584c2c065ebaf60ae052d18722b1113 MD5 | raw file
 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_col_offset;
15    int			n_nchildren;
16    struct _node	*n_child;
17} node;
18
19PyAPI_FUNC(node *) PyNode_New(int type);
20PyAPI_FUNC(int) PyNode_AddChild(node *n, int type,
21                                      char *str, int lineno, int col_offset);
22PyAPI_FUNC(void) PyNode_Free(node *n);
23
24/* Node access functions */
25#define NCH(n)		((n)->n_nchildren)
26	
27#define CHILD(n, i)	(&(n)->n_child[i])
28#define RCHILD(n, i)	(CHILD(n, NCH(n) + i))
29#define TYPE(n)		((n)->n_type)
30#define STR(n)		((n)->n_str)
31
32/* Assert that the type of a node is what we expect */
33#define REQ(n, type) assert(TYPE(n) == (type))
34
35PyAPI_FUNC(void) PyNode_ListTree(node *);
36
37#ifdef __cplusplus
38}
39#endif
40#endif /* !Py_NODE_H */