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