Mercurial > hg-old > index.cgi
comparison lwlib/lw_expr.h @ 334:f2173d18c73f
Checkpoint
author | lost |
---|---|
date | Thu, 04 Mar 2010 02:24:38 +0000 |
parents | |
children | 9f58e3bca6e3 |
comparison
equal
deleted
inserted
replaced
333:ebff3a3e8fa6 | 334:f2173d18c73f |
---|---|
1 /* | |
2 lwexpr.h | |
3 | |
4 Copyright © 2010 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 ___lw_expr_h_seen___ | |
23 #define ___lw_expr_h_seen___ | |
24 | |
25 | |
26 enum | |
27 { | |
28 lw_expr_type_oper, // operator term | |
29 lw_expr_type_int, // integer | |
30 lw_expr_type_var, // a "variable" (string for the name) | |
31 lw_expr_type_special // a "special" reference (user defined) | |
32 }; | |
33 | |
34 enum | |
35 { | |
36 lw_expr_oper_plus = 1, // addition | |
37 lw_expr_oper_minus, // subtraction | |
38 lw_expr_oper_times, // multiplication | |
39 lw_expr_oper_divide, // division | |
40 lw_expr_oper_mod, // modulus | |
41 lw_expr_oper_intdiv, // integer division | |
42 lw_expr_oper_bwand, // bitwise and | |
43 lw_expr_oper_bwor, // bitwise or | |
44 lw_expr_oper_bwxor, // bitwise xor | |
45 lw_expr_oper_and, // boolean and | |
46 lw_expr_oper_or, // boolean or | |
47 lw_expr_oper_neg, // unary negation, 2's complement | |
48 lw_expr_oper_com // unary 1's complement | |
49 }; | |
50 | |
51 #ifdef ___lw_expr_c_seen___ | |
52 | |
53 typedef struct lw_expr_priv * lw_expr_t; | |
54 | |
55 struct lw_expr_opers | |
56 { | |
57 lw_expr_t p; | |
58 struct lw_expr_opers *next; | |
59 }; | |
60 | |
61 struct lw_expr_priv | |
62 { | |
63 int type; // type of term | |
64 int value; // integer value | |
65 void *value2; // misc pointer value | |
66 int refcount; // reference count | |
67 struct lw_expr_opers *operands; // ptr to list of operands (for operators) | |
68 }; | |
69 | |
70 | |
71 #else /* def ___lw_expr_c_seen___ */ | |
72 | |
73 typedef void * lw_expr_t; | |
74 | |
75 extern lw_expr_t lwexpr_create(void); | |
76 extern void lwexpr_destroy(lw_expr_t E); | |
77 extern lw_expr_t lw_expr_deref(lw_expr_t r); | |
78 extern lw_expr_t lw_expr_copy(lw_expr_t E); | |
79 extern void lw_expr_add_operand(lw_expr_t E, lw_expr_t O); | |
80 extern lw_expr_t lw_expr_deepcopy(lw_expr_t E); | |
81 extern lw_expr_t lw_expr_build(int exprtype, ...); | |
82 extern void lw_expr_print(lw_expr_t E); | |
83 extern int lw_expr_compare(lw_expr_t E1, lw_expr_t E2); | |
84 | |
85 #endif /* def ___lw_expr_c_seen___ */ | |
86 | |
87 #endif /* ___lw_expr_h_seen___ */ |