Mercurial > hg > index.cgi
annotate lwcc/tree.h @ 503:17fa03d69df3
Unbork "make install"
The merge of the lwcc stuff borked the Makefile some. This should unbork it.
At least it should install the binaries in .../bin again.
author | William Astle <lost@l-w.ca> |
---|---|
date | Thu, 26 Sep 2019 21:37:49 -0600 |
parents | 14a40f8bb4eb |
children | 7e8298f7bc0a |
rev | line source |
---|---|
312
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1 /* |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
2 lwcc/tree.h |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
3 |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
4 Copyright © 2013 William Astle |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
5 |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
6 This file is part of LWTOOLS. |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
7 |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
8 LWTOOLS is free software: you can redistribute it and/or modify it under the |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
9 terms of the GNU General Public License as published by the Free Software |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
10 Foundation, either version 3 of the License, or (at your option) any later |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
11 version. |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
12 |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
13 This program is distributed in the hope that it will be useful, but WITHOUT |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
16 more details. |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
17 |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License along with |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
19 this program. If not, see <http://www.gnu.org/licenses/>. |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
20 */ |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
21 |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
22 #ifndef tree_h_seen___ |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
23 #define tree_h_seen___ |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
24 |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
25 #include <stdio.h> |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
26 |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
27 /* the various node types */ |
314
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
28 #define NODE_NONE 0 // a node with no type |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
29 #define NODE_PROGRAM 1 // the whole program |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
30 #define NODE_DECL 2 // a declaration |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
31 #define NODE_TYPE_CHAR 3 // a character type |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
32 #define NODE_TYPE_SHORT 4 // short int |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
33 #define NODE_TYPE_INT 5 // integer |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
34 #define NODE_TYPE_LONG 6 // long int |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
35 #define NODE_TYPE_LONGLONG 7 // long long |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
36 #define NODE_IDENT 8 // an identifier of some kind |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
37 #define NODE_TYPE_PTR 9 // a pointer |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
38 #define NODE_TYPE_SCHAR 10 // signed char |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
39 #define NODE_TYPE_UCHAR 11 // unsigned char |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
40 #define NODE_TYPE_USHORT 12 // unsigned short |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
41 #define NODE_TYPE_UINT 13 // unsigned int |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
42 #define NODE_TYPE_ULONG 14 // unsigned long |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
43 #define NODE_TYPE_ULONGLONG 15 // unsigned long long |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
44 #define NODE_TYPE_VOID 16 // void |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
45 #define NODE_TYPE_FLOAT 17 // float |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
46 #define NODE_TYPE_DOUBLE 18 // double |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
47 #define NODE_TYPE_LDOUBLE 19 // long double |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
48 #define NODE_FUNDEF 20 // function definition |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
49 #define NODE_FUNDECL 21 // function declaration |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
50 #define NODE_FUNARGS 22 // list of function args |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
312
diff
changeset
|
51 #define NODE_BLOCK 23 // statement block |
498
1bd2d590d734
Rejig parser to eliminate lemon
William Astle <lost@l-w.ca>
parents:
314
diff
changeset
|
52 #define NODE_STMT_RETURN 24 // return statement |
1bd2d590d734
Rejig parser to eliminate lemon
William Astle <lost@l-w.ca>
parents:
314
diff
changeset
|
53 #define NODE_CONST_INT 25 // constant integer |
501
f3e9732973f1
Add basic integer operations to lwcc
William Astle <lost@l-w.ca>
parents:
498
diff
changeset
|
54 #define NODE_OPER_PLUS 26 // addition |
f3e9732973f1
Add basic integer operations to lwcc
William Astle <lost@l-w.ca>
parents:
498
diff
changeset
|
55 #define NODE_OPER_MINUS 27 // subtraction |
f3e9732973f1
Add basic integer operations to lwcc
William Astle <lost@l-w.ca>
parents:
498
diff
changeset
|
56 #define NODE_OPER_TIMES 28 // multiplcation |
f3e9732973f1
Add basic integer operations to lwcc
William Astle <lost@l-w.ca>
parents:
498
diff
changeset
|
57 #define NODE_OPER_DIVIDE 29 // division |
502 | 58 #define NODE_OPER_MOD 30 // modulus |
59 #define NODE_OPER_COND 31 // ternary conditional | |
60 #define NODE_OPER_FNCALL 32 // function call | |
61 #define NODE_OPER_SUBSCRIPT 33 // array subscript | |
62 #define NODE_OPER_POSTINC 34 // post increment | |
63 #define NODE_OPER_POSTDEC 35 // post decrement | |
64 #define NODE_OPER_PTRMEM 36 // member of pointer operator | |
65 #define NODE_OPER_OBJMEM 37 // member of object operator | |
66 #define NODE_OPER_LSH 38 // left shift | |
67 #define NODE_OPER_RSH 39 // right shift | |
68 #define NODE_OPER_LT 40 // less than | |
69 #define NODE_OPER_LE 41 // less than or equal | |
70 #define NODE_OPER_GT 42 // greater than | |
71 #define NODE_OPER_GE 43 // greater than or equal | |
72 #define NODE_OPER_EQ 44 // equality | |
73 #define NODE_OPER_NE 45 // inequality | |
74 #define NODE_OPER_BWAND 46 // bitwise and | |
75 #define NODE_OPER_BWXOR 47 // bitwise xor | |
76 #define NODE_OPER_BWOR 48 // bitwise or | |
77 #define NODE_OPER_BAND 49 // boolean and | |
78 #define NODE_OPER_BOR 50 // boolean or | |
79 #define NODE_OPER_ASS 51 // assignment | |
80 #define NODE_OPER_ADDASS 52 // add/assign combo | |
81 #define NODE_OPER_SUBASS 53 // subtract/assign combo | |
82 #define NODE_OPER_MULASS 54 // multiply/assign combo | |
83 #define NODE_OPER_DIVASS 55 // divide/assign combo | |
84 #define NODE_OPER_MODASS 56 // modulus/assign combo | |
85 #define NODE_OPER_LSHASS 57 // left shift/assign combo | |
86 #define NODE_OPER_RSHASS 58 // right shift/assign combo | |
87 #define NODE_OPER_BWANDASS 59 // bitwise and/assign combo | |
88 #define NODE_OPER_BWXORASS 60 // bitwise xor/assign combo | |
89 #define NODE_OPER_BWORASS 61 // bitwise or/assign combo | |
90 #define NODE_OPER_COMMA 62 // comma sequential evaluation operator | |
91 #define NODE_NUMTYPES 63 // the number of node types | |
312
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
92 |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
93 typedef struct node_s node_t; |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
94 |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
95 struct node_s |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
96 { |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
97 int type; // node type |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
98 char *strval; // any string value associated with the node |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
99 unsigned char ival[8]; // any 64 bit integer value associated with the node, signed or unsigned |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
100 node_t *children; // pointer to list of child nodes |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
101 node_t *next_child; // pointer to next child in the list |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
102 node_t *parent; // pointer to parent node |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
103 }; |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
104 |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
105 extern node_t *node_create(int, ...); |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
106 extern void node_destroy(node_t *); |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
107 extern void node_addchild(node_t *, node_t *); |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
108 extern void node_removechild(node_t *, node_t *); |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
109 extern void node_display(node_t *, FILE *); |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
110 extern void node_removechild_destroy(node_t *, node_t *); |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
111 |
41118fb0a8f2
Add no-op parser and parse tree infrastructure
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
112 #endif // tree_h_seen___ |