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