More semantic typing - a step towards eliminating packing.

This commit is contained in:
Eric S. Raymond 2017-06-19 14:20:45 -04:00
parent f4ac82b9f8
commit 79f5701e07
3 changed files with 7 additions and 12 deletions

View file

@ -5,16 +5,11 @@
#include "newdb.h" #include "newdb.h"
/* Limit visibility of ugly globals. Eventually these should go away. */ /* Limit visibility of ugly globals. Eventually these should go away. */
extern long WD1, WD1X, WD2, WD2X; extern token_t WD1, WD1X, WD2, WD2X;
/* static int fill(token_t, token_t);
* Action handlers. Eventually we'll do lookup through a method table
* that calls these.
*/
static int fill(token_t verb, token_t); static int attack(FILE *input, token_t verb, token_t obj)
static int attack(FILE *input, long verb, token_t obj)
/* Attack. Assume target if unambiguous. "Throw" also links here. /* Attack. Assume target if unambiguous. "Throw" also links here.
* Attackable objects fall into two categories: enemies (snake, * Attackable objects fall into two categories: enemies (snake,
* dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2 * dwarf, etc.) and others (bird, clam, machine). Ambiguous if 2
@ -110,7 +105,7 @@ static int attack(FILE *input, long verb, token_t obj)
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
static int bigwords(long foo) static int bigwords(token_t foo)
/* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order. /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
* Look up WD1 in section 3 of vocab to determine which word we've got. Last * Look up WD1 in section 3 of vocab to determine which word we've got. Last
* word zips the eggs back to the giant room (unless already there). */ * word zips the eggs back to the giant room (unless already there). */
@ -1000,7 +995,7 @@ static int wave(token_t verb, token_t obj)
} }
} }
int action(FILE *input, enum speechpart part, long verb, token_t obj) int action(FILE *input, enum speechpart part, token_t verb, token_t obj)
/* Analyse a verb. Remember what it was, go back for object if second word /* Analyse a verb. Remember what it was, go back for object if second word
* unless verb is "say", which snarfs arbitrary second word. * unless verb is "say", which snarfs arbitrary second word.
*/ */

View file

@ -178,7 +178,7 @@ extern long AMBER, ATTACK, AXE, BACK, BATTERY, BEAR,
enum speechpart {unknown, intransitive, transitive}; enum speechpart {unknown, intransitive, transitive};
void initialise(void); void initialise(void);
int action(FILE *input, enum speechpart part, long verb, token_t obj); int action(FILE *input, enum speechpart part, token_t verb, token_t obj);
/* Phase codes for action returns. /* Phase codes for action returns.
* These were at one time FORTRAN line numbers. * These were at one time FORTRAN line numbers.

2
main.c
View file

@ -41,7 +41,7 @@ long AMBER, AXE, BACK, BATTERY, BEAR, BIRD, BLOOD,
RUBY, RUG, SAPPH, SAY, SIGN, SNAKE, RUBY, RUG, SAPPH, SAY, SIGN, SNAKE,
STEPS, STREAM, THROW, TRIDENT, TROLL, TROLL2, STEPS, STREAM, THROW, TRIDENT, TROLL, TROLL2,
URN, VASE, VEND, VOLCANO, WATER; URN, VASE, VEND, VOLCANO, WATER;
long WD1, WD1X, WD2, WD2X; token_t WD1, WD1X, WD2, WD2X;
FILE *logfp = NULL, *rfp = NULL; FILE *logfp = NULL, *rfp = NULL;
bool oldstyle = false; bool oldstyle = false;