cpp.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /******************************************************************************
  2. * FREXXWARE
  3. * ----------------------------------------------------------------------------
  4. *
  5. * Project: Frexx C Preprocessor
  6. * $Source: /home/user/start/cpp/RCS/cpp.h,v $
  7. * $Revision: 1.3 $
  8. * $Date: 1993/12/06 13:51:20 $
  9. * $Author: start $
  10. * $State: Exp $
  11. * $Locker: start $
  12. *
  13. * ----------------------------------------------------------------------------
  14. * $Log: cpp.h,v $
  15. * Revision 1.3 1993/12/06 13:51:20 start
  16. * A lot of new stuff (too much to mention)
  17. *
  18. * Revision 1.2 1993/11/11 07:16:39 start
  19. * New stuff
  20. *
  21. * Revision 1.2 1993/11/11 07:16:39 start
  22. * New stuff
  23. *
  24. * Revision 1.1 1993/11/03 09:15:59 start
  25. * Initial revision
  26. *
  27. *
  28. *****************************************************************************/
  29. /*
  30. * 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
  31. *
  32. * In general, definitions in this file should not be changed.
  33. */
  34. #include <stdlib.h>
  35. #include <string.h>
  36. #ifndef toupper
  37. #define toupper(c) ((c) + ('A' - 'a'))
  38. #endif /* no toupper */
  39. #ifndef tolower
  40. #define tolower(c) ((c) + ('a' - 'A'))
  41. #endif /* no tolower */
  42. #ifndef TRUE
  43. #define TRUE 1
  44. #define FALSE 0
  45. #endif
  46. #ifndef EOS
  47. /*
  48. * This is predefined in Decus C
  49. */
  50. #define EOS '\0' /* End of string */
  51. #endif
  52. #define EOF_CHAR 0 /* Returned by get() on eof */
  53. #define NULLST ((char *) NULL) /* Pointer to nowhere (linted) */
  54. #define DEF_NOARGS (-1) /* #define foo vs #define foo() */
  55. /*
  56. * The following may need to change if the host system doesn't use ASCII.
  57. */
  58. #define QUOTE_PARM 0x1C /* Magic quoting operator */
  59. #define DEF_MAGIC 0x1D /* Magic for #defines */
  60. #define TOK_SEP 0x1E /* Token concatenation delim. */
  61. #define COM_SEP 0x1F /* Magic comment separator */
  62. /*
  63. * Note -- in Ascii, the following will map macro formals onto DEL + the
  64. * C1 control character region (decimal 128 .. (128 + PAR_MAC)) which will
  65. * be ok as long as PAR_MAC is less than 33). Note that the last PAR_MAC
  66. * value is reserved for string substitution.
  67. */
  68. #define MAC_PARM 0x7F /* Macro formals start here */
  69. #ifndef OS9
  70. #if (PAR_MAC >= 33)
  71. #error "assertion fails -- PAR_MAC isn't less than 33"
  72. #endif
  73. #endif
  74. #define LASTPARM (PAR_MAC - 1)
  75. /*
  76. * Character type codes.
  77. */
  78. #define INV 0 /* Invalid, must be zero */
  79. #define OP_EOE INV /* End of expression */
  80. #define DIG 1 /* Digit */
  81. #define LET 2 /* Identifier start */
  82. #define FIRST_BINOP OP_ADD
  83. #define OP_ADD 3
  84. #define OP_SUB 4
  85. #define OP_MUL 5
  86. #define OP_DIV 6
  87. #define OP_MOD 7
  88. #define OP_ASL 8
  89. #define OP_ASR 9
  90. #define OP_AND 10 /* &, not && */
  91. #define OP_OR 11 /* |, not || */
  92. #define OP_XOR 12
  93. #define OP_EQ 13
  94. #define OP_NE 14
  95. #define OP_LT 15
  96. #define OP_LE 16
  97. #define OP_GE 17
  98. #define OP_GT 18
  99. #define OP_ANA 19 /* && */
  100. #define OP_ORO 20 /* || */
  101. #define OP_QUE 21 /* ? */
  102. #define OP_COL 22 /* : */
  103. #define OP_CMA 23 /* , (relevant?) */
  104. #define LAST_BINOP OP_CMA /* Last binary operand */
  105. /*
  106. * The following are unary.
  107. */
  108. #define FIRST_UNOP OP_PLU /* First Unary operand */
  109. #define OP_PLU 24 /* + (draft ANSI standard) */
  110. #define OP_NEG 25 /* - */
  111. #define OP_COM 26 /* ~ */
  112. #define OP_NOT 27 /* ! */
  113. #define LAST_UNOP OP_NOT
  114. #define OP_LPA 28 /* ( */
  115. #define OP_RPA 29 /* ) */
  116. #define OP_END 30 /* End of expression marker */
  117. #define OP_MAX (OP_END + 1) /* Number of operators */
  118. #define OP_FAIL (OP_END + 1) /* For error returns */
  119. /*
  120. * The following are for lexical scanning only.
  121. */
  122. #define QUO 65 /* Both flavors of quotation */
  123. #define DOT 66 /* . might start a number */
  124. #define SPA 67 /* Space and tab */
  125. #define BSH 68 /* Just a backslash */
  126. #define END 69 /* EOF */
  127. /*
  128. * These bits are set in ifstack[]
  129. */
  130. #define WAS_COMPILING 1 /* TRUE if compile set at entry */
  131. #define ELSE_SEEN 2 /* TRUE when #else processed */
  132. #define TRUE_SEEN 4 /* TRUE when #if TRUE processed */
  133. /*
  134. * Define bits for the basic types and their adjectives
  135. */
  136. #define T_CHAR 1
  137. #define T_INT 2
  138. #define T_FLOAT 4
  139. #define T_DOUBLE 8
  140. #define T_SHORT 16
  141. #define T_LONG 32
  142. #define T_SIGNED 64
  143. #define T_UNSIGNED 128
  144. #define T_PTR 256 /* Pointer */
  145. #define T_FPTR 512 /* Pointer to functions */
  146. /*
  147. * The DEFBUF structure stores information about #defined
  148. * macros. Note that the defbuf->repl information is always
  149. * in malloc storage.
  150. */
  151. typedef struct defbuf {
  152. struct defbuf *link; /* Next define in chain */
  153. char *repl; /* -> replacement */
  154. int hash; /* Symbol table hash */
  155. int nargs; /* For define(args) */
  156. char name[1]; /* #define name */
  157. } DEFBUF;
  158. /*
  159. * The FILEINFO structure stores information about open files
  160. * and macros being expanded.
  161. */
  162. typedef struct fileinfo {
  163. char *bptr; /* Buffer pointer */
  164. int line; /* for include or macro */
  165. FILE *fp; /* File if non-null */
  166. struct fileinfo *parent; /* Link to includer */
  167. char *filename; /* File/macro name */
  168. char *progname; /* From #line statement */
  169. unsigned int unrecur; /* For macro recursion */
  170. char buffer[1]; /* current input line */
  171. } FILEINFO;
  172. /*
  173. * The SIZES structure is used to store the values for #if sizeof
  174. */
  175. typedef struct sizes {
  176. short bits; /* If this bit is set, */
  177. short size; /* this is the datum size value */
  178. short psize; /* this is the pointer size */
  179. } SIZES;
  180. /*
  181. * nomacarg is a built-in #define on Decus C.
  182. */
  183. #ifdef nomacarg
  184. #define cput output /* cput concatenates tokens */
  185. #else
  186. #if COMMENT_INVISIBLE
  187. #define cput(c) { if (c != TOK_SEP && c != COM_SEP) putchar(c); }
  188. #else
  189. #define cput(c) { if (c != TOK_SEP) putchar(c); }
  190. #endif
  191. #endif
  192. #ifndef nomacarg
  193. #define streq(s1, s2) (strcmp(s1, s2) == 0)
  194. #endif
  195. /*
  196. * Note: IO_NORMAL and IO_ERROR are defined in the Decus C stdio.h file
  197. */
  198. #ifndef IO_NORMAL
  199. #define IO_NORMAL 0
  200. #endif
  201. #ifndef IO_ERROR
  202. #define IO_ERROR 1
  203. #endif
  204. /*
  205. * Externs
  206. */
  207. #include "fpp.h" /* structs and defines */
  208. #include "cppadd.h" /* Added prototypes for ANSI complience! */
  209. #ifdef AMIGA
  210. #include <dos.h>
  211. extern int _OSERR;
  212. #endif
  213. extern char type[]; /* Character classifier */
  214. #define compiling global->ifstack[0]
  215. #if DEBUG
  216. extern int debug; /* Debug level */
  217. #endif
  218. extern SIZES size_table[]; /* For #if sizeof sizes */
  219. #define MAX_SPACE_SIZE 512 /* maximum number of whitespaces possible
  220. to remember */