/*  ==========================
 *       K R 2 A N S I . H
 *
 *  Date:   9/32/91
 *  Author: Harry Karayiannis
 *  =========================
 */



/* -------------------------------------------- */

/*
 * The following constants (hopefully) improve the readability
 * of large code which consists of more than one files.
 */
#define STD_CLIB  extern  /* for identifying funcs of the standard C-library */
#define GLOBAL    extern  /* for identifying symbols declared in the same file */




/* -------------------------------------------- */

/*
 * Here are some values for identifying
 * up to 8 command line options.  They
 * are meant to be ORed in a bit map.
 */
#define NONE      0x00
#define SHOW_PARA 0x01    /* show parameters */
#define RD_TYPES  0x02    /* read user-defined types from a file */
#define UNUSED4   0x04    /* unused slot */
#define UNUSED5   0x08    /* unused slot */
#define UNUSED6   0x10    /* unused slot */
#define UNUSED7   0x20    /* unused slot */
#define UNUSED8   0x40    /* unused slot */



/* -------------------------------------------- */

#define MAXNAME   80      /* max length for a filename */
#define MAXLINE   256     /* max length for a line */
#define MAXWORD   50      /* max length for a data_type */




/* -------------------------------------------- */

/*
 * the following string constants must be
 * _at_most_ (MAXWORD-1) characters long.
 */
#define W_TOO_LONG            "* WORD'S_TOO_LONG *"
#define UNDEFINED_DATA_TYPE   "U_N_D_E_F_I_N_E_D"





/* -------------------------------------------- */

typedef int BOOLEAN;      /* possible values: TRUE, FALSE */
#undef FALSE
#undef TRUE
#define FALSE     0
#define TRUE      !FALSE





/* -------------------------------------------- */

/*
 * constants for standard C data-types
 * (actually they are used for accessing
 *  standard data-types in the array: data_type[]
 *  (see in file KR2ANSI.C))
 */
#define DT_STD1   0
#define DT_STD2   1
#define DT_STD3   2
#define DT_STD4   3
#define DT_STD5   4
#define DT_STD6   5
#define DT_STD7   6
#define DT_STD8   7
#define DT_STD9   8
#define DT_STD10  9

#define LAST_DT_STD 9




/* -------------------------------------------- */

/*
 * constants for DT_USR_N user-defined data types
 */

#define N_DT_USR  20    /* maximum number of user-defined data types */

#define DT_USR1   LAST_DT_STD+1
#define DT_USR2   LAST_DT_STD+2
#define DT_USR3   LAST_DT_STD+3
#define DT_USR4   LAST_DT_STD+4
#define DT_USR5   LAST_DT_STD+5
#define DT_USR6   LAST_DT_STD+6
#define DT_USR7   LAST_DT_STD+7
#define DT_USR8   LAST_DT_STD+8
#define DT_USR9   LAST_DT_STD+9
#define DT_USR10  LAST_DT_STD+10
#define DT_USR11  LAST_DT_STD+11
#define DT_USR12  LAST_DT_STD+12
#define DT_USR13  LAST_DT_STD+13
#define DT_USR14  LAST_DT_STD+14
#define DT_USR15  LAST_DT_STD+15
#define DT_USR16  LAST_DT_STD+16
#define DT_USR17  LAST_DT_STD+17
#define DT_USR18  LAST_DT_STD+18
#define DT_USR19  LAST_DT_STD+19
#define DT_USR20  LAST_DT_STD+20





/* -------------------------------------------- */

/*
 * list of valid data-types accepted by the program
 * (note: there's room for N_DT_USR user-defined types.
 *        if you alter N_DT_USR, the change should also
 *        show on the number of lines in this table)
 */
#define DATA_TYPES\
    "void",\
    "int",\
    "short",\
    "unsigned",\
    "long",\
    "register",\
    "char",\
    "float",\
    "double",\
    "FILE",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   ",\
    "   user_defined   "

/*
 * The following constant _must_ be equal to the length of
 * the longest data-type defined in DATA_TYPES (see above)
 * PLUS one (for the '\0' at the end of the string)
 * Here this value is: strlen("   user_defined   ")+1 = 19
 */
#define DT_MAXWORD    19





/* -------------------------------------------- */

/*
 * This macro returns:
 *    TRUE if c is a white(BLANK) character,
 *    FALSE otherwise.
 */
#define IS_BLANK(c)\
   ( (c)==' ' || (c)=='\t' || (c)=='\n' )




/* -------------------------------------------- */

/*
 * The following macro handles fatal errors.
 * It "demands" that a condition is TRUE...if not,
 * it prints an error-message and exits the program
 * (via the function fatal(), declared in the file: ERROR.C)
 * NOTE:
 *  If you don't want the depedancy on 'fatal()' (which
 *  pritns the name of the running program in front of
 *  the error message) you can rewrite it as following:
 *
 * #define demand(cond,mesg)\
 * if ( !(cond) ) \
 * {
 *   puts(mesg);\
 *   exit(1);\
 * }
 */
#define demand(cond,mesg)\
    if ( !(cond) )\
      fatal(mesg)
