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