Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * Hypervisor Software File: aslex.c | |
5 | * | |
6 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
7 | * | |
8 | * - Do no alter or remove copyright notices | |
9 | * | |
10 | * - Redistribution and use of this software in source and binary forms, with | |
11 | * or without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistribution of source code must retain the above copyright notice, | |
15 | * this list of conditions and the following disclaimer. | |
16 | * | |
17 | * - Redistribution in binary form must reproduce the above copyright notice, | |
18 | * this list of conditions and the following disclaimer in the | |
19 | * documentation and/or other materials provided with the distribution. | |
20 | * | |
21 | * Neither the name of Sun Microsystems, Inc. or the names of contributors | |
22 | * may be used to endorse or promote products derived from this software | |
23 | * without specific prior written permission. | |
24 | * | |
25 | * This software is provided "AS IS," without a warranty of any kind. | |
26 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
27 | * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
28 | * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
29 | * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
30 | * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
31 | * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
32 | * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
33 | * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
34 | * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
35 | * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
36 | * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
37 | * | |
38 | * You acknowledge that this software is not designed, licensed or | |
39 | * intended for use in the design, construction, operation or maintenance of | |
40 | * any nuclear facility. | |
41 | * | |
42 | * ========== Copyright Header End ============================================ | |
43 | */ | |
44 | #line 2 "aslex.c" | |
45 | ||
46 | #line 4 "aslex.c" | |
47 | ||
48 | #define YY_INT_ALIGNED short int | |
49 | ||
50 | /* A lexical scanner generated by flex */ | |
51 | ||
52 | #define FLEX_SCANNER | |
53 | #define YY_FLEX_MAJOR_VERSION 2 | |
54 | #define YY_FLEX_MINOR_VERSION 5 | |
55 | #define YY_FLEX_SUBMINOR_VERSION 31 | |
56 | #if YY_FLEX_SUBMINOR_VERSION > 0 | |
57 | #define FLEX_BETA | |
58 | #endif | |
59 | ||
60 | /* First, we deal with platform-specific or compiler-specific issues. */ | |
61 | ||
62 | /* begin standard C headers. */ | |
63 | #include <stdio.h> | |
64 | #include <string.h> | |
65 | #include <errno.h> | |
66 | #include <stdlib.h> | |
67 | ||
68 | /* end standard C headers. */ | |
69 | ||
70 | /* flex integer type definitions */ | |
71 | ||
72 | #ifndef FLEXINT_H | |
73 | #define FLEXINT_H | |
74 | ||
75 | /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ | |
76 | ||
77 | #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L | |
78 | #include <inttypes.h> | |
79 | typedef int8_t flex_int8_t; | |
80 | typedef uint8_t flex_uint8_t; | |
81 | typedef int16_t flex_int16_t; | |
82 | typedef uint16_t flex_uint16_t; | |
83 | typedef int32_t flex_int32_t; | |
84 | typedef uint32_t flex_uint32_t; | |
85 | #else | |
86 | typedef signed char flex_int8_t; | |
87 | typedef short int flex_int16_t; | |
88 | typedef int flex_int32_t; | |
89 | typedef unsigned char flex_uint8_t; | |
90 | typedef unsigned short int flex_uint16_t; | |
91 | typedef unsigned int flex_uint32_t; | |
92 | #endif /* ! C99 */ | |
93 | ||
94 | /* Limits of integral types. */ | |
95 | #ifndef INT8_MIN | |
96 | #define INT8_MIN (-128) | |
97 | #endif | |
98 | #ifndef INT16_MIN | |
99 | #define INT16_MIN (-32767-1) | |
100 | #endif | |
101 | #ifndef INT32_MIN | |
102 | #define INT32_MIN (-2147483647-1) | |
103 | #endif | |
104 | #ifndef INT8_MAX | |
105 | #define INT8_MAX (127) | |
106 | #endif | |
107 | #ifndef INT16_MAX | |
108 | #define INT16_MAX (32767) | |
109 | #endif | |
110 | #ifndef INT32_MAX | |
111 | #define INT32_MAX (2147483647) | |
112 | #endif | |
113 | #ifndef UINT8_MAX | |
114 | #define UINT8_MAX (255U) | |
115 | #endif | |
116 | #ifndef UINT16_MAX | |
117 | #define UINT16_MAX (65535U) | |
118 | #endif | |
119 | #ifndef UINT32_MAX | |
120 | #define UINT32_MAX (4294967295U) | |
121 | #endif | |
122 | ||
123 | #endif /* ! FLEXINT_H */ | |
124 | ||
125 | #ifdef __cplusplus | |
126 | ||
127 | /* The "const" storage-class-modifier is valid. */ | |
128 | #define YY_USE_CONST | |
129 | ||
130 | #else /* ! __cplusplus */ | |
131 | ||
132 | #if __STDC__ | |
133 | ||
134 | #define YY_USE_CONST | |
135 | ||
136 | #endif /* __STDC__ */ | |
137 | #endif /* ! __cplusplus */ | |
138 | ||
139 | #ifdef YY_USE_CONST | |
140 | #define yyconst const | |
141 | #else | |
142 | #define yyconst | |
143 | #endif | |
144 | ||
145 | /* Returned upon end-of-file. */ | |
146 | #define YY_NULL 0 | |
147 | ||
148 | /* Promotes a possibly negative, possibly signed char to an unsigned | |
149 | * integer for use as an array index. If the signed char is negative, | |
150 | * we want to instead treat it as an 8-bit unsigned char, hence the | |
151 | * double cast. | |
152 | */ | |
153 | #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) | |
154 | ||
155 | /* Enter a start condition. This macro really ought to take a parameter, | |
156 | * but we do it the disgusting crufty way forced on us by the ()-less | |
157 | * definition of BEGIN. | |
158 | */ | |
159 | #define BEGIN (yy_start) = 1 + 2 * | |
160 | ||
161 | /* Translate the current start state into a value that can be later handed | |
162 | * to BEGIN to return to the state. The YYSTATE alias is for lex | |
163 | * compatibility. | |
164 | */ | |
165 | #define YY_START (((yy_start) - 1) / 2) | |
166 | #define YYSTATE YY_START | |
167 | ||
168 | /* Action number for EOF rule of a given start state. */ | |
169 | #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) | |
170 | ||
171 | /* Special action meaning "start processing a new file". */ | |
172 | #define YY_NEW_FILE aslexrestart(aslexin ) | |
173 | ||
174 | #define YY_END_OF_BUFFER_CHAR 0 | |
175 | ||
176 | /* Size of default input buffer. */ | |
177 | #ifndef YY_BUF_SIZE | |
178 | #define YY_BUF_SIZE 16384 | |
179 | #endif | |
180 | ||
181 | #ifndef YY_TYPEDEF_YY_BUFFER_STATE | |
182 | #define YY_TYPEDEF_YY_BUFFER_STATE | |
183 | typedef struct yy_buffer_state *YY_BUFFER_STATE; | |
184 | #endif | |
185 | ||
186 | extern int aslexleng; | |
187 | ||
188 | extern FILE *aslexin, *aslexout; | |
189 | ||
190 | #define EOB_ACT_CONTINUE_SCAN 0 | |
191 | #define EOB_ACT_END_OF_FILE 1 | |
192 | #define EOB_ACT_LAST_MATCH 2 | |
193 | ||
194 | #define YY_LESS_LINENO(n) | |
195 | ||
196 | /* Return all but the first "n" matched characters back to the input stream. */ | |
197 | #define yyless(n) \ | |
198 | do \ | |
199 | { \ | |
200 | /* Undo effects of setting up aslextext. */ \ | |
201 | int yyless_macro_arg = (n); \ | |
202 | YY_LESS_LINENO(yyless_macro_arg);\ | |
203 | *yy_cp = (yy_hold_char); \ | |
204 | YY_RESTORE_YY_MORE_OFFSET \ | |
205 | (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ | |
206 | YY_DO_BEFORE_ACTION; /* set up aslextext again */ \ | |
207 | } \ | |
208 | while ( 0 ) | |
209 | ||
210 | #define unput(c) yyunput( c, (yytext_ptr) ) | |
211 | ||
212 | /* The following is because we cannot portably get our hands on size_t | |
213 | * (without autoconf's help, which isn't available because we want | |
214 | * flex-generated scanners to compile on their own). | |
215 | */ | |
216 | ||
217 | #ifndef YY_TYPEDEF_YY_SIZE_T | |
218 | #define YY_TYPEDEF_YY_SIZE_T | |
219 | typedef unsigned int yy_size_t; | |
220 | #endif | |
221 | ||
222 | #ifndef YY_STRUCT_YY_BUFFER_STATE | |
223 | #define YY_STRUCT_YY_BUFFER_STATE | |
224 | struct yy_buffer_state | |
225 | { | |
226 | FILE *yy_input_file; | |
227 | ||
228 | char *yy_ch_buf; /* input buffer */ | |
229 | char *yy_buf_pos; /* current position in input buffer */ | |
230 | ||
231 | /* Size of input buffer in bytes, not including room for EOB | |
232 | * characters. | |
233 | */ | |
234 | yy_size_t yy_buf_size; | |
235 | ||
236 | /* Number of characters read into yy_ch_buf, not including EOB | |
237 | * characters. | |
238 | */ | |
239 | int yy_n_chars; | |
240 | ||
241 | /* Whether we "own" the buffer - i.e., we know we created it, | |
242 | * and can realloc() it to grow it, and should free() it to | |
243 | * delete it. | |
244 | */ | |
245 | int yy_is_our_buffer; | |
246 | ||
247 | /* Whether this is an "interactive" input source; if so, and | |
248 | * if we're using stdio for input, then we want to use getc() | |
249 | * instead of fread(), to make sure we stop fetching input after | |
250 | * each newline. | |
251 | */ | |
252 | int yy_is_interactive; | |
253 | ||
254 | /* Whether we're considered to be at the beginning of a line. | |
255 | * If so, '^' rules will be active on the next match, otherwise | |
256 | * not. | |
257 | */ | |
258 | int yy_at_bol; | |
259 | ||
260 | int yy_bs_lineno; /**< The line count. */ | |
261 | int yy_bs_column; /**< The column count. */ | |
262 | ||
263 | /* Whether to try to fill the input buffer when we reach the | |
264 | * end of it. | |
265 | */ | |
266 | int yy_fill_buffer; | |
267 | ||
268 | int yy_buffer_status; | |
269 | ||
270 | #define YY_BUFFER_NEW 0 | |
271 | #define YY_BUFFER_NORMAL 1 | |
272 | /* When an EOF's been seen but there's still some text to process | |
273 | * then we mark the buffer as YY_EOF_PENDING, to indicate that we | |
274 | * shouldn't try reading from the input source any more. We might | |
275 | * still have a bunch of tokens to match, though, because of | |
276 | * possible backing-up. | |
277 | * | |
278 | * When we actually see the EOF, we change the status to "new" | |
279 | * (via aslexrestart()), so that the user can continue scanning by | |
280 | * just pointing aslexin at a new input file. | |
281 | */ | |
282 | #define YY_BUFFER_EOF_PENDING 2 | |
283 | ||
284 | }; | |
285 | #endif /* !YY_STRUCT_YY_BUFFER_STATE */ | |
286 | ||
287 | /* Stack of input buffers. */ | |
288 | static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ | |
289 | static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ | |
290 | static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ | |
291 | ||
292 | /* We provide macros for accessing buffer states in case in the | |
293 | * future we want to put the buffer states in a more general | |
294 | * "scanner state". | |
295 | * | |
296 | * Returns the top of the stack, or NULL. | |
297 | */ | |
298 | #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ | |
299 | ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ | |
300 | : NULL) | |
301 | ||
302 | /* Same as previous macro, but useful when we know that the buffer stack is not | |
303 | * NULL or when we need an lvalue. For internal use only. | |
304 | */ | |
305 | #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] | |
306 | ||
307 | /* yy_hold_char holds the character lost when aslextext is formed. */ | |
308 | static char yy_hold_char; | |
309 | static int yy_n_chars; /* number of characters read into yy_ch_buf */ | |
310 | int aslexleng; | |
311 | ||
312 | /* Points to current character in buffer. */ | |
313 | static char *yy_c_buf_p = (char *) 0; | |
314 | static int yy_init = 1; /* whether we need to initialize */ | |
315 | static int yy_start = 0; /* start state number */ | |
316 | ||
317 | /* Flag which is used to allow aslexwrap()'s to do buffer switches | |
318 | * instead of setting up a fresh aslexin. A bit of a hack ... | |
319 | */ | |
320 | static int yy_did_buffer_switch_on_eof; | |
321 | ||
322 | void aslexrestart (FILE *input_file ); | |
323 | void aslex_switch_to_buffer (YY_BUFFER_STATE new_buffer ); | |
324 | YY_BUFFER_STATE aslex_create_buffer (FILE *file,int size ); | |
325 | void aslex_delete_buffer (YY_BUFFER_STATE b ); | |
326 | void aslex_flush_buffer (YY_BUFFER_STATE b ); | |
327 | void aslexpush_buffer_state (YY_BUFFER_STATE new_buffer ); | |
328 | void aslexpop_buffer_state (void ); | |
329 | ||
330 | static void aslexensure_buffer_stack (void ); | |
331 | static void aslex_load_buffer_state (void ); | |
332 | static void aslex_init_buffer (YY_BUFFER_STATE b,FILE *file ); | |
333 | ||
334 | #define YY_FLUSH_BUFFER aslex_flush_buffer(YY_CURRENT_BUFFER ) | |
335 | ||
336 | YY_BUFFER_STATE aslex_scan_buffer (char *base,yy_size_t size ); | |
337 | YY_BUFFER_STATE aslex_scan_string (yyconst char *yy_str ); | |
338 | YY_BUFFER_STATE aslex_scan_bytes (yyconst char *bytes,int len ); | |
339 | ||
340 | void *aslexalloc (yy_size_t ); | |
341 | void *aslexrealloc (void *,yy_size_t ); | |
342 | void aslexfree (void * ); | |
343 | ||
344 | #define yy_new_buffer aslex_create_buffer | |
345 | ||
346 | #define yy_set_interactive(is_interactive) \ | |
347 | { \ | |
348 | if ( ! YY_CURRENT_BUFFER ){ \ | |
349 | aslexensure_buffer_stack (); \ | |
350 | YY_CURRENT_BUFFER_LVALUE = \ | |
351 | aslex_create_buffer(aslexin,YY_BUF_SIZE ); \ | |
352 | } \ | |
353 | YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ | |
354 | } | |
355 | ||
356 | #define yy_set_bol(at_bol) \ | |
357 | { \ | |
358 | if ( ! YY_CURRENT_BUFFER ){\ | |
359 | aslexensure_buffer_stack (); \ | |
360 | YY_CURRENT_BUFFER_LVALUE = \ | |
361 | aslex_create_buffer(aslexin,YY_BUF_SIZE ); \ | |
362 | } \ | |
363 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ | |
364 | } | |
365 | ||
366 | #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) | |
367 | ||
368 | /* Begin user sect3 */ | |
369 | ||
370 | typedef unsigned char YY_CHAR; | |
371 | ||
372 | FILE *aslexin = (FILE *) 0, *aslexout = (FILE *) 0; | |
373 | ||
374 | typedef int yy_state_type; | |
375 | ||
376 | extern int aslexlineno; | |
377 | ||
378 | int aslexlineno = 1; | |
379 | ||
380 | extern char *aslextext; | |
381 | #define yytext_ptr aslextext | |
382 | ||
383 | static yy_state_type yy_get_previous_state (void ); | |
384 | static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); | |
385 | static int yy_get_next_buffer (void ); | |
386 | static void yy_fatal_error (yyconst char msg[] ); | |
387 | ||
388 | /* Done after the current pattern has been matched and before the | |
389 | * corresponding action - sets up aslextext. | |
390 | */ | |
391 | #define YY_DO_BEFORE_ACTION \ | |
392 | (yytext_ptr) = yy_bp; \ | |
393 | aslexleng = (size_t) (yy_cp - yy_bp); \ | |
394 | (yy_hold_char) = *yy_cp; \ | |
395 | *yy_cp = '\0'; \ | |
396 | (yy_c_buf_p) = yy_cp; | |
397 | ||
398 | #define YY_NUM_RULES 36 | |
399 | #define YY_END_OF_BUFFER 37 | |
400 | /* This struct is not used in this scanner, | |
401 | but its presence is necessary. */ | |
402 | struct yy_trans_info | |
403 | { | |
404 | flex_int32_t yy_verify; | |
405 | flex_int32_t yy_nxt; | |
406 | }; | |
407 | static yyconst flex_int16_t yy_accept[99] = | |
408 | { 0, | |
409 | 0, 0, 0, 0, 11, 11, 37, 35, 34, 12, | |
410 | 35, 7, 35, 35, 35, 33, 30, 30, 30, 35, | |
411 | 35, 35, 33, 30, 35, 30, 30, 5, 4, 5, | |
412 | 11, 9, 8, 11, 34, 0, 1, 29, 3, 0, | |
413 | 33, 30, 30, 30, 0, 2, 0, 28, 0, 33, | |
414 | 30, 30, 30, 6, 11, 10, 29, 32, 31, 21, | |
415 | 19, 30, 30, 20, 22, 27, 23, 26, 24, 25, | |
416 | 32, 31, 21, 19, 30, 30, 20, 22, 27, 23, | |
417 | 26, 24, 25, 31, 13, 15, 17, 14, 16, 18, | |
418 | 31, 13, 15, 17, 14, 16, 18, 0 | |
419 | ||
420 | } ; | |
421 | ||
422 | static yyconst flex_int32_t yy_ec[256] = | |
423 | { 0, | |
424 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, | |
425 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
426 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
427 | 1, 2, 4, 5, 6, 1, 7, 1, 1, 1, | |
428 | 1, 8, 1, 1, 1, 9, 10, 11, 12, 12, | |
429 | 12, 12, 12, 12, 12, 12, 12, 13, 1, 1, | |
430 | 1, 1, 1, 1, 14, 14, 14, 14, 14, 14, | |
431 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, | |
432 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, | |
433 | 1, 16, 1, 1, 17, 1, 18, 19, 18, 20, | |
434 | ||
435 | 18, 18, 21, 22, 21, 21, 21, 23, 21, 24, | |
436 | 21, 21, 21, 21, 25, 26, 27, 21, 28, 29, | |
437 | 21, 21, 1, 1, 1, 1, 1, 1, 1, 1, | |
438 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
439 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
440 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
441 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
442 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
443 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
444 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
445 | ||
446 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
447 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
448 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
449 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
450 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
451 | 1, 1, 1, 1, 1 | |
452 | } ; | |
453 | ||
454 | static yyconst flex_int32_t yy_meta[30] = | |
455 | { 0, | |
456 | 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, | |
457 | 3, 3, 4, 3, 5, 1, 5, 6, 6, 6, | |
458 | 7, 7, 7, 7, 7, 7, 7, 7, 7 | |
459 | } ; | |
460 | ||
461 | static yyconst flex_int16_t yy_base[110] = | |
462 | { 0, | |
463 | 0, 29, 56, 57, 58, 63, 225, 226, 222, 226, | |
464 | 220, 226, 0, 214, 192, 58, 0, 200, 192, 214, | |
465 | 0, 49, 60, 201, 200, 62, 54, 226, 226, 196, | |
466 | 0, 0, 226, 191, 182, 153, 226, 65, 226, 144, | |
467 | 72, 0, 65, 76, 151, 226, 132, 226, 95, 75, | |
468 | 123, 103, 120, 226, 0, 226, 90, 226, 0, 0, | |
469 | 0, 98, 103, 0, 0, 0, 0, 0, 0, 0, | |
470 | 122, 139, 121, 116, 124, 119, 111, 108, 106, 105, | |
471 | 99, 98, 97, 0, 0, 0, 0, 0, 0, 0, | |
472 | 0, 90, 86, 84, 80, 78, 68, 226, 159, 166, | |
473 | ||
474 | 173, 175, 180, 187, 192, 197, 204, 209, 213 | |
475 | } ; | |
476 | ||
477 | static yyconst flex_int16_t yy_def[110] = | |
478 | { 0, | |
479 | 98, 98, 99, 99, 100, 100, 98, 98, 98, 98, | |
480 | 101, 98, 102, 98, 98, 98, 103, 103, 103, 104, | |
481 | 105, 105, 105, 106, 105, 106, 106, 98, 98, 98, | |
482 | 107, 107, 98, 107, 98, 101, 98, 102, 98, 108, | |
483 | 98, 103, 103, 103, 104, 98, 105, 98, 105, 105, | |
484 | 106, 106, 106, 98, 107, 98, 98, 98, 109, 103, | |
485 | 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, | |
486 | 105, 49, 106, 106, 106, 75, 106, 106, 106, 106, | |
487 | 106, 106, 106, 109, 103, 103, 103, 103, 103, 103, | |
488 | 72, 106, 106, 106, 106, 106, 106, 0, 98, 98, | |
489 | ||
490 | 98, 98, 98, 98, 98, 98, 98, 98, 98 | |
491 | } ; | |
492 | ||
493 | static yyconst flex_int16_t yy_nxt[256] = | |
494 | { 0, | |
495 | 8, 9, 10, 11, 12, 8, 13, 8, 8, 14, | |
496 | 15, 16, 8, 17, 17, 8, 8, 17, 17, 17, | |
497 | 17, 17, 18, 17, 19, 17, 17, 17, 17, 8, | |
498 | 9, 10, 11, 12, 20, 13, 8, 21, 14, 22, | |
499 | 23, 8, 24, 24, 8, 25, 24, 24, 24, 24, | |
500 | 24, 26, 24, 27, 24, 24, 24, 24, 29, 29, | |
501 | 32, 48, 33, 30, 30, 32, 48, 33, 41, 41, | |
502 | 50, 50, 48, 34, 48, 57, 57, 49, 34, 53, | |
503 | 48, 52, 41, 41, 60, 50, 50, 48, 61, 62, | |
504 | 48, 63, 48, 64, 65, 66, 48, 67, 48, 68, | |
505 | ||
506 | 57, 57, 48, 69, 70, 71, 72, 48, 72, 48, | |
507 | 48, 48, 72, 72, 72, 48, 85, 48, 48, 86, | |
508 | 48, 88, 73, 48, 89, 87, 74, 75, 48, 76, | |
509 | 90, 77, 48, 48, 48, 48, 48, 95, 78, 79, | |
510 | 96, 80, 92, 81, 48, 93, 97, 82, 83, 91, | |
511 | 91, 94, 91, 46, 58, 37, 91, 91, 91, 28, | |
512 | 28, 28, 28, 28, 28, 28, 31, 31, 31, 31, | |
513 | 31, 31, 31, 36, 36, 36, 36, 36, 36, 36, | |
514 | 38, 38, 42, 35, 42, 42, 42, 45, 45, 45, | |
515 | 45, 45, 45, 45, 47, 56, 47, 47, 47, 51, | |
516 | ||
517 | 51, 51, 51, 51, 55, 54, 55, 55, 55, 55, | |
518 | 55, 59, 48, 48, 59, 84, 46, 44, 84, 43, | |
519 | 40, 39, 37, 35, 98, 7, 98, 98, 98, 98, | |
520 | 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, | |
521 | 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, | |
522 | 98, 98, 98, 98, 98 | |
523 | } ; | |
524 | ||
525 | static yyconst flex_int16_t yy_chk[256] = | |
526 | { 0, | |
527 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
528 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
529 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, | |
530 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
531 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
532 | 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, | |
533 | 5, 22, 5, 3, 4, 6, 27, 6, 16, 16, | |
534 | 23, 23, 23, 5, 26, 38, 38, 22, 6, 27, | |
535 | 97, 26, 41, 41, 43, 50, 50, 50, 43, 43, | |
536 | 96, 43, 95, 43, 44, 44, 94, 44, 93, 44, | |
537 | ||
538 | 57, 57, 92, 44, 44, 49, 49, 49, 49, 83, | |
539 | 82, 81, 49, 49, 49, 52, 62, 80, 79, 62, | |
540 | 78, 63, 52, 77, 63, 62, 52, 52, 74, 52, | |
541 | 63, 52, 53, 73, 71, 51, 75, 76, 53, 53, | |
542 | 76, 53, 75, 53, 47, 75, 76, 53, 53, 72, | |
543 | 72, 75, 72, 45, 40, 36, 72, 72, 72, 99, | |
544 | 99, 99, 99, 99, 99, 99, 100, 100, 100, 100, | |
545 | 100, 100, 100, 101, 101, 101, 101, 101, 101, 101, | |
546 | 102, 102, 103, 35, 103, 103, 103, 104, 104, 104, | |
547 | 104, 104, 104, 104, 105, 34, 105, 105, 105, 106, | |
548 | ||
549 | 106, 106, 106, 106, 107, 30, 107, 107, 107, 107, | |
550 | 107, 108, 25, 24, 108, 109, 20, 19, 109, 18, | |
551 | 15, 14, 11, 9, 7, 98, 98, 98, 98, 98, | |
552 | 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, | |
553 | 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, | |
554 | 98, 98, 98, 98, 98 | |
555 | } ; | |
556 | ||
557 | static yy_state_type yy_last_accepting_state; | |
558 | static char *yy_last_accepting_cpos; | |
559 | ||
560 | extern int aslex_flex_debug; | |
561 | int aslex_flex_debug = 0; | |
562 | ||
563 | /* The intent behind this definition is that it'll catch | |
564 | * any uses of REJECT which flex missed. | |
565 | */ | |
566 | #define REJECT reject_used_but_not_detected | |
567 | #define yymore() yymore_used_but_not_detected | |
568 | #define YY_MORE_ADJ 0 | |
569 | #define YY_RESTORE_YY_MORE_OFFSET | |
570 | char *aslextext; | |
571 | #line 1 "aslex.l" | |
572 | /* | |
573 | * Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
574 | * Use is subject to license terms. | |
575 | */ | |
576 | #line 7 "aslex.l" | |
577 | ||
578 | #pragma ident "@(#)aslex.l 1.2 07/02/12 SMI" | |
579 | ||
580 | #include <stdio.h> | |
581 | #include <stdlib.h> | |
582 | #include <unistd.h> | |
583 | #include <stdarg.h> | |
584 | #include <errno.h> | |
585 | #include <sys/param.h> /* for MAXPATHLEN */ | |
586 | #include <string.h> /* for strchr & strdup */ | |
587 | #include <ctype.h> /* for islower / toupper */ | |
588 | ||
589 | #include <assert.h> | |
590 | ||
591 | #include "basics.h" | |
592 | #include "internal.h" | |
593 | #include "parser.h" | |
594 | ||
595 | ||
596 | int aslexwrap(); | |
597 | ||
598 | bool_t flag_debug = false; | |
599 | ||
600 | YYLTYPE yyloc; | |
601 | yylval_t yylval; | |
602 | ||
603 | int yy_line_num; | |
604 | ||
605 | #define UOP(_t, _size) { yylval.ldst.wordsize=(_size); yylval.ldst.signext=false; return (_t); } | |
606 | #define SOP(_t, _size) { yylval.ldst.wordsize=(_size); yylval.ldst.signext=true; return (_t); } | |
607 | ||
608 | void validate_op(token_t tok, ldst_t *ldstinfop, char *namep); | |
609 | ||
610 | ||
611 | ||
612 | #line 570 "aslex.c" | |
613 | ||
614 | #define INITIAL 0 | |
615 | #define comment 1 | |
616 | #define string 2 | |
617 | ||
618 | /* Special case for "unistd.h", since it is non-ANSI. We include it way | |
619 | * down here because we want the user's section 1 to have been scanned first. | |
620 | * The user has a chance to override it with an option. | |
621 | */ | |
622 | #include <unistd.h> | |
623 | ||
624 | #ifndef YY_EXTRA_TYPE | |
625 | #define YY_EXTRA_TYPE void * | |
626 | #endif | |
627 | ||
628 | /* Macros after this point can all be overridden by user definitions in | |
629 | * section 1. | |
630 | */ | |
631 | ||
632 | #ifndef YY_SKIP_YYWRAP | |
633 | #ifdef __cplusplus | |
634 | extern "C" int aslexwrap (void ); | |
635 | #else | |
636 | extern int aslexwrap (void ); | |
637 | #endif | |
638 | #endif | |
639 | ||
640 | static void yyunput (int c,char *buf_ptr ); | |
641 | ||
642 | #ifndef yytext_ptr | |
643 | static void yy_flex_strncpy (char *,yyconst char *,int ); | |
644 | #endif | |
645 | ||
646 | #ifdef YY_NEED_STRLEN | |
647 | static int yy_flex_strlen (yyconst char * ); | |
648 | #endif | |
649 | ||
650 | #ifndef YY_NO_INPUT | |
651 | ||
652 | #ifdef __cplusplus | |
653 | static int yyinput (void ); | |
654 | #else | |
655 | static int input (void ); | |
656 | #endif | |
657 | ||
658 | #endif | |
659 | ||
660 | /* Amount of stuff to slurp up with each read. */ | |
661 | #ifndef YY_READ_BUF_SIZE | |
662 | #define YY_READ_BUF_SIZE 8192 | |
663 | #endif | |
664 | ||
665 | /* Copy whatever the last rule matched to the standard output. */ | |
666 | #ifndef ECHO | |
667 | /* This used to be an fputs(), but since the string might contain NUL's, | |
668 | * we now use fwrite(). | |
669 | */ | |
670 | #define ECHO (void) fwrite( aslextext, aslexleng, 1, aslexout ) | |
671 | #endif | |
672 | ||
673 | /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, | |
674 | * is returned in "result". | |
675 | */ | |
676 | #ifndef YY_INPUT | |
677 | #define YY_INPUT(buf,result,max_size) \ | |
678 | if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ | |
679 | { \ | |
680 | int c = '*'; \ | |
681 | size_t n; \ | |
682 | for ( n = 0; n < max_size && \ | |
683 | (c = getc( aslexin )) != EOF && c != '\n'; ++n ) \ | |
684 | buf[n] = (char) c; \ | |
685 | if ( c == '\n' ) \ | |
686 | buf[n++] = (char) c; \ | |
687 | if ( c == EOF && ferror( aslexin ) ) \ | |
688 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ | |
689 | result = n; \ | |
690 | } \ | |
691 | else \ | |
692 | { \ | |
693 | errno=0; \ | |
694 | while ( (result = fread(buf, 1, max_size, aslexin))==0 && ferror(aslexin)) \ | |
695 | { \ | |
696 | if( errno != EINTR) \ | |
697 | { \ | |
698 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ | |
699 | break; \ | |
700 | } \ | |
701 | errno=0; \ | |
702 | clearerr(aslexin); \ | |
703 | } \ | |
704 | }\ | |
705 | \ | |
706 | ||
707 | #endif | |
708 | ||
709 | /* No semi-colon after return; correct usage is to write "yyterminate();" - | |
710 | * we don't want an extra ';' after the "return" because that will cause | |
711 | * some compilers to complain about unreachable statements. | |
712 | */ | |
713 | #ifndef yyterminate | |
714 | #define yyterminate() return YY_NULL | |
715 | #endif | |
716 | ||
717 | /* Number of entries by which start-condition stack grows. */ | |
718 | #ifndef YY_START_STACK_INCR | |
719 | #define YY_START_STACK_INCR 25 | |
720 | #endif | |
721 | ||
722 | /* Report a fatal error. */ | |
723 | #ifndef YY_FATAL_ERROR | |
724 | #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) | |
725 | #endif | |
726 | ||
727 | /* end tables serialization structures and prototypes */ | |
728 | ||
729 | /* Default declaration of generated scanner - a define so the user can | |
730 | * easily add parameters. | |
731 | */ | |
732 | #ifndef YY_DECL | |
733 | #define YY_DECL_IS_OURS 1 | |
734 | ||
735 | extern int aslexlex (void); | |
736 | ||
737 | #define YY_DECL int aslexlex (void) | |
738 | #endif /* !YY_DECL */ | |
739 | ||
740 | /* Code executed at the beginning of each rule, after aslextext and aslexleng | |
741 | * have been set up. | |
742 | */ | |
743 | #ifndef YY_USER_ACTION | |
744 | #define YY_USER_ACTION | |
745 | #endif | |
746 | ||
747 | /* Code executed at the end of each rule. */ | |
748 | #ifndef YY_BREAK | |
749 | #define YY_BREAK break; | |
750 | #endif | |
751 | ||
752 | #define YY_RULE_SETUP \ | |
753 | if ( aslexleng > 0 ) \ | |
754 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ | |
755 | (aslextext[aslexleng - 1] == '\n'); \ | |
756 | YY_USER_ACTION | |
757 | ||
758 | /** The main scanner function which does all the work. | |
759 | */ | |
760 | YY_DECL | |
761 | { | |
762 | register yy_state_type yy_current_state; | |
763 | register char *yy_cp, *yy_bp; | |
764 | register int yy_act; | |
765 | ||
766 | #line 45 "aslex.l" | |
767 | ||
768 | ||
769 | #line 727 "aslex.c" | |
770 | ||
771 | if ( (yy_init) ) | |
772 | { | |
773 | (yy_init) = 0; | |
774 | ||
775 | #ifdef YY_USER_INIT | |
776 | YY_USER_INIT; | |
777 | #endif | |
778 | ||
779 | if ( ! (yy_start) ) | |
780 | (yy_start) = 1; /* first start state */ | |
781 | ||
782 | if ( ! aslexin ) | |
783 | aslexin = stdin; | |
784 | ||
785 | if ( ! aslexout ) | |
786 | aslexout = stdout; | |
787 | ||
788 | if ( ! YY_CURRENT_BUFFER ) { | |
789 | aslexensure_buffer_stack (); | |
790 | YY_CURRENT_BUFFER_LVALUE = | |
791 | aslex_create_buffer(aslexin,YY_BUF_SIZE ); | |
792 | } | |
793 | ||
794 | aslex_load_buffer_state( ); | |
795 | } | |
796 | ||
797 | while ( 1 ) /* loops until end-of-file is reached */ | |
798 | { | |
799 | yy_cp = (yy_c_buf_p); | |
800 | ||
801 | /* Support of aslextext. */ | |
802 | *yy_cp = (yy_hold_char); | |
803 | ||
804 | /* yy_bp points to the position in yy_ch_buf of the start of | |
805 | * the current run. | |
806 | */ | |
807 | yy_bp = yy_cp; | |
808 | ||
809 | yy_current_state = (yy_start); | |
810 | yy_current_state += YY_AT_BOL(); | |
811 | yy_match: | |
812 | do | |
813 | { | |
814 | register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; | |
815 | if ( yy_accept[yy_current_state] ) | |
816 | { | |
817 | (yy_last_accepting_state) = yy_current_state; | |
818 | (yy_last_accepting_cpos) = yy_cp; | |
819 | } | |
820 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | |
821 | { | |
822 | yy_current_state = (int) yy_def[yy_current_state]; | |
823 | if ( yy_current_state >= 99 ) | |
824 | yy_c = yy_meta[(unsigned int) yy_c]; | |
825 | } | |
826 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | |
827 | ++yy_cp; | |
828 | } | |
829 | while ( yy_base[yy_current_state] != 226 ); | |
830 | ||
831 | yy_find_action: | |
832 | yy_act = yy_accept[yy_current_state]; | |
833 | if ( yy_act == 0 ) | |
834 | { /* have to back up */ | |
835 | yy_cp = (yy_last_accepting_cpos); | |
836 | yy_current_state = (yy_last_accepting_state); | |
837 | yy_act = yy_accept[yy_current_state]; | |
838 | } | |
839 | ||
840 | YY_DO_BEFORE_ACTION; | |
841 | ||
842 | do_action: /* This label is used only to access EOF actions. */ | |
843 | ||
844 | switch ( yy_act ) | |
845 | { /* beginning of action switch */ | |
846 | case 0: /* must back up */ | |
847 | /* undo the effects of YY_DO_BEFORE_ACTION */ | |
848 | *yy_cp = (yy_hold_char); | |
849 | yy_cp = (yy_last_accepting_cpos); | |
850 | yy_current_state = (yy_last_accepting_state); | |
851 | goto yy_find_action; | |
852 | ||
853 | case YY_STATE_EOF(INITIAL): | |
854 | case YY_STATE_EOF(comment): | |
855 | case YY_STATE_EOF(string): | |
856 | #line 47 "aslex.l" | |
857 | { | |
858 | return T_eof; | |
859 | } | |
860 | YY_BREAK | |
861 | case 1: | |
862 | *yy_cp = (yy_hold_char); /* undo effects of setting up aslextext */ | |
863 | (yy_c_buf_p) = yy_cp -= 1; | |
864 | YY_DO_BEFORE_ACTION; /* set up aslextext again */ | |
865 | YY_RULE_SETUP | |
866 | #line 51 "aslex.l" | |
867 | { | |
868 | DBG(printf("comment: %s\n", aslextext);); | |
869 | } | |
870 | YY_BREAK | |
871 | case 2: | |
872 | *yy_cp = (yy_hold_char); /* undo effects of setting up aslextext */ | |
873 | (yy_c_buf_p) = yy_cp -= 1; | |
874 | YY_DO_BEFORE_ACTION; /* set up aslextext again */ | |
875 | YY_RULE_SETUP | |
876 | #line 55 "aslex.l" | |
877 | { | |
878 | DBG(printf("directive: %s\n", aslextext);); | |
879 | } | |
880 | YY_BREAK | |
881 | case 3: | |
882 | YY_RULE_SETUP | |
883 | #line 59 "aslex.l" | |
884 | { | |
885 | BEGIN(comment); | |
886 | DBG(printf("comment begin\n");); | |
887 | } | |
888 | YY_BREAK | |
889 | case 4: | |
890 | /* rule 4 can match eol */ | |
891 | YY_RULE_SETUP | |
892 | #line 64 "aslex.l" | |
893 | { | |
894 | yy_line_num++; | |
895 | } | |
896 | YY_BREAK | |
897 | case 5: | |
898 | YY_RULE_SETUP | |
899 | #line 68 "aslex.l" | |
900 | /* swallow */ | |
901 | YY_BREAK | |
902 | case 6: | |
903 | YY_RULE_SETUP | |
904 | #line 70 "aslex.l" | |
905 | { | |
906 | BEGIN(INITIAL); | |
907 | DBG(printf("comment end\n");); | |
908 | } | |
909 | YY_BREAK | |
910 | case 7: | |
911 | YY_RULE_SETUP | |
912 | #line 75 "aslex.l" | |
913 | { | |
914 | BEGIN(string); | |
915 | DBG(printf("string begin\n");); | |
916 | } | |
917 | YY_BREAK | |
918 | case 8: | |
919 | YY_RULE_SETUP | |
920 | #line 80 "aslex.l" | |
921 | { | |
922 | BEGIN(INITIAL); | |
923 | DBG(printf("string end\n");); | |
924 | yylval.namep = NULL; /* dont care for now */ | |
925 | return T_string; | |
926 | } | |
927 | YY_BREAK | |
928 | case 9: | |
929 | /* rule 9 can match eol */ | |
930 | YY_RULE_SETUP | |
931 | #line 87 "aslex.l" | |
932 | { | |
933 | yy_line_num++; | |
934 | } | |
935 | YY_BREAK | |
936 | case 10: | |
937 | YY_RULE_SETUP | |
938 | #line 91 "aslex.l" | |
939 | { /* escaped quote is part of string */ } | |
940 | YY_BREAK | |
941 | case 11: | |
942 | /* rule 11 can match eol */ | |
943 | YY_RULE_SETUP | |
944 | #line 93 "aslex.l" | |
945 | { /* swallow for now */ } | |
946 | YY_BREAK | |
947 | case 12: | |
948 | /* rule 12 can match eol */ | |
949 | YY_RULE_SETUP | |
950 | #line 96 "aslex.l" | |
951 | { | |
952 | yyloc.first_line = | |
953 | yyloc.last_line = ++yy_line_num; | |
954 | return T_nl; | |
955 | } | |
956 | YY_BREAK | |
957 | case 13: | |
958 | YY_RULE_SETUP | |
959 | #line 102 "aslex.l" | |
960 | { SOP(T_load, 1); } | |
961 | YY_BREAK | |
962 | case 14: | |
963 | YY_RULE_SETUP | |
964 | #line 104 "aslex.l" | |
965 | { UOP(T_load, 1); } | |
966 | YY_BREAK | |
967 | case 15: | |
968 | YY_RULE_SETUP | |
969 | #line 106 "aslex.l" | |
970 | { SOP(T_load, 2); } | |
971 | YY_BREAK | |
972 | case 16: | |
973 | YY_RULE_SETUP | |
974 | #line 108 "aslex.l" | |
975 | { UOP(T_load, 2); } | |
976 | YY_BREAK | |
977 | case 17: | |
978 | YY_RULE_SETUP | |
979 | #line 110 "aslex.l" | |
980 | { SOP(T_load, 4); } | |
981 | YY_BREAK | |
982 | case 18: | |
983 | YY_RULE_SETUP | |
984 | #line 112 "aslex.l" | |
985 | { UOP(T_load, 4); } | |
986 | YY_BREAK | |
987 | case 19: | |
988 | YY_RULE_SETUP | |
989 | #line 114 "aslex.l" | |
990 | { UOP(T_load, 8); } | |
991 | YY_BREAK | |
992 | case 20: | |
993 | YY_RULE_SETUP | |
994 | #line 116 "aslex.l" | |
995 | { UOP(T_load, 8); } | |
996 | YY_BREAK | |
997 | case 21: | |
998 | YY_RULE_SETUP | |
999 | #line 118 "aslex.l" | |
1000 | { UOP(T_load, 16); } | |
1001 | YY_BREAK | |
1002 | case 22: | |
1003 | YY_RULE_SETUP | |
1004 | #line 120 "aslex.l" | |
1005 | { UOP(T_store, 1); } | |
1006 | YY_BREAK | |
1007 | case 23: | |
1008 | YY_RULE_SETUP | |
1009 | #line 122 "aslex.l" | |
1010 | { UOP(T_store, 2); } | |
1011 | YY_BREAK | |
1012 | case 24: | |
1013 | YY_RULE_SETUP | |
1014 | #line 124 "aslex.l" | |
1015 | { UOP(T_store, 4); } | |
1016 | YY_BREAK | |
1017 | case 25: | |
1018 | YY_RULE_SETUP | |
1019 | #line 126 "aslex.l" | |
1020 | { UOP(T_store, 8); } | |
1021 | YY_BREAK | |
1022 | case 26: | |
1023 | YY_RULE_SETUP | |
1024 | #line 128 "aslex.l" | |
1025 | { UOP(T_store, 8); } | |
1026 | YY_BREAK | |
1027 | case 27: | |
1028 | YY_RULE_SETUP | |
1029 | #line 130 "aslex.l" | |
1030 | { UOP(T_store, 16); } | |
1031 | YY_BREAK | |
1032 | case 28: | |
1033 | YY_RULE_SETUP | |
1034 | #line 132 "aslex.l" | |
1035 | { | |
1036 | yylval.namep = strdup(aslextext); | |
1037 | return T_labeldef; | |
1038 | } | |
1039 | YY_BREAK | |
1040 | case 29: | |
1041 | YY_RULE_SETUP | |
1042 | #line 137 "aslex.l" | |
1043 | { | |
1044 | yylval.namep = strdup(aslextext); | |
1045 | return T_register; | |
1046 | } | |
1047 | YY_BREAK | |
1048 | case 30: | |
1049 | YY_RULE_SETUP | |
1050 | #line 142 "aslex.l" | |
1051 | { | |
1052 | yylval.namep = strdup(aslextext); | |
1053 | return T_name; | |
1054 | } | |
1055 | YY_BREAK | |
1056 | case 31: | |
1057 | YY_RULE_SETUP | |
1058 | #line 147 "aslex.l" | |
1059 | { | |
1060 | uint64_t val; | |
1061 | val = strtoull(aslextext, NULL, 16); | |
1062 | yylval.val = val; | |
1063 | return T_number; | |
1064 | } | |
1065 | YY_BREAK | |
1066 | case 32: | |
1067 | YY_RULE_SETUP | |
1068 | #line 154 "aslex.l" | |
1069 | { | |
1070 | yylval.val = 0; | |
1071 | return T_number; | |
1072 | } | |
1073 | YY_BREAK | |
1074 | case 33: | |
1075 | YY_RULE_SETUP | |
1076 | #line 159 "aslex.l" | |
1077 | { | |
1078 | uint64_t val; | |
1079 | val = strtoull(aslextext, NULL, 10); | |
1080 | yylval.val = val; | |
1081 | return T_number; | |
1082 | } | |
1083 | YY_BREAK | |
1084 | case 34: | |
1085 | YY_RULE_SETUP | |
1086 | #line 167 "aslex.l" | |
1087 | { /* swallow */ } | |
1088 | YY_BREAK | |
1089 | case 35: | |
1090 | YY_RULE_SETUP | |
1091 | #line 169 "aslex.l" | |
1092 | return aslextext[0] ; | |
1093 | YY_BREAK | |
1094 | case 36: | |
1095 | YY_RULE_SETUP | |
1096 | #line 171 "aslex.l" | |
1097 | ECHO; | |
1098 | YY_BREAK | |
1099 | #line 1057 "aslex.c" | |
1100 | ||
1101 | case YY_END_OF_BUFFER: | |
1102 | { | |
1103 | /* Amount of text matched not including the EOB char. */ | |
1104 | int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; | |
1105 | ||
1106 | /* Undo the effects of YY_DO_BEFORE_ACTION. */ | |
1107 | *yy_cp = (yy_hold_char); | |
1108 | YY_RESTORE_YY_MORE_OFFSET | |
1109 | ||
1110 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) | |
1111 | { | |
1112 | /* We're scanning a new file or input source. It's | |
1113 | * possible that this happened because the user | |
1114 | * just pointed aslexin at a new source and called | |
1115 | * aslexlex(). If so, then we have to assure | |
1116 | * consistency between YY_CURRENT_BUFFER and our | |
1117 | * globals. Here is the right place to do so, because | |
1118 | * this is the first action (other than possibly a | |
1119 | * back-up) that will match for the new input source. | |
1120 | */ | |
1121 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; | |
1122 | YY_CURRENT_BUFFER_LVALUE->yy_input_file = aslexin; | |
1123 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; | |
1124 | } | |
1125 | ||
1126 | /* Note that here we test for yy_c_buf_p "<=" to the position | |
1127 | * of the first EOB in the buffer, since yy_c_buf_p will | |
1128 | * already have been incremented past the NUL character | |
1129 | * (since all states make transitions on EOB to the | |
1130 | * end-of-buffer state). Contrast this with the test | |
1131 | * in input(). | |
1132 | */ | |
1133 | if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) | |
1134 | { /* This was really a NUL. */ | |
1135 | yy_state_type yy_next_state; | |
1136 | ||
1137 | (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; | |
1138 | ||
1139 | yy_current_state = yy_get_previous_state( ); | |
1140 | ||
1141 | /* Okay, we're now positioned to make the NUL | |
1142 | * transition. We couldn't have | |
1143 | * yy_get_previous_state() go ahead and do it | |
1144 | * for us because it doesn't know how to deal | |
1145 | * with the possibility of jamming (and we don't | |
1146 | * want to build jamming into it because then it | |
1147 | * will run more slowly). | |
1148 | */ | |
1149 | ||
1150 | yy_next_state = yy_try_NUL_trans( yy_current_state ); | |
1151 | ||
1152 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | |
1153 | ||
1154 | if ( yy_next_state ) | |
1155 | { | |
1156 | /* Consume the NUL. */ | |
1157 | yy_cp = ++(yy_c_buf_p); | |
1158 | yy_current_state = yy_next_state; | |
1159 | goto yy_match; | |
1160 | } | |
1161 | ||
1162 | else | |
1163 | { | |
1164 | yy_cp = (yy_c_buf_p); | |
1165 | goto yy_find_action; | |
1166 | } | |
1167 | } | |
1168 | ||
1169 | else switch ( yy_get_next_buffer( ) ) | |
1170 | { | |
1171 | case EOB_ACT_END_OF_FILE: | |
1172 | { | |
1173 | (yy_did_buffer_switch_on_eof) = 0; | |
1174 | ||
1175 | if ( aslexwrap( ) ) | |
1176 | { | |
1177 | /* Note: because we've taken care in | |
1178 | * yy_get_next_buffer() to have set up | |
1179 | * aslextext, we can now set up | |
1180 | * yy_c_buf_p so that if some total | |
1181 | * hoser (like flex itself) wants to | |
1182 | * call the scanner after we return the | |
1183 | * YY_NULL, it'll still work - another | |
1184 | * YY_NULL will get returned. | |
1185 | */ | |
1186 | (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; | |
1187 | ||
1188 | yy_act = YY_STATE_EOF(YY_START); | |
1189 | goto do_action; | |
1190 | } | |
1191 | ||
1192 | else | |
1193 | { | |
1194 | if ( ! (yy_did_buffer_switch_on_eof) ) | |
1195 | YY_NEW_FILE; | |
1196 | } | |
1197 | break; | |
1198 | } | |
1199 | ||
1200 | case EOB_ACT_CONTINUE_SCAN: | |
1201 | (yy_c_buf_p) = | |
1202 | (yytext_ptr) + yy_amount_of_matched_text; | |
1203 | ||
1204 | yy_current_state = yy_get_previous_state( ); | |
1205 | ||
1206 | yy_cp = (yy_c_buf_p); | |
1207 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | |
1208 | goto yy_match; | |
1209 | ||
1210 | case EOB_ACT_LAST_MATCH: | |
1211 | (yy_c_buf_p) = | |
1212 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; | |
1213 | ||
1214 | yy_current_state = yy_get_previous_state( ); | |
1215 | ||
1216 | yy_cp = (yy_c_buf_p); | |
1217 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | |
1218 | goto yy_find_action; | |
1219 | } | |
1220 | break; | |
1221 | } | |
1222 | ||
1223 | default: | |
1224 | YY_FATAL_ERROR( | |
1225 | "fatal flex scanner internal error--no action found" ); | |
1226 | } /* end of action switch */ | |
1227 | } /* end of scanning one token */ | |
1228 | } /* end of aslexlex */ | |
1229 | ||
1230 | /* yy_get_next_buffer - try to read in a new buffer | |
1231 | * | |
1232 | * Returns a code representing an action: | |
1233 | * EOB_ACT_LAST_MATCH - | |
1234 | * EOB_ACT_CONTINUE_SCAN - continue scanning from current position | |
1235 | * EOB_ACT_END_OF_FILE - end of file | |
1236 | */ | |
1237 | static int yy_get_next_buffer (void) | |
1238 | { | |
1239 | register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; | |
1240 | register char *source = (yytext_ptr); | |
1241 | register int number_to_move, i; | |
1242 | int ret_val; | |
1243 | ||
1244 | if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) | |
1245 | YY_FATAL_ERROR( | |
1246 | "fatal flex scanner internal error--end of buffer missed" ); | |
1247 | ||
1248 | if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) | |
1249 | { /* Don't try to fill the buffer, so this is an EOF. */ | |
1250 | if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) | |
1251 | { | |
1252 | /* We matched a single character, the EOB, so | |
1253 | * treat this as a final EOF. | |
1254 | */ | |
1255 | return EOB_ACT_END_OF_FILE; | |
1256 | } | |
1257 | ||
1258 | else | |
1259 | { | |
1260 | /* We matched some text prior to the EOB, first | |
1261 | * process it. | |
1262 | */ | |
1263 | return EOB_ACT_LAST_MATCH; | |
1264 | } | |
1265 | } | |
1266 | ||
1267 | /* Try to read more data. */ | |
1268 | ||
1269 | /* First move last chars to start of buffer. */ | |
1270 | number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; | |
1271 | ||
1272 | for ( i = 0; i < number_to_move; ++i ) | |
1273 | *(dest++) = *(source++); | |
1274 | ||
1275 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) | |
1276 | /* don't do the read, it's not guaranteed to return an EOF, | |
1277 | * just force an EOF | |
1278 | */ | |
1279 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; | |
1280 | ||
1281 | else | |
1282 | { | |
1283 | size_t num_to_read = | |
1284 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; | |
1285 | ||
1286 | while ( num_to_read <= 0 ) | |
1287 | { /* Not enough room in the buffer - grow it. */ | |
1288 | ||
1289 | /* just a shorter name for the current buffer */ | |
1290 | YY_BUFFER_STATE b = YY_CURRENT_BUFFER; | |
1291 | ||
1292 | int yy_c_buf_p_offset = | |
1293 | (int) ((yy_c_buf_p) - b->yy_ch_buf); | |
1294 | ||
1295 | if ( b->yy_is_our_buffer ) | |
1296 | { | |
1297 | int new_size = b->yy_buf_size * 2; | |
1298 | ||
1299 | if ( new_size <= 0 ) | |
1300 | b->yy_buf_size += b->yy_buf_size / 8; | |
1301 | else | |
1302 | b->yy_buf_size *= 2; | |
1303 | ||
1304 | b->yy_ch_buf = (char *) | |
1305 | /* Include room in for 2 EOB chars. */ | |
1306 | aslexrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); | |
1307 | } | |
1308 | else | |
1309 | /* Can't grow it, we don't own it. */ | |
1310 | b->yy_ch_buf = 0; | |
1311 | ||
1312 | if ( ! b->yy_ch_buf ) | |
1313 | YY_FATAL_ERROR( | |
1314 | "fatal error - scanner input buffer overflow" ); | |
1315 | ||
1316 | (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; | |
1317 | ||
1318 | num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - | |
1319 | number_to_move - 1; | |
1320 | ||
1321 | } | |
1322 | ||
1323 | if ( num_to_read > YY_READ_BUF_SIZE ) | |
1324 | num_to_read = YY_READ_BUF_SIZE; | |
1325 | ||
1326 | /* Read in more data. */ | |
1327 | YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), | |
1328 | (yy_n_chars), num_to_read ); | |
1329 | ||
1330 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | |
1331 | } | |
1332 | ||
1333 | if ( (yy_n_chars) == 0 ) | |
1334 | { | |
1335 | if ( number_to_move == YY_MORE_ADJ ) | |
1336 | { | |
1337 | ret_val = EOB_ACT_END_OF_FILE; | |
1338 | aslexrestart(aslexin ); | |
1339 | } | |
1340 | ||
1341 | else | |
1342 | { | |
1343 | ret_val = EOB_ACT_LAST_MATCH; | |
1344 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = | |
1345 | YY_BUFFER_EOF_PENDING; | |
1346 | } | |
1347 | } | |
1348 | ||
1349 | else | |
1350 | ret_val = EOB_ACT_CONTINUE_SCAN; | |
1351 | ||
1352 | (yy_n_chars) += number_to_move; | |
1353 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; | |
1354 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; | |
1355 | ||
1356 | (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; | |
1357 | ||
1358 | return ret_val; | |
1359 | } | |
1360 | ||
1361 | /* yy_get_previous_state - get the state just before the EOB char was reached */ | |
1362 | ||
1363 | static yy_state_type yy_get_previous_state (void) | |
1364 | { | |
1365 | register yy_state_type yy_current_state; | |
1366 | register char *yy_cp; | |
1367 | ||
1368 | yy_current_state = (yy_start); | |
1369 | yy_current_state += YY_AT_BOL(); | |
1370 | ||
1371 | for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) | |
1372 | { | |
1373 | register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); | |
1374 | if ( yy_accept[yy_current_state] ) | |
1375 | { | |
1376 | (yy_last_accepting_state) = yy_current_state; | |
1377 | (yy_last_accepting_cpos) = yy_cp; | |
1378 | } | |
1379 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | |
1380 | { | |
1381 | yy_current_state = (int) yy_def[yy_current_state]; | |
1382 | if ( yy_current_state >= 99 ) | |
1383 | yy_c = yy_meta[(unsigned int) yy_c]; | |
1384 | } | |
1385 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | |
1386 | } | |
1387 | ||
1388 | return yy_current_state; | |
1389 | } | |
1390 | ||
1391 | /* yy_try_NUL_trans - try to make a transition on the NUL character | |
1392 | * | |
1393 | * synopsis | |
1394 | * next_state = yy_try_NUL_trans( current_state ); | |
1395 | */ | |
1396 | static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) | |
1397 | { | |
1398 | register int yy_is_jam; | |
1399 | register char *yy_cp = (yy_c_buf_p); | |
1400 | ||
1401 | register YY_CHAR yy_c = 1; | |
1402 | if ( yy_accept[yy_current_state] ) | |
1403 | { | |
1404 | (yy_last_accepting_state) = yy_current_state; | |
1405 | (yy_last_accepting_cpos) = yy_cp; | |
1406 | } | |
1407 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | |
1408 | { | |
1409 | yy_current_state = (int) yy_def[yy_current_state]; | |
1410 | if ( yy_current_state >= 99 ) | |
1411 | yy_c = yy_meta[(unsigned int) yy_c]; | |
1412 | } | |
1413 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | |
1414 | yy_is_jam = (yy_current_state == 98); | |
1415 | ||
1416 | return yy_is_jam ? 0 : yy_current_state; | |
1417 | } | |
1418 | ||
1419 | static void yyunput (int c, register char * yy_bp ) | |
1420 | { | |
1421 | register char *yy_cp; | |
1422 | ||
1423 | yy_cp = (yy_c_buf_p); | |
1424 | ||
1425 | /* undo effects of setting up aslextext */ | |
1426 | *yy_cp = (yy_hold_char); | |
1427 | ||
1428 | if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) | |
1429 | { /* need to shift things up to make room */ | |
1430 | /* +2 for EOB chars. */ | |
1431 | register int number_to_move = (yy_n_chars) + 2; | |
1432 | register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ | |
1433 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; | |
1434 | register char *source = | |
1435 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; | |
1436 | ||
1437 | while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) | |
1438 | *--dest = *--source; | |
1439 | ||
1440 | yy_cp += (int) (dest - source); | |
1441 | yy_bp += (int) (dest - source); | |
1442 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = | |
1443 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; | |
1444 | ||
1445 | if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) | |
1446 | YY_FATAL_ERROR( "flex scanner push-back overflow" ); | |
1447 | } | |
1448 | ||
1449 | *--yy_cp = (char) c; | |
1450 | ||
1451 | (yytext_ptr) = yy_bp; | |
1452 | (yy_hold_char) = *yy_cp; | |
1453 | (yy_c_buf_p) = yy_cp; | |
1454 | } | |
1455 | ||
1456 | #ifndef YY_NO_INPUT | |
1457 | #ifdef __cplusplus | |
1458 | static int yyinput (void) | |
1459 | #else | |
1460 | static int input (void) | |
1461 | #endif | |
1462 | ||
1463 | { | |
1464 | int c; | |
1465 | ||
1466 | *(yy_c_buf_p) = (yy_hold_char); | |
1467 | ||
1468 | if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) | |
1469 | { | |
1470 | /* yy_c_buf_p now points to the character we want to return. | |
1471 | * If this occurs *before* the EOB characters, then it's a | |
1472 | * valid NUL; if not, then we've hit the end of the buffer. | |
1473 | */ | |
1474 | if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) | |
1475 | /* This was really a NUL. */ | |
1476 | *(yy_c_buf_p) = '\0'; | |
1477 | ||
1478 | else | |
1479 | { /* need more input */ | |
1480 | int offset = (yy_c_buf_p) - (yytext_ptr); | |
1481 | ++(yy_c_buf_p); | |
1482 | ||
1483 | switch ( yy_get_next_buffer( ) ) | |
1484 | { | |
1485 | case EOB_ACT_LAST_MATCH: | |
1486 | /* This happens because yy_g_n_b() | |
1487 | * sees that we've accumulated a | |
1488 | * token and flags that we need to | |
1489 | * try matching the token before | |
1490 | * proceeding. But for input(), | |
1491 | * there's no matching to consider. | |
1492 | * So convert the EOB_ACT_LAST_MATCH | |
1493 | * to EOB_ACT_END_OF_FILE. | |
1494 | */ | |
1495 | ||
1496 | /* Reset buffer status. */ | |
1497 | aslexrestart(aslexin ); | |
1498 | ||
1499 | /*FALLTHROUGH*/ | |
1500 | ||
1501 | case EOB_ACT_END_OF_FILE: | |
1502 | { | |
1503 | if ( aslexwrap( ) ) | |
1504 | return EOF; | |
1505 | ||
1506 | if ( ! (yy_did_buffer_switch_on_eof) ) | |
1507 | YY_NEW_FILE; | |
1508 | #ifdef __cplusplus | |
1509 | return yyinput(); | |
1510 | #else | |
1511 | return input(); | |
1512 | #endif | |
1513 | } | |
1514 | ||
1515 | case EOB_ACT_CONTINUE_SCAN: | |
1516 | (yy_c_buf_p) = (yytext_ptr) + offset; | |
1517 | break; | |
1518 | } | |
1519 | } | |
1520 | } | |
1521 | ||
1522 | c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ | |
1523 | *(yy_c_buf_p) = '\0'; /* preserve aslextext */ | |
1524 | (yy_hold_char) = *++(yy_c_buf_p); | |
1525 | ||
1526 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); | |
1527 | ||
1528 | return c; | |
1529 | } | |
1530 | #endif /* ifndef YY_NO_INPUT */ | |
1531 | ||
1532 | /** Immediately switch to a different input stream. | |
1533 | * @param input_file A readable stream. | |
1534 | * | |
1535 | * @note This function does not reset the start condition to @c INITIAL . | |
1536 | */ | |
1537 | void aslexrestart (FILE * input_file ) | |
1538 | { | |
1539 | ||
1540 | if ( ! YY_CURRENT_BUFFER ){ | |
1541 | aslexensure_buffer_stack (); | |
1542 | YY_CURRENT_BUFFER_LVALUE = | |
1543 | aslex_create_buffer(aslexin,YY_BUF_SIZE ); | |
1544 | } | |
1545 | ||
1546 | aslex_init_buffer(YY_CURRENT_BUFFER,input_file ); | |
1547 | aslex_load_buffer_state( ); | |
1548 | } | |
1549 | ||
1550 | /** Switch to a different input buffer. | |
1551 | * @param new_buffer The new input buffer. | |
1552 | * | |
1553 | */ | |
1554 | void aslex_switch_to_buffer (YY_BUFFER_STATE new_buffer ) | |
1555 | { | |
1556 | ||
1557 | /* TODO. We should be able to replace this entire function body | |
1558 | * with | |
1559 | * aslexpop_buffer_state(); | |
1560 | * aslexpush_buffer_state(new_buffer); | |
1561 | */ | |
1562 | aslexensure_buffer_stack (); | |
1563 | if ( YY_CURRENT_BUFFER == new_buffer ) | |
1564 | return; | |
1565 | ||
1566 | if ( YY_CURRENT_BUFFER ) | |
1567 | { | |
1568 | /* Flush out information for old buffer. */ | |
1569 | *(yy_c_buf_p) = (yy_hold_char); | |
1570 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); | |
1571 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | |
1572 | } | |
1573 | ||
1574 | YY_CURRENT_BUFFER_LVALUE = new_buffer; | |
1575 | aslex_load_buffer_state( ); | |
1576 | ||
1577 | /* We don't actually know whether we did this switch during | |
1578 | * EOF (aslexwrap()) processing, but the only time this flag | |
1579 | * is looked at is after aslexwrap() is called, so it's safe | |
1580 | * to go ahead and always set it. | |
1581 | */ | |
1582 | (yy_did_buffer_switch_on_eof) = 1; | |
1583 | } | |
1584 | ||
1585 | static void aslex_load_buffer_state (void) | |
1586 | { | |
1587 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; | |
1588 | (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; | |
1589 | aslexin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; | |
1590 | (yy_hold_char) = *(yy_c_buf_p); | |
1591 | } | |
1592 | ||
1593 | /** Allocate and initialize an input buffer state. | |
1594 | * @param file A readable stream. | |
1595 | * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. | |
1596 | * | |
1597 | * @return the allocated buffer state. | |
1598 | */ | |
1599 | YY_BUFFER_STATE aslex_create_buffer (FILE * file, int size ) | |
1600 | { | |
1601 | YY_BUFFER_STATE b; | |
1602 | ||
1603 | b = (YY_BUFFER_STATE) aslexalloc(sizeof( struct yy_buffer_state ) ); | |
1604 | if ( ! b ) | |
1605 | YY_FATAL_ERROR( "out of dynamic memory in aslex_create_buffer()" ); | |
1606 | ||
1607 | b->yy_buf_size = size; | |
1608 | ||
1609 | /* yy_ch_buf has to be 2 characters longer than the size given because | |
1610 | * we need to put in 2 end-of-buffer characters. | |
1611 | */ | |
1612 | b->yy_ch_buf = (char *) aslexalloc(b->yy_buf_size + 2 ); | |
1613 | if ( ! b->yy_ch_buf ) | |
1614 | YY_FATAL_ERROR( "out of dynamic memory in aslex_create_buffer()" ); | |
1615 | ||
1616 | b->yy_is_our_buffer = 1; | |
1617 | ||
1618 | aslex_init_buffer(b,file ); | |
1619 | ||
1620 | return b; | |
1621 | } | |
1622 | ||
1623 | /** Destroy the buffer. | |
1624 | * @param b a buffer created with aslex_create_buffer() | |
1625 | * | |
1626 | */ | |
1627 | void aslex_delete_buffer (YY_BUFFER_STATE b ) | |
1628 | { | |
1629 | ||
1630 | if ( ! b ) | |
1631 | return; | |
1632 | ||
1633 | if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ | |
1634 | YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; | |
1635 | ||
1636 | if ( b->yy_is_our_buffer ) | |
1637 | aslexfree((void *) b->yy_ch_buf ); | |
1638 | ||
1639 | aslexfree((void *) b ); | |
1640 | } | |
1641 | ||
1642 | #ifndef __cplusplus | |
1643 | extern int isatty (int ); | |
1644 | #endif /* __cplusplus */ | |
1645 | ||
1646 | /* Initializes or reinitializes a buffer. | |
1647 | * This function is sometimes called more than once on the same buffer, | |
1648 | * such as during a aslexrestart() or at EOF. | |
1649 | */ | |
1650 | static void aslex_init_buffer (YY_BUFFER_STATE b, FILE * file ) | |
1651 | ||
1652 | { | |
1653 | int oerrno = errno; | |
1654 | ||
1655 | aslex_flush_buffer(b ); | |
1656 | ||
1657 | b->yy_input_file = file; | |
1658 | b->yy_fill_buffer = 1; | |
1659 | ||
1660 | /* If b is the current buffer, then aslex_init_buffer was _probably_ | |
1661 | * called from aslexrestart() or through yy_get_next_buffer. | |
1662 | * In that case, we don't want to reset the lineno or column. | |
1663 | */ | |
1664 | if (b != YY_CURRENT_BUFFER){ | |
1665 | b->yy_bs_lineno = 1; | |
1666 | b->yy_bs_column = 0; | |
1667 | } | |
1668 | ||
1669 | b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; | |
1670 | ||
1671 | errno = oerrno; | |
1672 | } | |
1673 | ||
1674 | /** Discard all buffered characters. On the next scan, YY_INPUT will be called. | |
1675 | * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. | |
1676 | * | |
1677 | */ | |
1678 | void aslex_flush_buffer (YY_BUFFER_STATE b ) | |
1679 | { | |
1680 | if ( ! b ) | |
1681 | return; | |
1682 | ||
1683 | b->yy_n_chars = 0; | |
1684 | ||
1685 | /* We always need two end-of-buffer characters. The first causes | |
1686 | * a transition to the end-of-buffer state. The second causes | |
1687 | * a jam in that state. | |
1688 | */ | |
1689 | b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; | |
1690 | b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; | |
1691 | ||
1692 | b->yy_buf_pos = &b->yy_ch_buf[0]; | |
1693 | ||
1694 | b->yy_at_bol = 1; | |
1695 | b->yy_buffer_status = YY_BUFFER_NEW; | |
1696 | ||
1697 | if ( b == YY_CURRENT_BUFFER ) | |
1698 | aslex_load_buffer_state( ); | |
1699 | } | |
1700 | ||
1701 | /** Pushes the new state onto the stack. The new state becomes | |
1702 | * the current state. This function will allocate the stack | |
1703 | * if necessary. | |
1704 | * @param new_buffer The new state. | |
1705 | * | |
1706 | */ | |
1707 | void aslexpush_buffer_state (YY_BUFFER_STATE new_buffer ) | |
1708 | { | |
1709 | if (new_buffer == NULL) | |
1710 | return; | |
1711 | ||
1712 | aslexensure_buffer_stack(); | |
1713 | ||
1714 | /* This block is copied from aslex_switch_to_buffer. */ | |
1715 | if ( YY_CURRENT_BUFFER ) | |
1716 | { | |
1717 | /* Flush out information for old buffer. */ | |
1718 | *(yy_c_buf_p) = (yy_hold_char); | |
1719 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); | |
1720 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | |
1721 | } | |
1722 | ||
1723 | /* Only push if top exists. Otherwise, replace top. */ | |
1724 | if (YY_CURRENT_BUFFER) | |
1725 | (yy_buffer_stack_top)++; | |
1726 | YY_CURRENT_BUFFER_LVALUE = new_buffer; | |
1727 | ||
1728 | /* copied from aslex_switch_to_buffer. */ | |
1729 | aslex_load_buffer_state( ); | |
1730 | (yy_did_buffer_switch_on_eof) = 1; | |
1731 | } | |
1732 | ||
1733 | /** Removes and deletes the top of the stack, if present. | |
1734 | * The next element becomes the new top. | |
1735 | * | |
1736 | */ | |
1737 | void aslexpop_buffer_state (void) | |
1738 | { | |
1739 | if (!YY_CURRENT_BUFFER) | |
1740 | return; | |
1741 | ||
1742 | aslex_delete_buffer(YY_CURRENT_BUFFER ); | |
1743 | YY_CURRENT_BUFFER_LVALUE = NULL; | |
1744 | if ((yy_buffer_stack_top) > 0) | |
1745 | --(yy_buffer_stack_top); | |
1746 | ||
1747 | if (YY_CURRENT_BUFFER) { | |
1748 | aslex_load_buffer_state( ); | |
1749 | (yy_did_buffer_switch_on_eof) = 1; | |
1750 | } | |
1751 | } | |
1752 | ||
1753 | /* Allocates the stack if it does not exist. | |
1754 | * Guarantees space for at least one push. | |
1755 | */ | |
1756 | static void aslexensure_buffer_stack (void) | |
1757 | { | |
1758 | int num_to_alloc; | |
1759 | ||
1760 | if (!(yy_buffer_stack)) { | |
1761 | ||
1762 | /* First allocation is just for 2 elements, since we don't know if this | |
1763 | * scanner will even need a stack. We use 2 instead of 1 to avoid an | |
1764 | * immediate realloc on the next call. | |
1765 | */ | |
1766 | num_to_alloc = 1; | |
1767 | (yy_buffer_stack) = (struct yy_buffer_state**)aslexalloc | |
1768 | (num_to_alloc * sizeof(struct yy_buffer_state*) | |
1769 | ); | |
1770 | ||
1771 | memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); | |
1772 | ||
1773 | (yy_buffer_stack_max) = num_to_alloc; | |
1774 | (yy_buffer_stack_top) = 0; | |
1775 | return; | |
1776 | } | |
1777 | ||
1778 | if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ | |
1779 | ||
1780 | /* Increase the buffer to prepare for a possible push. */ | |
1781 | int grow_size = 8 /* arbitrary grow size */; | |
1782 | ||
1783 | num_to_alloc = (yy_buffer_stack_max) + grow_size; | |
1784 | (yy_buffer_stack) = (struct yy_buffer_state**)aslexrealloc | |
1785 | ((yy_buffer_stack), | |
1786 | num_to_alloc * sizeof(struct yy_buffer_state*) | |
1787 | ); | |
1788 | ||
1789 | /* zero only the new slots.*/ | |
1790 | memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); | |
1791 | (yy_buffer_stack_max) = num_to_alloc; | |
1792 | } | |
1793 | } | |
1794 | ||
1795 | /** Setup the input buffer state to scan directly from a user-specified character buffer. | |
1796 | * @param base the character buffer | |
1797 | * @param size the size in bytes of the character buffer | |
1798 | * | |
1799 | * @return the newly allocated buffer state object. | |
1800 | */ | |
1801 | YY_BUFFER_STATE aslex_scan_buffer (char * base, yy_size_t size ) | |
1802 | { | |
1803 | YY_BUFFER_STATE b; | |
1804 | ||
1805 | if ( size < 2 || | |
1806 | base[size-2] != YY_END_OF_BUFFER_CHAR || | |
1807 | base[size-1] != YY_END_OF_BUFFER_CHAR ) | |
1808 | /* They forgot to leave room for the EOB's. */ | |
1809 | return 0; | |
1810 | ||
1811 | b = (YY_BUFFER_STATE) aslexalloc(sizeof( struct yy_buffer_state ) ); | |
1812 | if ( ! b ) | |
1813 | YY_FATAL_ERROR( "out of dynamic memory in aslex_scan_buffer()" ); | |
1814 | ||
1815 | b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ | |
1816 | b->yy_buf_pos = b->yy_ch_buf = base; | |
1817 | b->yy_is_our_buffer = 0; | |
1818 | b->yy_input_file = 0; | |
1819 | b->yy_n_chars = b->yy_buf_size; | |
1820 | b->yy_is_interactive = 0; | |
1821 | b->yy_at_bol = 1; | |
1822 | b->yy_fill_buffer = 0; | |
1823 | b->yy_buffer_status = YY_BUFFER_NEW; | |
1824 | ||
1825 | aslex_switch_to_buffer(b ); | |
1826 | ||
1827 | return b; | |
1828 | } | |
1829 | ||
1830 | /** Setup the input buffer state to scan a string. The next call to aslexlex() will | |
1831 | * scan from a @e copy of @a str. | |
1832 | * @param str a NUL-terminated string to scan | |
1833 | * | |
1834 | * @return the newly allocated buffer state object. | |
1835 | * @note If you want to scan bytes that may contain NUL values, then use | |
1836 | * aslex_scan_bytes() instead. | |
1837 | */ | |
1838 | YY_BUFFER_STATE aslex_scan_string (yyconst char * str ) | |
1839 | { | |
1840 | ||
1841 | return aslex_scan_bytes(str,strlen(str) ); | |
1842 | } | |
1843 | ||
1844 | /** Setup the input buffer state to scan the given bytes. The next call to aslexlex() will | |
1845 | * scan from a @e copy of @a bytes. | |
1846 | * @param bytes the byte buffer to scan | |
1847 | * @param len the number of bytes in the buffer pointed to by @a bytes. | |
1848 | * | |
1849 | * @return the newly allocated buffer state object. | |
1850 | */ | |
1851 | YY_BUFFER_STATE aslex_scan_bytes (yyconst char * bytes, int len ) | |
1852 | { | |
1853 | YY_BUFFER_STATE b; | |
1854 | char *buf; | |
1855 | yy_size_t n; | |
1856 | int i; | |
1857 | ||
1858 | /* Get memory for full buffer, including space for trailing EOB's. */ | |
1859 | n = len + 2; | |
1860 | buf = (char *) aslexalloc(n ); | |
1861 | if ( ! buf ) | |
1862 | YY_FATAL_ERROR( "out of dynamic memory in aslex_scan_bytes()" ); | |
1863 | ||
1864 | for ( i = 0; i < len; ++i ) | |
1865 | buf[i] = bytes[i]; | |
1866 | ||
1867 | buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; | |
1868 | ||
1869 | b = aslex_scan_buffer(buf,n ); | |
1870 | if ( ! b ) | |
1871 | YY_FATAL_ERROR( "bad buffer in aslex_scan_bytes()" ); | |
1872 | ||
1873 | /* It's okay to grow etc. this buffer, and we should throw it | |
1874 | * away when we're done. | |
1875 | */ | |
1876 | b->yy_is_our_buffer = 1; | |
1877 | ||
1878 | return b; | |
1879 | } | |
1880 | ||
1881 | #ifndef YY_EXIT_FAILURE | |
1882 | #define YY_EXIT_FAILURE 2 | |
1883 | #endif | |
1884 | ||
1885 | static void yy_fatal_error (yyconst char* msg ) | |
1886 | { | |
1887 | (void) fprintf( stderr, "%s\n", msg ); | |
1888 | exit( YY_EXIT_FAILURE ); | |
1889 | } | |
1890 | ||
1891 | /* Redefine yyless() so it works in section 3 code. */ | |
1892 | ||
1893 | #undef yyless | |
1894 | #define yyless(n) \ | |
1895 | do \ | |
1896 | { \ | |
1897 | /* Undo effects of setting up aslextext. */ \ | |
1898 | int yyless_macro_arg = (n); \ | |
1899 | YY_LESS_LINENO(yyless_macro_arg);\ | |
1900 | aslextext[aslexleng] = (yy_hold_char); \ | |
1901 | (yy_c_buf_p) = aslextext + yyless_macro_arg; \ | |
1902 | (yy_hold_char) = *(yy_c_buf_p); \ | |
1903 | *(yy_c_buf_p) = '\0'; \ | |
1904 | aslexleng = yyless_macro_arg; \ | |
1905 | } \ | |
1906 | while ( 0 ) | |
1907 | ||
1908 | /* Accessor methods (get/set functions) to struct members. */ | |
1909 | ||
1910 | /** Get the current line number. | |
1911 | * | |
1912 | */ | |
1913 | int aslexget_lineno (void) | |
1914 | { | |
1915 | ||
1916 | return aslexlineno; | |
1917 | } | |
1918 | ||
1919 | /** Get the input stream. | |
1920 | * | |
1921 | */ | |
1922 | FILE *aslexget_in (void) | |
1923 | { | |
1924 | return aslexin; | |
1925 | } | |
1926 | ||
1927 | /** Get the output stream. | |
1928 | * | |
1929 | */ | |
1930 | FILE *aslexget_out (void) | |
1931 | { | |
1932 | return aslexout; | |
1933 | } | |
1934 | ||
1935 | /** Get the length of the current token. | |
1936 | * | |
1937 | */ | |
1938 | int aslexget_leng (void) | |
1939 | { | |
1940 | return aslexleng; | |
1941 | } | |
1942 | ||
1943 | /** Get the current token. | |
1944 | * | |
1945 | */ | |
1946 | ||
1947 | char *aslexget_text (void) | |
1948 | { | |
1949 | return aslextext; | |
1950 | } | |
1951 | ||
1952 | /** Set the current line number. | |
1953 | * @param line_number | |
1954 | * | |
1955 | */ | |
1956 | void aslexset_lineno (int line_number ) | |
1957 | { | |
1958 | ||
1959 | aslexlineno = line_number; | |
1960 | } | |
1961 | ||
1962 | /** Set the input stream. This does not discard the current | |
1963 | * input buffer. | |
1964 | * @param in_str A readable stream. | |
1965 | * | |
1966 | * @see aslex_switch_to_buffer | |
1967 | */ | |
1968 | void aslexset_in (FILE * in_str ) | |
1969 | { | |
1970 | aslexin = in_str ; | |
1971 | } | |
1972 | ||
1973 | void aslexset_out (FILE * out_str ) | |
1974 | { | |
1975 | aslexout = out_str ; | |
1976 | } | |
1977 | ||
1978 | int aslexget_debug (void) | |
1979 | { | |
1980 | return aslex_flex_debug; | |
1981 | } | |
1982 | ||
1983 | void aslexset_debug (int bdebug ) | |
1984 | { | |
1985 | aslex_flex_debug = bdebug ; | |
1986 | } | |
1987 | ||
1988 | /* aslexlex_destroy is for both reentrant and non-reentrant scanners. */ | |
1989 | int aslexlex_destroy (void) | |
1990 | { | |
1991 | ||
1992 | /* Pop the buffer stack, destroying each element. */ | |
1993 | while(YY_CURRENT_BUFFER){ | |
1994 | aslex_delete_buffer(YY_CURRENT_BUFFER ); | |
1995 | YY_CURRENT_BUFFER_LVALUE = NULL; | |
1996 | aslexpop_buffer_state(); | |
1997 | } | |
1998 | ||
1999 | /* Destroy the stack itself. */ | |
2000 | aslexfree((yy_buffer_stack) ); | |
2001 | (yy_buffer_stack) = NULL; | |
2002 | ||
2003 | return 0; | |
2004 | } | |
2005 | ||
2006 | /* | |
2007 | * Internal utility routines. | |
2008 | */ | |
2009 | ||
2010 | #ifndef yytext_ptr | |
2011 | static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) | |
2012 | { | |
2013 | register int i; | |
2014 | for ( i = 0; i < n; ++i ) | |
2015 | s1[i] = s2[i]; | |
2016 | } | |
2017 | #endif | |
2018 | ||
2019 | #ifdef YY_NEED_STRLEN | |
2020 | static int yy_flex_strlen (yyconst char * s ) | |
2021 | { | |
2022 | register int n; | |
2023 | for ( n = 0; s[n]; ++n ) | |
2024 | ; | |
2025 | ||
2026 | return n; | |
2027 | } | |
2028 | #endif | |
2029 | ||
2030 | void *aslexalloc (yy_size_t size ) | |
2031 | { | |
2032 | return (void *) malloc( size ); | |
2033 | } | |
2034 | ||
2035 | void *aslexrealloc (void * ptr, yy_size_t size ) | |
2036 | { | |
2037 | /* The cast to (char *) in the following accommodates both | |
2038 | * implementations that use char* generic pointers, and those | |
2039 | * that use void* generic pointers. It works with the latter | |
2040 | * because both ANSI C and C++ allow castless assignment from | |
2041 | * any pointer type to void*, and deal with argument conversions | |
2042 | * as though doing an assignment. | |
2043 | */ | |
2044 | return (void *) realloc( (char *) ptr, size ); | |
2045 | } | |
2046 | ||
2047 | void aslexfree (void * ptr ) | |
2048 | { | |
2049 | free( (char *) ptr ); /* see aslexrealloc() for (char *) cast */ | |
2050 | } | |
2051 | ||
2052 | #define YYTABLES_NAME "yytables" | |
2053 | ||
2054 | #undef YY_NEW_FILE | |
2055 | #undef YY_FLUSH_BUFFER | |
2056 | #undef yy_set_bol | |
2057 | #undef yy_new_buffer | |
2058 | #undef yy_set_interactive | |
2059 | #undef yytext_ptr | |
2060 | #undef YY_DO_BEFORE_ACTION | |
2061 | ||
2062 | #ifdef YY_DECL_IS_OURS | |
2063 | #undef YY_DECL_IS_OURS | |
2064 | #undef YY_DECL | |
2065 | #endif | |
2066 | #line 171 "aslex.l" | |
2067 | ||
2068 | ||
2069 | ||
2070 | ||
2071 | ||
2072 | ||
2073 | ||
2074 | ||
2075 | int aslexwrap() | |
2076 | { | |
2077 | return 1; | |
2078 | } | |
2079 | ||
2080 | ||
2081 | void yyerror(char *strp) | |
2082 | { | |
2083 | fprintf(stderr,"error @ line %d: %s\n", | |
2084 | yyloc.first_line, | |
2085 | strp); | |
2086 | exit(1); | |
2087 | } | |
2088 | ||
2089 | ||
2090 | static char *tok_to_str(int tok) | |
2091 | { | |
2092 | static char buf[2]; | |
2093 | char * s; | |
2094 | ||
2095 | if (tok<256) { | |
2096 | buf[0]=tok; | |
2097 | buf[1]='\0'; | |
2098 | return (char*)buf; | |
2099 | } | |
2100 | #define T(_t) case _t : s = #_t; break; | |
2101 | switch(tok) { | |
2102 | T(T_nl); | |
2103 | T(T_name); | |
2104 | T(T_labeldef); | |
2105 | T(T_register); | |
2106 | T(T_number); | |
2107 | T(T_string); | |
2108 | T(T_load); | |
2109 | T(T_store); | |
2110 | T(T_cas); | |
2111 | default: s = "unknown"; | |
2112 | } | |
2113 | #undef T | |
2114 | return s; | |
2115 | } | |
2116 | ||
2117 | token_t get_token() | |
2118 | { | |
2119 | token_t tok; | |
2120 | ||
2121 | tok = aslexlex(); | |
2122 | ||
2123 | DBG( printf("Line %d : token %d : %s", | |
2124 | yyloc.first_line, tok, tok_to_str(tok)); | |
2125 | switch(tok) { | |
2126 | case T_eof: printf("END OF FILE"); break; | |
2127 | case T_name: printf(" : %s", yylval.namep); break; | |
2128 | case T_labeldef: printf(" : %s", yylval.namep); break; | |
2129 | case T_register: printf(" : %s", yylval.namep); break; | |
2130 | case T_number: printf(" : 0x%llx", yylval.val); break; | |
2131 | case T_cas: | |
2132 | case T_store: | |
2133 | case T_load: printf(" : %s : bytes=%d", | |
2134 | yylval.ldst.signext ? "s" : "u", yylval.ldst.wordsize); | |
2135 | break; | |
2136 | default: | |
2137 | break; | |
2138 | } | |
2139 | printf("\n"); | |
2140 | ); | |
2141 | ||
2142 | return tok; | |
2143 | } | |
2144 | ||
2145 | ||
2146 | void free_yyval(token_t tok) | |
2147 | { | |
2148 | switch (tok) { | |
2149 | case T_name: | |
2150 | case T_labeldef: | |
2151 | case T_register: | |
2152 | free(yylval.namep); | |
2153 | yylval.namep = NULL; | |
2154 | break; | |
2155 | default: | |
2156 | break; | |
2157 | } | |
2158 | } | |
2159 | ||
2160 | ||
2161 | /* | |
2162 | * Ultra simple parser to pull out only load or store instructions | |
2163 | * that fit a very basic template. | |
2164 | */ | |
2165 | ||
2166 | void lex_only() | |
2167 | { | |
2168 | token_t tok, ldsttok, tok_left, tok_right; | |
2169 | char *tok_left_ptr, *tok_right_ptr; | |
2170 | ldst_t ldstinfo; | |
2171 | ||
2172 | while ((tok = get_token())!=T_eof) { | |
2173 | DBG( printf("Start line with token %d\n", tok); ); | |
2174 | if (tok == T_nl) { | |
2175 | continue; | |
2176 | } | |
2177 | ||
2178 | /* | |
2179 | * Look for a load or store at the beginning of a line. | |
2180 | * if not found - swallow the line and move to the next. | |
2181 | * A line may also be allowed to have an initial label def. | |
2182 | */ | |
2183 | if (tok == T_labeldef) { | |
2184 | free_yyval(tok); | |
2185 | tok = get_token(); | |
2186 | if (tok==T_eof) break; | |
2187 | if (tok == T_nl) continue; | |
2188 | } | |
2189 | ||
2190 | DBG( printf("look for memop %d\n", tok); ); | |
2191 | ||
2192 | tok_left = -1; | |
2193 | tok_right = -1; | |
2194 | tok_left_ptr = NULL; | |
2195 | tok_right_ptr = NULL; | |
2196 | ||
2197 | if (tok != T_load && tok != T_store) goto swallow; | |
2198 | ||
2199 | ldsttok = tok; | |
2200 | ldstinfo = yylval.ldst; | |
2201 | ||
2202 | if (tok == T_store) goto handle_store; | |
2203 | DBG( printf("Handle load\n"); ); | |
2204 | ||
2205 | tok = get_token(); | |
2206 | if (tok != '[') goto swallow; | |
2207 | ||
2208 | tok = get_token(); | |
2209 | if (tok != T_register && tok != T_name && tok != T_number) goto swallow; | |
2210 | tok_left = tok; | |
2211 | tok_left_ptr = yylval.namep; | |
2212 | ||
2213 | /* only want a + b forms */ | |
2214 | tok = get_token(); | |
2215 | if (tok != '+') goto cleanup; | |
2216 | ||
2217 | tok = get_token(); | |
2218 | if (tok != T_register && tok != T_name && tok != T_number) goto cleanup; | |
2219 | tok_right = tok; | |
2220 | tok_right_ptr = yylval.namep; | |
2221 | ||
2222 | tok = get_token(); | |
2223 | if (tok != ']') goto cleanup; | |
2224 | ||
2225 | DBG( printf("Load accepted\n"); ); | |
2226 | ||
2227 | goto sanity_check; | |
2228 | ||
2229 | ||
2230 | ||
2231 | ||
2232 | handle_store:; | |
2233 | DBG( printf("Handle store\n");); | |
2234 | ||
2235 | tok = get_token(); | |
2236 | if (tok != T_register) goto swallow; | |
2237 | ||
2238 | tok = get_token(); | |
2239 | if (tok != ',') goto swallow; | |
2240 | ||
2241 | tok = get_token(); | |
2242 | if (tok != '[') goto swallow; | |
2243 | ||
2244 | tok = get_token(); | |
2245 | if (tok != T_register && tok != T_name && tok != T_number) goto swallow; | |
2246 | tok_left = tok; | |
2247 | tok_left_ptr = yylval.namep; | |
2248 | ||
2249 | /* only want a + b forms */ | |
2250 | tok = get_token(); | |
2251 | if (tok != '+') goto cleanup; | |
2252 | ||
2253 | tok = get_token(); | |
2254 | if (tok != T_register && tok != T_name && tok != T_number) goto cleanup; | |
2255 | tok_right = tok; | |
2256 | tok_right_ptr = yylval.namep; | |
2257 | ||
2258 | tok = get_token(); | |
2259 | if (tok != ']') goto cleanup; | |
2260 | ||
2261 | DBG( printf("Store accepted\n"); ); | |
2262 | ||
2263 | goto sanity_check; | |
2264 | ||
2265 | ||
2266 | ||
2267 | /* | |
2268 | * Finally the check we care about ... | |
2269 | */ | |
2270 | ||
2271 | sanity_check:; | |
2272 | /* | |
2273 | * The load/store operands can be given in any order - | |
2274 | * register + offset or offset + register ... so to make things easier | |
2275 | * if we find one form we swap the paramaters to give us the other. | |
2276 | */ | |
2277 | ||
2278 | /* one side must have a name for us to check */ | |
2279 | ||
2280 | if (tok_left != T_name && tok_right != T_name) goto cleanup; | |
2281 | ||
2282 | /* | |
2283 | * if both sides are a name - we bail since there is likely more than one type | |
2284 | * for us to have to sanity check .. i.e. %g3 + BASE_OFSET + FOOBAR | |
2285 | */ | |
2286 | if (tok_left == T_name && tok_right == T_name) goto cleanup; | |
2287 | ||
2288 | /* now for the switch over */ | |
2289 | ||
2290 | if (tok_left == T_name) { | |
2291 | token_t temptok; | |
2292 | char *tempptr; | |
2293 | ||
2294 | temptok = tok_left; | |
2295 | tempptr = tok_left_ptr; | |
2296 | tok_left = tok_right; | |
2297 | tok_left_ptr = tok_right_ptr; | |
2298 | tok_right = temptok; | |
2299 | tok_right_ptr = tempptr; | |
2300 | } | |
2301 | ||
2302 | /* finally something we can validate ... */ | |
2303 | ||
2304 | DBG( printf("Validation of name %s\n", tok_right_ptr); ); | |
2305 | ||
2306 | validate_op(ldsttok, &ldstinfo, tok_right_ptr); | |
2307 | ||
2308 | goto cleanup; | |
2309 | ||
2310 | ||
2311 | cleanup:; | |
2312 | if (tok_left == T_name || tok_left == T_register) { | |
2313 | free(tok_left_ptr); | |
2314 | } | |
2315 | if (tok_left == T_name || tok_left == T_register) { | |
2316 | free(tok_left_ptr); | |
2317 | } | |
2318 | goto swallow; | |
2319 | ||
2320 | swallow_loop:; | |
2321 | tok = get_token(); | |
2322 | if (tok==T_eof) break; | |
2323 | swallow:; | |
2324 | free_yyval(tok); | |
2325 | if (tok!=T_nl) goto swallow_loop; | |
2326 | } | |
2327 | } | |
2328 | ||
2329 | ||
2330 | ||
2331 | ||
2332 | void validate_op(token_t ldsttok, ldst_t *ldstinfop, char *namep) | |
2333 | { | |
2334 | symbol_t *symp; | |
2335 | ||
2336 | symp = hash_find(namep); | |
2337 | if (symp == NULL) { | |
2338 | if (!flag_suppress_unknowns) { | |
2339 | fprintf(stderr,"%s:%d : Warning: unknown symbol \'%s\' for memop\n", | |
2340 | yyloc.fnamep, yyloc.first_line, namep); | |
2341 | warning_count++; | |
2342 | } | |
2343 | return; | |
2344 | } | |
2345 | ||
2346 | /* Compare sizes */ | |
2347 | if (symp->size != ldstinfop->wordsize) { | |
2348 | fprintf(stderr,"%s:%d : Warning: access size mismatch using symbol \'%s\'\n", | |
2349 | yyloc.fnamep, yyloc.first_line, namep); | |
2350 | fprintf(stderr,"\tAccess uses %d byte memop, but should be a %d byte memop\n", | |
2351 | ldstinfop->wordsize, symp->size); | |
2352 | warning_count++; | |
2353 | } | |
2354 | ||
2355 | /* if its a load compare sign extension */ | |
2356 | ||
2357 | if (ldsttok == T_load) { | |
2358 | if (ldstinfop->signext && ((symp->flags & Sym_unsigned)!=0)) { | |
2359 | fprintf(stderr,"%s:%d : Warning: sign extension mismatch for symbol \'%s\'\n", | |
2360 | yyloc.fnamep, yyloc.first_line, namep); | |
2361 | fprintf(stderr,"\tAccess uses signed memop, but should be unsigned\n"); | |
2362 | warning_count++; | |
2363 | } else | |
2364 | if (!ldstinfop->signext && ((symp->flags & Sym_signed)!=0)) { | |
2365 | fprintf(stderr,"%s:%d : Warning: sign extension mismatch for symbol \'%s\'\n", | |
2366 | yyloc.fnamep, yyloc.first_line, namep); | |
2367 | fprintf(stderr,"\tAccess uses unsigned memop, but should be signed\n"); | |
2368 | warning_count++; | |
2369 | } | |
2370 | } | |
2371 | } | |
2372 |