/************************************************************************
 *               init.c                                                 *
 ************************************************************************
 * Initialize the symbol table with keywords and built-ins etc.         *
 ************************************************************************
 *   Part of the project : BASCY  Version 1.0                           *
 *   Copyright (C) 2001 - S. Narasimhan, No.11, Sathya Nagar,           *
 *                        MADURAI-625018. INDIA                         *
 *                       email: narasimhan_s_@hotmail.com               *
 ************************************************************************
 * This program is free software; you can redistribute it and/or modify *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation; either version 2 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * This program is distributed in the hope that it will be useful,      *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with this program; if not, write to the Free Software          *
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.            *
 *                                                                      *
 ************************************************************************/
#include "basic.h"
extern struct symbol symtab[];
void init(void)
{
	int i;
	for ( i = 0; i < HTSIZE; i++)
                symtab[i].name = 0 ;
/* Instal the Statement Key words */
        instal("REM", STATKEY, 1);
        instal("LET", STATKEY, 2);
        instal("IF", STATKEY, 3);
        instal("FOR", STATKEY, 4);
        instal("DIM", STATKEY, 5);
        instal("NEXT", STATKEY, 6);
        instal("GOTO", STATKEY, 7);
        instal("GOSUB", STATKEY, 8);
        instal("ON", STATKEY, 9);
        instal("CLS", STATKEY, 10);
        instal("READ", STATKEY, 11);
        instal("DATA", STATKEY, 12);
        instal("PRINT", STATKEY, 13);
        instal("INPUT", STATKEY, 14);
        instal("END", STATKEY, 15);
        instal("RETURN", STATKEY, 16);
        instal("RANDOMIZE", STATKEY, 17);
        instal("DEF", STATKEY, 18);
        instal("RESTORE", STATKEY, 19);
        instal("BEEP", STATKEY, 20);
        instal("STOP", STATKEY, 21);
        instal("SWAP", STATKEY, 22);
        instal("KILL", STATKEY, 23);
        instal("SHELL", STATKEY, 24);
        instal("NAME", STATKEY, 25);
        instal("WHILE", STATKEY, 26);
        instal("WEND", STATKEY, 27);
        instal("DO", STATKEY, 28);
        instal("LOOP", STATKEY, 29);
        instal("EXIT", STATKEY, 30);
        instal("WRITE", STATKEY, 31);
        instal("LINE", STATKEY, 32);
        instal("ENVIRON", STATKEY, 33);
        instal("SLEEP", STATKEY, 34);
        instal("CLOSE", STATKEY, 35);
        instal("OPEN", STATKEY, 36);
        instal("ELSE", STATKEY, 37);
        instal("ELSEIF", STATKEY, 38);
        instal("ENDIF", STATKEY, 39);
        instal("CHDIR", STATKEY, 40);
        instal("RMDIR", STATKEY, 41);
        instal("CHAIN", STATKEY, 42);

/* Instal Other Keywords */
        instal("USING", OTHERKEY, 0);
        instal("THEN", OTHERKEY, 0);
        instal("TO", OTHERKEY, 0);
        instal("STEP", OTHERKEY, 0);
        instal("AS", OTHERKEY, 0);
        instal("UNTIL", OTHERKEY, 0);

/*Instal the BUILTIN FUNCTIONS */
        instal("ABS", BUILTIN, -1);
        instal("ATN", BUILTIN, -2);
        instal("COS", BUILTIN, -3);
        instal("EXP", BUILTIN, -4);
        instal("INT", BUILTIN, -5);
        instal("LOG", BUILTIN, -6);
        instal("LOG10", BUILTIN, -7);
        instal("RND", BUILTIN, -8);
        instal("SGN", BUILTIN, -9);
        instal("SIN", BUILTIN, -10);
        instal("SQR", BUILTIN, -11);
        instal("TAN", BUILTIN, -12);
        instal("ASC", BUILTIN, -13);
        instal("CHR$", BUILTIN, -14);
        instal("LEFT$", BUILTIN, -15);
        instal("MID$", BUILTIN, -16);
        instal("RIGHT$", BUILTIN, -17);
        instal("SPACE$", BUILTIN, -18);
        instal("STR$", BUILTIN, -19);
        instal("LEN", BUILTIN, -20);
        instal("VAL", BUILTIN, -21);
        instal("getstr", BUILTIN, -22);
        instal("getnum", BUILTIN, -23);
        instal("idiv", BUILTIN, -24);
        instal("power",BUILTIN, -25);
        instal("CINT",BUILTIN, -26);
        instal("FIX",BUILTIN, -27);
        instal("SIND",BUILTIN, -28);
        instal("COSD",BUILTIN, -29);
        instal("str2num",BUILTIN, -30);
        instal("LTRIM$",BUILTIN, -31);
        instal("RTRIM$",BUILTIN, -32);
        instal("LCASE$",BUILTIN, -33);
        instal("UCASE$",BUILTIN, -34);
        instal("TRIM$",BUILTIN, -35);
        instal("TAND",BUILTIN, -36);
        instal("getline",BUILTIN, -37);
        instal("HEX$", BUILTIN, -38);
        instal("OCT$", BUILTIN, -39);
        instal("ENVIRON$", BUILTIN, -40);
        instal("STRING$", BUILTIN, -41);
        instal("INSTR", BUILTIN, -42);
        instal("DOW", BUILTIN, -43);
        instal("DATE$", BUILTIN, -44);
        instal("TIME$", BUILTIN, -45);
        instal("TIMER", BUILTIN, -46);
        instal("EOF", BUILTIN, -47);
        instal("LOF", BUILTIN, -48);
        instal("FREEFILE", BUILTIN, -49);

/* Instal Logical Operators & MOD operator*/
        instal("OR", BINOP, 0);
        instal("AND", BINOP, 0);
        instal("NOT", UNOP, 0);
        instal("MOD", BINOP, 0);

/* Instal pre-defined Variables */
        instal("ERR", NUMVAR, 1);
        instal("COMMAND$", STRVAR, 0);
}
