annotate lwasm/lwval.h @ 159:71561c12b20b

Updated docs to reflect new cescapes pragma and discuss implicit assumption of the bss section flag for sections named bss and .bss
author lost
date Sat, 31 Jan 2009 06:32:27 +0000
parents 427e268e876b
children
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 /*
15
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
2 lwval.h
13
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
15
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
52 #ifndef __lwval_h_seen__
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
53 #define __lwval_h_seen__
13
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
54
14
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
55 typedef struct lwval LWVAL;
13
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
56
15
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
57 struct lwval_dt_expr
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
58 {
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
59 LWVAL *v1; // first value
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
60 LWVAL *v2; // second value
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
61 int op; // operator
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
62 };
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
63
14
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
64 union lwval_dt
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
65 {
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
66 int lwval_int; // integer type data
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
67 char *lwval_var; // pointer to variable name
15
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
68 struct lwval_dt_expr expr; // expression
14
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
69 };
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
70
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
71 enum
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
72 {
15
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
73 LWVAL_TYPE_UNDEF, // undefined
14
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
74 LWVAL_TYPE_NAN, // not a number
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
75 LWVAL_TYPE_INT, // integer
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
76 LWVAL_TYPE_VAR, // variable (symbol)
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
77 LWVAL_TYPE_EXPR, // expression
15
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
78 LWVAL_TYPE_ERR // error
14
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
79 };
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
80
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
81 struct lwval
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
82 {
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
83 int lwval_type; // data type
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
84 union lwval_dt dt; // type specific stuff
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
85 };
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
86
15
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
87 #ifndef __lwval_c_seen__
16
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
88 #define __lwval_extern__ extern
14
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
89 #else
16
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
90 #define __lwval_extern__
14
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
91 #endif
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
92
16
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
93 __lwval_extern__ LWVAL *lwval_construct_int(int value);
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
94 __lwval_extern__ LWVAL *lwval_construct_err(int errno);
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
95 __lwval_extern__ LWVAL *lwval_construct_nan(void);
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
96 __lwval_extern__ LWVAL *lwval_construct_expr(LWVAL *v1, LWVAL *v2, int op);
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
97 __lwval_extern__ LWVAL *lwval_construct_undef(void);
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
98 __lwval_extern__ void lwval_clear(LWVAL *value);
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
99 __lwval_extern__ void lwval_destroy(LWVAL *value);
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
100 __lwval_extern__ void lwval_dup(LWVAL *v1, LWVAL *v2);
14
b28d7cb60779 checkpoint
lost
parents: 13
diff changeset
101
15
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
102 // operators - operate on v1 and v2 in order, result goes into
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
103 // v1; return v1
16
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
104 __lwval_extern__ LWVAL *lwval_add(LWVAL *v1, LWVAL *v2);
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
105 __lwval_extern__ LWVAL *lwval_sub(LWVAL *v1, LWVAL *v2);
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
106 __lwval_extern__ LWVAL *lwval_mul(LWVAL *v1, LWVAL *v2);
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
107 __lwval_extern__ LWVAL *lwval_div(LWVAL *v1, LWVAL *v2);
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
108 __lwval_extern__ LWVAL *lwval_mod(LWVAL *v1, LWVAL *v2);
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
109 __lwval_extern__ LWVAL *lwval_neg(LWVAL *v1);
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
110
4f14eae64d38 Made header less likely to conflict with other #defines
lost
parents: 15
diff changeset
111 #undef __lwval_extern__
13
05d4115b4860 Started work on new expression evaluator system and major code re-work for next release
lost
parents:
diff changeset
112
15
1f598d89b9b0 Started creating expression parser
lost
parents: 14
diff changeset
113 #endif //__lwval_h_seen__