Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * Hypervisor Software File: mdlex.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 "mdlex.c" | |
45 | ||
46 | #line 4 "mdlex.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 mdlexrestart(mdlexin ) | |
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 mdlexleng; | |
187 | ||
188 | extern FILE *mdlexin, *mdlexout; | |
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 mdlextext. */ \ | |
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 mdlextext 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 mdlexrestart()), so that the user can continue scanning by | |
280 | * just pointing mdlexin 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 mdlextext is formed. */ | |
308 | static char yy_hold_char; | |
309 | static int yy_n_chars; /* number of characters read into yy_ch_buf */ | |
310 | int mdlexleng; | |
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 mdlexwrap()'s to do buffer switches | |
318 | * instead of setting up a fresh mdlexin. A bit of a hack ... | |
319 | */ | |
320 | static int yy_did_buffer_switch_on_eof; | |
321 | ||
322 | void mdlexrestart (FILE *input_file ); | |
323 | void mdlex_switch_to_buffer (YY_BUFFER_STATE new_buffer ); | |
324 | YY_BUFFER_STATE mdlex_create_buffer (FILE *file,int size ); | |
325 | void mdlex_delete_buffer (YY_BUFFER_STATE b ); | |
326 | void mdlex_flush_buffer (YY_BUFFER_STATE b ); | |
327 | void mdlexpush_buffer_state (YY_BUFFER_STATE new_buffer ); | |
328 | void mdlexpop_buffer_state (void ); | |
329 | ||
330 | static void mdlexensure_buffer_stack (void ); | |
331 | static void mdlex_load_buffer_state (void ); | |
332 | static void mdlex_init_buffer (YY_BUFFER_STATE b,FILE *file ); | |
333 | ||
334 | #define YY_FLUSH_BUFFER mdlex_flush_buffer(YY_CURRENT_BUFFER ) | |
335 | ||
336 | YY_BUFFER_STATE mdlex_scan_buffer (char *base,yy_size_t size ); | |
337 | YY_BUFFER_STATE mdlex_scan_string (yyconst char *yy_str ); | |
338 | YY_BUFFER_STATE mdlex_scan_bytes (yyconst char *bytes,int len ); | |
339 | ||
340 | void *mdlexalloc (yy_size_t ); | |
341 | void *mdlexrealloc (void *,yy_size_t ); | |
342 | void mdlexfree (void * ); | |
343 | ||
344 | #define yy_new_buffer mdlex_create_buffer | |
345 | ||
346 | #define yy_set_interactive(is_interactive) \ | |
347 | { \ | |
348 | if ( ! YY_CURRENT_BUFFER ){ \ | |
349 | mdlexensure_buffer_stack (); \ | |
350 | YY_CURRENT_BUFFER_LVALUE = \ | |
351 | mdlex_create_buffer(mdlexin,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 | mdlexensure_buffer_stack (); \ | |
360 | YY_CURRENT_BUFFER_LVALUE = \ | |
361 | mdlex_create_buffer(mdlexin,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 *mdlexin = (FILE *) 0, *mdlexout = (FILE *) 0; | |
373 | ||
374 | typedef int yy_state_type; | |
375 | ||
376 | extern int mdlexlineno; | |
377 | ||
378 | int mdlexlineno = 1; | |
379 | ||
380 | extern char *mdlextext; | |
381 | #define yytext_ptr mdlextext | |
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 mdlextext. | |
390 | */ | |
391 | #define YY_DO_BEFORE_ACTION \ | |
392 | (yytext_ptr) = yy_bp; \ | |
393 | mdlexleng = (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 48 | |
399 | #define YY_END_OF_BUFFER 49 | |
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[109] = | |
408 | { 0, | |
409 | 45, 45, 0, 0, 0, 0, 49, 47, 45, 46, | |
410 | 26, 43, 9, 21, 3, 7, 6, 4, 8, 47, | |
411 | 41, 41, 5, 47, 14, 16, 15, 11, 43, 43, | |
412 | 43, 43, 43, 43, 1, 10, 2, 12, 43, 48, | |
413 | 37, 28, 27, 48, 45, 43, 42, 42, 25, 44, | |
414 | 40, 0, 41, 13, 43, 43, 43, 43, 43, 43, | |
415 | 0, 37, 36, 29, 30, 34, 35, 31, 33, 32, | |
416 | 42, 44, 38, 38, 39, 43, 43, 43, 43, 43, | |
417 | 43, 0, 17, 29, 30, 38, 38, 39, 43, 43, | |
418 | 43, 18, 43, 43, 29, 22, 43, 43, 19, 43, | |
419 | ||
420 | 43, 43, 43, 20, 23, 43, 24, 0 | |
421 | } ; | |
422 | ||
423 | static yyconst flex_int32_t yy_ec[256] = | |
424 | { 0, | |
425 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, | |
426 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
427 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
428 | 1, 2, 1, 4, 5, 6, 1, 7, 1, 8, | |
429 | 9, 10, 11, 12, 13, 1, 14, 15, 16, 16, | |
430 | 16, 16, 16, 16, 16, 17, 17, 1, 18, 19, | |
431 | 20, 21, 6, 1, 22, 22, 22, 22, 22, 22, | |
432 | 23, 6, 6, 6, 23, 6, 23, 6, 6, 6, | |
433 | 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, | |
434 | 24, 25, 26, 27, 6, 1, 28, 29, 30, 31, | |
435 | ||
436 | 32, 33, 23, 6, 34, 6, 35, 36, 23, 37, | |
437 | 38, 39, 6, 40, 41, 42, 43, 6, 6, 44, | |
438 | 6, 6, 45, 46, 47, 48, 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 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
446 | ||
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, 1, 1, 1, 1, 1, | |
452 | 1, 1, 1, 1, 1 | |
453 | } ; | |
454 | ||
455 | static yyconst flex_int32_t yy_meta[49] = | |
456 | { 0, | |
457 | 1, 1, 2, 3, 4, 4, 1, 1, 1, 1, | |
458 | 1, 1, 4, 1, 5, 5, 5, 1, 1, 1, | |
459 | 1, 5, 4, 1, 3, 1, 1, 5, 5, 5, | |
460 | 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, | |
461 | 4, 4, 4, 4, 1, 1, 1, 1 | |
462 | } ; | |
463 | ||
464 | static yyconst flex_int16_t yy_base[118] = | |
465 | { 0, | |
466 | 0, 187, 0, 0, 46, 48, 191, 193, 188, 193, | |
467 | 193, 0, 193, 193, 193, 193, 193, 193, 38, 175, | |
468 | 33, 46, 193, 169, 193, 193, 193, 193, 143, 149, | |
469 | 147, 146, 143, 150, 193, 193, 193, 193, 179, 193, | |
470 | 0, 193, 193, 67, 178, 0, 193, 49, 193, 0, | |
471 | 193, 63, 71, 193, 140, 148, 139, 145, 137, 132, | |
472 | 170, 0, 193, 59, 74, 193, 193, 193, 193, 193, | |
473 | 82, 0, 86, 95, 150, 131, 134, 134, 136, 125, | |
474 | 119, 146, 193, 98, 103, 106, 109, 126, 122, 86, | |
475 | 84, 0, 78, 65, 117, 193, 64, 54, 0, 54, | |
476 | ||
477 | 40, 62, 28, 0, 193, 52, 193, 193, 134, 139, | |
478 | 141, 146, 151, 156, 53, 161, 52 | |
479 | } ; | |
480 | ||
481 | static yyconst flex_int16_t yy_def[118] = | |
482 | { 0, | |
483 | 108, 1, 109, 109, 110, 110, 108, 108, 108, 108, | |
484 | 108, 111, 108, 108, 108, 108, 108, 108, 108, 108, | |
485 | 108, 108, 108, 108, 108, 108, 108, 108, 111, 111, | |
486 | 111, 111, 111, 111, 108, 108, 108, 108, 111, 108, | |
487 | 112, 108, 108, 113, 108, 111, 108, 108, 108, 114, | |
488 | 108, 115, 108, 108, 111, 111, 111, 111, 111, 111, | |
489 | 116, 112, 108, 108, 108, 108, 108, 108, 108, 108, | |
490 | 108, 114, 117, 108, 117, 111, 111, 111, 111, 111, | |
491 | 111, 116, 108, 108, 108, 117, 108, 117, 111, 111, | |
492 | 111, 111, 111, 111, 108, 108, 111, 111, 111, 111, | |
493 | ||
494 | 111, 111, 111, 111, 108, 111, 108, 0, 108, 108, | |
495 | 108, 108, 108, 108, 108, 108, 108 | |
496 | } ; | |
497 | ||
498 | static yyconst flex_int16_t yy_nxt[242] = | |
499 | { 0, | |
500 | 8, 9, 10, 11, 12, 12, 13, 14, 15, 16, | |
501 | 17, 18, 19, 20, 21, 22, 22, 23, 24, 25, | |
502 | 8, 12, 12, 26, 8, 27, 28, 12, 12, 12, | |
503 | 12, 29, 12, 30, 12, 31, 32, 12, 33, 12, | |
504 | 34, 12, 12, 12, 35, 36, 37, 38, 42, 43, | |
505 | 42, 43, 47, 48, 48, 51, 88, 75, 49, 107, | |
506 | 53, 53, 53, 71, 71, 71, 106, 51, 51, 105, | |
507 | 44, 104, 44, 84, 84, 85, 52, 73, 73, 73, | |
508 | 51, 64, 64, 65, 74, 53, 53, 53, 85, 85, | |
509 | 85, 103, 102, 51, 101, 66, 71, 71, 71, 67, | |
510 | ||
511 | 86, 86, 86, 68, 100, 51, 69, 87, 70, 87, | |
512 | 87, 87, 95, 95, 85, 99, 87, 85, 85, 85, | |
513 | 86, 86, 86, 87, 87, 87, 98, 87, 97, 96, | |
514 | 87, 85, 85, 85, 40, 40, 40, 40, 40, 41, | |
515 | 41, 41, 41, 41, 46, 46, 62, 108, 83, 62, | |
516 | 62, 63, 63, 63, 63, 63, 72, 94, 72, 72, | |
517 | 72, 82, 82, 82, 82, 82, 93, 92, 91, 90, | |
518 | 89, 108, 83, 81, 80, 79, 78, 77, 76, 45, | |
519 | 61, 60, 59, 58, 57, 56, 55, 54, 50, 45, | |
520 | 108, 39, 7, 108, 108, 108, 108, 108, 108, 108, | |
521 | ||
522 | 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, | |
523 | 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, | |
524 | 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, | |
525 | 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, | |
526 | 108 | |
527 | } ; | |
528 | ||
529 | static yyconst flex_int16_t yy_chk[242] = | |
530 | { 0, | |
531 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
532 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
533 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
534 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
535 | 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, | |
536 | 6, 6, 19, 19, 19, 21, 117, 115, 19, 106, | |
537 | 22, 22, 22, 48, 48, 48, 103, 21, 22, 102, | |
538 | 5, 101, 6, 64, 64, 64, 21, 52, 52, 52, | |
539 | 22, 44, 44, 44, 52, 53, 53, 53, 65, 65, | |
540 | 65, 100, 98, 53, 97, 44, 71, 71, 71, 44, | |
541 | ||
542 | 73, 73, 73, 44, 94, 53, 44, 73, 44, 74, | |
543 | 74, 74, 84, 84, 84, 93, 74, 85, 85, 85, | |
544 | 86, 86, 86, 87, 87, 87, 91, 86, 90, 89, | |
545 | 87, 95, 95, 95, 109, 109, 109, 109, 109, 110, | |
546 | 110, 110, 110, 110, 111, 111, 112, 88, 82, 112, | |
547 | 112, 113, 113, 113, 113, 113, 114, 81, 114, 114, | |
548 | 114, 116, 116, 116, 116, 116, 80, 79, 78, 77, | |
549 | 76, 75, 61, 60, 59, 58, 57, 56, 55, 45, | |
550 | 39, 34, 33, 32, 31, 30, 29, 24, 20, 9, | |
551 | 7, 2, 108, 108, 108, 108, 108, 108, 108, 108, | |
552 | ||
553 | 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, | |
554 | 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, | |
555 | 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, | |
556 | 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, | |
557 | 108 | |
558 | } ; | |
559 | ||
560 | static yy_state_type yy_last_accepting_state; | |
561 | static char *yy_last_accepting_cpos; | |
562 | ||
563 | extern int mdlex_flex_debug; | |
564 | int mdlex_flex_debug = 0; | |
565 | ||
566 | /* The intent behind this definition is that it'll catch | |
567 | * any uses of REJECT which flex missed. | |
568 | */ | |
569 | #define REJECT reject_used_but_not_detected | |
570 | #define yymore() yymore_used_but_not_detected | |
571 | #define YY_MORE_ADJ 0 | |
572 | #define YY_RESTORE_YY_MORE_OFFSET | |
573 | char *mdlextext; | |
574 | #line 1 "mdlex.l" | |
575 | /* | |
576 | * Copyright 2005 Sun Microsystems, Inc. All rights reserved. | |
577 | * Use is subject to license terms. | |
578 | */ | |
579 | #line 8 "mdlex.l" | |
580 | ||
581 | #pragma ident "@(#)mdlex.l 1.3 05/11/03 SMI" | |
582 | ||
583 | /* any C includes here */ | |
584 | #include <stdio.h> | |
585 | #include <stdlib.h> | |
586 | #include <unistd.h> | |
587 | #include <string.h> | |
588 | #include <stdarg.h> | |
589 | #include <errno.h> | |
590 | ||
591 | #include "basics.h" | |
592 | #include "allocate.h" | |
593 | #include "lexer.h" | |
594 | #include "fatal.h" | |
595 | ||
596 | lexer_t lex; /* additional return value info */ | |
597 | #define MAX_STR_LEN (1024+1) | |
598 | static struct { | |
599 | char base[MAX_STR_LEN]; | |
600 | char * ptr; | |
601 | } sbuffer; | |
602 | ||
603 | #if TESTRIG /* { */ | |
604 | #include <stdarg.h> | |
605 | #include <errno.h> | |
606 | void fatal(char *s,...); | |
607 | #endif /* } */ | |
608 | ||
609 | #define SBUFFER_INS(_c) do { \ | |
610 | if ((sbuffer.ptr - sbuffer.base)>=MAX_STR_LEN) \ | |
611 | lex_fatal("Parse string too long - maximum is %d characters", MAX_STR_LEN); \ | |
612 | *sbuffer.ptr++ = (_c); \ | |
613 | } while(0) | |
614 | ||
615 | ||
616 | #line 574 "mdlex.c" | |
617 | ||
618 | #define INITIAL 0 | |
619 | #define comment 1 | |
620 | #define string 2 | |
621 | ||
622 | /* Special case for "unistd.h", since it is non-ANSI. We include it way | |
623 | * down here because we want the user's section 1 to have been scanned first. | |
624 | * The user has a chance to override it with an option. | |
625 | */ | |
626 | #include <unistd.h> | |
627 | ||
628 | #ifndef YY_EXTRA_TYPE | |
629 | #define YY_EXTRA_TYPE void * | |
630 | #endif | |
631 | ||
632 | /* Macros after this point can all be overridden by user definitions in | |
633 | * section 1. | |
634 | */ | |
635 | ||
636 | #ifndef YY_SKIP_YYWRAP | |
637 | #ifdef __cplusplus | |
638 | extern "C" int mdlexwrap (void ); | |
639 | #else | |
640 | extern int mdlexwrap (void ); | |
641 | #endif | |
642 | #endif | |
643 | ||
644 | static void yyunput (int c,char *buf_ptr ); | |
645 | ||
646 | #ifndef yytext_ptr | |
647 | static void yy_flex_strncpy (char *,yyconst char *,int ); | |
648 | #endif | |
649 | ||
650 | #ifdef YY_NEED_STRLEN | |
651 | static int yy_flex_strlen (yyconst char * ); | |
652 | #endif | |
653 | ||
654 | #ifndef YY_NO_INPUT | |
655 | ||
656 | #ifdef __cplusplus | |
657 | static int yyinput (void ); | |
658 | #else | |
659 | static int input (void ); | |
660 | #endif | |
661 | ||
662 | #endif | |
663 | ||
664 | /* Amount of stuff to slurp up with each read. */ | |
665 | #ifndef YY_READ_BUF_SIZE | |
666 | #define YY_READ_BUF_SIZE 8192 | |
667 | #endif | |
668 | ||
669 | /* Copy whatever the last rule matched to the standard output. */ | |
670 | #ifndef ECHO | |
671 | /* This used to be an fputs(), but since the string might contain NUL's, | |
672 | * we now use fwrite(). | |
673 | */ | |
674 | #define ECHO (void) fwrite( mdlextext, mdlexleng, 1, mdlexout ) | |
675 | #endif | |
676 | ||
677 | /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, | |
678 | * is returned in "result". | |
679 | */ | |
680 | #ifndef YY_INPUT | |
681 | #define YY_INPUT(buf,result,max_size) \ | |
682 | if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ | |
683 | { \ | |
684 | int c = '*'; \ | |
685 | size_t n; \ | |
686 | for ( n = 0; n < max_size && \ | |
687 | (c = getc( mdlexin )) != EOF && c != '\n'; ++n ) \ | |
688 | buf[n] = (char) c; \ | |
689 | if ( c == '\n' ) \ | |
690 | buf[n++] = (char) c; \ | |
691 | if ( c == EOF && ferror( mdlexin ) ) \ | |
692 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ | |
693 | result = n; \ | |
694 | } \ | |
695 | else \ | |
696 | { \ | |
697 | errno=0; \ | |
698 | while ( (result = fread(buf, 1, max_size, mdlexin))==0 && ferror(mdlexin)) \ | |
699 | { \ | |
700 | if( errno != EINTR) \ | |
701 | { \ | |
702 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ | |
703 | break; \ | |
704 | } \ | |
705 | errno=0; \ | |
706 | clearerr(mdlexin); \ | |
707 | } \ | |
708 | }\ | |
709 | \ | |
710 | ||
711 | #endif | |
712 | ||
713 | /* No semi-colon after return; correct usage is to write "yyterminate();" - | |
714 | * we don't want an extra ';' after the "return" because that will cause | |
715 | * some compilers to complain about unreachable statements. | |
716 | */ | |
717 | #ifndef yyterminate | |
718 | #define yyterminate() return YY_NULL | |
719 | #endif | |
720 | ||
721 | /* Number of entries by which start-condition stack grows. */ | |
722 | #ifndef YY_START_STACK_INCR | |
723 | #define YY_START_STACK_INCR 25 | |
724 | #endif | |
725 | ||
726 | /* Report a fatal error. */ | |
727 | #ifndef YY_FATAL_ERROR | |
728 | #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) | |
729 | #endif | |
730 | ||
731 | /* end tables serialization structures and prototypes */ | |
732 | ||
733 | /* Default declaration of generated scanner - a define so the user can | |
734 | * easily add parameters. | |
735 | */ | |
736 | #ifndef YY_DECL | |
737 | #define YY_DECL_IS_OURS 1 | |
738 | ||
739 | extern int mdlexlex (void); | |
740 | ||
741 | #define YY_DECL int mdlexlex (void) | |
742 | #endif /* !YY_DECL */ | |
743 | ||
744 | /* Code executed at the beginning of each rule, after mdlextext and mdlexleng | |
745 | * have been set up. | |
746 | */ | |
747 | #ifndef YY_USER_ACTION | |
748 | #define YY_USER_ACTION | |
749 | #endif | |
750 | ||
751 | /* Code executed at the end of each rule. */ | |
752 | #ifndef YY_BREAK | |
753 | #define YY_BREAK break; | |
754 | #endif | |
755 | ||
756 | #define YY_RULE_SETUP \ | |
757 | if ( mdlexleng > 0 ) \ | |
758 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ | |
759 | (mdlextext[mdlexleng - 1] == '\n'); \ | |
760 | YY_USER_ACTION | |
761 | ||
762 | /** The main scanner function which does all the work. | |
763 | */ | |
764 | YY_DECL | |
765 | { | |
766 | register yy_state_type yy_current_state; | |
767 | register char *yy_cp, *yy_bp; | |
768 | register int yy_act; | |
769 | ||
770 | #line 49 "mdlex.l" | |
771 | ||
772 | ||
773 | #line 731 "mdlex.c" | |
774 | ||
775 | if ( (yy_init) ) | |
776 | { | |
777 | (yy_init) = 0; | |
778 | ||
779 | #ifdef YY_USER_INIT | |
780 | YY_USER_INIT; | |
781 | #endif | |
782 | ||
783 | if ( ! (yy_start) ) | |
784 | (yy_start) = 1; /* first start state */ | |
785 | ||
786 | if ( ! mdlexin ) | |
787 | mdlexin = stdin; | |
788 | ||
789 | if ( ! mdlexout ) | |
790 | mdlexout = stdout; | |
791 | ||
792 | if ( ! YY_CURRENT_BUFFER ) { | |
793 | mdlexensure_buffer_stack (); | |
794 | YY_CURRENT_BUFFER_LVALUE = | |
795 | mdlex_create_buffer(mdlexin,YY_BUF_SIZE ); | |
796 | } | |
797 | ||
798 | mdlex_load_buffer_state( ); | |
799 | } | |
800 | ||
801 | while ( 1 ) /* loops until end-of-file is reached */ | |
802 | { | |
803 | yy_cp = (yy_c_buf_p); | |
804 | ||
805 | /* Support of mdlextext. */ | |
806 | *yy_cp = (yy_hold_char); | |
807 | ||
808 | /* yy_bp points to the position in yy_ch_buf of the start of | |
809 | * the current run. | |
810 | */ | |
811 | yy_bp = yy_cp; | |
812 | ||
813 | yy_current_state = (yy_start); | |
814 | yy_current_state += YY_AT_BOL(); | |
815 | yy_match: | |
816 | do | |
817 | { | |
818 | register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; | |
819 | if ( yy_accept[yy_current_state] ) | |
820 | { | |
821 | (yy_last_accepting_state) = yy_current_state; | |
822 | (yy_last_accepting_cpos) = yy_cp; | |
823 | } | |
824 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | |
825 | { | |
826 | yy_current_state = (int) yy_def[yy_current_state]; | |
827 | if ( yy_current_state >= 109 ) | |
828 | yy_c = yy_meta[(unsigned int) yy_c]; | |
829 | } | |
830 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | |
831 | ++yy_cp; | |
832 | } | |
833 | while ( yy_base[yy_current_state] != 193 ); | |
834 | ||
835 | yy_find_action: | |
836 | yy_act = yy_accept[yy_current_state]; | |
837 | if ( yy_act == 0 ) | |
838 | { /* have to back up */ | |
839 | yy_cp = (yy_last_accepting_cpos); | |
840 | yy_current_state = (yy_last_accepting_state); | |
841 | yy_act = yy_accept[yy_current_state]; | |
842 | } | |
843 | ||
844 | YY_DO_BEFORE_ACTION; | |
845 | ||
846 | do_action: /* This label is used only to access EOF actions. */ | |
847 | ||
848 | switch ( yy_act ) | |
849 | { /* beginning of action switch */ | |
850 | case 0: /* must back up */ | |
851 | /* undo the effects of YY_DO_BEFORE_ACTION */ | |
852 | *yy_cp = (yy_hold_char); | |
853 | yy_cp = (yy_last_accepting_cpos); | |
854 | yy_current_state = (yy_last_accepting_state); | |
855 | goto yy_find_action; | |
856 | ||
857 | case YY_STATE_EOF(INITIAL): | |
858 | case YY_STATE_EOF(comment): | |
859 | case YY_STATE_EOF(string): | |
860 | #line 51 "mdlex.l" | |
861 | return T_EOF; | |
862 | YY_BREAK | |
863 | case 1: | |
864 | YY_RULE_SETUP | |
865 | #line 53 "mdlex.l" | |
866 | return T_L_Brace; | |
867 | YY_BREAK | |
868 | case 2: | |
869 | YY_RULE_SETUP | |
870 | #line 55 "mdlex.l" | |
871 | return T_R_Brace; | |
872 | YY_BREAK | |
873 | case 3: | |
874 | YY_RULE_SETUP | |
875 | #line 57 "mdlex.l" | |
876 | return T_R_Bracket; | |
877 | YY_BREAK | |
878 | case 4: | |
879 | YY_RULE_SETUP | |
880 | #line 59 "mdlex.l" | |
881 | return T_Comma; | |
882 | YY_BREAK | |
883 | case 5: | |
884 | YY_RULE_SETUP | |
885 | #line 61 "mdlex.l" | |
886 | return T_S_Colon; | |
887 | YY_BREAK | |
888 | case 6: | |
889 | YY_RULE_SETUP | |
890 | #line 63 "mdlex.l" | |
891 | return T_Plus; | |
892 | YY_BREAK | |
893 | case 7: | |
894 | YY_RULE_SETUP | |
895 | #line 65 "mdlex.l" | |
896 | return T_Multiply; | |
897 | YY_BREAK | |
898 | case 8: | |
899 | YY_RULE_SETUP | |
900 | #line 67 "mdlex.l" | |
901 | return T_Minus; | |
902 | YY_BREAK | |
903 | case 9: | |
904 | YY_RULE_SETUP | |
905 | #line 69 "mdlex.l" | |
906 | return T_And; | |
907 | YY_BREAK | |
908 | case 10: | |
909 | YY_RULE_SETUP | |
910 | #line 71 "mdlex.l" | |
911 | return T_Or; | |
912 | YY_BREAK | |
913 | case 11: | |
914 | YY_RULE_SETUP | |
915 | #line 73 "mdlex.l" | |
916 | return T_Xor; | |
917 | YY_BREAK | |
918 | case 12: | |
919 | YY_RULE_SETUP | |
920 | #line 75 "mdlex.l" | |
921 | return T_Not; | |
922 | YY_BREAK | |
923 | case 13: | |
924 | YY_RULE_SETUP | |
925 | #line 77 "mdlex.l" | |
926 | return T_LShift; | |
927 | YY_BREAK | |
928 | case 14: | |
929 | YY_RULE_SETUP | |
930 | #line 79 "mdlex.l" | |
931 | return T_Equals; | |
932 | YY_BREAK | |
933 | case 15: | |
934 | YY_RULE_SETUP | |
935 | #line 81 "mdlex.l" | |
936 | return T_R_Bracket; | |
937 | YY_BREAK | |
938 | case 16: | |
939 | YY_RULE_SETUP | |
940 | #line 83 "mdlex.l" | |
941 | return T_L_Bracket; | |
942 | YY_BREAK | |
943 | case 17: | |
944 | *yy_cp = (yy_hold_char); /* undo effects of setting up mdlextext */ | |
945 | (yy_c_buf_p) = yy_cp -= 1; | |
946 | YY_DO_BEFORE_ACTION; /* set up mdlextext again */ | |
947 | YY_RULE_SETUP | |
948 | #line 85 "mdlex.l" | |
949 | { | |
950 | char lbuf[1024]; | |
951 | int num; | |
952 | if (sscanf(mdlextext,"# %d \"%[^\"]\"", &num, lbuf)!=2) | |
953 | lex_fatal("Illegal # directive"); | |
954 | lex.linenum = num-1; | |
955 | if (lex.fnamep != (char*)0) Xfree(lex.fnamep); | |
956 | lex.fnamep = Xstrdup(lbuf); | |
957 | } | |
958 | YY_BREAK | |
959 | case 18: | |
960 | YY_RULE_SETUP | |
961 | #line 95 "mdlex.l" | |
962 | return T_KW_node; | |
963 | YY_BREAK | |
964 | case 19: | |
965 | YY_RULE_SETUP | |
966 | #line 97 "mdlex.l" | |
967 | return T_KW_proto; | |
968 | YY_BREAK | |
969 | case 20: | |
970 | YY_RULE_SETUP | |
971 | #line 99 "mdlex.l" | |
972 | return T_KW_include; | |
973 | YY_BREAK | |
974 | case 21: | |
975 | YY_RULE_SETUP | |
976 | #line 101 "mdlex.l" | |
977 | return T_KW_expr; | |
978 | YY_BREAK | |
979 | case 22: | |
980 | YY_RULE_SETUP | |
981 | #line 103 "mdlex.l" | |
982 | return T_KW_expr; | |
983 | YY_BREAK | |
984 | case 23: | |
985 | YY_RULE_SETUP | |
986 | #line 105 "mdlex.l" | |
987 | return T_KW_lookup; | |
988 | YY_BREAK | |
989 | case 24: | |
990 | YY_RULE_SETUP | |
991 | #line 107 "mdlex.l" | |
992 | return T_KW_setprop; | |
993 | YY_BREAK | |
994 | case 25: | |
995 | YY_RULE_SETUP | |
996 | #line 109 "mdlex.l" | |
997 | return T_KW_arc; | |
998 | YY_BREAK | |
999 | case 26: | |
1000 | YY_RULE_SETUP | |
1001 | #line 112 "mdlex.l" | |
1002 | { | |
1003 | sbuffer.ptr = sbuffer.base; | |
1004 | BEGIN(string); | |
1005 | } | |
1006 | YY_BREAK | |
1007 | case 27: | |
1008 | YY_RULE_SETUP | |
1009 | #line 117 "mdlex.l" | |
1010 | { /* closing quote - wrap up string and return it */ | |
1011 | BEGIN(INITIAL); | |
1012 | sbuffer.ptr[0]='\0'; | |
1013 | lex.strp = sbuffer.base; | |
1014 | return T_String; | |
1015 | } | |
1016 | YY_BREAK | |
1017 | case 28: | |
1018 | /* rule 28 can match eol */ | |
1019 | YY_RULE_SETUP | |
1020 | #line 124 "mdlex.l" | |
1021 | { | |
1022 | lex_fatal("unterminated string"); | |
1023 | } | |
1024 | YY_BREAK | |
1025 | case 29: | |
1026 | YY_RULE_SETUP | |
1027 | #line 128 "mdlex.l" | |
1028 | { | |
1029 | /* octal escape sequence */ | |
1030 | int result; | |
1031 | ||
1032 | result=-1; | |
1033 | (void) sscanf( mdlextext + 1, "%o", &result ); | |
1034 | ||
1035 | if ( result<0 || result>0xff ) | |
1036 | lex_fatal("error, constant is out-of-bounds"); | |
1037 | ||
1038 | SBUFFER_INS( result ); | |
1039 | } | |
1040 | YY_BREAK | |
1041 | case 30: | |
1042 | YY_RULE_SETUP | |
1043 | #line 141 "mdlex.l" | |
1044 | { | |
1045 | lex_fatal("illegal escape sequence"); | |
1046 | } | |
1047 | YY_BREAK | |
1048 | case 31: | |
1049 | YY_RULE_SETUP | |
1050 | #line 145 "mdlex.l" | |
1051 | SBUFFER_INS( '\n' ); | |
1052 | YY_BREAK | |
1053 | case 32: | |
1054 | YY_RULE_SETUP | |
1055 | #line 146 "mdlex.l" | |
1056 | SBUFFER_INS( '\t' ); | |
1057 | YY_BREAK | |
1058 | case 33: | |
1059 | YY_RULE_SETUP | |
1060 | #line 147 "mdlex.l" | |
1061 | SBUFFER_INS( '\r' ); | |
1062 | YY_BREAK | |
1063 | case 34: | |
1064 | YY_RULE_SETUP | |
1065 | #line 148 "mdlex.l" | |
1066 | SBUFFER_INS( '\b' ); | |
1067 | YY_BREAK | |
1068 | case 35: | |
1069 | YY_RULE_SETUP | |
1070 | #line 149 "mdlex.l" | |
1071 | SBUFFER_INS( '\f' ); | |
1072 | YY_BREAK | |
1073 | case 36: | |
1074 | /* rule 36 can match eol */ | |
1075 | YY_RULE_SETUP | |
1076 | #line 151 "mdlex.l" | |
1077 | SBUFFER_INS( mdlextext[1] ); | |
1078 | YY_BREAK | |
1079 | case 37: | |
1080 | YY_RULE_SETUP | |
1081 | #line 153 "mdlex.l" | |
1082 | { | |
1083 | char *iptr = mdlextext; | |
1084 | ||
1085 | while ( *iptr ) SBUFFER_INS( *iptr++ ); | |
1086 | } | |
1087 | YY_BREAK | |
1088 | case 38: | |
1089 | YY_RULE_SETUP | |
1090 | #line 162 "mdlex.l" | |
1091 | { | |
1092 | lex.val = strtoull(mdlextext, (char **)NULL, 16); | |
1093 | return T_Number; | |
1094 | } | |
1095 | YY_BREAK | |
1096 | case 39: | |
1097 | YY_RULE_SETUP | |
1098 | #line 167 "mdlex.l" | |
1099 | { | |
1100 | lex.val = strtoull(mdlextext, (char **)NULL, 16); | |
1101 | ||
1102 | return T_Number; | |
1103 | } | |
1104 | YY_BREAK | |
1105 | case 40: | |
1106 | YY_RULE_SETUP | |
1107 | #line 173 "mdlex.l" | |
1108 | { | |
1109 | char * ep; | |
1110 | lex.val = strtoll(mdlextext, &ep, 10); | |
1111 | switch(*ep) { | |
1112 | case 'G': case 'g': | |
1113 | lex.val <<= 30; | |
1114 | break; | |
1115 | case 'M': case 'm': | |
1116 | lex.val <<= 20; | |
1117 | break; | |
1118 | case 'K': case 'k': | |
1119 | lex.val <<= 10; | |
1120 | break; | |
1121 | default: | |
1122 | lex_fatal("parsing number"); | |
1123 | } | |
1124 | return T_Number; | |
1125 | } | |
1126 | YY_BREAK | |
1127 | case 41: | |
1128 | YY_RULE_SETUP | |
1129 | #line 192 "mdlex.l" | |
1130 | { | |
1131 | lex.val = atoll(mdlextext); | |
1132 | return T_Number; | |
1133 | } | |
1134 | YY_BREAK | |
1135 | case 42: | |
1136 | YY_RULE_SETUP | |
1137 | #line 197 "mdlex.l" | |
1138 | { | |
1139 | lex.val = atoll(mdlextext); | |
1140 | return T_Number; | |
1141 | } | |
1142 | YY_BREAK | |
1143 | case 43: | |
1144 | YY_RULE_SETUP | |
1145 | #line 203 "mdlex.l" | |
1146 | { | |
1147 | lex.strp = mdlextext; | |
1148 | return T_Token; | |
1149 | } | |
1150 | YY_BREAK | |
1151 | /* Note: . = any character EXCEPT newline */ | |
1152 | case 44: | |
1153 | YY_RULE_SETUP | |
1154 | #line 209 "mdlex.l" | |
1155 | { /* nada - swallow single line comments */ } | |
1156 | YY_BREAK | |
1157 | case 45: | |
1158 | YY_RULE_SETUP | |
1159 | #line 211 "mdlex.l" | |
1160 | { /* nada - swallow white space */ } | |
1161 | YY_BREAK | |
1162 | case 46: | |
1163 | /* rule 46 can match eol */ | |
1164 | YY_RULE_SETUP | |
1165 | #line 214 "mdlex.l" | |
1166 | { | |
1167 | lex.linenum ++; | |
1168 | } | |
1169 | YY_BREAK | |
1170 | case 47: | |
1171 | YY_RULE_SETUP | |
1172 | #line 218 "mdlex.l" | |
1173 | { | |
1174 | lex_fatal("Illegal character %s", mdlextext); | |
1175 | } | |
1176 | YY_BREAK | |
1177 | case 48: | |
1178 | YY_RULE_SETUP | |
1179 | #line 222 "mdlex.l" | |
1180 | ECHO; | |
1181 | YY_BREAK | |
1182 | #line 1140 "mdlex.c" | |
1183 | ||
1184 | case YY_END_OF_BUFFER: | |
1185 | { | |
1186 | /* Amount of text matched not including the EOB char. */ | |
1187 | int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; | |
1188 | ||
1189 | /* Undo the effects of YY_DO_BEFORE_ACTION. */ | |
1190 | *yy_cp = (yy_hold_char); | |
1191 | YY_RESTORE_YY_MORE_OFFSET | |
1192 | ||
1193 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) | |
1194 | { | |
1195 | /* We're scanning a new file or input source. It's | |
1196 | * possible that this happened because the user | |
1197 | * just pointed mdlexin at a new source and called | |
1198 | * mdlexlex(). If so, then we have to assure | |
1199 | * consistency between YY_CURRENT_BUFFER and our | |
1200 | * globals. Here is the right place to do so, because | |
1201 | * this is the first action (other than possibly a | |
1202 | * back-up) that will match for the new input source. | |
1203 | */ | |
1204 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; | |
1205 | YY_CURRENT_BUFFER_LVALUE->yy_input_file = mdlexin; | |
1206 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; | |
1207 | } | |
1208 | ||
1209 | /* Note that here we test for yy_c_buf_p "<=" to the position | |
1210 | * of the first EOB in the buffer, since yy_c_buf_p will | |
1211 | * already have been incremented past the NUL character | |
1212 | * (since all states make transitions on EOB to the | |
1213 | * end-of-buffer state). Contrast this with the test | |
1214 | * in input(). | |
1215 | */ | |
1216 | if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) | |
1217 | { /* This was really a NUL. */ | |
1218 | yy_state_type yy_next_state; | |
1219 | ||
1220 | (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; | |
1221 | ||
1222 | yy_current_state = yy_get_previous_state( ); | |
1223 | ||
1224 | /* Okay, we're now positioned to make the NUL | |
1225 | * transition. We couldn't have | |
1226 | * yy_get_previous_state() go ahead and do it | |
1227 | * for us because it doesn't know how to deal | |
1228 | * with the possibility of jamming (and we don't | |
1229 | * want to build jamming into it because then it | |
1230 | * will run more slowly). | |
1231 | */ | |
1232 | ||
1233 | yy_next_state = yy_try_NUL_trans( yy_current_state ); | |
1234 | ||
1235 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | |
1236 | ||
1237 | if ( yy_next_state ) | |
1238 | { | |
1239 | /* Consume the NUL. */ | |
1240 | yy_cp = ++(yy_c_buf_p); | |
1241 | yy_current_state = yy_next_state; | |
1242 | goto yy_match; | |
1243 | } | |
1244 | ||
1245 | else | |
1246 | { | |
1247 | yy_cp = (yy_c_buf_p); | |
1248 | goto yy_find_action; | |
1249 | } | |
1250 | } | |
1251 | ||
1252 | else switch ( yy_get_next_buffer( ) ) | |
1253 | { | |
1254 | case EOB_ACT_END_OF_FILE: | |
1255 | { | |
1256 | (yy_did_buffer_switch_on_eof) = 0; | |
1257 | ||
1258 | if ( mdlexwrap( ) ) | |
1259 | { | |
1260 | /* Note: because we've taken care in | |
1261 | * yy_get_next_buffer() to have set up | |
1262 | * mdlextext, we can now set up | |
1263 | * yy_c_buf_p so that if some total | |
1264 | * hoser (like flex itself) wants to | |
1265 | * call the scanner after we return the | |
1266 | * YY_NULL, it'll still work - another | |
1267 | * YY_NULL will get returned. | |
1268 | */ | |
1269 | (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; | |
1270 | ||
1271 | yy_act = YY_STATE_EOF(YY_START); | |
1272 | goto do_action; | |
1273 | } | |
1274 | ||
1275 | else | |
1276 | { | |
1277 | if ( ! (yy_did_buffer_switch_on_eof) ) | |
1278 | YY_NEW_FILE; | |
1279 | } | |
1280 | break; | |
1281 | } | |
1282 | ||
1283 | case EOB_ACT_CONTINUE_SCAN: | |
1284 | (yy_c_buf_p) = | |
1285 | (yytext_ptr) + yy_amount_of_matched_text; | |
1286 | ||
1287 | yy_current_state = yy_get_previous_state( ); | |
1288 | ||
1289 | yy_cp = (yy_c_buf_p); | |
1290 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | |
1291 | goto yy_match; | |
1292 | ||
1293 | case EOB_ACT_LAST_MATCH: | |
1294 | (yy_c_buf_p) = | |
1295 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; | |
1296 | ||
1297 | yy_current_state = yy_get_previous_state( ); | |
1298 | ||
1299 | yy_cp = (yy_c_buf_p); | |
1300 | yy_bp = (yytext_ptr) + YY_MORE_ADJ; | |
1301 | goto yy_find_action; | |
1302 | } | |
1303 | break; | |
1304 | } | |
1305 | ||
1306 | default: | |
1307 | YY_FATAL_ERROR( | |
1308 | "fatal flex scanner internal error--no action found" ); | |
1309 | } /* end of action switch */ | |
1310 | } /* end of scanning one token */ | |
1311 | } /* end of mdlexlex */ | |
1312 | ||
1313 | /* yy_get_next_buffer - try to read in a new buffer | |
1314 | * | |
1315 | * Returns a code representing an action: | |
1316 | * EOB_ACT_LAST_MATCH - | |
1317 | * EOB_ACT_CONTINUE_SCAN - continue scanning from current position | |
1318 | * EOB_ACT_END_OF_FILE - end of file | |
1319 | */ | |
1320 | static int yy_get_next_buffer (void) | |
1321 | { | |
1322 | register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; | |
1323 | register char *source = (yytext_ptr); | |
1324 | register int number_to_move, i; | |
1325 | int ret_val; | |
1326 | ||
1327 | if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) | |
1328 | YY_FATAL_ERROR( | |
1329 | "fatal flex scanner internal error--end of buffer missed" ); | |
1330 | ||
1331 | if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) | |
1332 | { /* Don't try to fill the buffer, so this is an EOF. */ | |
1333 | if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) | |
1334 | { | |
1335 | /* We matched a single character, the EOB, so | |
1336 | * treat this as a final EOF. | |
1337 | */ | |
1338 | return EOB_ACT_END_OF_FILE; | |
1339 | } | |
1340 | ||
1341 | else | |
1342 | { | |
1343 | /* We matched some text prior to the EOB, first | |
1344 | * process it. | |
1345 | */ | |
1346 | return EOB_ACT_LAST_MATCH; | |
1347 | } | |
1348 | } | |
1349 | ||
1350 | /* Try to read more data. */ | |
1351 | ||
1352 | /* First move last chars to start of buffer. */ | |
1353 | number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; | |
1354 | ||
1355 | for ( i = 0; i < number_to_move; ++i ) | |
1356 | *(dest++) = *(source++); | |
1357 | ||
1358 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) | |
1359 | /* don't do the read, it's not guaranteed to return an EOF, | |
1360 | * just force an EOF | |
1361 | */ | |
1362 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; | |
1363 | ||
1364 | else | |
1365 | { | |
1366 | size_t num_to_read = | |
1367 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; | |
1368 | ||
1369 | while ( num_to_read <= 0 ) | |
1370 | { /* Not enough room in the buffer - grow it. */ | |
1371 | ||
1372 | /* just a shorter name for the current buffer */ | |
1373 | YY_BUFFER_STATE b = YY_CURRENT_BUFFER; | |
1374 | ||
1375 | int yy_c_buf_p_offset = | |
1376 | (int) ((yy_c_buf_p) - b->yy_ch_buf); | |
1377 | ||
1378 | if ( b->yy_is_our_buffer ) | |
1379 | { | |
1380 | int new_size = b->yy_buf_size * 2; | |
1381 | ||
1382 | if ( new_size <= 0 ) | |
1383 | b->yy_buf_size += b->yy_buf_size / 8; | |
1384 | else | |
1385 | b->yy_buf_size *= 2; | |
1386 | ||
1387 | b->yy_ch_buf = (char *) | |
1388 | /* Include room in for 2 EOB chars. */ | |
1389 | mdlexrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); | |
1390 | } | |
1391 | else | |
1392 | /* Can't grow it, we don't own it. */ | |
1393 | b->yy_ch_buf = 0; | |
1394 | ||
1395 | if ( ! b->yy_ch_buf ) | |
1396 | YY_FATAL_ERROR( | |
1397 | "fatal error - scanner input buffer overflow" ); | |
1398 | ||
1399 | (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; | |
1400 | ||
1401 | num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - | |
1402 | number_to_move - 1; | |
1403 | ||
1404 | } | |
1405 | ||
1406 | if ( num_to_read > YY_READ_BUF_SIZE ) | |
1407 | num_to_read = YY_READ_BUF_SIZE; | |
1408 | ||
1409 | /* Read in more data. */ | |
1410 | YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), | |
1411 | (yy_n_chars), num_to_read ); | |
1412 | ||
1413 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | |
1414 | } | |
1415 | ||
1416 | if ( (yy_n_chars) == 0 ) | |
1417 | { | |
1418 | if ( number_to_move == YY_MORE_ADJ ) | |
1419 | { | |
1420 | ret_val = EOB_ACT_END_OF_FILE; | |
1421 | mdlexrestart(mdlexin ); | |
1422 | } | |
1423 | ||
1424 | else | |
1425 | { | |
1426 | ret_val = EOB_ACT_LAST_MATCH; | |
1427 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = | |
1428 | YY_BUFFER_EOF_PENDING; | |
1429 | } | |
1430 | } | |
1431 | ||
1432 | else | |
1433 | ret_val = EOB_ACT_CONTINUE_SCAN; | |
1434 | ||
1435 | (yy_n_chars) += number_to_move; | |
1436 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; | |
1437 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; | |
1438 | ||
1439 | (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; | |
1440 | ||
1441 | return ret_val; | |
1442 | } | |
1443 | ||
1444 | /* yy_get_previous_state - get the state just before the EOB char was reached */ | |
1445 | ||
1446 | static yy_state_type yy_get_previous_state (void) | |
1447 | { | |
1448 | register yy_state_type yy_current_state; | |
1449 | register char *yy_cp; | |
1450 | ||
1451 | yy_current_state = (yy_start); | |
1452 | yy_current_state += YY_AT_BOL(); | |
1453 | ||
1454 | for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) | |
1455 | { | |
1456 | register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); | |
1457 | if ( yy_accept[yy_current_state] ) | |
1458 | { | |
1459 | (yy_last_accepting_state) = yy_current_state; | |
1460 | (yy_last_accepting_cpos) = yy_cp; | |
1461 | } | |
1462 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | |
1463 | { | |
1464 | yy_current_state = (int) yy_def[yy_current_state]; | |
1465 | if ( yy_current_state >= 109 ) | |
1466 | yy_c = yy_meta[(unsigned int) yy_c]; | |
1467 | } | |
1468 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | |
1469 | } | |
1470 | ||
1471 | return yy_current_state; | |
1472 | } | |
1473 | ||
1474 | /* yy_try_NUL_trans - try to make a transition on the NUL character | |
1475 | * | |
1476 | * synopsis | |
1477 | * next_state = yy_try_NUL_trans( current_state ); | |
1478 | */ | |
1479 | static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) | |
1480 | { | |
1481 | register int yy_is_jam; | |
1482 | register char *yy_cp = (yy_c_buf_p); | |
1483 | ||
1484 | register YY_CHAR yy_c = 1; | |
1485 | if ( yy_accept[yy_current_state] ) | |
1486 | { | |
1487 | (yy_last_accepting_state) = yy_current_state; | |
1488 | (yy_last_accepting_cpos) = yy_cp; | |
1489 | } | |
1490 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | |
1491 | { | |
1492 | yy_current_state = (int) yy_def[yy_current_state]; | |
1493 | if ( yy_current_state >= 109 ) | |
1494 | yy_c = yy_meta[(unsigned int) yy_c]; | |
1495 | } | |
1496 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | |
1497 | yy_is_jam = (yy_current_state == 108); | |
1498 | ||
1499 | return yy_is_jam ? 0 : yy_current_state; | |
1500 | } | |
1501 | ||
1502 | static void yyunput (int c, register char * yy_bp ) | |
1503 | { | |
1504 | register char *yy_cp; | |
1505 | ||
1506 | yy_cp = (yy_c_buf_p); | |
1507 | ||
1508 | /* undo effects of setting up mdlextext */ | |
1509 | *yy_cp = (yy_hold_char); | |
1510 | ||
1511 | if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) | |
1512 | { /* need to shift things up to make room */ | |
1513 | /* +2 for EOB chars. */ | |
1514 | register int number_to_move = (yy_n_chars) + 2; | |
1515 | register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ | |
1516 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; | |
1517 | register char *source = | |
1518 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; | |
1519 | ||
1520 | while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) | |
1521 | *--dest = *--source; | |
1522 | ||
1523 | yy_cp += (int) (dest - source); | |
1524 | yy_bp += (int) (dest - source); | |
1525 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = | |
1526 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; | |
1527 | ||
1528 | if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) | |
1529 | YY_FATAL_ERROR( "flex scanner push-back overflow" ); | |
1530 | } | |
1531 | ||
1532 | *--yy_cp = (char) c; | |
1533 | ||
1534 | (yytext_ptr) = yy_bp; | |
1535 | (yy_hold_char) = *yy_cp; | |
1536 | (yy_c_buf_p) = yy_cp; | |
1537 | } | |
1538 | ||
1539 | #ifndef YY_NO_INPUT | |
1540 | #ifdef __cplusplus | |
1541 | static int yyinput (void) | |
1542 | #else | |
1543 | static int input (void) | |
1544 | #endif | |
1545 | ||
1546 | { | |
1547 | int c; | |
1548 | ||
1549 | *(yy_c_buf_p) = (yy_hold_char); | |
1550 | ||
1551 | if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) | |
1552 | { | |
1553 | /* yy_c_buf_p now points to the character we want to return. | |
1554 | * If this occurs *before* the EOB characters, then it's a | |
1555 | * valid NUL; if not, then we've hit the end of the buffer. | |
1556 | */ | |
1557 | if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) | |
1558 | /* This was really a NUL. */ | |
1559 | *(yy_c_buf_p) = '\0'; | |
1560 | ||
1561 | else | |
1562 | { /* need more input */ | |
1563 | int offset = (yy_c_buf_p) - (yytext_ptr); | |
1564 | ++(yy_c_buf_p); | |
1565 | ||
1566 | switch ( yy_get_next_buffer( ) ) | |
1567 | { | |
1568 | case EOB_ACT_LAST_MATCH: | |
1569 | /* This happens because yy_g_n_b() | |
1570 | * sees that we've accumulated a | |
1571 | * token and flags that we need to | |
1572 | * try matching the token before | |
1573 | * proceeding. But for input(), | |
1574 | * there's no matching to consider. | |
1575 | * So convert the EOB_ACT_LAST_MATCH | |
1576 | * to EOB_ACT_END_OF_FILE. | |
1577 | */ | |
1578 | ||
1579 | /* Reset buffer status. */ | |
1580 | mdlexrestart(mdlexin ); | |
1581 | ||
1582 | /*FALLTHROUGH*/ | |
1583 | ||
1584 | case EOB_ACT_END_OF_FILE: | |
1585 | { | |
1586 | if ( mdlexwrap( ) ) | |
1587 | return EOF; | |
1588 | ||
1589 | if ( ! (yy_did_buffer_switch_on_eof) ) | |
1590 | YY_NEW_FILE; | |
1591 | #ifdef __cplusplus | |
1592 | return yyinput(); | |
1593 | #else | |
1594 | return input(); | |
1595 | #endif | |
1596 | } | |
1597 | ||
1598 | case EOB_ACT_CONTINUE_SCAN: | |
1599 | (yy_c_buf_p) = (yytext_ptr) + offset; | |
1600 | break; | |
1601 | } | |
1602 | } | |
1603 | } | |
1604 | ||
1605 | c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ | |
1606 | *(yy_c_buf_p) = '\0'; /* preserve mdlextext */ | |
1607 | (yy_hold_char) = *++(yy_c_buf_p); | |
1608 | ||
1609 | YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); | |
1610 | ||
1611 | return c; | |
1612 | } | |
1613 | #endif /* ifndef YY_NO_INPUT */ | |
1614 | ||
1615 | /** Immediately switch to a different input stream. | |
1616 | * @param input_file A readable stream. | |
1617 | * | |
1618 | * @note This function does not reset the start condition to @c INITIAL . | |
1619 | */ | |
1620 | void mdlexrestart (FILE * input_file ) | |
1621 | { | |
1622 | ||
1623 | if ( ! YY_CURRENT_BUFFER ){ | |
1624 | mdlexensure_buffer_stack (); | |
1625 | YY_CURRENT_BUFFER_LVALUE = | |
1626 | mdlex_create_buffer(mdlexin,YY_BUF_SIZE ); | |
1627 | } | |
1628 | ||
1629 | mdlex_init_buffer(YY_CURRENT_BUFFER,input_file ); | |
1630 | mdlex_load_buffer_state( ); | |
1631 | } | |
1632 | ||
1633 | /** Switch to a different input buffer. | |
1634 | * @param new_buffer The new input buffer. | |
1635 | * | |
1636 | */ | |
1637 | void mdlex_switch_to_buffer (YY_BUFFER_STATE new_buffer ) | |
1638 | { | |
1639 | ||
1640 | /* TODO. We should be able to replace this entire function body | |
1641 | * with | |
1642 | * mdlexpop_buffer_state(); | |
1643 | * mdlexpush_buffer_state(new_buffer); | |
1644 | */ | |
1645 | mdlexensure_buffer_stack (); | |
1646 | if ( YY_CURRENT_BUFFER == new_buffer ) | |
1647 | return; | |
1648 | ||
1649 | if ( YY_CURRENT_BUFFER ) | |
1650 | { | |
1651 | /* Flush out information for old buffer. */ | |
1652 | *(yy_c_buf_p) = (yy_hold_char); | |
1653 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); | |
1654 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | |
1655 | } | |
1656 | ||
1657 | YY_CURRENT_BUFFER_LVALUE = new_buffer; | |
1658 | mdlex_load_buffer_state( ); | |
1659 | ||
1660 | /* We don't actually know whether we did this switch during | |
1661 | * EOF (mdlexwrap()) processing, but the only time this flag | |
1662 | * is looked at is after mdlexwrap() is called, so it's safe | |
1663 | * to go ahead and always set it. | |
1664 | */ | |
1665 | (yy_did_buffer_switch_on_eof) = 1; | |
1666 | } | |
1667 | ||
1668 | static void mdlex_load_buffer_state (void) | |
1669 | { | |
1670 | (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; | |
1671 | (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; | |
1672 | mdlexin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; | |
1673 | (yy_hold_char) = *(yy_c_buf_p); | |
1674 | } | |
1675 | ||
1676 | /** Allocate and initialize an input buffer state. | |
1677 | * @param file A readable stream. | |
1678 | * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. | |
1679 | * | |
1680 | * @return the allocated buffer state. | |
1681 | */ | |
1682 | YY_BUFFER_STATE mdlex_create_buffer (FILE * file, int size ) | |
1683 | { | |
1684 | YY_BUFFER_STATE b; | |
1685 | ||
1686 | b = (YY_BUFFER_STATE) mdlexalloc(sizeof( struct yy_buffer_state ) ); | |
1687 | if ( ! b ) | |
1688 | YY_FATAL_ERROR( "out of dynamic memory in mdlex_create_buffer()" ); | |
1689 | ||
1690 | b->yy_buf_size = size; | |
1691 | ||
1692 | /* yy_ch_buf has to be 2 characters longer than the size given because | |
1693 | * we need to put in 2 end-of-buffer characters. | |
1694 | */ | |
1695 | b->yy_ch_buf = (char *) mdlexalloc(b->yy_buf_size + 2 ); | |
1696 | if ( ! b->yy_ch_buf ) | |
1697 | YY_FATAL_ERROR( "out of dynamic memory in mdlex_create_buffer()" ); | |
1698 | ||
1699 | b->yy_is_our_buffer = 1; | |
1700 | ||
1701 | mdlex_init_buffer(b,file ); | |
1702 | ||
1703 | return b; | |
1704 | } | |
1705 | ||
1706 | /** Destroy the buffer. | |
1707 | * @param b a buffer created with mdlex_create_buffer() | |
1708 | * | |
1709 | */ | |
1710 | void mdlex_delete_buffer (YY_BUFFER_STATE b ) | |
1711 | { | |
1712 | ||
1713 | if ( ! b ) | |
1714 | return; | |
1715 | ||
1716 | if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ | |
1717 | YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; | |
1718 | ||
1719 | if ( b->yy_is_our_buffer ) | |
1720 | mdlexfree((void *) b->yy_ch_buf ); | |
1721 | ||
1722 | mdlexfree((void *) b ); | |
1723 | } | |
1724 | ||
1725 | #ifndef __cplusplus | |
1726 | extern int isatty (int ); | |
1727 | #endif /* __cplusplus */ | |
1728 | ||
1729 | /* Initializes or reinitializes a buffer. | |
1730 | * This function is sometimes called more than once on the same buffer, | |
1731 | * such as during a mdlexrestart() or at EOF. | |
1732 | */ | |
1733 | static void mdlex_init_buffer (YY_BUFFER_STATE b, FILE * file ) | |
1734 | ||
1735 | { | |
1736 | int oerrno = errno; | |
1737 | ||
1738 | mdlex_flush_buffer(b ); | |
1739 | ||
1740 | b->yy_input_file = file; | |
1741 | b->yy_fill_buffer = 1; | |
1742 | ||
1743 | /* If b is the current buffer, then mdlex_init_buffer was _probably_ | |
1744 | * called from mdlexrestart() or through yy_get_next_buffer. | |
1745 | * In that case, we don't want to reset the lineno or column. | |
1746 | */ | |
1747 | if (b != YY_CURRENT_BUFFER){ | |
1748 | b->yy_bs_lineno = 1; | |
1749 | b->yy_bs_column = 0; | |
1750 | } | |
1751 | ||
1752 | b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; | |
1753 | ||
1754 | errno = oerrno; | |
1755 | } | |
1756 | ||
1757 | /** Discard all buffered characters. On the next scan, YY_INPUT will be called. | |
1758 | * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. | |
1759 | * | |
1760 | */ | |
1761 | void mdlex_flush_buffer (YY_BUFFER_STATE b ) | |
1762 | { | |
1763 | if ( ! b ) | |
1764 | return; | |
1765 | ||
1766 | b->yy_n_chars = 0; | |
1767 | ||
1768 | /* We always need two end-of-buffer characters. The first causes | |
1769 | * a transition to the end-of-buffer state. The second causes | |
1770 | * a jam in that state. | |
1771 | */ | |
1772 | b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; | |
1773 | b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; | |
1774 | ||
1775 | b->yy_buf_pos = &b->yy_ch_buf[0]; | |
1776 | ||
1777 | b->yy_at_bol = 1; | |
1778 | b->yy_buffer_status = YY_BUFFER_NEW; | |
1779 | ||
1780 | if ( b == YY_CURRENT_BUFFER ) | |
1781 | mdlex_load_buffer_state( ); | |
1782 | } | |
1783 | ||
1784 | /** Pushes the new state onto the stack. The new state becomes | |
1785 | * the current state. This function will allocate the stack | |
1786 | * if necessary. | |
1787 | * @param new_buffer The new state. | |
1788 | * | |
1789 | */ | |
1790 | void mdlexpush_buffer_state (YY_BUFFER_STATE new_buffer ) | |
1791 | { | |
1792 | if (new_buffer == NULL) | |
1793 | return; | |
1794 | ||
1795 | mdlexensure_buffer_stack(); | |
1796 | ||
1797 | /* This block is copied from mdlex_switch_to_buffer. */ | |
1798 | if ( YY_CURRENT_BUFFER ) | |
1799 | { | |
1800 | /* Flush out information for old buffer. */ | |
1801 | *(yy_c_buf_p) = (yy_hold_char); | |
1802 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); | |
1803 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); | |
1804 | } | |
1805 | ||
1806 | /* Only push if top exists. Otherwise, replace top. */ | |
1807 | if (YY_CURRENT_BUFFER) | |
1808 | (yy_buffer_stack_top)++; | |
1809 | YY_CURRENT_BUFFER_LVALUE = new_buffer; | |
1810 | ||
1811 | /* copied from mdlex_switch_to_buffer. */ | |
1812 | mdlex_load_buffer_state( ); | |
1813 | (yy_did_buffer_switch_on_eof) = 1; | |
1814 | } | |
1815 | ||
1816 | /** Removes and deletes the top of the stack, if present. | |
1817 | * The next element becomes the new top. | |
1818 | * | |
1819 | */ | |
1820 | void mdlexpop_buffer_state (void) | |
1821 | { | |
1822 | if (!YY_CURRENT_BUFFER) | |
1823 | return; | |
1824 | ||
1825 | mdlex_delete_buffer(YY_CURRENT_BUFFER ); | |
1826 | YY_CURRENT_BUFFER_LVALUE = NULL; | |
1827 | if ((yy_buffer_stack_top) > 0) | |
1828 | --(yy_buffer_stack_top); | |
1829 | ||
1830 | if (YY_CURRENT_BUFFER) { | |
1831 | mdlex_load_buffer_state( ); | |
1832 | (yy_did_buffer_switch_on_eof) = 1; | |
1833 | } | |
1834 | } | |
1835 | ||
1836 | /* Allocates the stack if it does not exist. | |
1837 | * Guarantees space for at least one push. | |
1838 | */ | |
1839 | static void mdlexensure_buffer_stack (void) | |
1840 | { | |
1841 | int num_to_alloc; | |
1842 | ||
1843 | if (!(yy_buffer_stack)) { | |
1844 | ||
1845 | /* First allocation is just for 2 elements, since we don't know if this | |
1846 | * scanner will even need a stack. We use 2 instead of 1 to avoid an | |
1847 | * immediate realloc on the next call. | |
1848 | */ | |
1849 | num_to_alloc = 1; | |
1850 | (yy_buffer_stack) = (struct yy_buffer_state**)mdlexalloc | |
1851 | (num_to_alloc * sizeof(struct yy_buffer_state*) | |
1852 | ); | |
1853 | ||
1854 | memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); | |
1855 | ||
1856 | (yy_buffer_stack_max) = num_to_alloc; | |
1857 | (yy_buffer_stack_top) = 0; | |
1858 | return; | |
1859 | } | |
1860 | ||
1861 | if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ | |
1862 | ||
1863 | /* Increase the buffer to prepare for a possible push. */ | |
1864 | int grow_size = 8 /* arbitrary grow size */; | |
1865 | ||
1866 | num_to_alloc = (yy_buffer_stack_max) + grow_size; | |
1867 | (yy_buffer_stack) = (struct yy_buffer_state**)mdlexrealloc | |
1868 | ((yy_buffer_stack), | |
1869 | num_to_alloc * sizeof(struct yy_buffer_state*) | |
1870 | ); | |
1871 | ||
1872 | /* zero only the new slots.*/ | |
1873 | memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); | |
1874 | (yy_buffer_stack_max) = num_to_alloc; | |
1875 | } | |
1876 | } | |
1877 | ||
1878 | /** Setup the input buffer state to scan directly from a user-specified character buffer. | |
1879 | * @param base the character buffer | |
1880 | * @param size the size in bytes of the character buffer | |
1881 | * | |
1882 | * @return the newly allocated buffer state object. | |
1883 | */ | |
1884 | YY_BUFFER_STATE mdlex_scan_buffer (char * base, yy_size_t size ) | |
1885 | { | |
1886 | YY_BUFFER_STATE b; | |
1887 | ||
1888 | if ( size < 2 || | |
1889 | base[size-2] != YY_END_OF_BUFFER_CHAR || | |
1890 | base[size-1] != YY_END_OF_BUFFER_CHAR ) | |
1891 | /* They forgot to leave room for the EOB's. */ | |
1892 | return 0; | |
1893 | ||
1894 | b = (YY_BUFFER_STATE) mdlexalloc(sizeof( struct yy_buffer_state ) ); | |
1895 | if ( ! b ) | |
1896 | YY_FATAL_ERROR( "out of dynamic memory in mdlex_scan_buffer()" ); | |
1897 | ||
1898 | b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ | |
1899 | b->yy_buf_pos = b->yy_ch_buf = base; | |
1900 | b->yy_is_our_buffer = 0; | |
1901 | b->yy_input_file = 0; | |
1902 | b->yy_n_chars = b->yy_buf_size; | |
1903 | b->yy_is_interactive = 0; | |
1904 | b->yy_at_bol = 1; | |
1905 | b->yy_fill_buffer = 0; | |
1906 | b->yy_buffer_status = YY_BUFFER_NEW; | |
1907 | ||
1908 | mdlex_switch_to_buffer(b ); | |
1909 | ||
1910 | return b; | |
1911 | } | |
1912 | ||
1913 | /** Setup the input buffer state to scan a string. The next call to mdlexlex() will | |
1914 | * scan from a @e copy of @a str. | |
1915 | * @param str a NUL-terminated string to scan | |
1916 | * | |
1917 | * @return the newly allocated buffer state object. | |
1918 | * @note If you want to scan bytes that may contain NUL values, then use | |
1919 | * mdlex_scan_bytes() instead. | |
1920 | */ | |
1921 | YY_BUFFER_STATE mdlex_scan_string (yyconst char * str ) | |
1922 | { | |
1923 | ||
1924 | return mdlex_scan_bytes(str,strlen(str) ); | |
1925 | } | |
1926 | ||
1927 | /** Setup the input buffer state to scan the given bytes. The next call to mdlexlex() will | |
1928 | * scan from a @e copy of @a bytes. | |
1929 | * @param bytes the byte buffer to scan | |
1930 | * @param len the number of bytes in the buffer pointed to by @a bytes. | |
1931 | * | |
1932 | * @return the newly allocated buffer state object. | |
1933 | */ | |
1934 | YY_BUFFER_STATE mdlex_scan_bytes (yyconst char * bytes, int len ) | |
1935 | { | |
1936 | YY_BUFFER_STATE b; | |
1937 | char *buf; | |
1938 | yy_size_t n; | |
1939 | int i; | |
1940 | ||
1941 | /* Get memory for full buffer, including space for trailing EOB's. */ | |
1942 | n = len + 2; | |
1943 | buf = (char *) mdlexalloc(n ); | |
1944 | if ( ! buf ) | |
1945 | YY_FATAL_ERROR( "out of dynamic memory in mdlex_scan_bytes()" ); | |
1946 | ||
1947 | for ( i = 0; i < len; ++i ) | |
1948 | buf[i] = bytes[i]; | |
1949 | ||
1950 | buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; | |
1951 | ||
1952 | b = mdlex_scan_buffer(buf,n ); | |
1953 | if ( ! b ) | |
1954 | YY_FATAL_ERROR( "bad buffer in mdlex_scan_bytes()" ); | |
1955 | ||
1956 | /* It's okay to grow etc. this buffer, and we should throw it | |
1957 | * away when we're done. | |
1958 | */ | |
1959 | b->yy_is_our_buffer = 1; | |
1960 | ||
1961 | return b; | |
1962 | } | |
1963 | ||
1964 | #ifndef YY_EXIT_FAILURE | |
1965 | #define YY_EXIT_FAILURE 2 | |
1966 | #endif | |
1967 | ||
1968 | static void yy_fatal_error (yyconst char* msg ) | |
1969 | { | |
1970 | (void) fprintf( stderr, "%s\n", msg ); | |
1971 | exit( YY_EXIT_FAILURE ); | |
1972 | } | |
1973 | ||
1974 | /* Redefine yyless() so it works in section 3 code. */ | |
1975 | ||
1976 | #undef yyless | |
1977 | #define yyless(n) \ | |
1978 | do \ | |
1979 | { \ | |
1980 | /* Undo effects of setting up mdlextext. */ \ | |
1981 | int yyless_macro_arg = (n); \ | |
1982 | YY_LESS_LINENO(yyless_macro_arg);\ | |
1983 | mdlextext[mdlexleng] = (yy_hold_char); \ | |
1984 | (yy_c_buf_p) = mdlextext + yyless_macro_arg; \ | |
1985 | (yy_hold_char) = *(yy_c_buf_p); \ | |
1986 | *(yy_c_buf_p) = '\0'; \ | |
1987 | mdlexleng = yyless_macro_arg; \ | |
1988 | } \ | |
1989 | while ( 0 ) | |
1990 | ||
1991 | /* Accessor methods (get/set functions) to struct members. */ | |
1992 | ||
1993 | /** Get the current line number. | |
1994 | * | |
1995 | */ | |
1996 | int mdlexget_lineno (void) | |
1997 | { | |
1998 | ||
1999 | return mdlexlineno; | |
2000 | } | |
2001 | ||
2002 | /** Get the input stream. | |
2003 | * | |
2004 | */ | |
2005 | FILE *mdlexget_in (void) | |
2006 | { | |
2007 | return mdlexin; | |
2008 | } | |
2009 | ||
2010 | /** Get the output stream. | |
2011 | * | |
2012 | */ | |
2013 | FILE *mdlexget_out (void) | |
2014 | { | |
2015 | return mdlexout; | |
2016 | } | |
2017 | ||
2018 | /** Get the length of the current token. | |
2019 | * | |
2020 | */ | |
2021 | int mdlexget_leng (void) | |
2022 | { | |
2023 | return mdlexleng; | |
2024 | } | |
2025 | ||
2026 | /** Get the current token. | |
2027 | * | |
2028 | */ | |
2029 | ||
2030 | char *mdlexget_text (void) | |
2031 | { | |
2032 | return mdlextext; | |
2033 | } | |
2034 | ||
2035 | /** Set the current line number. | |
2036 | * @param line_number | |
2037 | * | |
2038 | */ | |
2039 | void mdlexset_lineno (int line_number ) | |
2040 | { | |
2041 | ||
2042 | mdlexlineno = line_number; | |
2043 | } | |
2044 | ||
2045 | /** Set the input stream. This does not discard the current | |
2046 | * input buffer. | |
2047 | * @param in_str A readable stream. | |
2048 | * | |
2049 | * @see mdlex_switch_to_buffer | |
2050 | */ | |
2051 | void mdlexset_in (FILE * in_str ) | |
2052 | { | |
2053 | mdlexin = in_str ; | |
2054 | } | |
2055 | ||
2056 | void mdlexset_out (FILE * out_str ) | |
2057 | { | |
2058 | mdlexout = out_str ; | |
2059 | } | |
2060 | ||
2061 | int mdlexget_debug (void) | |
2062 | { | |
2063 | return mdlex_flex_debug; | |
2064 | } | |
2065 | ||
2066 | void mdlexset_debug (int bdebug ) | |
2067 | { | |
2068 | mdlex_flex_debug = bdebug ; | |
2069 | } | |
2070 | ||
2071 | /* mdlexlex_destroy is for both reentrant and non-reentrant scanners. */ | |
2072 | int mdlexlex_destroy (void) | |
2073 | { | |
2074 | ||
2075 | /* Pop the buffer stack, destroying each element. */ | |
2076 | while(YY_CURRENT_BUFFER){ | |
2077 | mdlex_delete_buffer(YY_CURRENT_BUFFER ); | |
2078 | YY_CURRENT_BUFFER_LVALUE = NULL; | |
2079 | mdlexpop_buffer_state(); | |
2080 | } | |
2081 | ||
2082 | /* Destroy the stack itself. */ | |
2083 | mdlexfree((yy_buffer_stack) ); | |
2084 | (yy_buffer_stack) = NULL; | |
2085 | ||
2086 | return 0; | |
2087 | } | |
2088 | ||
2089 | /* | |
2090 | * Internal utility routines. | |
2091 | */ | |
2092 | ||
2093 | #ifndef yytext_ptr | |
2094 | static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) | |
2095 | { | |
2096 | register int i; | |
2097 | for ( i = 0; i < n; ++i ) | |
2098 | s1[i] = s2[i]; | |
2099 | } | |
2100 | #endif | |
2101 | ||
2102 | #ifdef YY_NEED_STRLEN | |
2103 | static int yy_flex_strlen (yyconst char * s ) | |
2104 | { | |
2105 | register int n; | |
2106 | for ( n = 0; s[n]; ++n ) | |
2107 | ; | |
2108 | ||
2109 | return n; | |
2110 | } | |
2111 | #endif | |
2112 | ||
2113 | void *mdlexalloc (yy_size_t size ) | |
2114 | { | |
2115 | return (void *) malloc( size ); | |
2116 | } | |
2117 | ||
2118 | void *mdlexrealloc (void * ptr, yy_size_t size ) | |
2119 | { | |
2120 | /* The cast to (char *) in the following accommodates both | |
2121 | * implementations that use char* generic pointers, and those | |
2122 | * that use void* generic pointers. It works with the latter | |
2123 | * because both ANSI C and C++ allow castless assignment from | |
2124 | * any pointer type to void*, and deal with argument conversions | |
2125 | * as though doing an assignment. | |
2126 | */ | |
2127 | return (void *) realloc( (char *) ptr, size ); | |
2128 | } | |
2129 | ||
2130 | void mdlexfree (void * ptr ) | |
2131 | { | |
2132 | free( (char *) ptr ); /* see mdlexrealloc() for (char *) cast */ | |
2133 | } | |
2134 | ||
2135 | #define YYTABLES_NAME "yytables" | |
2136 | ||
2137 | #undef YY_NEW_FILE | |
2138 | #undef YY_FLUSH_BUFFER | |
2139 | #undef yy_set_bol | |
2140 | #undef yy_new_buffer | |
2141 | #undef yy_set_interactive | |
2142 | #undef yytext_ptr | |
2143 | #undef YY_DO_BEFORE_ACTION | |
2144 | ||
2145 | #ifdef YY_DECL_IS_OURS | |
2146 | #undef YY_DECL_IS_OURS | |
2147 | #undef YY_DECL | |
2148 | #endif | |
2149 | #line 222 "mdlex.l" | |
2150 | ||
2151 | ||
2152 | ||
2153 | ||
2154 | ||
2155 | ||
2156 | ||
2157 | ||
2158 | ||
2159 | void init_lexer(char * fnamep, FILE *fp, char * cleanup_filep) | |
2160 | { | |
2161 | lex.cleanup_filep = cleanup_filep ? Xstrdup(cleanup_filep) : (char*)0; | |
2162 | lex.linenum = 1; | |
2163 | lex.fnamep = Xstrdup(fnamep); | |
2164 | ||
2165 | lex.ungot_available = false; | |
2166 | lex.last_token = T_Error; | |
2167 | ||
2168 | mdlexin = fp; | |
2169 | } | |
2170 | ||
2171 | ||
2172 | lexer_tok_t lex_get_token() | |
2173 | { | |
2174 | if (lex.ungot_available) { | |
2175 | lex.ungot_available = false; | |
2176 | return lex.last_token; | |
2177 | } | |
2178 | ||
2179 | lex.last_token = mdlexlex(); | |
2180 | ||
2181 | return lex.last_token; | |
2182 | } | |
2183 | ||
2184 | ||
2185 | ||
2186 | void lex_unget() | |
2187 | { | |
2188 | if (lex.ungot_available) fatal("Internal error, lex_unget with token already ungot"); | |
2189 | ||
2190 | lex.ungot_available = true; | |
2191 | } | |
2192 | ||
2193 | ||
2194 | void lex_get(lexer_tok_t expected) | |
2195 | { | |
2196 | lexer_tok_t tok; | |
2197 | char *s; | |
2198 | char buffer[1024]; | |
2199 | ||
2200 | tok = lex_get_token(); | |
2201 | ||
2202 | if (tok == expected) return; | |
2203 | ||
2204 | switch(tok) { | |
2205 | case T_EOF: s="end of file"; break; | |
2206 | case T_L_Brace: s="{"; break; | |
2207 | case T_R_Brace: s="}"; break; | |
2208 | case T_S_Colon: s=";"; break; | |
2209 | case T_Plus: s="+"; break; | |
2210 | case T_Minus: s="-"; break; | |
2211 | case T_Equals: s="="; break; | |
2212 | case T_Number: s="number"; break; | |
2213 | case T_String: s="string"; break; | |
2214 | case T_Token: | |
2215 | sprintf(buffer,"token %s", lex.strp); | |
2216 | s=buffer; | |
2217 | break; | |
2218 | case T_KW_node: s="node"; break; | |
2219 | case T_KW_proto: s="proto"; break; | |
2220 | case T_KW_include: s="include("; break; | |
2221 | case T_KW_expr: s="expr("; break; | |
2222 | case T_KW_lookup: s="lookup("; break; | |
2223 | case T_KW_setprop: s="setprop("; break; | |
2224 | ||
2225 | case T_Error: s="error"; break; | |
2226 | default: | |
2227 | s="unknown token - internal error"; | |
2228 | break; | |
2229 | } | |
2230 | ||
2231 | lex_fatal("unexpected %s", s); | |
2232 | } | |
2233 | ||
2234 | ||
2235 | /* | |
2236 | * Special version of fatal for the lexer | |
2237 | * to enable cleanup of stuff before death | |
2238 | */ | |
2239 | void | |
2240 | lex_fatal(char * fmt, ...) | |
2241 | { | |
2242 | va_list args; | |
2243 | ||
2244 | if (errno != 0) | |
2245 | perror("FATAL: "); | |
2246 | else | |
2247 | fprintf(stderr,"FATAL: "); | |
2248 | if (fmt) { | |
2249 | va_start(args, fmt); | |
2250 | (void) vfprintf(stderr, fmt, args); | |
2251 | ||
2252 | va_end(args); | |
2253 | } | |
2254 | ||
2255 | if (lex.cleanup_filep != (char *)0) { | |
2256 | unlink(lex.cleanup_filep); | |
2257 | Xfree(lex.cleanup_filep); | |
2258 | } | |
2259 | fprintf(stderr," at line %d of %s\n", lex.linenum, lex.fnamep); | |
2260 | Xfree(lex.fnamep); | |
2261 | ||
2262 | SANITY( lex.fnamep = NULL; ); | |
2263 | SANITY( lex.cleanup_filep = NULL; ); | |
2264 | exit(1); | |
2265 | } | |
2266 | ||
2267 | ||
2268 | ||
2269 | int | |
2270 | mdlexwrap(void) | |
2271 | { | |
2272 | return (1); | |
2273 | } | |
2274 | ||
2275 | #if TESTRIG /* { */ | |
2276 | main() | |
2277 | { | |
2278 | lexer_tok_t tok; | |
2279 | ||
2280 | lex.linenum = 1; | |
2281 | lex.fnamep = "test"; | |
2282 | ||
2283 | do { | |
2284 | tok = lexlex(); | |
2285 | ||
2286 | fprintf(stderr,"token = %d at line %d in %s\n",tok, lex.linenum, lex.fnamep); | |
2287 | } while (tok!=T_Error && tok!=T_EOF); | |
2288 | } | |
2289 | ||
2290 | ||
2291 | void fatal(char* fmt, ...) | |
2292 | { | |
2293 | va_list args; | |
2294 | int status; | |
2295 | ||
2296 | if (errno!=0) perror("FATAL: "); else fprintf(stderr,"FATAL: "); | |
2297 | if (fmt) { | |
2298 | va_start(args, fmt); | |
2299 | (void)vfprintf(stderr, fmt, args); | |
2300 | ||
2301 | va_end(args); | |
2302 | } | |
2303 | ||
2304 | fprintf(stderr,"\n"); | |
2305 | fflush(stderr); | |
2306 | fflush(stdout); | |
2307 | ||
2308 | thr_exit(&status); | |
2309 | } | |
2310 | ||
2311 | #endif /* } */ | |
2312 |