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