* added compilers lcc and bcc (linux86)
[mascara-docs.git] / compilers / linux86-0.16.17 / as / scan.c
blob97be265393ba44a35dfce8841106060ef266a2f9
1 /* scan.c - lexical analyser for assembler */
3 #include "syshead.h"
4 #include "const.h"
5 #include "type.h"
6 #include "globvar.h"
7 #undef EXTERN
8 #define EXTERN
9 #include "scan.h"
11 PRIVATE int numbase; /* base for number */
13 PRIVATE char symofchar[256] = /* table to convert chars to their symbols */
15 EOLSYM, WHITESPACE, WHITESPACE, WHITESPACE,
16 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
17 WHITESPACE, WHITESPACE, EOLSYM, WHITESPACE,
18 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
19 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
20 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
21 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
22 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
24 WHITESPACE, EOLSYM, STRINGCONST, IMMEDIATE, /* !"# */
25 HEXCONST, BINCONST, ANDOP, CHARCONST, /* $%&' */
26 LPAREN, RPAREN, STAR, ADDOP, /* ()*+ */
27 COMMA, SUBOP, IDENT, SLASH, /* ,-./ */
29 INTCONST, INTCONST, INTCONST, INTCONST, /* 0123 */
30 INTCONST, INTCONST, INTCONST, INTCONST, /* 4567 */
31 INTCONST, INTCONST, COLON, EOLSYM, /* 89:; */
32 LESSTHAN, EQOP, GREATERTHAN, MACROARG, /* <=>? */
34 INDIRECT, IDENT, IDENT, IDENT, /* @ABC */
35 IDENT, IDENT, IDENT, IDENT, /* DEFG */
36 IDENT, IDENT, IDENT, IDENT, /* HIJK */
37 IDENT, IDENT, IDENT, IDENT, /* LMNO */
38 IDENT, IDENT, IDENT, IDENT, /* PQRS */
39 IDENT, IDENT, IDENT, IDENT, /* TUVW */
40 IDENT, IDENT, IDENT, LBRACKET, /* XYZ[ */
41 OTHERSYM, RBRACKET, OTHERSYM, IDENT, /* \]^_ */
43 OTHERSYM, IDENT, IDENT, IDENT, /* `abc */
44 IDENT, IDENT, IDENT, IDENT, /* defg */
45 IDENT, IDENT, IDENT, IDENT, /* hijk */
46 IDENT, IDENT, IDENT, IDENT, /* lmno */
47 IDENT, IDENT, IDENT, IDENT, /* pqrs */
48 IDENT, IDENT, IDENT, IDENT, /* tuvw */
49 IDENT, IDENT, IDENT, OTHERSYM, /* xyz{ */
50 OROP, OTHERSYM, NOTOP, OTHERSYM, /* |}~ */
52 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
53 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
54 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
55 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
56 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
57 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
58 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
59 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
61 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
62 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
63 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
64 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
65 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
66 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
67 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
68 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
70 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
71 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
72 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
73 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
74 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
75 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
76 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
77 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
79 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
80 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
81 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
82 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
83 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
84 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
85 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE,
86 WHITESPACE, WHITESPACE, WHITESPACE, WHITESPACE
89 FORWARD void intconst P((void));
91 PUBLIC void context_hexconst()
93 numbase = 16;
94 intconst();
97 PUBLIC void getsym()
99 register char *reglineptr;
101 reglineptr = lineptr;
102 advance:
103 symname = reglineptr;
104 switch (sym = symofchar[(unsigned char) *reglineptr++])
106 case WHITESPACE:
107 goto advance;
108 case ADDOP:
109 if (*reglineptr == '+')
111 sym = POSTINCOP;
112 ++reglineptr;
114 break;
115 case BINCONST:
116 numbase = 2;
117 lineptr = reglineptr;
118 intconst();
119 return;
120 case CHARCONST:
121 if ((number = *reglineptr) < ' ')
122 number = ' ';
123 if (*reglineptr != EOL)
124 ++reglineptr;
125 sym = INTCONST;
126 break;
127 case GREATERTHAN: /* context-sensitive */
128 if (*reglineptr == '>')
130 sym = SROP;
131 ++reglineptr;
133 break;
134 case HEXCONST:
135 numbase = 16;
136 lineptr = reglineptr;
137 intconst();
138 return;
139 case IDENT:
140 /* walk to end of identifier - magic INTCONST is max of INT, IDENT */
141 while (symofchar[(unsigned char) *reglineptr] <= INTCONST)
142 ++reglineptr;
143 lineptr = reglineptr;
144 gsymptr = lookup();
145 return;
146 case INTCONST:
147 if (*(reglineptr - 1) == '0')
149 if (*reglineptr != 'x' && *reglineptr != 'X')
150 numbase = 8;
151 else
153 numbase = 16;
154 ++reglineptr;
157 else
159 --reglineptr;
160 numbase = 10;
162 lineptr = reglineptr;
163 intconst();
164 return;
165 case LESSTHAN: /* context-sensitive */
166 if (*reglineptr == '<')
168 sym = SLOP;
169 ++reglineptr;
171 break;
172 case SUBOP:
173 if (*reglineptr == '-')
175 sym = PREDECOP;
176 ++reglineptr;
178 break;
180 lineptr = reglineptr;
181 return;
184 PUBLIC void getsym_nolookup()
186 bool_t old_ifflag;
188 old_ifflag = ifflag;
189 ifflag = FALSE;
190 getsym();
191 ifflag = old_ifflag;
194 PRIVATE void intconst()
196 register char *reglineptr;
198 number = 0;
199 reglineptr = lineptr;
200 for (; *reglineptr >= '0'; ++reglineptr)
202 if (*reglineptr > '9')
204 if (numbase != 16)
205 break;
206 if (*reglineptr >= 'a' && *reglineptr <= 'f')
208 if (number != 0)
209 number = numbase * number + (*reglineptr - 'a' + 10);
210 else
211 number = *reglineptr - 'a' + 10;
213 else if (*reglineptr >= 'A' && *reglineptr <= 'F')
215 if (number != 0)
216 number = numbase * number + (*reglineptr - 'A' + 10);
217 else
218 number = *reglineptr - 'A' + 10;
220 else
221 break;
223 else if (number != 0)
224 number = numbase * number + (*reglineptr - '0');
225 else
226 number = *reglineptr - '0';
228 if (*reglineptr == 'L' || *reglineptr == 'l')
229 ++reglineptr;
230 sym = INTCONST;
231 lineptr = reglineptr;
234 PUBLIC void initscan()
236 #ifndef MC6809
237 if (asld_compatible)
239 lindirect = LPAREN;
240 rindexp = RPEXP;
241 rindirect = RPAREN;
243 else
245 #endif
246 lindirect = LBRACKET;
247 rindexp = RBEXP;
248 rindirect = RBRACKET;
249 #ifndef MC6809
251 #endif