BSD 4_4 release
[unix-history] / usr / src / old / as.vax / asscanl.h
CommitLineData
541d16cf 1/*
bcf1365c
DF
2 * Copyright (c) 1982 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 *
95f51977 6 * @(#)asscanl.h 5.1 (Berkeley) 4/30/85
541d16cf 7 */
bcf1365c 8
541d16cf
RH
9/*
10 * This file contains definitions local to the files implementing
11 * the character scanner and the token buffer managers.
12 * It is not intended to be shared with any other parts of the
13 * assembler.
14 * The file ``asscan.h'' is shared with other parts of the assembler
15 */
16#include <stdio.h>
17#include "as.h"
18#include "asscan.h"
541d16cf 19
12044a7d 20#define EOFCHAR (-1)
541d16cf
RH
21/*
22 * The table of possible uses for each character to test set inclusion.
541d16cf
RH
23 */
24#define HEXFLAG 01 /* 'x' or 'X' */
25#define HEXLDIGIT 02 /* 'a' .. 'f' */
26#define HEXUDIGIT 04 /* 'A' .. 'F' */
27#define ALPHA 010 /* 'A' .. 'Z', 'a' .. 'z', '_'*/
28#define DIGIT 020 /* '0' .. '9' */
29#define FLOATEXP 040 /* 'd' 'e' 'D' 'E' 'g' 'h' 'G' 'H' */
30#define SIGN 0100 /* '+' .. '-'*/
31#define REGDIGIT 0200 /* '0' .. '5' */
32#define SZSPECBEGIN 0400 /* 'b', 'B', 'l', 'L', 'w', 'W' */
33#define POINT 01000 /* '.' */
34#define SPACE 02000 /* '\t' or ' ' */
35#define BSESCAPE 04000 /* bnrtf */
36#define STRESCAPE 010000 /* '"', '\\', '\n' */
37#define OCTDIGIT 020000 /* '0' .. '7' */
38#define FLOATFLAG 040000 /* 'd', 'D', 'f', 'F' */
39
40#define INCHARSET(val, kind) (charsets[val] & (kind) )
541d16cf 41/*
12044a7d
RH
42 * We use our own version of getchar/ungetc to get
43 * some speed improvement
541d16cf 44 */
12044a7d
RH
45extern char *Ginbufptr;
46extern int Ginbufcnt;
47#define REGTOMEMBUF Ginbufptr = inbufptr, Ginbufcnt = inbufcnt
48#define MEMTOREGBUF inbufptr = Ginbufptr, inbufcnt = Ginbufcnt
49#undef getchar
50#define getchar() \
51 (inbufcnt-- > 0 ? (*inbufptr++) : \
52 (fillinbuffer(), \
53 MEMTOREGBUF, \
54 inbufptr[-1]))
55#undef ungetc
56#define ungetc(ch) \
57 (++inbufcnt, *--inbufptr = ch)
58\f
541d16cf 59/*
12044a7d 60 * Variables and definitions to manage the token buffering.
541d16cf
RH
61 * We scan (lexically analyze) a large number of tokens, and
62 * then parse all of the tokens in the scan buffer.
63 * This reduces procedure call overhead when the parser
64 * demands a token, allows for an efficient reread during
65 * the second pass, and confuses the line number reporting
66 * for errors encountered in the scanner and in the parser.
67 */
68#define TOKDALLOP 8
69struct tokbufdesc *bufstart; /*where the buffer list begins*/
70struct tokbufdesc *buftail; /*last one on the list*/
71struct tokbufdesc *emptybuf; /*the one being filled*/
72/*
73 * If we are using VM, during the second pass we reclaim the used
74 * token buffers for saving the relocation information
75 */
76struct tokbufdesc *tok_free; /* free pool */
77struct tokbufdesc *tok_temp; /* temporary for doing list manipulation */
78/*
79 * Other token buffer managers
80 */
81int bufno; /*which buffer number: 0,1 for tmp file*/
82struct tokbufdesc tokbuf[2]; /*our initial increment of buffers*/
83ptrall tokptr; /*where the current token comes from*/
84ptrall tokub; /*the last token in the current token buffer*/
12044a7d
RH
85/*
86 * as does not use fread and fwrite for the token buffering.
87 * The token buffers are integrals of BUFSIZ
88 * at all times, so we use direct read and write.
89 * fread and fwrite in stdio are HORRENDOUSLY inefficient,
90 * as they use putchar for each character, nested two deep in loops.
91 */
92#define writeTEST(pointer, size, nelements, ioptr) \
93 write(ioptr->_file, pointer, nelements * size) != nelements * size
541d16cf 94
12044a7d
RH
95#define readTEST(pointer, size, nelements, ioptr) \
96 read(ioptr->_file, pointer, nelements * size) != nelements * size
541d16cf
RH
97
98#define bskiplg(from, length) \
99 *(lgtype *)from = length; \
100 (bytetoktype *)from += sizeof(lgtype) + length
101
102#define bskipfromto(from, to) \
103 *(lgtype *)from = (bytetoktype *)to - (bytetoktype *)from - sizeof(lgtype); \
104 (bytetoktype *)from += sizeof (lgtype) + (bytetoktype *)to - (bytetoktype *)from
105
106#define eatskiplg(from) \
107 (bytetoktype *)from += sizeof(lgtype) + *(lgtype *)from
108
109#ifdef DEBUG
110 ptrall firsttoken;
111#endif DEBUG
112
113/*
114 * The following three variables are the slots for global
115 * communication with the parser.
116 * They are the semantic values associated with a particular token.
117 * The token itself is the return value from yylex()
118 */
119int yylval; /* normal semantic value */
120Bignum yybignum; /* a big number */
121struct Opcode yyopcode; /* a structure opcode */
122
123int newfflag;
124char *newfname;
125int scanlineno; /*the scanner's linenumber*/
126
127/*
128 * Definitions for sets of characters
129 */
130readonly short charsets[];
131readonly short type[];