/*
	kwords.c	-	Bill Nickerson, 1988

	Implement routines for initializing symbol table with keywords.

	Export: init
	Static: none
*/

#include <stdio.h>
#include "lex.h"
#include "symbol.h"
#include "kwords.h"

/*
	Imported variables.
*/
extern Entry *symtab[];

/* Reserved words of language. Delimited by NULL pointer. */
struct kw
{
	char *reserved;
	int token;
}
reserved_words[] =
{
	"acos",		ACOSt,
	"cosh",		COSHt,
	"cos",		COSt,
	"asin",		ASINt,
	"sinh",		SINHt,
	"sin",		SINt,
	"atan",		ATANt,
	"tanh",		TANHt,
	"tan",		TANt,
	"exp",		EXPt,
	"ln",		LNt,
	"log",		LOGt,
	"sqrt",		SQRTt,
	NULL,		0
};

/*
	Initialize symbol table with reserved words.
	Returns 1 if successful, 0 if failure.
*/
int initkw()
{
	struct kw *tmp = reserved_words;
	int i;

	for (i = 0; i < BUCKETS; i++)
		symtab[i] = NULL;
	for (; tmp->reserved != NULL; tmp++)
		if (insert(tmp->reserved, tmp->token) == NULL)
			return(0);
	return(1);
}
