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