home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 243_01 / cpp.h < prev    next >
C/C++ Source or Header  |  1990-05-14  |  10KB  |  237 lines

  1. /*
  2. **    name:        cpp.h
  3. */
  4.  
  5. /*
  6.  *      I n t e r n a l   D e f i n i t i o n s    f o r   C P P
  7.  *
  8.  * In general, definitions in this file should not be changed.
  9.  */
  10.  
  11. #ifndef TRUE
  12. #define TRUE            1
  13. #define FALSE           0
  14. #endif
  15. #ifndef EOS
  16. /*
  17.  * This is predefined in Decus C
  18.  */
  19. #define EOS             '\0'            /* End of string                */
  20. #endif
  21. #define EOF_CHAR        0               /* Returned by get() on eof     */
  22. #define NULLST          ((char *) NULL) /* Pointer to nowhere (linted)  */
  23. #define DEF_NOARGS      (-1)            /* #define foo vs #define foo() */
  24.  
  25. /*
  26.  * The following may need to change if the host system doesn't use ASCII.
  27.  */
  28. #define ST_QUOTE        0x1C            /* Magic for stringizing        */
  29. #define DEF_MAGIC       0x1D            /* Magic for #defines           */
  30. #define TOK_SEP         0x1E            /* Token concatenation delim.   */
  31. #define COM_SEP         0x1F            /* Magic comment separator      */
  32. #define MAC_PARM        0x7F            /* Macro formals signal         */
  33.  
  34. /*
  35.  * Character type codes.
  36.  */
  37.  
  38. #define INV             0               /* Invalid, must be zero        */
  39. #define OP_EOE          INV             /* End of expression            */
  40. #define DIG             1               /* Digit                        */
  41. #define LET             2               /* Identifier start             */
  42. #define FIRST_BINOP     OP_ADD
  43. #define OP_ADD          3
  44. #define OP_SUB          4
  45. #define OP_MUL          5
  46. #define OP_DIV          6
  47. #define OP_MOD          7
  48. #define OP_ASL          8
  49. #define OP_ASR          9
  50. #define OP_AND          10              /* &, not &&                    */
  51. #define OP_OR           11              /* |, not ||                    */
  52. #define OP_XOR          12
  53. #define OP_EQ           13
  54. #define OP_NE           14
  55. #define OP_LT           15
  56. #define OP_LE           16
  57. #define OP_GE           17
  58. #define OP_GT           18
  59. #define OP_ANA          19              /* &&                           */
  60. #define OP_ORO          20              /* ||                           */
  61. #define OP_QUE          21              /* ?                            */
  62. #define OP_COL          22              /* :                            */
  63. #define OP_CMA          23              /* , (relevant?)                */
  64. #define LAST_BINOP      OP_CMA          /* Last binary operand          */
  65. /*
  66.  * The following are unary.
  67.  */
  68. #define FIRST_UNOP      OP_PLU          /* First Unary operand          */
  69. #define OP_PLU          24              /* + (draft ANSI standard)      */
  70. #define OP_NEG          25              /* -                            */
  71. #define OP_COM          26              /* ~                            */
  72. #define OP_NOT          27              /* !                            */
  73. #define LAST_UNOP       OP_NOT
  74. #define OP_LPA          28              /* (                            */
  75. #define OP_RPA          29              /* )                            */
  76. #define OP_END          30              /* End of expression marker     */
  77. #define OP_MAX          (OP_END + 1)    /* Number of operators          */
  78. #define OP_FAIL         (OP_END + 1)    /* For error returns            */
  79.  
  80. /*
  81.  * The following are for lexical scanning only.
  82.  */
  83.  
  84. #define QUO             65              /* Both flavors of quotation    */
  85. #define DOT             66              /* . might start a number       */
  86. #define SPA             67              /* Space and tab                */
  87. #define BSH             68              /* Just a backslash             */
  88. #define END             69              /* EOF                          */
  89.  
  90. /*
  91.  * These bits are set in ifstack[]
  92.  */
  93. #define WAS_COMPILING   1               /* TRUE if compile set at entry */
  94. #define ELSE_SEEN       2               /* TRUE when #else processed    */
  95. #define TRUE_SEEN       4               /* TRUE when #if TRUE processed */
  96.  
  97. /*
  98.  * Define bits for the basic types and their adjectives
  99.  */
  100.  
  101. #define T_CHAR            1
  102. #define T_INT             2
  103. #define T_FLOAT           4
  104. #define T_DOUBLE          8
  105. #define T_SHORT          16
  106. #define T_LONG           32
  107. #define T_SIGNED         64
  108. #define T_UNSIGNED      128
  109. #define T_PTR           256             /* Pointer                      */
  110. #define T_FPTR          512             /* Pointer to functions         */
  111.  
  112.  
  113. /*
  114.  * The DEFBUF structure stores information about #defined
  115.  * macros.  Note that the defbuf->repl information is always
  116.  * in malloc storage.
  117.  */
  118.  
  119. typedef struct defbuf {
  120.         struct defbuf   *link;          /* Next define in chain */
  121.         char            *repl;          /* -> replacement       */
  122.         int             hash;           /* Symbol table hash    */
  123.         int             nargs;          /* For define(args)     */
  124.         char            name[1];        /* #define name         */
  125. } DEFBUF;
  126.  
  127. /*
  128.  * The FILEINFO structure stores information about open files
  129.  * and macros being expanded.
  130.  */
  131.  
  132. typedef struct fileinfo {
  133.         char            *bptr;          /* Buffer pointer       */
  134.         int             line;           /* for include or macro */
  135.         FILE            *fp;            /* File if non-null     */
  136.         struct fileinfo *parent;        /* Link to includer     */
  137.         char            *filename;      /* File/macro name      */
  138.         char            *progname;      /* From #line statement */
  139.         unsigned int    unrecur;        /* For macro recursion  */
  140.         char            buffer[1];      /* current input line   */
  141. } FILEINFO;
  142.  
  143. /*
  144.  * The SIZES structure is used to store the values for #if sizeof
  145.  */
  146.  
  147. typedef struct sizes {
  148.     short       bits;                   /* If this bit is set,          */
  149.     short       size;                   /* this is the datum size value */
  150.     short       psize;                  /* this is the pointer size     */
  151. } SIZES;
  152. /*
  153.  * nomacarg is a built-in #define on Decus C.
  154.  */
  155.  
  156. #ifdef  nomacarg
  157. #define cput            output          /* cput concatenates tokens     */
  158. #else
  159. #if COMMENT_INVISIBLE || OK_CONCAT == CON_EXPAND
  160. #define cput(c)         { if ((c) != TOK_SEP && (c) != COM_SEP) \
  161.                             putchar((c == ST_QUOTE) ? '"' : (c)); }
  162. #else
  163. #define cput(c)         { if (c != TOK_SEP) \
  164.                             putchar((c == ST_QUOTE) ? '"' : (c)); }
  165. #endif
  166. #endif
  167.  
  168. #ifndef nomacarg
  169. #define streq(s1, s2)   (strcmp(s1, s2) == 0)
  170. #endif
  171.  
  172. /*
  173.  * Error codes.  VMS uses system definitions.
  174.  * Decus C codes are defined in stdio.h.
  175.  * Others are cooked to order.
  176.  */
  177.  
  178. #if HOST == SYS_VMS
  179. #include                <ssdef.h>
  180. #include                <stsdef.h>
  181. #define IO_SUCCESS      (SS$_NORMAL | STS$M_INHIB_MSG)
  182. #define IO_ERROR        SS$_ABORT
  183. #endif
  184. /*
  185.  * Note: IO_SUCCESS and IO_ERROR are defined in the Decus C stdio.h file
  186.  */
  187. #ifndef IO_SUCCESS
  188. #define IO_SUCCESS      0
  189. #endif
  190. #ifndef IO_ERROR
  191. #define IO_ERROR        1
  192. #endif
  193.  
  194. /*
  195.  * Externs
  196.  */
  197.  
  198. extern int      line;                   /* Current line number          */
  199. extern int      wrongline;              /* Force #line to cc pass 1     */
  200. extern char     type[];                 /* Character classifier         */
  201. extern char     token[IDMAX + 1];       /* Current input token          */
  202. extern int      instring;               /* TRUE if scanning string      */
  203. extern int      inmacro;                /* TRUE if scanning #define     */
  204. extern int      errors;                 /* Error counter                */
  205. extern int      recursion;              /* Macro depth counter          */
  206. extern char     ifstack[BLK_NEST];      /* #if information              */
  207. #define compiling ifstack[0]
  208. extern char     *ifptr;                 /* -> current ifstack item      */
  209. extern char     *incdir[NINCLUDE];      /* -i directories               */
  210. extern char     **incend;               /* -> active end of incdir      */
  211. extern int      cflag;                  /* -C option (keep comments)    */
  212. extern int      eflag;                  /* -E option (ignore errors)    */
  213. extern int      nflag;                  /* -N option (no pre-defines)   */
  214. extern int      pflag;                  /* -P option (no #line output)  */
  215. extern int      tflag;                  /* -T option (enable trigraphs) */
  216. extern int      rec_recover;            /* unwind recursive macros      */
  217. extern char     *preset[];              /* Standard predefined symbols  */
  218. extern char     *magic[];               /* Magic predefined symbols     */
  219. extern FILEINFO *infile;                /* Current input file           */
  220. extern char     work[NWORK + 1];        /* #define scratch              */
  221. extern char     *workp;                 /* Free space in work           */
  222. #if     DEBUG
  223. extern int      debug;                  /* Debug level                  */
  224. #endif
  225. extern int      keepcomments;           /* Don't remove comments if set */
  226. extern SIZES    size_table[];           /* For #if sizeof sizes         */
  227. extern char     *getmem();              /* Get memory or die.           */
  228. extern DEFBUF   *lookid();              /* Look for a #define'd thing   */
  229. extern DEFBUF   *defendel();            /* Symbol table enter/delete    */
  230. extern char     *savestring();          /* Stuff string in malloc mem.  */
  231. extern char     *strcpy();
  232. extern char     *strcat();
  233. extern char     *strrchr();
  234. extern char     *strchr();
  235. extern long     time();
  236.  
  237.