/************************************************************************
 *                     basic.h                                          *
 ************************************************************************
 *   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.            *
 *                                                                      *
 ************************************************************************/
#define   YES         1
#define   NO          0
#define   TRUE      YES
#define   FALSE      NO
#define  toupper(c)     (((c) >= 'a' && (c) <= 'z' ) ? ((c) -'a' + 'A') : (c))
#define  MAX(a,b)    (a) > (b) ? (a) : (b)
#define  MIN(a,b)    (a) < (b) ? (a) : (b)
#define  HTSIZE  2411   /* Must be a prime */
#define  ISIZE            2   /* Size of indentation */
#define  MAXINDENT      255
#define  MAXDIM           2   /* Max. 2 dimensions per array */
#define  MAXARG          10   /* Max.10 args. per function */
#define  MAXFILENUM     255
#define  MAXIDLEN        11   /*actual length = 10 + 1 for \0*/
#define  MAXFNLEN        66
#define  MAXWORDLEN	255
#define  NUMBER     256
#define  STRING     257
#define  NUMVAR     258
#define  STRVAR     259
#define  NUMARR     260
#define  STRARR     261
#define  LABEL      262
#define  STATKEY    263
#define  OTHERKEY   264
#define  BUILTIN    265   /* Built-in function */
#define  UDF        266   /* User defined function */
#define  PROC       267   /* Sub routine/procedure */
#define  UNOP       268
#define  BINOP      269
#define  EQ         270
#define  NE         271
#define  GT         272
#define  GE         273
#define  LT         274
#define  LE         275
#define  FORLOOP    501
#define  WHILELOOP  502
#define  TOPDOLOOP  503
#define  DOLOOP     504
#define  BLOCKIF    505
struct  symbol { /* symbol table entry */
                        char *name;
		        unsigned int type;  /*Numeric var, string var ,label, keyword etc. */
                        union uval{ int    ival; /*Stores routine number for statement key,builtin etc.*/
                                    double dval; /* Not used at present */
                                    char   *str; /* Not used at present */
			} u;
} ;
struct ndx { /* FOR Loop Index variable - Linked List entry */
        char name[MAXIDLEN];
	struct ndx *next;
};
typedef struct Function{
      char  *name;    /* Name of Function/ Procedure */
      int   ArgCount; /* No. of arguments of the Function */
      char  *Arg[MAXARG]; /* Argument name */
      unsigned int ArgType[MAXARG]; /* Argument Type */
      struct Function *next;    /* Link to the next Function in the list */
}   FUNCTION;
typedef struct Array{
     char  *name;  /* Name of Array */
     int   DimCount; /* No. of Dimensions of the Array */
     struct Array *next;  /* Link to the next Array in the list */
}  ARRAY;
#include <stdio.h>
typedef char *String;
/* Prototypes of functions */
/**   bascy.c    **/
extern int      main(int, char*[]);
extern FILE    *efopen(char *, char *);
extern int      lex(void);
extern int      xlatline(void);
extern int      statement(void);
extern int      getnumber(void);
extern void     word2upper(char *);
extern void     cleanup(void);
extern int      follow(int, int, int);
extern char    *emalloc(unsigned);
extern void     combine(char *, char *, char *);
extern void     append(FILE *, FILE *);
extern void     ungetw(char *, FILE *);
extern int      StatEnd(int);
extern void     EmitSource(void);

/**  init.c     **/
extern void     init(void);

/**  error.c    **/
extern void     error(int);
extern void     warning(char *);

/**   symbol.c  **/
extern int      transformid(char *);
extern int      generatenewindex(int, int);
extern int      hash(char *);
extern int      instal(char *, unsigned int, int);
extern int      lookup(char *);

/**   code.c    **/
extern int      remstat(void);
extern int      ifprc(void);
extern int      swaprc(void);
extern int      letprc(void);
extern int      haltprc(void);
extern int      cls(void);
extern int      beep(void);
extern int      gotoprc(void);
extern int      gosubprc(void);
extern int      returnprc(void);
extern void     labelprc(void);
extern int      onprc(void);
extern int      asgn1(void);
extern int      forprc(void);
extern int      nextprc(void);
extern int      validndx(char *);
extern int      whileprc(void);
extern int      wendprc(void);
extern void     lblconv(char *);
extern void     strvarconv(char *);
extern void     vardec(char *);
extern int      randomprc(void);
extern int      pushloop(int);
extern int      poploop(void);
extern int      doprc(void);
extern int      whilooprc(int);
extern int      untilooprc(int);
extern int      looprc(void);
extern int      exitprc(void);
extern int      envirstat(void);
extern int      sleeprc(void);
extern int      defstat(void);
extern FUNCTION *FunSearch(char *);
extern int      IsInteger(double);
extern int      getsubscript(void);
extern int      dimstat(void);
extern ARRAY    *ArrSearch(char *);
extern int      arr2var(void);
extern int      TranSubVal(char *);
extern int      elseprc(void);
extern int      elseifprc(void);
extern int      endifprc(void);
extern int      endprc(void);

/**   code1.c   **/
extern int      inputprc(void);
extern int      readprc(void);
extern int      dataprc(void);
extern int      restoreprc(void);
extern int      skipwhite(void);
extern int      getstring(char *);
extern int      datadec(void);
extern int      printprc(void);
extern int      writeprc(void);
extern int      lineprc(void);
extern int      lineinprc(void);

/**    lib.c    **/
extern int      libcode(char *);
extern int      copycode(char *);
extern int      commandprc(void);
extern void     num2str(int, char *);
extern void     pushprc(void);
extern void     popprc(void);
extern void     InitFilePrc(void);
extern void     AddHeaders(void);
extern void     SetIndent(void);
extern void     DeIndent(void);

/**    files.c   **/
extern int      killprc(void);
extern int      nameprc(void);
extern int      shellprc(void);
extern int      closeprc(void);
extern int      getFileNum(void);
extern int      openprc(void);
extern void     IncludeFilInit(void);
extern int      RmChDirprc(char *);
extern int      chainprc(void);

/**    expr.c   **/
extern double   str2num(char *);
extern int      expr(void);
extern int      ValidExpr(void);
extern int      intopost(void);
extern int      precedence(char *);
extern int      push(String, unsigned);
extern String   pop(unsigned *);
extern int      post2in(void);
extern int      VTest1(unsigned, unsigned);
extern void     ParenCover(String);
extern int      oprprc(String);
extern void     freemem(void);
extern int      un2binop(void);
extern int      moveup(int);
extern int      makearg(void);
extern int      bltin(char *);
extern int      ebltin(char *);
extern int      udf(char *);
extern int      ArrHandler(char *);
