comparison lwcc/tree.h @ 312:41118fb0a8f2 ccdev

Add no-op parser and parse tree infrastructure
author William Astle <lost@l-w.ca>
date Sat, 21 Sep 2013 18:43:39 -0600
parents
children a3e277c58df9
comparison
equal deleted inserted replaced
311:7957e90d0a35 312:41118fb0a8f2
1 /*
2 lwcc/tree.h
3
4 Copyright © 2013 William Astle
5
6 This file is part of LWTOOLS.
7
8 LWTOOLS is free software: you can redistribute it and/or modify it under the
9 terms of the GNU General Public License as published by the Free Software
10 Foundation, either version 3 of the License, or (at your option) any later
11 version.
12
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 more details.
17
18 You should have received a copy of the GNU General Public License along with
19 this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef tree_h_seen___
23 #define tree_h_seen___
24
25 #include <stdio.h>
26
27 /* the various node types */
28 #define NODE_NONE 0 // a node with no type
29 #define NODE_PROGRAM 1 // the whole program
30 #define NODE_NUMTYPES 2 // the number of node types
31
32 typedef struct node_s node_t;
33
34 struct node_s
35 {
36 int type; // node type
37 char *strval; // any string value associated with the node
38 unsigned char ival[8]; // any 64 bit integer value associated with the node, signed or unsigned
39 node_t *children; // pointer to list of child nodes
40 node_t *next_child; // pointer to next child in the list
41 node_t *parent; // pointer to parent node
42 };
43
44 extern node_t *node_create(int, ...);
45 extern void node_destroy(node_t *);
46 extern void node_addchild(node_t *, node_t *);
47 extern void node_removechild(node_t *, node_t *);
48 extern void node_display(node_t *, FILE *);
49 extern void node_removechild_destroy(node_t *, node_t *);
50
51 #endif // tree_h_seen___