1 /**
2   Mirror _node.h
3 
4   Parse tree node interface 
5   */
6 module deimos.python.node;
7 
8 extern(C):
9 // Python-header-file: Include/node.h
10 /// _
11 struct node {
12     /// _
13     short	n_type;
14     /// _
15     char*	n_str;
16     /// _
17     int		n_lineno;
18     version(Python_2_5_Or_Later){
19         /// Availability: >= 2.5
20         int		n_col_offset;
21     }
22     /// _
23     int		n_nchildren;
24     /// _
25     node*	n_child;
26 }
27 /// _
28 node* PyNode_New(int type);
29 /// _
30 int PyNode_AddChild(node* n, int type,
31         char* str, int lineno, int col_offset);
32 /// _
33 void PyNode_Free(node* n);
34 /// _
35 void PyNode_ListTree(node*);
36 
37 /** Node access functions */
38 auto NCH()(node* n) {
39     return n.nchildren;
40 }
41 /// _
42 auto CHILD()(node* n, size_t i) {
43     return n.n_child[i];
44 }
45 /// _
46 auto RCHILD()(node* n, size_t i) {
47     return CHILD(n, NCH(n)+i);
48 }
49 /// _
50 auto TYPE()(node* n) {
51     return n.n_type;
52 }
53 /// _
54 auto STR()(node* n) {
55     return n.n_str;
56 }