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