source: trunk/minix/commands/advent/vocab.c@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 14.1 KB
Line 
1
2/*
3 look-up vocabulary word in lex-ordered table. words may have
4 two entries with different codes. if minimum acceptable type
5 = 0, then return minimum of different codes. last word CANNOT
6 have two entries(due to binary sort).
7 word is the word to look up.
8 type is the minimum acceptable value,
9 if != 0 return %1000
10*/
11
12#include <string.h>
13#include <stdio.h>
14#include "advent.h"
15#include "advdec.h"
16
17static _CONST struct wac wc[] = {
18 "\"spelunker\"", 1016,
19 "22", 2053,
20 "22", 3012,
21 "34", 2053,
22 "34", 3013,
23 "4-leafed", 5034,
24 "7", 2053,
25 "7", 3011,
26 "?", 3051,
27 "above", 29,
28 "abra", 3050,
29 "abracd", 3050,
30 "across", 42,
31 "alacaz", 3050,
32 "all", 1109,
33 "altar", 90,
34 "and", 6001,
35 "answer", 2035,
36 "anvil", 1091,
37 "ascend", 29,
38 "at", 4009,
39 "attack", 2012,
40 "awaken", 2029,
41 "awkward", 26,
42 "axe", 1028,
43 "back", 8,
44 "ball", 1120,
45 "barren", 40,
46 "bat", 1104,
47 "bats", 1104,
48 "batshit", 1104,
49 "batteries", 1039,
50 "beans", 1024,
51 "bear", 1035,
52 "bed", 16,
53 "bedquilt", 70,
54 "bee", 1087,
55 "beehive", 1097,
56 "bees", 1087,
57 "billboard", 1116,
58 "bird", 1101,
59 "bitch", 2048,
60 "black", 5006,
61 "blast", 2023,
62 "blow", 2036,
63 "blowup", 2023,
64 "boat", 1048,
65 "book", 1110,
66 "booth", 1093,
67 "bottle", 1020,
68 "box", 1055,
69 "brass", 5004,
70 "break", 2028,
71 "bridge", 89,
72 "brief", 2026,
73 "broken", 54,
74 "broom", 1114,
75 "brush", 1114,
76 "brush", 2054,
77 "building", 12,
78 "bumble", 1087,
79 "burn", 2047,
80 "cage", 1004,
81 "cake", 1107, /* value must be
82 mushrooms + 1 */
83 "cakes", 1107,
84 "call", 2038,
85 "calm", 2010,
86 "canister", 1118,
87 "canyon", 25,
88 "cape", 1047,
89 "capture", 2001,
90 "carpet", 1040,
91 "carry", 2001,
92 "carving", 1115,
93 "cask", 1071,
94 "catch", 2001,
95 "cave", 67,
96 "cavern", 73,
97 "chain", 1064,
98 "chalice", 1070,
99 "chant", 2003,
100 "chasm", 1021, /* troll bridge */
101 "chest", 1055,
102 "chimney", 78,
103 "clam", 1014,
104 "click", 85,
105 "climb", 56,
106 "cloak", 1047,
107 "close", 2006,
108 "clover", 1073,
109 "cobble", 18,
110 "coins", 1054,
111 "comb", 1096,
112 "complain", 2048,
113 "continue", 7,
114 "continue", 2011,
115 "crack", 33,
116 "crap", 3106,
117 "crap!", 3106,
118 "crawl", 17,
119 "cross", 69,
120 "crown", 1066,
121 "crystal", 5033,
122 "cup", 1070,
123 "cupcakes", 1107,
124 "d", 30,
125 "dark", 22,
126 "debris", 51,
127 "defile", 23,
128 "depression", 63,
129 "descend", 30,
130 "describe", 2052,
131 "detonate", 2023,
132 "devour", 2014,
133 "diagnose", 2051,
134 "dial", 2039,
135 "diamond", 1051,
136 "diamonds", 1051,
137 "dig", 3066,
138 "discard", 2002,
139 "disturb", 2029,
140 "doff", 2002,
141 "dog", 1098,
142 "dome", 35,
143 "don", 2033,
144 "door", 1041, /* giant door */
145 "down", 30,
146 "down", 4008,
147 "downstream", 5,
148 "downward", 30,
149 "dragon", 1031,
150 "drawing", 1029,
151 "drink", 2015,
152 "drop", 2002,
153 "droplet", 1075,
154 "dump", 2002,
155 "dust", 2054,
156 "dwarf", 1017,
157 "dwarves", 1017,
158 "e", 43,
159 "east", 43,
160 "eat", 2014,
161 "egg", 1056,
162 "eggs", 1056,
163 "elfin", 5019,
164 "emerald", 1059,
165 "empty", 2013,
166 "enter", 3,
167 "entrance", 64,
168 "everything", 1109,
169 "examine", 2052,
170 "excavate", 3066,
171 "exit", 11,
172 "explore", 2011,
173 "extinguish", 2008,
174 "fee", 2025,
175 "fee", 3001,
176 "feed", 2021,
177 "fie", 2025,
178 "fie", 3002,
179 "fight", 2012,
180 "figure", 1027,
181 "fill", 2022,
182 "find", 2019,
183 "fissure", 1012,
184 "fling", 2017,
185 "floor", 58,
186 "flower", 1046,
187 "flowers", 1046,
188 "foe", 2025,
189 "foe", 3003,
190 "follow", 2011,
191 "foo", 2025,
192 "foo", 3004,
193 "food", 1019,
194 "forcd", 1,
195 "forest", 6,
196 "fork", 77,
197 "forward", 7,
198 "fountain", 1103,
199 "four-leafed", 5034,
200 "free", 2002,
201 "fresh", 5010,
202 "from", 4005,
203 "fuck", 3079,
204 "fuck!", 3079,
205 "fum", 2025,
206 "fum", 3005,
207 "gate", 2058,
208 "get", 2044,
209 "geyser", 1037, /* same as volcano */
210 "giant", 27,
211 "giant", 5029,
212 "glowing", 5031,
213 "gnome", 1105,
214 "go", 2011,
215 "gold", 1050,
216 "golden", 5001,
217 "goto", 2011,
218 "grab", 2032,
219 "grail", 1070,
220 "grate", 1003,
221 "green", 5032,
222 "grey", 5032,
223 "gripe", 2048,
224 "grotto", 91,
225 "guano", 1104,
226 "gully", 13,
227 "h20", 1081,
228 "hall", 38,
229 "headlamp", 1002,
230 "health", 2051,
231 "heave", 2017,
232 "heels", 1067,
233 "help", 3051,
234 "hike", 2011,
235 "hill", 2,
236 "hit", 2034,
237 "hive", 1097,
238 "hocus", 3050,
239 "hole", 52,
240 "holy", 5021,
241 "honey", 1096,
242 "honeycomb", 1096,
243 "horn", 1052,
244 "hound", 1098,
245 "house", 12,
246 "hurl", 2017,
247 "i", 2020,
248 "ice", 88,
249 "ignite", 2023,
250 "in", 19,
251 "in", 4001,
252 "insert", 2045,
253 "inside", 19,
254 "inside", 4001,
255 "into", 4001,
256 "inventory", 2020,
257 "inward", 19,
258 "iron", 5011,
259 "issue", 1016,
260 "jar", 1020,
261 "jerk", 2032,
262 "jewelry", 1053,
263 "jewels", 1053,
264 "jump", 39,
265 "keep", 2001,
266 "keg", 1071,
267 "key", 1090,
268 "keys", 1102,
269 "kick", 2034,
270 "kill", 2012,
271 "knapsack", 1108,
272 "knife", 1018,
273 "knives", 1018,
274 "knoll", 81,
275 "l", 2052,
276 "lamp", 1002,
277 "lantern", 1002,
278 "lead", 5023,
279 "leaden", 5023,
280 "leap", 39,
281 "leather", 5024,
282 "leave", 11,
283 "leave", 2037,
284 "ledge", 83,
285 "left", 36,
286 "light", 1002,
287 "little", 5012,
288 "lock", 2049,
289 "look", 2052,
290 "lost", 3068,
291 "low", 24,
292 "lyre", 1068,
293 "machine", 1038,
294 "magazine", 1016,
295 "main", 76,
296 "map", 2057,
297 "message", 1036,
298 "metal", 5035,
299 "ming", 5016,
300 "mirror", 1023,
301 "mist", 3069,
302 "moss", 1040,
303 "mumble", 2003,
304 "mushroom", 1106,
305 "mushrooms", 1106,
306 "n", 45,
307 "ne", 47,
308 "nest", 1056,
309 "north", 45,
310 "northeast", 47,
311 "northwest", 50,
312 "nothing", 2005,
313 "nowhere", 21,
314 "nugget", 1050,
315 "null", 21,
316 "nw", 50,
317 "oak", 5022,
318 "oaken", 5022,
319 "off", 4006,
320 "office", 76,
321 "oil", 1083, /* in bottle */
322 "on", 4002,
323 "onto", 4002,
324 "onward", 7,
325 "open", 2004,
326 "opensesame", 3050,
327 "oriental", 72,
328 "out", 11,
329 "outdoors", 32,
330 "outside", 11,
331 "over", 41,
332 "oyster", 1015,
333 "pantry", 57,
334 "passage", 23,
335 "pause", 2030,
336 "pearl", 1061,
337 "persian", 5002,
338 "peruse", 2027,
339 "peyote", 1106,
340 "phone", 1094,
341 "phonebooth", 1094,
342 "phuce", 82,
343 "pick", 2041,
344 "pillow", 1010,
345 "pirate", 1030,
346 "pirloc", 2059,
347 "piss", 3107,
348 "piss!", 3107,
349 "pit", 31,
350 "placate", 2010,
351 "plant", 1024,
352 "platinum", 5017,
353 "play", 2040,
354 "plover", 71,
355 "plugh", 65,
356 "pocus", 3050,
357 "pole", 1009,
358 "pool", 80,
359 "poster", 1113,
360 "pottery", 1058,
361 "pound", 2034,
362 "pour", 2013,
363 "pray", 92,
364 "prayer", 92,
365 "proceed", 2011,
366 "pull", 2032,
367 "punch", 2034,
368 "put", 2042,
369 "pyramid", 1060,
370 "q", 2018,
371 "quartz", 5036,
372 "quit", 2018,
373 "radium", 1119,
374 "rare", 5018,
375 "ration", 1019,
376 "read", 2027,
377 "refill", 2022,
378 "release", 2002,
379 "remove", 2046,
380 "reply", 2035,
381 "report", 2048,
382 "reservoir", 75,
383 "restore", 2031,
384 "retreat", 8,
385 "return", 8,
386 "right", 37,
387 "ring", 1072,
388 "road", 2,
389 "rock", 1119,
390 "rock", 15,
391 "rocks", 1092,
392 "rocks", 1115,
393 "rod", 1005,
394 "room", 59,
395 "rowboat", 1048,
396 "rub", 2016,
397 "ruby", 5020,
398 "rug", 1062,
399 "run", 2011,
400 "rusty", 5028,
401 "s", 46,
402 "sack", 1108,
403 "safe", 1112,
404 "saint-michel", 93,
405 "sandwich", 1019,
406 "sapphire", 1069,
407 "save", 2030,
408 "say", 2003,
409 "score", 2024,
410 "se", 48,
411 "secret", 66,
412 "sesame", 3050,
413 "shadowy", 5027,
414 "shake", 2009,
415 "shards", 1058,
416 "shatter", 2028,
417 "shazam", 3050,
418 "shelf", 83,
419 "shell", 74,
420 "shield", 1118,
421 "ship", 1048,
422 "shit", 3106,
423 "shit!", 3106,
424 "shoes", 1067,
425 "shut", 2006,
426 "silk", 5013,
427 "silken", 5013,
428 "silver", 5014,
429 "sing", 2003,
430 "slab", 61,
431 "slabroom", 61,
432 "slay", 2012,
433 "slide", 79,
434 "slippers", 1067,
435 "slit", 60,
436 "slugs", 1095,
437 "small", 5012,
438 "smash", 2028,
439 "snake", 1011,
440 "south", 46,
441 "southeast", 48,
442 "southwest", 49,
443 "spelunker", 1016,
444 "sphere", 1120,
445 "spices", 1063,
446 "stair", 10,
447 "stairs", 10,
448 "stalagmite", 1026,
449 "star", 5026,
450 "statue", 1074,
451 "steal", 2001,
452 "steel", 5025,
453 "steps", 1007,
454 "steps", 34,
455 "stick", 1049,
456 "sticks", 1049,
457 "stone", 1119,
458 "stop", 3139,
459 "stream", 14,
460 "strike", 2034,
461 "strum", 2040,
462 "suggest", 2048,
463 "surface", 20,
464 "suspend", 2030,
465 "sw", 49,
466 "sweep", 2054,
467 "swim", 3147,
468 "swing", 2009,
469 "sword", 1065,
470 "tablet", 1013,
471 "take", 2001,
472 "tame", 2010,
473 "tasty", 5030,
474 "telephone", 1094,
475 "terse", 2055,
476 "then", 6002,
477 "throw", 2017,
478 "thunder", 84,
479 "tiny", 5012,
480 "to", 4004,
481 "tome", 1110,
482 "toss", 2017,
483 "tote", 2001,
484 "travel", 2011,
485 "treasure", 5015,
486 "tree", 1074,
487 "tree", 3064,
488 "trees", 3064,
489 "trident", 1057,
490 "troll", 1033,
491 "tube", 1118,
492 "tunnel", 23,
493 "turn", 2043,
494 "u", 29,
495 "unbrief", 2026,
496 "unlock", 2050,
497 "unterse", 2055,
498 "up", 29,
499 "up", 4007,
500 "upon", 4002,
501 "upstream", 4,
502 "upward", 29,
503 "used", 5009,
504 "utter", 2003,
505 "valley", 9,
506 "vase", 1058,
507 "velvet", 5007,
508 "vending", 5008,
509 "view", 28,
510 "volcano", 1037,
511 "volume", 1110,
512 "w", 44,
513 "wake", 2029,
514 "waken", 2029,
515 "walk", 2011,
516 "wall", 53,
517 "wall", 1088, /* in blue grotto */
518 "wand", 1005,
519 "water", 1081, /* in bottle */
520 "wave", 2009,
521 "wear", 2033,
522 "west", 44,
523 "whack", 2034,
524 "where", 2019,
525 "whirl", 80,
526 "whirlpool", 80,
527 "whisk", 1114,
528 "whiskbroom", 1114,
529 "wicker", 5005,
530 "wine", 1085, /* in bottle */
531 "with", 4003,
532 "wiz", 2056,
533 "wolf", 1098,
534 "wooden", 5003,
535 "worn", 5009,
536 "worn-out", 5009,
537 "wornout", 5009,
538 "wumpus", 1099,
539 "xyzzy", 62,
540 "y2", 55,
541 "yank", 2032
542};
543
544#define MAXWC (sizeof(wc) / sizeof(struct wac))
545
546_PROTOTYPE(int binary, (char *));
547
548int vocab(word, type)
549char *word;
550int type;
551{
552 int v1, v2, temp;
553
554 if ((v1 = binary(word)) >= 0) {
555 if (v1 > 0 && strcmp(word, wc[v1 - 1].aword) == 0)
556 v2 = v1 - 1;
557 else if (v1 < (MAXWC - 1) && strcmp(word, wc[v1 + 1].aword) == 0)
558 v2 = v1 + 1;
559 else
560 v2 = v1;
561 if (wc[v1].acode > wc[v2].acode) {
562 temp = v1;
563 v1 = v2;
564 v2 = temp;
565 }
566 if (type <= CLASS(wc[v1].acode))
567 return (wc[v1].acode);
568 else if (type <= CLASS(wc[v2].acode))
569 return (wc[v2].acode);
570 else
571 return (-1);
572 } else
573 return (-1);
574}
575
576int binary(w)
577char *w;
578{
579 int lo, mid, hi, check;
580
581 lo = 0;
582 hi = MAXWC - 1;
583 do {
584 mid = (lo + hi) / 2;
585 check = strcmp(w, wc[mid].aword);
586 if (check == 0)
587 return (mid);
588 else if (check < 0)
589 hi = mid - 1;
590 else
591 lo = mid + 1;
592 } while (lo <= hi);
593 return (-1);
594}
Note: See TracBrowser for help on using the repository browser.