home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / program / kr2ansi / kr2ansi.h < prev    next >
Text File  |  1993-10-23  |  5KB  |  219 lines

  1. /*  ==========================
  2.  *       K R 2 A N S I . H
  3.  *
  4.  *  Date:   9/32/91
  5.  *  Author: Harry Karayiannis
  6.  *  =========================
  7.  */
  8.  
  9.  
  10.  
  11. /* -------------------------------------------- */
  12.  
  13. /*
  14.  * The following constants (hopefully) improve the readability
  15.  * of large code which consists of more than one files.
  16.  */
  17. #define STD_CLIB  extern  /* for identifying funcs of the standard C-library */
  18. #define GLOBAL    extern  /* for identifying symbols declared in the same file */
  19.  
  20.  
  21.  
  22.  
  23. /* -------------------------------------------- */
  24.  
  25. /*
  26.  * Here are some values for identifying
  27.  * up to 8 command line options.  They
  28.  * are meant to be ORed in a bit map.
  29.  */
  30. #define NONE      0x00
  31. #define SHOW_PARA 0x01    /* show parameters */
  32. #define RD_TYPES  0x02    /* read user-defined types from a file */
  33. #define UNUSED4   0x04    /* unused slot */
  34. #define UNUSED5   0x08    /* unused slot */
  35. #define UNUSED6   0x10    /* unused slot */
  36. #define UNUSED7   0x20    /* unused slot */
  37. #define UNUSED8   0x40    /* unused slot */
  38.  
  39.  
  40.  
  41. /* -------------------------------------------- */
  42.  
  43. #define MAXNAME   80      /* max length for a filename */
  44. #define MAXLINE   256     /* max length for a line */
  45. #define MAXWORD   50      /* max length for a data_type */
  46.  
  47.  
  48.  
  49.  
  50. /* -------------------------------------------- */
  51.  
  52. /*
  53.  * the following string constants must be
  54.  * _at_most_ (MAXWORD-1) characters long.
  55.  */
  56. #define W_TOO_LONG            "* WORD'S_TOO_LONG *"
  57. #define UNDEFINED_DATA_TYPE   "U_N_D_E_F_I_N_E_D"
  58.  
  59.  
  60.  
  61.  
  62.  
  63. /* -------------------------------------------- */
  64.  
  65. typedef int BOOLEAN;      /* possible values: TRUE, FALSE */
  66. #undef FALSE
  67. #undef TRUE
  68. #define FALSE     0
  69. #define TRUE      !FALSE
  70.  
  71.  
  72.  
  73.  
  74.  
  75. /* -------------------------------------------- */
  76.  
  77. /*
  78.  * constants for standard C data-types
  79.  * (actually they are used for accessing
  80.  *  standard data-types in the array: data_type[]
  81.  *  (see in file KR2ANSI.C))
  82.  */
  83. #define DT_STD1   0
  84. #define DT_STD2   1
  85. #define DT_STD3   2
  86. #define DT_STD4   3
  87. #define DT_STD5   4
  88. #define DT_STD6   5
  89. #define DT_STD7   6
  90. #define DT_STD8   7
  91. #define DT_STD9   8
  92. #define DT_STD10  9
  93.  
  94. #define LAST_DT_STD 9
  95.  
  96.  
  97.  
  98.  
  99. /* -------------------------------------------- */
  100.  
  101. /*
  102.  * constants for DT_USR_N user-defined data types
  103.  */
  104.  
  105. #define N_DT_USR  20    /* maximum number of user-defined data types */
  106.  
  107. #define DT_USR1   LAST_DT_STD+1
  108. #define DT_USR2   LAST_DT_STD+2
  109. #define DT_USR3   LAST_DT_STD+3
  110. #define DT_USR4   LAST_DT_STD+4
  111. #define DT_USR5   LAST_DT_STD+5
  112. #define DT_USR6   LAST_DT_STD+6
  113. #define DT_USR7   LAST_DT_STD+7
  114. #define DT_USR8   LAST_DT_STD+8
  115. #define DT_USR9   LAST_DT_STD+9
  116. #define DT_USR10  LAST_DT_STD+10
  117. #define DT_USR11  LAST_DT_STD+11
  118. #define DT_USR12  LAST_DT_STD+12
  119. #define DT_USR13  LAST_DT_STD+13
  120. #define DT_USR14  LAST_DT_STD+14
  121. #define DT_USR15  LAST_DT_STD+15
  122. #define DT_USR16  LAST_DT_STD+16
  123. #define DT_USR17  LAST_DT_STD+17
  124. #define DT_USR18  LAST_DT_STD+18
  125. #define DT_USR19  LAST_DT_STD+19
  126. #define DT_USR20  LAST_DT_STD+20
  127.  
  128.  
  129.  
  130.  
  131.  
  132. /* -------------------------------------------- */
  133.  
  134. /*
  135.  * list of valid data-types accepted by the program
  136.  * (note: there's room for N_DT_USR user-defined types.
  137.  *        if you alter N_DT_USR, the change should also
  138.  *        show on the number of lines in this table)
  139.  */
  140. #define DATA_TYPES\
  141.     "void",\
  142.     "int",\
  143.     "short",\
  144.     "unsigned",\
  145.     "long",\
  146.     "register",\
  147.     "char",\
  148.     "float",\
  149.     "double",\
  150.     "FILE",\
  151.     "   user_defined   ",\
  152.     "   user_defined   ",\
  153.     "   user_defined   ",\
  154.     "   user_defined   ",\
  155.     "   user_defined   ",\
  156.     "   user_defined   ",\
  157.     "   user_defined   ",\
  158.     "   user_defined   ",\
  159.     "   user_defined   ",\
  160.     "   user_defined   ",\
  161.     "   user_defined   ",\
  162.     "   user_defined   ",\
  163.     "   user_defined   ",\
  164.     "   user_defined   ",\
  165.     "   user_defined   ",\
  166.     "   user_defined   ",\
  167.     "   user_defined   ",\
  168.     "   user_defined   ",\
  169.     "   user_defined   ",\
  170.     "   user_defined   "
  171.  
  172. /*
  173.  * The following constant _must_ be equal to the length of
  174.  * the longest data-type defined in DATA_TYPES (see above)
  175.  * PLUS one (for the '\0' at the end of the string)
  176.  * Here this value is: strlen("   user_defined   ")+1 = 19
  177.  */
  178. #define DT_MAXWORD    19
  179.  
  180.  
  181.  
  182.  
  183.  
  184. /* -------------------------------------------- */
  185.  
  186. /*
  187.  * This macro returns:
  188.  *    TRUE if c is a white(BLANK) character,
  189.  *    FALSE otherwise.
  190.  */
  191. #define IS_BLANK(c)\
  192.    ( (c)==' ' || (c)=='\t' || (c)=='\n' )
  193.  
  194.  
  195.  
  196.  
  197. /* -------------------------------------------- */
  198.  
  199. /*
  200.  * The following macro handles fatal errors.
  201.  * It "demands" that a condition is TRUE...if not,
  202.  * it prints an error-message and exits the program
  203.  * (via the function fatal(), declared in the file: ERROR.C)
  204.  * NOTE:
  205.  *  If you don't want the depedancy on 'fatal()' (which
  206.  *  pritns the name of the running program in front of
  207.  *  the error message) you can rewrite it as following:
  208.  *
  209.  * #define demand(cond,mesg)\
  210.  * if ( !(cond) ) \
  211.  * {
  212.  *   puts(mesg);\
  213.  *   exit(1);\
  214.  * }
  215.  */
  216. #define demand(cond,mesg)\
  217.     if ( !(cond) )\
  218.       fatal(mesg)
  219.