1 /* yForth? - Written by Luca Padovani (C) 1996/97
2 * ------------------------------------------------------------------------
3 * This software is FreeWare as long as it comes with this header in each
4 * source file, anyway you can use it or any part of it whatever
5 * you want. It comes without any warranty, so use it at your own risk.
6 * ------------------------------------------------------------------------
8 * Abstract: include file for "core" word set
28 /**************************************************************************/
29 /* VARIABLES **************************************************************/
30 /**************************************************************************/
32 variable(Cell, to_in, ">in")
33 variable(Cell, source_id, "source-id")
34 variable(Char *, tib, "tib")
35 variable(Char *, input_buffer, "input-buffer")
36 variable(Cell, in_input_buffer, "in-input-buffer")
37 variable(Cell, base, "base")
38 variable(Char *, dp, "dp")
39 variable(Cell, error, "error")
40 variable(struct word_def *, last, "last")
41 variable(Cell, state, "state")
42 variable(Cell, env_slash_counted_string, "&counted-string")
43 variable(Cell, env_slash_hold, "&hold")
44 variable(Cell, env_slash_pad, "&pad")
45 variable(Cell, env_address_unit_bits, "&address-unit-bits")
46 variable(Cell, env_core, "&core")
47 variable(Cell, env_core_ext, "&core-ext")
48 variable(Cell, env_floored, "&floored")
49 variable(Cell, env_max_char, "&max-char")
50 variable(Cell, env_max_d, "&max-d")
51 variable(Cell, env_max_n, "&max-n")
52 variable(Cell, env_max_u, "&max-u")
53 variable(Cell, env_max_ud, "&max-ud")
54 variable(Cell, env_return_stack_cells, "&return-stack-cells")
55 variable(Cell, env_stack_cells, "&stack-cells")
56 variable(Cell, env_double, "&double")
57 variable(Cell, env_double_ext, "&double-ext")
58 variable(Cell, env_floating, "&floating")
59 variable(Cell, env_floating_stack, "&floating-stack")
60 variable(Cell, env_max_float, "&max-float")
61 variable(Cell, env_floating_ext, "&floating-ext")
62 variable(Cell, env_memory_alloc, "&memory-alloc")
63 variable(Cell, env_memory_alloc_ext, "&memory-alloc-ext")
64 variable(Cell, env_search_order, "&search-order")
65 variable(Cell, env_wordlists, "&wordlists")
66 variable(Cell, env_search_order_ext, "&search-order-ext")
67 variable(Cell, env_tools, "&tools")
68 variable(Cell, env_tools_ext, "&tools-ext")
69 variable(Cell, env_number_locals, "&#locals")
70 variable(Cell, env_locals, "&locals")
71 variable(Cell, env_locals_ext, "&locals-ext")
72 variable(Cell, env_facility, "&facility")
73 variable(Cell, env_facility_ext, "&facility-ext")
74 variable(Cell, env_block, "&block")
75 variable(Cell, env_block_ext, "&block-ext")
76 variable(Cell, env_exception, "&exception")
77 variable(Cell, env_exception_ext, "&exception-ext")
78 variable(Cell, env_file, "&file")
79 variable(Cell, env_file_ext, "&file-ext")
80 variable(Cell, env_string, "&string")
81 variable(Cell, env_string_ext, "&string-ext")
82 variable(Cell, check_system, "(check-system)")
84 /**************************************************************************/
85 /* PROTOTYPES *************************************************************/
86 /**************************************************************************/
90 code(star_slash, "*/", 0)
91 code(star_slash_mod, "*/mod", 0)
93 code(plus_store, "+!", 0)
96 code(slash_mod, "/mod", 0)
97 code(zero_less, "0<", 0)
98 code(zero_equals, "0=", 0)
99 code(one_plus, "1+", 0)
100 code(one_minus, "1-", 0)
101 code(two_store, "2!", 0)
102 code(two_star, "2*", 0)
103 code(two_slash, "2/", 0)
104 code(two_fetch, "2@", 0)
105 code(two_drop, "2drop", 0)
106 code(two_dupe, "2dup", 0)
107 code(two_over, "2over", 0)
108 code(two_swap, "2swap", 0)
109 code(less_than, "<", 0)
111 code(greater_than, ">", 0)
112 code(to_r, ">r", COMP_ONLY)
113 code(question_dupe, "?dup", 0)
116 code(align, "align", 0)
117 code(aligned, "aligned", 0)
120 code(c_store, "c!", 0)
121 code(c_fetch, "c@", 0)
122 code(cell_plus, "cell+", 0)
123 code(cells, "cells", 0)
124 code(char_plus, "char+", 0)
125 code(chars, "chars", 0)
126 code(depth, "depth", 0)
127 code(drop, "drop", 0)
129 code(f_m_slash_mod, "fm/mod", 0)
130 code(invert, "invert", 0)
131 code(l_shift, "lshift", 0)
132 code(m_star, "m*", 0)
136 code(negate, "negate", 0)
138 code(over, "over", 0)
139 code(r_from, "r>", COMP_ONLY)
140 code(r_fetch, "r@", COMP_ONLY)
142 code(r_shift, "rshift", 0)
143 code(s_to_d, "s>d", 0)
144 code(s_m_slash_rem, "sm/rem", 0)
145 code(swap, "swap", 0)
146 code(u_less_than, "u<", 0)
147 code(u_m_star, "um*", 0)
148 code(u_m_slash_mod, "um/mod", 0)
150 code(word, "word", 0)
151 code(to_number, ">number", 0)
152 code(interpret, "interpret", 0)
153 code(accept, "accept", 0)
154 code(source, "source", 0)
156 code(evaluate, "evaluate", 0)
157 code(quit, "quit", 0)
159 code(allot, "allot", 0)
160 code(c_comma, "c,", 0)
161 code(here, "here", 0)
162 code(exit_imm, "exit", COMP_ONLY | IMMEDIATE)
164 code(variable, "variable", 0)
165 code(constant, "constant", 0)
166 code(create, "create", 0)
167 code(does, "does>", COMP_ONLY | IMMEDIATE)
168 code(semi_colon, ";", COMP_ONLY | IMMEDIATE)
169 code(if, "if", COMP_ONLY | IMMEDIATE)
170 code(then, "then", COMP_ONLY | IMMEDIATE)
171 code(else, "else", COMP_ONLY | IMMEDIATE)
172 code(begin, "begin", COMP_ONLY | IMMEDIATE)
173 code(do, "do", COMP_ONLY | IMMEDIATE)
174 code(loop, "loop", COMP_ONLY | IMMEDIATE)
175 code(i, "i", COMP_ONLY)
176 code(j, "j", COMP_ONLY)
177 code(plus_loop, "+loop", COMP_ONLY | IMMEDIATE)
178 code(recurse, "recurse", COMP_ONLY | IMMEDIATE)
179 code(find, "find", 0)
180 code(less_number_sign, "<#", 0)
181 code(number_sign, "#", 0)
182 code(hold, "hold", 0)
183 code(number_sign_s, "#s", 0)
184 code(number_sign_greater, "#>", 0)
187 code(emit, "emit", 0)
188 code(space, "space", 0)
189 code(spaces, "spaces", 0)
190 code(type, "type", 0)
192 code(dot_quote, ".\"", COMP_ONLY | IMMEDIATE)
194 code(to_body, ">body", 0)
195 code(abort, "abort", 0)
196 code(abort_quote, "abort\"", COMP_ONLY | IMMEDIATE)
197 code(count, "count", 0)
198 code(decimal, "decimal", 0)
199 code(environment_query, "environment?", 0)
200 code(execute, "execute", 0)
201 code(fill, "fill", 0)
202 code(immediate, "immediate", 0)
204 code(leave, "leave", COMP_ONLY)
205 code(literal, "literal", COMP_ONLY | IMMEDIATE)
206 code(move, "move", 0)
207 code(postpone, "postpone", COMP_ONLY | IMMEDIATE)
208 code(s_quote, "s\"", IMMEDIATE)
209 code(sign, "sign", 0)
210 code(unloop, "unloop", COMP_ONLY)
211 code(left_bracket, "[", COMP_ONLY | IMMEDIATE)
212 code(bracket_tick, "[']", COMP_ONLY | IMMEDIATE)
213 code(char, "char", 0)
214 code(bracket_char, "[char]", COMP_ONLY | IMMEDIATE)
215 code(right_bracket, "]", 0)
216 code(while, "while", COMP_ONLY | IMMEDIATE)
217 code(repeat, "repeat", COMP_ONLY | IMMEDIATE)
218 code(paren_does_paren, "(does)", 0)
219 code(paren_compile_paren, "(compile)", 0)
220 code(paren_do_paren, "(do)", 0)
221 code(paren_loop_paren, "(loop)", 0)
222 code(paren_plus_loop_paren, "(+loop)", 0)
223 code(paren_dot_quote_paren, "(.\")", 0)
224 code(paren_do_colon_paren, "(doCol)", 0)
225 code(zero_branch, "(0branch)", 0)
226 code(branch, "(branch)", 0)
227 code(do_literal, "(doLit)", 0)
228 code(do_fliteral, "(doFLit)", 0)
229 code(do_exit, "(doExit)", 0)
230 code(do_value, "(doValue)", 0)
231 code(view_error_msg, "view-error-message", 0)
232 code(read_const, "read-const", 0)
236 /**************************************************************************/
237 /* AUXILIARY FUNCTIONS PROTOTYPES *****************************************/
238 /**************************************************************************/
240 struct word_def *search_wordlist(Char *name, Cell len, struct vocabulary *wid);
241 struct word_def *search_word(Char *name, Cell len);
242 void ins_word(struct word_def *p);
243 void mark_word(struct word_def *p);
244 void set_find_stack(Char *addr, struct word_def *xt);
245 int strmatch(const Char *s1, const Char *s2, int len1);
246 int is_base_digit(Char ch);
247 int process_char(Char *addr, int max_len, int cur_pos, char ch);
248 void create_definition(Cell class);
249 void exec_colon(pfp *ip0);
250 void exec_word(struct word_def *xt);
251 void compile_word(struct word_def *xt);
252 void save_input_specification(void);
253 void restore_input_specification(void);
254 void check_system(void);