Mercurial > hg > index.cgi
annotate lwbasic/attic/lwbasic.h @ 207:07e1fac76321
Added pragma to allow non case sensitive symbols
Added "nosymbolcase" and "symbolnocase" pragmas to cause symbols defined
while the pragma is in effect to be treated as case insensitive. Also
documented the new pragma.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sat, 09 Jun 2012 15:47:22 -0600 |
parents | cca933d32298 |
children |
rev | line source |
---|---|
22 | 1 /* |
2 lwbasic.h | |
3 | |
4 Copyright © 2011 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 /* | |
23 definitions used throughout lwbasic | |
24 */ | |
25 | |
26 #ifndef __lwbasic_h_seen__ | |
27 #define __lwbasic_h_seen__ | |
28 | |
25 | 29 #include <stdint.h> |
30 | |
32
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
31 #include "symtab.h" |
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
32 |
25 | 33 /* note: integer and uinteger will be the same for positive values from 0 |
34 through 0x7FFFFFFF; the unsigned type should be used for doing ascii | |
35 conversions and then if a negative value was discovered, it should be | |
36 negated IFF it is in range. */ | |
37 | |
38 union lexer_numbers | |
39 { | |
40 uint32_t uinteger; | |
41 int32_t integer; | |
42 }; | |
43 | |
22 | 44 typedef struct |
45 { | |
46 char *output_file; | |
47 char *input_file; | |
48 | |
49 int debug_level; | |
25 | 50 |
51 char *lexer_token_string; | |
52 union lexer_numbers lexer_token_number; | |
53 int lexer_token; | |
54 int lexer_curchar; | |
55 int lexer_ignorechar; | |
35 | 56 int expression; |
25 | 57 int parser_state; |
23 | 58 |
59 void *input_state; | |
26
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
60 |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
61 char *currentsub; |
32
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
62 symtab_t *global_syms; |
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
63 symtab_t *local_syms; |
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
64 int returntype; |
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
65 int framesize; |
22 | 66 } cstate; |
67 | |
25 | 68 /* parser states */ |
69 enum | |
70 { | |
71 parser_state_global = 0, /* only global decls allowed */ | |
72 parser_state_error | |
73 }; | |
74 | |
75 /* token types */ | |
76 enum | |
77 { | |
78 token_kw_sub, /* SUB keyword */ | |
79 token_kw_function, /* FUNCTION keyword */ | |
80 token_kw_as, /* AS keyword */ | |
81 token_kw_public, /* PUBLIC keyword */ | |
82 token_kw_private, /* PRIVATE keyword */ | |
83 token_kw_params, /* PARAMS keyword */ | |
84 token_kw_returns, /* RETURNS keyword */ | |
85 token_kw_integer, /* INTEGER keyword */ | |
26
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
86 token_kw_endsub, /* ENDSUB keyword */ |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
87 token_kw_endfunction, /* ENDFUNCTION keyword */ |
33 | 88 token_kw_dim, /* DIM keyword */ |
34 | 89 token_op_assignment, /* assignment operator */ |
35 | 90 token_op_equality, /* equality test */ |
91 token_op_greater, /* greater than */ | |
92 token_op_less, /* less than */ | |
93 token_op_greaterequal, /* greater or equal */ | |
94 token_op_lessequal, /* less or equal */ | |
95 token_op_notequal, /* not equal */ | |
96 token_op_and, /* boolean and */ | |
97 token_op_or, /* boolean or */ | |
98 token_op_xor, /* boolean exlusive or */ | |
99 token_op_band, /* bitwise and */ | |
100 token_op_bor, /* bitwise or */ | |
101 token_op_bxor, /* bitwise xor */ | |
102 token_op_plus, /* plus */ | |
103 token_op_minus, /* minus */ | |
104 token_op_times, /* times */ | |
105 token_op_divide, /* divide */ | |
106 token_op_modulus, /* modulus */ | |
36 | 107 token_op_oparen, /* open paren */ |
108 token_op_cparen, /* close paren */ | |
109 token_op_not, /* boolean not */ | |
110 token_op_bnot, /* bitwise not */ | |
25 | 111 token_identifier, /* an identifier (variable, function, etc. */ |
112 token_char, /* single character; fallback */ | |
113 token_uint, /* unsigned integer up to 32 bits */ | |
114 token_int, /* signed integer up to 32 bits */ | |
115 token_eol, /* end of line */ | |
116 token_eof /* end of file */ | |
117 }; | |
118 | |
32
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
119 /* symbol types */ |
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
120 enum |
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
121 { |
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
122 symtype_sub, /* "sub" (void function) */ |
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
123 symtype_func, /* function (nonvoid) */ |
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
124 symtype_param, /* function parameter */ |
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
125 symtype_var /* variable */ |
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
126 }; |
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
127 |
23 | 128 #ifndef __input_c_seen__ |
129 extern int input_getchar(cstate *state); | |
130 #endif | |
131 | |
25 | 132 #ifndef __main_c_seen__ |
133 extern void lwb_error(const char *fmt, ...); | |
134 #endif | |
135 | |
136 #ifndef __lexer_c_seen__ | |
137 extern void lexer(cstate *state); | |
31
574931d87abd
Created a function to prettyprint the current lexer token
lost@l-w.ca
parents:
27
diff
changeset
|
138 extern char *lexer_return_token(cstate *state); |
34 | 139 extern char *lexer_token_name(int token); |
25 | 140 #endif |
141 | |
26
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
142 #ifndef __emit_c_seen__ |
32
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
143 extern void emit_prolog(cstate *state, int vis); |
49d608aecc4d
Framework for handling local stack frame and/or variables
lost@l-w.ca
parents:
31
diff
changeset
|
144 extern void emit_epilog(cstate *state); |
26
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
145 #endif |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
146 |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
147 |
22 | 148 #endif /* __lwbasic_h_seen__ */ |