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