Mercurial > hg > index.cgi
annotate lwbasic/lwbasic.h @ 30:bcd532a90e53
Renamed "compiler" to "parser" for more consistent terminology
author | lost@l-w.ca |
---|---|
date | Thu, 03 Feb 2011 21:19:11 -0700 |
parents | 77626fc37af2 |
children | 574931d87abd |
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 | |
31 /* note: integer and uinteger will be the same for positive values from 0 | |
32 through 0x7FFFFFFF; the unsigned type should be used for doing ascii | |
33 conversions and then if a negative value was discovered, it should be | |
34 negated IFF it is in range. */ | |
35 | |
36 union lexer_numbers | |
37 { | |
38 uint32_t uinteger; | |
39 int32_t integer; | |
40 }; | |
41 | |
22 | 42 typedef struct |
43 { | |
44 char *output_file; | |
45 char *input_file; | |
46 | |
47 int debug_level; | |
25 | 48 |
49 char *lexer_token_string; | |
50 union lexer_numbers lexer_token_number; | |
51 int lexer_token; | |
52 int lexer_curchar; | |
53 int lexer_ignorechar; | |
54 | |
55 int parser_state; | |
23 | 56 |
57 void *input_state; | |
26
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
58 |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
59 char *currentsub; |
22 | 60 } cstate; |
61 | |
25 | 62 /* parser states */ |
63 enum | |
64 { | |
65 parser_state_global = 0, /* only global decls allowed */ | |
66 parser_state_error | |
67 }; | |
68 | |
69 /* token types */ | |
70 enum | |
71 { | |
72 token_kw_sub, /* SUB keyword */ | |
73 token_kw_function, /* FUNCTION keyword */ | |
74 token_kw_as, /* AS keyword */ | |
75 token_kw_public, /* PUBLIC keyword */ | |
76 token_kw_private, /* PRIVATE keyword */ | |
77 token_kw_params, /* PARAMS keyword */ | |
78 token_kw_returns, /* RETURNS keyword */ | |
79 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
|
80 token_kw_endsub, /* ENDSUB keyword */ |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
81 token_kw_endfunction, /* ENDFUNCTION keyword */ |
25 | 82 token_identifier, /* an identifier (variable, function, etc. */ |
83 token_char, /* single character; fallback */ | |
84 token_uint, /* unsigned integer up to 32 bits */ | |
85 token_int, /* signed integer up to 32 bits */ | |
86 token_eol, /* end of line */ | |
87 token_eof /* end of file */ | |
88 }; | |
89 | |
23 | 90 #ifndef __input_c_seen__ |
91 extern int input_getchar(cstate *state); | |
92 #endif | |
93 | |
25 | 94 #ifndef __main_c_seen__ |
95 extern void lwb_error(const char *fmt, ...); | |
96 #endif | |
97 | |
98 #ifndef __lexer_c_seen__ | |
99 extern void lexer(cstate *state); | |
100 #endif | |
101 | |
26
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
102 #ifndef __emit_c_seen__ |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
103 extern void emit_prolog(cstate *state, int vis, int framesize); |
27 | 104 extern void emit_epilog(cstate *state, int framesize); |
26
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
105 #endif |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
106 |
26aa76da75ad
Additional parsing in function/sub; emission of prolog/epilog code
lost@l-w.ca
parents:
25
diff
changeset
|
107 |
22 | 108 #endif /* __lwbasic_h_seen__ */ |