annotate src/expr.h @ 13:05d4115b4860

Started work on new expression evaluator system and major code re-work for next release
author lost
date Wed, 22 Oct 2008 04:51:16 +0000
parents
children b28d7cb60779
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
1 /*
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
2 expr.h
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
3 Copyright © 2008 William Astle
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
4
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
5 This file is part of LWASM.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
6
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
7 LWASM is free software: you can redistribute it and/or modify it under the
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
10 version.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
11
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
15 more details.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
16
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
19 */
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
20
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
21 /*
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
22 This file contains definitions associated with the expression evaluator used
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
23 by LWASM.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
24
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
25 The core of the entire expression handler is the opaque type LWVAL, pointers
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
26 to which are passed around to keep track of values. A value may be a simple
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
27 integer or it could be a more complex expression linked by operators or it
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
28 could be a polynomial expression. Simple integers are merely a degenerate
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
29 case of polynomials.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
30
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
31 The package understands the following operations:
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
32
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
33 addition
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
34 subtraction
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
35 multiplication
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
36 division
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
37 modulus
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
38 parentheses
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
39 unary negation
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
40 unary "positive"
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
41 bitwise and
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
42 bitwise or
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
43 bitwise not (1's complement)
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
44 bitwise exclusive or
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
45
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
46 Infix operators can be expressed as LWVAL <op> LWVAL. Thus, the order of
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
47 operations is only relevant when initially parsing the expression. The order
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
48 of evaluation is determined by what appears on either side of the <op> as
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
49 an LWVAL may be an expression.
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
50 */
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
51
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
52 typedef union lwval LWVAL;
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
53
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
54 struct lwval_int
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
55 {
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
56 int lwval_type; // type of value
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
57 int lwval_int_value; // integer value
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
58 };
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
59
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
60 union lwval
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
61 {
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
62 struct lwval_int lwval_type_int; // integer type
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
63 };
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
64
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
65 enum lwval_types
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
66 {
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
67 LWVAL_TYPE_INT
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
68 };
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
69
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
70 #ifndef __expr_h_seen__
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
71 #define __expr_h_seen__
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
72
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
73
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
74
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
75 #endif //__expr_h_seen__