1*603Sbill /* Copyright (c) 1980 Regents of the University of California */ 2*603Sbill /* "@(#)asscan.h 4.1 08/13/80" */ 3*603Sbill /* 4*603Sbill * The character scanner is called to fill up one token buffer 5*603Sbill * 6*603Sbill * However, once the tokens are filled up by the 7*603Sbill * character scanner, they are used in both the first and the second 8*603Sbill * pass. Holes created by .stab removal are replaced 9*603Sbill * with 'skip' tokens that direct the second pass to ignore the 10*603Sbill * following tokens. 11*603Sbill */ 12*603Sbill 13*603Sbill #define TOKBUFLG BUFSIZ 14*603Sbill #define MAXVAX 32 15*603Sbill #define SAFETY 16 16*603Sbill 17*603Sbill #define AVAILTOKS TOKBUFLG -\ 18*603Sbill sizeof(int) -\ 19*603Sbill sizeof (struct tokbufdesc *) -\ 20*603Sbill MAXVAX - SAFETY 21*603Sbill 22*603Sbill struct tokbufdesc{ 23*603Sbill int tok_count; /*absolute byte length*/ 24*603Sbill struct tokbufdesc *tok_next; 25*603Sbill char toks[AVAILTOKS]; 26*603Sbill char bufovf[MAXVAX + SAFETY]; 27*603Sbill }; 28*603Sbill /* 29*603Sbill * Definitions for handling tokens in the intermediate file 30*603Sbill * buffers. 31*603Sbill * 32*603Sbill * We want to have the compiler produce the efficient auto increment 33*603Sbill * instruction for stepping through the buffer of tokens. We must 34*603Sbill * fool the type checker into thinking that a pointer can point 35*603Sbill * to various size things. 36*603Sbill */ 37*603Sbill 38*603Sbill typedef char toktype; 39*603Sbill 40*603Sbill typedef char *ptrall; /*all uses will be type cast*/ 41*603Sbill typedef short lgtype; /*for storing length of strings or skiping*/ 42*603Sbill /* 43*603Sbill * defintions for putting various typed values 44*603Sbill * into the intermediate buffers 45*603Sbill * ptr will ALWAYS be of type ptrall 46*603Sbill */ 47*603Sbill 48*603Sbill #define pchar(ptr,val) *ptr++ = val 49*603Sbill #define puchar(ptr,val) *ptr++ = val 50*603Sbill 51*603Sbill #define pshort(ptr,val) *(short *)ptr=val, ptr += sizeof(short) 52*603Sbill #define pushort(ptr,val) *(unsigned short *)ptr=val, ptr += sizeof(short) 53*603Sbill #define pint(ptr,val) *(int *)ptr = val, ptr += sizeof(int) 54*603Sbill #define puint(ptr,val) *(unsigned int *)ptr=val, ptr += sizeof(int) 55*603Sbill #define plong(ptr,val) *(long *)ptr = val, ptr += sizeof(long) 56*603Sbill #define pulong(ptr,val) *(unsigned long *)ptr=val,ptr += sizeof(long) 57*603Sbill #define pfloat(ptr,val) *(float *)ptr = val, ptr += sizeof (float) 58*603Sbill #define pdouble(ptr,val) *(double *)ptr = val, ptr += sizeof (double) 59*603Sbill #define pptr(ptr,val) *(int *)ptr = (val), ptr += sizeof(ptrall) 60*603Sbill #define ptoken(ptr,val) *ptr++ = val 61*603Sbill #define pstrlg(ptr,val) *(lgtype *)ptr = val, ptr += sizeof(short) 62*603Sbill #define pskiplg(ptr,val) *(lgtype *)ptr = val, ptr += sizeof(short) 63*603Sbill 64*603Sbill #define gchar(val, ptr) val = *ptr++ 65*603Sbill #define guchar(val, ptr) val = *ptr++ 66*603Sbill 67*603Sbill #define gshort(val, ptr) val = *(short *)ptr , ptr += sizeof (short) 68*603Sbill #define gushort(val, ptr) val = *(unsigned short *)ptr , ptr += sizeof (short) 69*603Sbill #define gint(val, ptr) val = *(int *)ptr, ptr += sizeof (int) 70*603Sbill #define guint(val, ptr) val = *(unsigend int *)ptr, ptr += sizeof (int) 71*603Sbill #define glong(val, ptr) val = *(long *)ptr, ptr += sizeof (long) 72*603Sbill #define gulong(val, ptr) val = *(unsigned long *)ptr, ptr += sizeof (long) 73*603Sbill #define gfloat(val, ptr) val = *(float *)ptr, ptr += sizeof (float) 74*603Sbill #define gdouble(val, ptr) val = *(double *)ptr, ptr += sizeof (double) 75*603Sbill #define gptr(val, ptr) val = *(int *)ptr, ptr += sizeof (ptrall) 76*603Sbill #define gtoken(val, ptr) val = *ptr++ 77*603Sbill #define gstrlg(val, ptr) val = *(lgtype *)ptr, ptr += sizeof (short) 78*603Sbill #define gskiplg(val, ptr) val = *(lgtype *)ptr, ptr += sizeof (short) 79*603Sbill 80*603Sbill 81*603Sbill extern ptrall tokptr; /*the next token to consume, call by copy*/ 82*603Sbill extern ptrall tokub; /*current upper bound in the current buffer*/ 83*603Sbill 84*603Sbill /* 85*603Sbill * Strings are known for their characters and for their length. 86*603Sbill * We cannot use a normal zero termination byte, because strings 87*603Sbill * can contain anything. 88*603Sbill * 89*603Sbill * We have two "strings", so that an input string that is too long can be 90*603Sbill * split across two string buffers, and not confuse the yacc grammar. 91*603Sbill * (This is probably superflous) 92*603Sbill * 93*603Sbill * We have a third string of nulls so that the .skip can be 94*603Sbill * handled in the same way as strings. 95*603Sbill */ 96*603Sbill #define MAXSTRLG 127 97*603Sbill 98*603Sbill struct strdesc{ 99*603Sbill char str_lg; 100*603Sbill char str[MAXSTRLG]; 101*603Sbill }; 102*603Sbill 103*603Sbill extern struct strdesc strbuf[3]; 104*603Sbill extern struct strdesc *strptr; /*points to the current string*/ 105*603Sbill extern int strno; /*the current string being filled*/ 106*603Sbill char *savestr(); 107