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