xref: /csrg-svn/old/as.vax/asscan.h (revision 9695)
1603Sbill /*
25830Srrh  *	Copyright (c) 1982 Regents of the University of California
3*9695Slinton  *	@(#)asscan.h 4.4 2/14/82
45830Srrh  */
55830Srrh /*
6603Sbill  *	The character scanner is called to fill up one token buffer
7603Sbill  *
8603Sbill  *	However, once the tokens are filled up by the
9603Sbill  *	character scanner, they are used in both the first and the second
10603Sbill  *	pass.  Holes created by .stab removal are replaced
11603Sbill  *	with 'skip' tokens that direct the second pass to ignore the
12603Sbill  *	following tokens.
13603Sbill  */
14603Sbill 
15*9695Slinton #define TOKBUFLG		4096
16603Sbill #define MAXVAX			32
17603Sbill #define SAFETY			16
18603Sbill 
19603Sbill #define AVAILTOKS		TOKBUFLG -\
20603Sbill 		sizeof(int) -\
21603Sbill 		sizeof (struct tokbufdesc *) -\
22603Sbill 		MAXVAX - SAFETY
23603Sbill 
24603Sbill struct tokbufdesc{
25603Sbill 	int		tok_count;		/*absolute byte length*/
26603Sbill 	struct		tokbufdesc *tok_next;
27603Sbill 	char		toks[AVAILTOKS];
28603Sbill 	char		bufovf[MAXVAX + SAFETY];
29603Sbill };
30603Sbill /*
31603Sbill  *	Definitions for handling tokens in the intermediate file
32603Sbill  *	buffers.
33603Sbill  *
34603Sbill  *	We want to have the compiler produce the efficient auto increment
35603Sbill  *	instruction for stepping through the buffer of tokens.  We must
36603Sbill  *	fool the type checker into thinking that a pointer can point
37603Sbill  *	to various size things.
38603Sbill  */
39603Sbill 
405830Srrh typedef int inttoktype;
415830Srrh typedef char bytetoktype;
42603Sbill 
43603Sbill typedef char *ptrall;			/*all uses will be type cast*/
44603Sbill typedef short lgtype;			/*for storing length of strings or skiping*/
45603Sbill /*
46603Sbill  *	defintions for putting various typed values
47603Sbill  *	into the intermediate buffers
48603Sbill  *	ptr will ALWAYS be of type ptrall
49603Sbill  */
50603Sbill 
51603Sbill #define	pchar(ptr,val)		*ptr++  = val
52603Sbill #define	puchar(ptr,val)		*ptr++  = val
53603Sbill 
54603Sbill #define	pshort(ptr,val)		*(short *)ptr=val,	ptr += sizeof(short)
555830Srrh #define	pushort(ptr,val)	*(u_short *)ptr=val,	ptr += sizeof(short)
56603Sbill #define	pint(ptr,val)		*(int *)ptr  = val,	ptr += sizeof(int)
575830Srrh #define	puint(ptr,val)		*(u_int int *)ptr=val,	ptr += sizeof(int)
58603Sbill #define	plong(ptr,val)		*(long *)ptr  = val,	ptr += sizeof(long)
595830Srrh #define	pulong(ptr,val)		*(u_int long *)ptr=val,	ptr += sizeof(long)
605830Srrh #define	pnumber(ptr,val)	*(Bignum*)ptr=val,	ptr += sizeof(Bignum)
615830Srrh #define	popcode(ptr,val)	*(struct Opcode*)ptr=val,	ptr += sizeof(struct Opcode)
625830Srrh 
63603Sbill #define	pptr(ptr,val)		*(int *)ptr  = (val),	ptr += sizeof(ptrall)
64603Sbill #define	ptoken(ptr,val)		*ptr++  = val
65603Sbill #define	pstrlg(ptr,val)		*(lgtype *)ptr  = val,	ptr += sizeof(short)
66603Sbill #define	pskiplg(ptr,val)	*(lgtype *)ptr  = val,	ptr += sizeof(short)
67603Sbill 
68603Sbill #define	gchar(val, ptr)		val = *ptr++
69603Sbill #define	guchar(val, ptr)	val = *ptr++
70603Sbill 
71603Sbill #define	gshort(val, ptr)	val = *(short *)ptr , ptr += sizeof (short)
725830Srrh #define	gushort(val, ptr)	val = *(u_short *)ptr , ptr += sizeof (short)
73603Sbill #define	gint(val, ptr)		val = *(int *)ptr, ptr += sizeof (int)
745830Srrh #define	guint(val, ptr)		val = *(u_int *)ptr, ptr += sizeof (int)
75603Sbill #define	glong(val, ptr)		val = *(long *)ptr, ptr += sizeof (long)
765830Srrh #define	gulong(val, ptr)	val = *(u_int *)ptr, ptr += sizeof (long)
775830Srrh #define	gnumber(val, ptr)	val = *(Bignum *)ptr, ptr += sizeof(Bignum)
785830Srrh #define	gopcode(val, ptr)	val = *(struct Opcode *)ptr, ptr += sizeof(struct Opcode)
795830Srrh 
80603Sbill #define	gptr(val, ptr)		val = *(int *)ptr, ptr += sizeof (ptrall)
81603Sbill #define	gtoken(val, ptr)	val = *ptr++
82603Sbill #define	gstrlg(val, ptr)	val = *(lgtype *)ptr, ptr += sizeof (short)
83603Sbill #define	gskiplg(val, ptr)	val = *(lgtype *)ptr, ptr += sizeof (short)
84603Sbill 
85603Sbill 
86603Sbill extern	ptrall tokptr;	/*the next token to consume, call by copy*/
87603Sbill extern	ptrall tokub;	/*current upper bound in the current buffer*/
88603Sbill 
89603Sbill /*
90603Sbill  *	Strings are known for their characters and for their length.
91603Sbill  *	We cannot use a normal zero termination byte, because strings
92603Sbill  *	can contain anything.
93603Sbill  *
94603Sbill  *	We have two "strings", so that an input string that is too long can be
95603Sbill  *	split across two string buffers, and not confuse the yacc grammar.
96603Sbill  *	(This is probably superflous)
97603Sbill  *
98603Sbill  *	We have a third string of nulls so that the .skip can be
99603Sbill  *	handled in the same way as strings.
100603Sbill  */
101*9695Slinton #define MAXSTRLG	2048
102603Sbill 
103*9695Slinton struct strdesc {
104*9695Slinton 	unsigned short	str_lg;
105603Sbill 	char		str[MAXSTRLG];
106603Sbill };
107603Sbill 
108603Sbill extern	struct 	strdesc		strbuf[3];
109603Sbill extern	struct 	strdesc		*strptr;	/*points to the current string*/
110603Sbill extern	int			strno;		/*the current string being filled*/
111603Sbill char	*savestr();
112