| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#include <stdio.h> |
| 29 |
#if LIBVMF |
| 30 |
#include <vmf.h> |
| 31 |
#endif |
| 32 |
|
| 33 |
typedef char usch; |
| 34 |
#ifdef CHAR_UNSIGNED |
| 35 |
#define SPECADD 0 |
| 36 |
#else |
| 37 |
#define SPECADD 128 |
| 38 |
#endif |
| 39 |
|
| 40 |
extern int trulvl; |
| 41 |
extern int flslvl; |
| 42 |
extern int elflvl; |
| 43 |
extern int elslvl; |
| 44 |
extern int dflag; |
| 45 |
extern int tflag, Aflag, Cflag, Pflag; |
| 46 |
extern int Mflag, dMflag, MPflag, MMDflag; |
| 47 |
extern char *Mfile, *MPfile; |
| 48 |
extern int defining, inclevel; |
| 49 |
extern int escln; |
| 50 |
|
| 51 |
|
| 52 |
#define FIND 0 |
| 53 |
#define ENTER 1 |
| 54 |
|
| 55 |
|
| 56 |
#if SIZEOF_INT_P == 2 || LIBVMF |
| 57 |
#define CPPL2 7 |
| 58 |
typedef unsigned short mvtyp; |
| 59 |
#else |
| 60 |
#define CPPL2 14 |
| 61 |
typedef unsigned int mvtyp; |
| 62 |
#endif |
| 63 |
|
| 64 |
#define CPPBUF (1 << CPPL2) |
| 65 |
#if CPPBUF < 1024 |
| 66 |
#define MINBUF 1024 |
| 67 |
#else |
| 68 |
#define MINBUF CPPBUF |
| 69 |
#endif |
| 70 |
#define VALPTR(x) ((x) & (MINBUF-1)) |
| 71 |
#define VALBUF(x) ((x) / MINBUF) |
| 72 |
#define MKVAL(b, c) (((b) * MINBUF) + (c)) |
| 73 |
|
| 74 |
extern usch pbbeg[], *pbinp, *pbend; |
| 75 |
|
| 76 |
#define MAXARGS 128 |
| 77 |
#define MAXIDSZ 63 |
| 78 |
|
| 79 |
#define PBMAX 10 |
| 80 |
|
| 81 |
#define FUNLIKE 0 |
| 82 |
#define CTRLOC 1 |
| 83 |
#define DEFLOC 2 |
| 84 |
#define PRAGLOC 3 |
| 85 |
#define LINLOC 4 |
| 86 |
#define FILLOC 5 |
| 87 |
#define OBJCT 6 |
| 88 |
#define VARG 7 |
| 89 |
|
| 90 |
|
| 91 |
#define C99ARG 253 |
| 92 |
#define GCCARG 254 |
| 93 |
|
| 94 |
#define WARN 1 |
| 95 |
#define CONC 2 |
| 96 |
#define SNUFF 3 |
| 97 |
#define BLKID 4 |
| 98 |
#define BLKID2 5 |
| 99 |
|
| 100 |
|
| 101 |
#define L2MAX 64 |
| 102 |
#define MKB(l,h) (l+((h)<<8)) |
| 103 |
|
| 104 |
|
| 105 |
#define C_SPEC 0001 |
| 106 |
#define C_2 0002 |
| 107 |
#define C_WSNL 0004 |
| 108 |
#define C_PACK 0010 |
| 109 |
#define C_ID (C_ID0|C_DIGIT) |
| 110 |
#define C_ID0 0020 |
| 111 |
#define C_Q 0040 |
| 112 |
#define C_DIGIT 0100 |
| 113 |
#define C_ESTR 0200 |
| 114 |
|
| 115 |
extern short spechr[]; |
| 116 |
|
| 117 |
#define ISSPEC(x) ((SPECADD+spechr)[(int)(x)] & (C_SPEC)) |
| 118 |
#define ISC2(x) ((SPECADD+spechr)[(int)(x)] & (C_2)) |
| 119 |
#define ISWSNL(x) ((SPECADD+spechr)[(int)(x)] & (C_WSNL)) |
| 120 |
#define ISWS(x) ((x) == '\t' || (x) == ' ') |
| 121 |
#define ISPACK(x) ((SPECADD+spechr)[(int)(x)] & C_PACK) |
| 122 |
#define ISID(x) ((SPECADD+spechr)[(int)(x)] & C_ID) |
| 123 |
#define ISID0(x) ((SPECADD+spechr)[(int)(x)] & C_ID0) |
| 124 |
#define ISDIGIT(x) ((SPECADD+spechr)[(int)(x)] & C_DIGIT) |
| 125 |
#define ISCQ(x) ((SPECADD+spechr)[(int)(x)] & C_Q) |
| 126 |
#define ISESTR(x) ((SPECADD+spechr)[(int)(x)] & C_ESTR) |
| 127 |
|
| 128 |
|
| 129 |
#define BNORMAL 0 |
| 130 |
#define BMAC 1 |
| 131 |
#define BINBUF 2 |
| 132 |
#define BUTBUF 3 |
| 133 |
struct iobuf { |
| 134 |
usch *buf; |
| 135 |
int cptr; |
| 136 |
int bsz; |
| 137 |
int ro:1, inuse:1, type:4; |
| 138 |
}; |
| 139 |
struct iobuf *getobuf(int); |
| 140 |
void putob(struct iobuf *ob, int ch); |
| 141 |
void bufree(struct iobuf *iob); |
| 142 |
|
| 143 |
#define curptr ib->cptr |
| 144 |
#define maxread ib->bsz |
| 145 |
#define buffer ib->buf+PBMAX |
| 146 |
#define bbuf ib->buf |
| 147 |
|
| 148 |
#if LIBVMF |
| 149 |
extern struct vspace ibspc, macspc; |
| 150 |
#endif |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
struct includ { |
| 156 |
struct includ *next; |
| 157 |
const usch *fname; |
| 158 |
const usch *orgfn; |
| 159 |
int lineno; |
| 160 |
int infil; |
| 161 |
int opend, oinp; |
| 162 |
usch *opbeg; |
| 163 |
int idx; |
| 164 |
void *incs; |
| 165 |
const usch *fn; |
| 166 |
#if LIBVMF |
| 167 |
struct vseg *vseg; |
| 168 |
#endif |
| 169 |
}; |
| 170 |
#define INCINC 0 |
| 171 |
#define SYSINC 1 |
| 172 |
|
| 173 |
extern struct includ *ifiles; |
| 174 |
extern usch *pbeg, *pend, *outp, *inp; |
| 175 |
|
| 176 |
|
| 177 |
struct symtab { |
| 178 |
const usch *namep; |
| 179 |
mvtyp valoff; |
| 180 |
const usch *file; |
| 181 |
int line; |
| 182 |
char type:4, |
| 183 |
wraps:1; |
| 184 |
unsigned char narg; |
| 185 |
}; |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
struct nd { |
| 194 |
int op; |
| 195 |
union { |
| 196 |
long long val; |
| 197 |
unsigned long long uval; |
| 198 |
struct iobuf *ob; |
| 199 |
} n; |
| 200 |
}; |
| 201 |
extern struct nd yynode; |
| 202 |
|
| 203 |
#define nd_val n.val |
| 204 |
#define nd_uval n.uval |
| 205 |
#define nd_ob n.ob |
| 206 |
|
| 207 |
enum { NUMBER = 257, UNUMBER, LS, RS, EQ, NE, STRING, WSPACE, CMNT, IDENT, |
| 208 |
OROR, ANDAND, DEFINED, LE, GE }; |
| 209 |
|
| 210 |
#define SLO_IGNOREWS 001 |
| 211 |
|
| 212 |
struct symtab *lookup(const usch *namep, int enterf); |
| 213 |
struct blocker; |
| 214 |
struct iobuf *submac(struct symtab *nl, int, struct iobuf *, int); |
| 215 |
struct iobuf *kfind(struct symtab *nl); |
| 216 |
void ppdir(void); |
| 217 |
|
| 218 |
void define(void); |
| 219 |
void include(void); |
| 220 |
void include_next(void); |
| 221 |
void line(void); |
| 222 |
|
| 223 |
void pushfile(const usch *fname, const usch *fn, int idx, void *incs); |
| 224 |
void prtline(int nl); |
| 225 |
int yylex(void); |
| 226 |
void cunput(int); |
| 227 |
int yyparse(void); |
| 228 |
void putch(int); |
| 229 |
void putstr(const usch *s); |
| 230 |
usch *sheap(const char *fmt, ...); |
| 231 |
struct iobuf *bsheap(struct iobuf *, const char *fmt, ...); |
| 232 |
struct iobuf *strtobuf(const usch *str, struct iobuf *iob); |
| 233 |
struct iobuf *buftobuf(struct iobuf *in, struct iobuf *iob); |
| 234 |
void warning(const char *fmt, ...); |
| 235 |
void error(const char *fmt, ...); |
| 236 |
int cinput(void); |
| 237 |
int inc2(void); |
| 238 |
void Ccmnt2(struct iobuf *, int); |
| 239 |
usch *bufid(int ch, struct iobuf *); |
| 240 |
usch *readid(int ch); |
| 241 |
void faststr(int bc, struct iobuf *); |
| 242 |
void *xrealloc(void *p, int sz); |
| 243 |
void *xmalloc(int sz); |
| 244 |
void fastscan(void); |
| 245 |
void cntline(void); |
| 246 |
int inpbuf(void); |