Mercurial > hg-old > index.cgi
annotate lwlib/lw_expr.h @ 354:60568b123281
Added os9 opcodes and ERROR
author | lost@starbug |
---|---|
date | Tue, 30 Mar 2010 23:10:01 -0600 |
parents | 1649bc7bda5a |
children | 34dfc9747f23 |
rev | line source |
---|---|
334 | 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 | |
346
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
342
diff
changeset
|
48 lw_expr_oper_com, // unary 1's complement |
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
342
diff
changeset
|
49 lw_expr_oper_none = 0 |
334 | 50 }; |
51 | |
52 #ifdef ___lw_expr_c_seen___ | |
53 | |
54 typedef struct lw_expr_priv * lw_expr_t; | |
55 | |
56 struct lw_expr_opers | |
57 { | |
58 lw_expr_t p; | |
59 struct lw_expr_opers *next; | |
60 }; | |
61 | |
62 struct lw_expr_priv | |
63 { | |
64 int type; // type of term | |
65 int value; // integer value | |
66 void *value2; // misc pointer value | |
67 struct lw_expr_opers *operands; // ptr to list of operands (for operators) | |
68 }; | |
69 | |
346
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
342
diff
changeset
|
70 typedef lw_expr_t lw_expr_fn_t(int t, void *ptr, void *priv); |
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
342
diff
changeset
|
71 typedef lw_expr_t lw_expr_fn2_t(char *var, void *priv); |
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
342
diff
changeset
|
72 typedef lw_expr_t lw_expr_fn3_t(char **p, void *priv); |
334 | 73 |
74 #else /* def ___lw_expr_c_seen___ */ | |
75 | |
76 typedef void * lw_expr_t; | |
77 | |
78 extern lw_expr_t lwexpr_create(void); | |
337 | 79 extern void lw_expr_destroy(lw_expr_t E); |
334 | 80 extern lw_expr_t lw_expr_copy(lw_expr_t E); |
81 extern void lw_expr_add_operand(lw_expr_t E, lw_expr_t O); | |
82 extern lw_expr_t lw_expr_build(int exprtype, ...); | |
83 extern void lw_expr_print(lw_expr_t E); | |
84 extern int lw_expr_compare(lw_expr_t E1, lw_expr_t E2); | |
346
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
342
diff
changeset
|
85 extern void lw_expr_simplify(lw_expr_t E, void *priv); |
337 | 86 |
346
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
342
diff
changeset
|
87 typedef lw_expr_t lw_expr_fn_t(int t, void *ptr, void *priv); |
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
342
diff
changeset
|
88 typedef lw_expr_t lw_expr_fn2_t(char *var, void *priv); |
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
342
diff
changeset
|
89 typedef lw_expr_t lw_expr_fn3_t(char **p, void *priv); |
342 | 90 |
91 extern void lw_expr_set_special_handler(lw_expr_fn_t *fn); | |
92 extern void lw_expr_set_var_handler(lw_expr_fn2_t *fn); | |
346
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
342
diff
changeset
|
93 extern void lw_expr_set_term_parser(lw_expr_fn3_t *fn); |
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
342
diff
changeset
|
94 |
a82c55070624
Added expression parsing infrastructure and misc fixes
lost@starbug
parents:
342
diff
changeset
|
95 extern lw_expr_t lw_expr_parse(char **p, void *priv); |
347 | 96 extern int lw_expr_istype(lw_expr_t e, int t); |
97 extern int lw_expr_intval(lw_expr_t e); | |
334 | 98 |
99 #endif /* def ___lw_expr_c_seen___ */ | |
100 | |
101 #endif /* ___lw_expr_h_seen___ */ |