1 /* yForth? - A Forth interpreter written in ANSI C
2 * Copyright (C) 2012 Luca Padovani
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * ------------------------------------------------------------------------
17 * Module name: yfvinit.c
18 * Abstract: Initialize the vocabulary.
68 # include "facility.h"
71 # include "facilite.h"
89 # include "exceptio.h"
95 static struct raw_voc iv[] = {
107 # include "doublee.h"
122 # include "searche.h"
134 # include "localse.h"
137 # include "facility.h"
140 # include "facilite.h"
158 # include "exceptio.h"
161 # include "excepte.h"
169 /* init_vocabulary: loads words into the real dictionary from the table
170 * builded by including all the header files after the declaration of
171 * DECLARE_WORDS. See the header files such as "core.h" and the macro
172 * file "macro.h" for the implementation of this.
173 * This function returns the dictionary pointer after loading.
175 void init_vocabulary(Char **dp) {
179 while (iv[i].name) { /* Last name is a NULL (see table above) */
180 name = *dp; /* "name" is a ptr to the name */
181 **dp = strlen(iv[i].name); /* first copy length... */
182 strcpy(*dp + 1, iv[i].name); /* ...and then the actual name */
183 *dp = (Char *) WORD_PTR(*dp); /* advance "dp" */
184 w = (struct word_def *) *dp; /* here begins the structure */
185 w->name = name; /* adjust pointer... */
186 w->class = iv[i].class; /* ...and the class of the word */
187 ins_word(w); /* Finally adjust the link field... */
188 mark_word(w); /* ...accordingly with the hash function
189 and make the word visible */
190 *dp += sizeof(struct word_def); /* advance "dp" */
191 switch (iv[i].class & A_WORD) { /* The last field must be adjusted here */
193 w->func[0] = iv[i].func;
196 w->func[0] = (pfp) iv[i].func;