home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 342b.lha / cpp / Cpp.h < prev    next >
C/C++ Source or Header  |  1990-01-26  |  8KB  |  259 lines

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