fix crashes reported by Debian Cylab Mayhem Team
[swftools.git] / src / parser.yy.c
blobd396d08e2c1d3bfdc9bc208f745fb128745e301f
1 #line 2 "parser.yy.c"
3 #line 4 "parser.yy.c"
5 #define YY_INT_ALIGNED short int
7 /* A lexical scanner generated by flex */
9 #define FLEX_SCANNER
10 #define YY_FLEX_MAJOR_VERSION 2
11 #define YY_FLEX_MINOR_VERSION 5
12 #define YY_FLEX_SUBMINOR_VERSION 35
13 #if YY_FLEX_SUBMINOR_VERSION > 0
14 #define FLEX_BETA
15 #endif
17 /* First, we deal with platform-specific or compiler-specific issues. */
19 /* begin standard C headers. */
20 #include <stdio.h>
21 #include <string.h>
22 #include <errno.h>
23 #include <stdlib.h>
25 /* end standard C headers. */
27 /* flex integer type definitions */
29 #ifndef FLEXINT_H
30 #define FLEXINT_H
32 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
34 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
36 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
37 * if you want the limit (max/min) macros for int types.
39 #ifndef __STDC_LIMIT_MACROS
40 #define __STDC_LIMIT_MACROS 1
41 #endif
43 #include <inttypes.h>
44 typedef int8_t flex_int8_t;
45 typedef uint8_t flex_uint8_t;
46 typedef int16_t flex_int16_t;
47 typedef uint16_t flex_uint16_t;
48 typedef int32_t flex_int32_t;
49 typedef uint32_t flex_uint32_t;
50 #else
51 typedef signed char flex_int8_t;
52 typedef short int flex_int16_t;
53 typedef int flex_int32_t;
54 typedef unsigned char flex_uint8_t;
55 typedef unsigned short int flex_uint16_t;
56 typedef unsigned int flex_uint32_t;
57 #endif /* ! C99 */
59 /* Limits of integral types. */
60 #ifndef INT8_MIN
61 #define INT8_MIN (-128)
62 #endif
63 #ifndef INT16_MIN
64 #define INT16_MIN (-32767-1)
65 #endif
66 #ifndef INT32_MIN
67 #define INT32_MIN (-2147483647-1)
68 #endif
69 #ifndef INT8_MAX
70 #define INT8_MAX (127)
71 #endif
72 #ifndef INT16_MAX
73 #define INT16_MAX (32767)
74 #endif
75 #ifndef INT32_MAX
76 #define INT32_MAX (2147483647)
77 #endif
78 #ifndef UINT8_MAX
79 #define UINT8_MAX (255U)
80 #endif
81 #ifndef UINT16_MAX
82 #define UINT16_MAX (65535U)
83 #endif
84 #ifndef UINT32_MAX
85 #define UINT32_MAX (4294967295U)
86 #endif
88 #endif /* ! FLEXINT_H */
90 #ifdef __cplusplus
92 /* The "const" storage-class-modifier is valid. */
93 #define YY_USE_CONST
95 #else /* ! __cplusplus */
97 /* C99 requires __STDC__ to be defined as 1. */
98 #if defined (__STDC__)
100 #define YY_USE_CONST
102 #endif /* defined (__STDC__) */
103 #endif /* ! __cplusplus */
105 #ifdef YY_USE_CONST
106 #define yyconst const
107 #else
108 #define yyconst
109 #endif
111 /* Returned upon end-of-file. */
112 #define YY_NULL 0
114 /* Promotes a possibly negative, possibly signed char to an unsigned
115 * integer for use as an array index. If the signed char is negative,
116 * we want to instead treat it as an 8-bit unsigned char, hence the
117 * double cast.
119 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
121 /* Enter a start condition. This macro really ought to take a parameter,
122 * but we do it the disgusting crufty way forced on us by the ()-less
123 * definition of BEGIN.
125 #define BEGIN (yy_start) = 1 + 2 *
127 /* Translate the current start state into a value that can be later handed
128 * to BEGIN to return to the state. The YYSTATE alias is for lex
129 * compatibility.
131 #define YY_START (((yy_start) - 1) / 2)
132 #define YYSTATE YY_START
134 /* Action number for EOF rule of a given start state. */
135 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
137 /* Special action meaning "start processing a new file". */
138 #define YY_NEW_FILE yyrestart(yyin )
140 #define YY_END_OF_BUFFER_CHAR 0
142 /* Size of default input buffer. */
143 #ifndef YY_BUF_SIZE
144 #define YY_BUF_SIZE 16384
145 #endif
147 /* The state buf must be large enough to hold one state per character in the main buffer.
149 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
151 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
152 #define YY_TYPEDEF_YY_BUFFER_STATE
153 typedef struct yy_buffer_state *YY_BUFFER_STATE;
154 #endif
156 extern int yyleng;
158 extern FILE *yyin, *yyout;
160 #define EOB_ACT_CONTINUE_SCAN 0
161 #define EOB_ACT_END_OF_FILE 1
162 #define EOB_ACT_LAST_MATCH 2
164 #define YY_LESS_LINENO(n)
166 /* Return all but the first "n" matched characters back to the input stream. */
167 #define yyless(n) \
168 do \
170 /* Undo effects of setting up yytext. */ \
171 int yyless_macro_arg = (n); \
172 YY_LESS_LINENO(yyless_macro_arg);\
173 *yy_cp = (yy_hold_char); \
174 YY_RESTORE_YY_MORE_OFFSET \
175 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
176 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
178 while ( 0 )
180 #define unput(c) yyunput( c, (yytext_ptr) )
182 #ifndef YY_TYPEDEF_YY_SIZE_T
183 #define YY_TYPEDEF_YY_SIZE_T
184 typedef size_t yy_size_t;
185 #endif
187 #ifndef YY_STRUCT_YY_BUFFER_STATE
188 #define YY_STRUCT_YY_BUFFER_STATE
189 struct yy_buffer_state
191 FILE *yy_input_file;
193 char *yy_ch_buf; /* input buffer */
194 char *yy_buf_pos; /* current position in input buffer */
196 /* Size of input buffer in bytes, not including room for EOB
197 * characters.
199 yy_size_t yy_buf_size;
201 /* Number of characters read into yy_ch_buf, not including EOB
202 * characters.
204 int yy_n_chars;
206 /* Whether we "own" the buffer - i.e., we know we created it,
207 * and can realloc() it to grow it, and should free() it to
208 * delete it.
210 int yy_is_our_buffer;
212 /* Whether this is an "interactive" input source; if so, and
213 * if we're using stdio for input, then we want to use getc()
214 * instead of fread(), to make sure we stop fetching input after
215 * each newline.
217 int yy_is_interactive;
219 /* Whether we're considered to be at the beginning of a line.
220 * If so, '^' rules will be active on the next match, otherwise
221 * not.
223 int yy_at_bol;
225 int yy_bs_lineno; /**< The line count. */
226 int yy_bs_column; /**< The column count. */
228 /* Whether to try to fill the input buffer when we reach the
229 * end of it.
231 int yy_fill_buffer;
233 int yy_buffer_status;
235 #define YY_BUFFER_NEW 0
236 #define YY_BUFFER_NORMAL 1
237 /* When an EOF's been seen but there's still some text to process
238 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
239 * shouldn't try reading from the input source any more. We might
240 * still have a bunch of tokens to match, though, because of
241 * possible backing-up.
243 * When we actually see the EOF, we change the status to "new"
244 * (via yyrestart()), so that the user can continue scanning by
245 * just pointing yyin at a new input file.
247 #define YY_BUFFER_EOF_PENDING 2
250 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
252 /* Stack of input buffers. */
253 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
254 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
255 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
257 /* We provide macros for accessing buffer states in case in the
258 * future we want to put the buffer states in a more general
259 * "scanner state".
261 * Returns the top of the stack, or NULL.
263 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
264 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
265 : NULL)
267 /* Same as previous macro, but useful when we know that the buffer stack is not
268 * NULL or when we need an lvalue. For internal use only.
270 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
272 /* yy_hold_char holds the character lost when yytext is formed. */
273 static char yy_hold_char;
274 static int yy_n_chars; /* number of characters read into yy_ch_buf */
275 int yyleng;
277 /* Points to current character in buffer. */
278 static char *yy_c_buf_p = (char *) 0;
279 static int yy_init = 0; /* whether we need to initialize */
280 static int yy_start = 0; /* start state number */
282 /* Flag which is used to allow yywrap()'s to do buffer switches
283 * instead of setting up a fresh yyin. A bit of a hack ...
285 static int yy_did_buffer_switch_on_eof;
287 void yyrestart (FILE *input_file );
288 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
289 YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
290 void yy_delete_buffer (YY_BUFFER_STATE b );
291 void yy_flush_buffer (YY_BUFFER_STATE b );
292 void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
293 void yypop_buffer_state (void );
295 static void yyensure_buffer_stack (void );
296 static void yy_load_buffer_state (void );
297 static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
299 #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
301 YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
302 YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
303 YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
305 void *yyalloc (yy_size_t );
306 void *yyrealloc (void *,yy_size_t );
307 void yyfree (void * );
309 #define yy_new_buffer yy_create_buffer
311 #define yy_set_interactive(is_interactive) \
313 if ( ! YY_CURRENT_BUFFER ){ \
314 yyensure_buffer_stack (); \
315 YY_CURRENT_BUFFER_LVALUE = \
316 yy_create_buffer(yyin,YY_BUF_SIZE ); \
318 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
321 #define yy_set_bol(at_bol) \
323 if ( ! YY_CURRENT_BUFFER ){\
324 yyensure_buffer_stack (); \
325 YY_CURRENT_BUFFER_LVALUE = \
326 yy_create_buffer(yyin,YY_BUF_SIZE ); \
328 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
331 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
333 /* Begin user sect3 */
335 typedef unsigned char YY_CHAR;
337 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
339 typedef int yy_state_type;
341 extern int yylineno;
343 int yylineno = 1;
345 extern char *yytext;
346 #define yytext_ptr yytext
348 static yy_state_type yy_get_previous_state (void );
349 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
350 static int yy_get_next_buffer (void );
351 static void yy_fatal_error (yyconst char msg[] );
353 /* Done after the current pattern has been matched and before the
354 * corresponding action - sets up yytext.
356 #define YY_DO_BEFORE_ACTION \
357 (yytext_ptr) = yy_bp; \
358 yyleng = (size_t) (yy_cp - yy_bp); \
359 (yy_hold_char) = *yy_cp; \
360 *yy_cp = '\0'; \
361 (yy_c_buf_p) = yy_cp;
363 #define YY_NUM_RULES 21
364 #define YY_END_OF_BUFFER 22
365 /* This struct is not used in this scanner,
366 but its presence is necessary. */
367 struct yy_trans_info
369 flex_int32_t yy_verify;
370 flex_int32_t yy_nxt;
372 static yyconst flex_int16_t yy_accept[111] =
373 { 0,
374 0, 0, 13, 13, 0, 0, 22, 20, 19, 19,
375 20, 20, 17, 17, 20, 20, 18, 20, 13, 13,
376 13, 13, 13, 13, 13, 13, 2, 3, 1, 0,
377 0, 9, 8, 0, 0, 0, 0, 0, 15, 17,
378 12, 15, 4, 0, 0, 0, 0, 0, 6, 13,
379 13, 8, 13, 13, 13, 13, 13, 13, 12, 13,
380 13, 13, 0, 7, 0, 10, 0, 11, 0, 15,
381 15, 0, 0, 10, 13, 11, 13, 13, 13, 13,
382 0, 15, 0, 0, 0, 13, 13, 13, 13, 15,
383 5, 16, 13, 15, 13, 15, 13, 15, 13, 0,
385 0, 0, 14, 0, 0, 12, 14, 10, 11, 0
388 static yyconst flex_int32_t yy_ec[256] =
389 { 0,
390 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
391 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
392 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
393 1, 2, 1, 4, 5, 1, 1, 1, 1, 1,
394 1, 1, 6, 1, 7, 8, 9, 10, 11, 11,
395 11, 11, 10, 11, 11, 11, 11, 12, 1, 1,
396 13, 1, 1, 1, 9, 9, 9, 9, 9, 9,
397 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
398 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
399 14, 15, 16, 1, 9, 1, 9, 9, 17, 18,
401 19, 9, 9, 9, 20, 9, 9, 21, 9, 22,
402 9, 9, 9, 9, 9, 9, 23, 9, 9, 9,
403 9, 9, 1, 1, 1, 1, 1, 1, 1, 1,
404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
405 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
406 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
407 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
408 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
410 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
413 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
414 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
417 1, 1, 1, 1, 1
420 static yyconst flex_int32_t yy_meta[24] =
421 { 0,
422 1, 2, 2, 1, 1, 3, 3, 3, 3, 3,
423 3, 4, 3, 1, 1, 1, 3, 3, 3, 3,
424 3, 3, 3
427 static yyconst flex_int16_t yy_base[122] =
428 { 0,
429 0, 230, 23, 229, 44, 45, 233, 395, 227, 395,
430 47, 42, 61, 83, 95, 85, 395, 228, 0, 105,
431 44, 120, 136, 158, 0, 54, 395, 395, 395, 227,
432 96, 395, 395, 225, 0, 168, 214, 180, 192, 204,
433 395, 216, 395, 237, 110, 144, 207, 222, 395, 0,
434 247, 0, 89, 0, 211, 261, 274, 0, 0, 199,
435 65, 92, 217, 395, 203, 395, 202, 395, 296, 192,
436 93, 48, 191, 0, 199, 0, 308, 0, 191, 140,
437 191, 141, 193, 162, 184, 187, 159, 168, 320, 150,
438 395, 182, 126, 170, 114, 97, 95, 187, 194, 330,
440 99, 342, 0, 164, 188, 74, 395, 62, 46, 395,
441 355, 359, 362, 365, 369, 373, 376, 380, 384, 387,
445 static yyconst flex_int16_t yy_def[122] =
446 { 0,
447 110, 1, 110, 3, 111, 111, 110, 110, 110, 110,
448 112, 110, 110, 113, 110, 114, 110, 115, 116, 117,
449 116, 110, 22, 116, 116, 118, 110, 110, 110, 119,
450 112, 110, 110, 112, 15, 110, 110, 113, 120, 113,
451 110, 120, 110, 110, 114, 114, 114, 115, 110, 116,
452 117, 116, 117, 24, 116, 23, 110, 23, 116, 57,
453 24, 118, 119, 110, 110, 110, 38, 110, 120, 42,
454 42, 44, 114, 116, 56, 116, 57, 57, 57, 24,
455 69, 42, 72, 83, 114, 77, 57, 24, 116, 42,
456 110, 114, 57, 42, 57, 42, 57, 42, 57, 121,
458 121, 121, 36, 121, 121, 121, 110, 121, 121, 0,
459 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
463 static yyconst flex_int16_t yy_nxt[419] =
464 { 0,
465 8, 9, 10, 11, 8, 8, 12, 13, 14, 15,
466 15, 16, 8, 17, 8, 8, 14, 14, 14, 14,
467 14, 14, 14, 19, 9, 10, 20, 19, 19, 21,
468 22, 23, 24, 24, 16, 19, 25, 19, 19, 23,
469 23, 23, 23, 23, 23, 23, 28, 28, 107, 32,
470 33, 35, 35, 54, 54, 48, 49, 83, 84, 29,
471 29, 34, 36, 36, 107, 48, 37, 38, 39, 39,
472 40, 40, 50, 41, 80, 80, 107, 39, 39, 39,
473 42, 39, 39, 39, 36, 36, 46, 46, 37, 38,
474 31, 110, 47, 48, 49, 41, 43, 43, 32, 33,
476 31, 107, 44, 48, 35, 35, 31, 32, 52, 82,
477 34, 46, 46, 99, 70, 98, 31, 47, 70, 53,
478 50, 36, 36, 50, 50, 55, 56, 57, 57, 58,
479 58, 97, 59, 50, 50, 50, 57, 57, 57, 60,
480 57, 57, 57, 58, 58, 46, 46, 50, 95, 88,
481 89, 47, 58, 58, 58, 58, 58, 58, 58, 43,
482 43, 90, 70, 91, 91, 61, 107, 54, 54, 36,
483 36, 70, 94, 37, 65, 50, 108, 89, 89, 93,
484 41, 110, 110, 110, 110, 110, 67, 96, 100, 100,
485 107, 70, 68, 36, 36, 100, 100, 37, 69, 50,
487 109, 92, 84, 110, 41, 36, 36, 87, 70, 37,
488 38, 50, 85, 70, 110, 68, 41, 36, 36, 64,
489 79, 37, 69, 74, 49, 73, 66, 110, 41, 64,
490 49, 30, 110, 26, 18, 110, 110, 71, 43, 43,
491 110, 110, 110, 110, 110, 110, 72, 72, 31, 32,
492 52, 110, 110, 110, 110, 110, 110, 110, 31, 110,
493 110, 53, 110, 110, 110, 110, 50, 75, 110, 110,
494 110, 110, 110, 76, 50, 36, 36, 50, 50, 55,
495 77, 78, 78, 78, 78, 110, 59, 50, 50, 50,
496 78, 78, 78, 78, 78, 78, 78, 110, 110, 110,
498 110, 110, 81, 110, 110, 110, 110, 110, 68, 110,
499 110, 110, 110, 50, 86, 110, 110, 110, 110, 110,
500 76, 91, 91, 110, 110, 110, 110, 110, 110, 89,
501 89, 102, 103, 110, 110, 104, 105, 110, 110, 110,
502 110, 110, 106, 102, 103, 110, 110, 104, 105, 110,
503 110, 110, 110, 110, 106, 27, 27, 27, 27, 31,
504 31, 31, 31, 40, 40, 45, 45, 45, 45, 48,
505 48, 48, 48, 50, 110, 50, 51, 51, 51, 51,
506 62, 62, 62, 62, 63, 63, 63, 63, 70, 70,
507 101, 101, 101, 101, 7, 110, 110, 110, 110, 110,
509 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
510 110, 110, 110, 110, 110, 110, 110, 110
513 static yyconst flex_int16_t yy_chk[419] =
514 { 0,
515 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
516 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
517 1, 1, 1, 3, 3, 3, 3, 3, 3, 3,
518 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
519 3, 3, 3, 3, 3, 3, 5, 6, 109, 11,
520 11, 12, 12, 21, 21, 26, 26, 72, 72, 5,
521 6, 11, 13, 13, 108, 26, 13, 13, 13, 13,
522 13, 13, 61, 13, 61, 61, 106, 13, 13, 13,
523 13, 13, 13, 13, 14, 14, 16, 16, 14, 14,
524 53, 53, 16, 62, 62, 14, 15, 15, 31, 31,
526 53, 101, 15, 62, 15, 15, 20, 20, 20, 71,
527 31, 45, 45, 97, 71, 96, 20, 45, 96, 20,
528 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
529 22, 95, 22, 22, 22, 22, 22, 22, 22, 22,
530 22, 22, 22, 23, 23, 46, 46, 80, 93, 80,
531 80, 46, 23, 23, 23, 23, 23, 23, 23, 24,
532 24, 82, 82, 84, 84, 24, 104, 24, 24, 36,
533 36, 90, 90, 36, 36, 88, 104, 88, 88, 87,
534 36, 38, 38, 92, 92, 38, 38, 94, 98, 98,
535 105, 94, 38, 39, 39, 99, 99, 39, 39, 86,
537 105, 85, 83, 81, 39, 40, 40, 79, 98, 40,
538 40, 75, 73, 70, 67, 65, 40, 42, 42, 63,
539 60, 42, 42, 55, 48, 47, 37, 34, 42, 30,
540 18, 9, 7, 4, 2, 0, 0, 42, 44, 44,
541 0, 0, 0, 0, 0, 0, 44, 44, 51, 51,
542 51, 0, 0, 0, 0, 0, 0, 0, 51, 0,
543 0, 51, 56, 56, 0, 0, 56, 56, 0, 0,
544 0, 0, 0, 56, 57, 57, 57, 57, 57, 57,
545 57, 57, 57, 57, 57, 0, 57, 57, 57, 57,
546 57, 57, 57, 57, 57, 57, 57, 69, 69, 0,
548 0, 69, 69, 0, 0, 0, 0, 0, 69, 77,
549 77, 0, 0, 77, 77, 0, 0, 0, 0, 0,
550 77, 89, 89, 0, 0, 0, 0, 0, 0, 89,
551 89, 100, 100, 0, 0, 100, 100, 0, 0, 0,
552 0, 0, 100, 102, 102, 0, 0, 102, 102, 0,
553 0, 0, 0, 0, 102, 111, 111, 111, 111, 112,
554 112, 112, 112, 113, 113, 114, 114, 114, 114, 115,
555 115, 115, 115, 116, 0, 116, 117, 117, 117, 117,
556 118, 118, 118, 118, 119, 119, 119, 119, 120, 120,
557 121, 121, 121, 121, 110, 110, 110, 110, 110, 110,
559 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
560 110, 110, 110, 110, 110, 110, 110, 110
563 static yy_state_type yy_last_accepting_state;
564 static char *yy_last_accepting_cpos;
566 extern int yy_flex_debug;
567 int yy_flex_debug = 0;
569 /* The intent behind this definition is that it'll catch
570 * any uses of REJECT which flex missed.
572 #define REJECT reject_used_but_not_detected
573 #define yymore() yymore_used_but_not_detected
574 #define YY_MORE_ADJ 0
575 #define YY_RESTORE_YY_MORE_OFFSET
576 char *yytext;
577 #line 1 "parser.lex"
578 #line 2 "parser.lex"
580 #include <string.h>
581 #include <stdlib.h>
582 #include <stdio.h>
583 #include "../lib/q.h"
584 #include "parser.h"
585 #include "../lib/utf8.h"
587 //RVALUE {NUMBER}|{PERCENT}|{NAME}|\"{STRING}\"|{DIM}
588 //<a>. {printf("<a>%s\n", yytext);}
589 // %x: exclusive, %s: inclusive
590 char*type_names[] = {"twip","number","command","string","assignment","identifier","label","end"};
591 static int line=1;
592 static int column=1;
594 mem_t strings;
595 mem_t tokens;
597 static void count(char*text, int len, int condition)
599 int t;
600 for(t=0;t<len;t++) {
601 if(text[t]=='\n') {
602 line++;
603 column=1;
604 } else {
605 column++;
610 static char*prefix = 0;
612 static void unescapeString(string_t * tmp)
614 char *p, *p1;
615 /* fixme - this routine expects the string to be
616 null-terminated */
618 for (p1=(char*)tmp->str; (p=strchr(p1, '\\')); p1 = p+1)
620 int nr=2;
621 int new=1;
622 switch(p[1])
624 case '\\': p[0] = '\\'; break;
625 case '"': p[0] = '"'; break;
626 case 'b': p[0] = '\b'; break;
627 case 'f': p[0] = '\f'; break;
628 case 'n': p[0] = '\n'; break;
629 case 'r': p[0] = '\r'; break;
630 case 't': p[0] = '\t'; break;
631 case 'x': case 'u': {
632 int max=4;
633 int num=0;
634 char*utf8;
635 char bracket = 0;
636 if(p[1] == 'u')
637 max = 6;
638 if(p[2] == '{') {
639 bracket = 1;nr++;max++;
641 while(strchr("0123456789abcdefABCDEF", p[nr]) && (bracket || nr < max)) {
642 num <<= 4;
643 if(p[nr]>='0' && p[nr]<='9') num |= p[nr] - '0';
644 if(p[nr]>='a' && p[nr]<='f') num |= p[nr] - 'a' + 10;
645 if(p[nr]>='A' && p[nr]<='F') num |= p[nr] - 'A' + 10;
646 nr++;
648 if(bracket && p[nr]=='}') {
649 bracket = 0;
650 nr++;
652 utf8 = getUTF8(num);
653 new = strlen(utf8);
654 memcpy(p, utf8, new); // do not copy the terminating zero
655 break;
657 default:
658 continue;
660 tmp->len -= (nr-new);
662 int t;
663 char*to=p+new,*from=p+nr;
664 while(*from) {
665 *to = *from;
666 to++;
667 from++;
673 static void store(enum type_t type, int line, int column, char*text, int length)
675 struct token_t token;
676 string_t tmp;
677 token.type = type;
678 token.line = line;
679 token.column = column;
680 //printf("->%d(%s) %s\n", type, type_names[type], text);fflush(stdout);
682 token.text_pos = 0;
683 token.text = 0;
684 switch(type) {
685 case END:
686 string_set2(&tmp, "", 0);
687 token.text_pos = mem_putstring(&strings, tmp);
688 break;
689 case STRING:
690 string_set2(&tmp, text+1, length-2);
691 unescapeString(&tmp);
692 token.text_pos = mem_putstring(&strings, tmp);
693 break;
694 case TWIP:
695 case NUMBER:
696 case IDENTIFIER:
697 string_set2(&tmp, text, length);
698 if(prefix) {
699 //strcat
700 token.text_pos = mem_put(&strings, prefix, strlen(prefix));
701 mem_putstring(&strings, tmp);
702 } else {
703 token.text_pos = mem_putstring(&strings, tmp);
705 prefix = 0;
706 break;
707 case RAWDATA:
708 string_set2(&tmp, text+1/*:*/, length-5/*.end*/);
709 token.text_pos = mem_putstring(&strings, tmp);
710 break;
711 case COMMAND:
712 string_set2(&tmp, text+1, length-1);
713 token.text_pos = mem_putstring(&strings, tmp);
714 break;
715 case ASSIGNMENT: {
716 char*x = &text[length-1];
717 if(x[-1] == '-' || x[-1] == '+')
718 x--;
719 do{x--;} while(*x==32 || *x==10 || *x==13 || *x=='\t');
720 x++; //first space
721 string_set2(&tmp, text, x-text);
722 token.text_pos = mem_putstring(&strings, tmp);
723 /*char*y,*x = strchr(text, '=');
724 if(!x) exit(1);
725 y=x;
726 do{y--;} while(*y==32 || *y==10 || *y==13 || *y=='\t');
727 do{x++;} while(*x==32 || *x==10 || *x==13 || *x=='\t');
728 token.text1 = (char*)put(&strings, text, y-text + 1, 1);
729 token.text2 = (char*)put(&strings, x, length-(x-text), 1);*/
730 } break;
733 mem_put(&tokens, &token, sizeof(struct token_t));
734 prefix = 0;
737 #define MAX_INCLUDE_DEPTH 16
738 static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
739 static int line_stack[MAX_INCLUDE_DEPTH];
740 static int column_stack[MAX_INCLUDE_DEPTH];
741 static int include_stack_ptr = 0;
743 static void handleInclude(char*text, int len)
745 text+=9;len-=9;
746 while(len >=1 && (text[0] == ' ' || text[0] == '\t')) {
747 text++;len--;
749 while(len >= 1 &&
750 (text[len-1] == ' ' ||
751 text[len-1] == '\r' ||
752 text[len-1] == '\n')) {
753 len--;
755 if(len >= 2 && text[0] == '"' && text[len-1] == '"') {
756 text++; len-=2;
758 text[len] = 0;
759 if(include_stack_ptr >= MAX_INCLUDE_DEPTH) {
760 fprintf( stderr, "Includes nested too deeply" );
761 exit( 1 );
763 include_stack[include_stack_ptr] = YY_CURRENT_BUFFER;
764 line_stack[include_stack_ptr] = line;
765 column_stack[include_stack_ptr] = column;
766 include_stack_ptr++;
767 yyin = fopen(text, "rb");
768 if (!yyin) {
769 fprintf(stderr, "Couldn't open %s\n", text);
770 exit(1);
772 yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE ) );
774 #ifdef INITIAL
775 BEGIN(INITIAL);
776 #else
777 // best guess
778 BEGIN(0);
779 #endif
782 #define c() {count(yytext, yyleng, YY_START);}
783 #define s(type) {store(type, line, column, yytext, yyleng);}
786 #line 787 "parser.yy.c"
788 #define INITIAL 0
789 #define R 1
790 #define BINARY 2
792 #ifndef YY_NO_UNISTD_H
793 /* Special case for "unistd.h", since it is non-ANSI. We include it way
794 * down here because we want the user's section 1 to have been scanned first.
795 * The user has a chance to override it with an option.
797 #include <unistd.h>
798 #endif
800 #ifndef YY_EXTRA_TYPE
801 #define YY_EXTRA_TYPE void *
802 #endif
804 static int yy_init_globals (void );
806 /* Accessor methods to globals.
807 These are made visible to non-reentrant scanners for convenience. */
809 int yylex_destroy (void );
811 int yyget_debug (void );
813 void yyset_debug (int debug_flag );
815 YY_EXTRA_TYPE yyget_extra (void );
817 void yyset_extra (YY_EXTRA_TYPE user_defined );
819 FILE *yyget_in (void );
821 void yyset_in (FILE * in_str );
823 FILE *yyget_out (void );
825 void yyset_out (FILE * out_str );
827 int yyget_leng (void );
829 char *yyget_text (void );
831 int yyget_lineno (void );
833 void yyset_lineno (int line_number );
835 /* Macros after this point can all be overridden by user definitions in
836 * section 1.
839 #ifndef YY_SKIP_YYWRAP
840 #ifdef __cplusplus
841 extern "C" int yywrap (void );
842 #else
843 extern int yywrap (void );
844 #endif
845 #endif
847 static void yyunput (int c,char *buf_ptr );
849 #ifndef yytext_ptr
850 static void yy_flex_strncpy (char *,yyconst char *,int );
851 #endif
853 #ifdef YY_NEED_STRLEN
854 static int yy_flex_strlen (yyconst char * );
855 #endif
857 #ifndef YY_NO_INPUT
859 #ifdef __cplusplus
860 static int yyinput (void );
861 #else
862 static int input (void );
863 #endif
865 #endif
867 /* Amount of stuff to slurp up with each read. */
868 #ifndef YY_READ_BUF_SIZE
869 #define YY_READ_BUF_SIZE 8192
870 #endif
872 /* Copy whatever the last rule matched to the standard output. */
873 #ifndef ECHO
874 /* This used to be an fputs(), but since the string might contain NUL's,
875 * we now use fwrite().
877 #define ECHO fwrite( yytext, yyleng, 1, yyout )
878 #endif
880 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
881 * is returned in "result".
883 #ifndef YY_INPUT
884 #define YY_INPUT(buf,result,max_size) \
885 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
887 int c = '*'; \
888 int n; \
889 for ( n = 0; n < max_size && \
890 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
891 buf[n] = (char) c; \
892 if ( c == '\n' ) \
893 buf[n++] = (char) c; \
894 if ( c == EOF && ferror( yyin ) ) \
895 YY_FATAL_ERROR( "input in flex scanner failed" ); \
896 result = n; \
898 else \
900 errno=0; \
901 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
903 if( errno != EINTR) \
905 YY_FATAL_ERROR( "input in flex scanner failed" ); \
906 break; \
908 errno=0; \
909 clearerr(yyin); \
914 #endif
916 /* No semi-colon after return; correct usage is to write "yyterminate();" -
917 * we don't want an extra ';' after the "return" because that will cause
918 * some compilers to complain about unreachable statements.
920 #ifndef yyterminate
921 #define yyterminate() return YY_NULL
922 #endif
924 /* Number of entries by which start-condition stack grows. */
925 #ifndef YY_START_STACK_INCR
926 #define YY_START_STACK_INCR 25
927 #endif
929 /* Report a fatal error. */
930 #ifndef YY_FATAL_ERROR
931 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
932 #endif
934 /* end tables serialization structures and prototypes */
936 /* Default declaration of generated scanner - a define so the user can
937 * easily add parameters.
939 #ifndef YY_DECL
940 #define YY_DECL_IS_OURS 1
942 extern int yylex (void);
944 #define YY_DECL int yylex (void)
945 #endif /* !YY_DECL */
947 /* Code executed at the beginning of each rule, after yytext and yyleng
948 * have been set up.
950 #ifndef YY_USER_ACTION
951 #define YY_USER_ACTION
952 #endif
954 /* Code executed at the end of each rule. */
955 #ifndef YY_BREAK
956 #define YY_BREAK break;
957 #endif
959 #define YY_RULE_SETUP \
960 if ( yyleng > 0 ) \
961 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
962 (yytext[yyleng - 1] == '\n'); \
963 YY_USER_ACTION
965 /** The main scanner function which does all the work.
967 YY_DECL
969 register yy_state_type yy_current_state;
970 register char *yy_cp, *yy_bp;
971 register int yy_act;
973 #line 220 "parser.lex"
976 #line 977 "parser.yy.c"
978 if ( !(yy_init) )
980 (yy_init) = 1;
982 #ifdef YY_USER_INIT
983 YY_USER_INIT;
984 #endif
986 if ( ! (yy_start) )
987 (yy_start) = 1; /* first start state */
989 if ( ! yyin )
990 yyin = stdin;
992 if ( ! yyout )
993 yyout = stdout;
995 if ( ! YY_CURRENT_BUFFER ) {
996 yyensure_buffer_stack ();
997 YY_CURRENT_BUFFER_LVALUE =
998 yy_create_buffer(yyin,YY_BUF_SIZE );
1001 yy_load_buffer_state( );
1004 while ( 1 ) /* loops until end-of-file is reached */
1006 yy_cp = (yy_c_buf_p);
1008 /* Support of yytext. */
1009 *yy_cp = (yy_hold_char);
1011 /* yy_bp points to the position in yy_ch_buf of the start of
1012 * the current run.
1014 yy_bp = yy_cp;
1016 yy_current_state = (yy_start);
1017 yy_current_state += YY_AT_BOL();
1018 yy_match:
1021 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
1022 if ( yy_accept[yy_current_state] )
1024 (yy_last_accepting_state) = yy_current_state;
1025 (yy_last_accepting_cpos) = yy_cp;
1027 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1029 yy_current_state = (int) yy_def[yy_current_state];
1030 if ( yy_current_state >= 111 )
1031 yy_c = yy_meta[(unsigned int) yy_c];
1033 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1034 ++yy_cp;
1036 while ( yy_current_state != 110 );
1037 yy_cp = (yy_last_accepting_cpos);
1038 yy_current_state = (yy_last_accepting_state);
1040 yy_find_action:
1041 yy_act = yy_accept[yy_current_state];
1043 YY_DO_BEFORE_ACTION;
1045 do_action: /* This label is used only to access EOF actions. */
1047 switch ( yy_act )
1048 { /* beginning of action switch */
1049 case 0: /* must back up */
1050 /* undo the effects of YY_DO_BEFORE_ACTION */
1051 *yy_cp = (yy_hold_char);
1052 yy_cp = (yy_last_accepting_cpos);
1053 yy_current_state = (yy_last_accepting_state);
1054 goto yy_find_action;
1056 case 1:
1057 YY_RULE_SETUP
1058 #line 222 "parser.lex"
1059 {c();BEGIN(0);}
1060 YY_BREAK
1061 case 2:
1062 YY_RULE_SETUP
1063 #line 223 "parser.lex"
1064 {c();}
1065 YY_BREAK
1066 case 3:
1067 /* rule 3 can match eol */
1068 YY_RULE_SETUP
1069 #line 224 "parser.lex"
1070 {c();}
1071 YY_BREAK
1072 case 4:
1073 /* rule 4 can match eol */
1074 *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */
1075 (yy_c_buf_p) = yy_cp -= 1;
1076 YY_DO_BEFORE_ACTION; /* set up yytext again */
1077 YY_RULE_SETUP
1078 #line 225 "parser.lex"
1079 {s(TWIP);c();BEGIN(0);}
1080 YY_BREAK
1081 case 5:
1082 /* rule 5 can match eol */
1083 *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */
1084 (yy_c_buf_p) = yy_cp -= 1;
1085 YY_DO_BEFORE_ACTION; /* set up yytext again */
1086 YY_RULE_SETUP
1087 #line 226 "parser.lex"
1088 {s(NUMBER);c();BEGIN(0);}
1089 YY_BREAK
1090 case 6:
1091 /* rule 6 can match eol */
1092 YY_RULE_SETUP
1093 #line 227 "parser.lex"
1094 {c();}
1095 YY_BREAK
1096 case 7:
1097 /* rule 7 can match eol */
1098 YY_RULE_SETUP
1099 #line 228 "parser.lex"
1100 {c();}
1101 YY_BREAK
1102 case 8:
1103 YY_RULE_SETUP
1104 #line 229 "parser.lex"
1105 {s(STRING);c();BEGIN(0);}
1106 YY_BREAK
1107 case 9:
1108 *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */
1109 (yy_c_buf_p) = yy_cp -= 1;
1110 YY_DO_BEFORE_ACTION; /* set up yytext again */
1111 YY_RULE_SETUP
1112 #line 230 "parser.lex"
1113 {c();printf("unterminated string in line %d: %s\n", line, yytext);exit(1);yyterminate();}
1114 YY_BREAK
1115 case 10:
1116 /* rule 10 can match eol */
1117 YY_RULE_SETUP
1118 #line 231 "parser.lex"
1119 {s(ASSIGNMENT);prefix="<plus>";c();BEGIN(R);}
1120 YY_BREAK
1121 case 11:
1122 /* rule 11 can match eol */
1123 YY_RULE_SETUP
1124 #line 232 "parser.lex"
1125 {s(ASSIGNMENT);prefix="<minus>";c();BEGIN(R);}
1126 YY_BREAK
1127 case 12:
1128 /* rule 12 can match eol */
1129 YY_RULE_SETUP
1130 #line 233 "parser.lex"
1131 {s(ASSIGNMENT);c();BEGIN(R);}
1132 YY_BREAK
1133 /* values which appear only on the right-hand side of assignments, like: x=50% */
1134 case 13:
1135 YY_RULE_SETUP
1136 #line 235 "parser.lex"
1137 {s(IDENTIFIER);c();BEGIN(0);}
1138 YY_BREAK
1140 case 14:
1141 /* rule 14 can match eol */
1142 YY_RULE_SETUP
1143 #line 237 "parser.lex"
1144 {handleInclude(yytext, yyleng);}
1145 YY_BREAK
1146 case 15:
1147 YY_RULE_SETUP
1148 #line 238 "parser.lex"
1149 {s(COMMAND);c();}
1150 YY_BREAK
1151 case 16:
1152 /* rule 16 can match eol */
1153 YY_RULE_SETUP
1154 #line 239 "parser.lex"
1155 {s(RAWDATA);c();}
1156 YY_BREAK
1157 case 17:
1158 YY_RULE_SETUP
1159 #line 240 "parser.lex"
1160 {s(IDENTIFIER);c();}
1161 YY_BREAK
1162 case 18:
1163 YY_RULE_SETUP
1164 #line 241 "parser.lex"
1165 {c();BEGIN(BINARY);}
1166 YY_BREAK
1167 case 19:
1168 /* rule 19 can match eol */
1169 YY_RULE_SETUP
1170 #line 242 "parser.lex"
1171 {c();}
1172 YY_BREAK
1173 case 20:
1174 YY_RULE_SETUP
1175 #line 243 "parser.lex"
1176 {char c,c1=yytext[0];
1177 printf("Syntax error in line %d, %d: %s", line, column, yytext);
1178 while(1) {
1179 c=input();
1180 if(c=='\n' || c==EOF)
1181 break;
1182 printf("%c", c);
1184 if(c1>='0' && c1<='9')
1185 printf(" (identifiers must not start with a digit)");
1186 printf("\n");
1187 exit(1);
1188 yyterminate();
1190 YY_BREAK
1191 case YY_STATE_EOF(INITIAL):
1192 case YY_STATE_EOF(R):
1193 case YY_STATE_EOF(BINARY):
1194 #line 257 "parser.lex"
1195 {c();
1196 if ( --include_stack_ptr < 0 ) {
1197 s(END);
1198 yyterminate();
1199 } else {
1200 yy_delete_buffer(YY_CURRENT_BUFFER );
1201 yy_switch_to_buffer(include_stack[include_stack_ptr] );
1202 column = column_stack[include_stack_ptr];
1203 line = line_stack[include_stack_ptr];
1206 YY_BREAK
1207 case 21:
1208 YY_RULE_SETUP
1209 #line 270 "parser.lex"
1210 YY_FATAL_ERROR( "flex scanner jammed" );
1211 YY_BREAK
1212 #line 1213 "parser.yy.c"
1214 case YY_END_OF_BUFFER:
1216 /* Amount of text matched not including the EOB char. */
1217 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1219 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1220 *yy_cp = (yy_hold_char);
1221 YY_RESTORE_YY_MORE_OFFSET
1223 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1225 /* We're scanning a new file or input source. It's
1226 * possible that this happened because the user
1227 * just pointed yyin at a new source and called
1228 * yylex(). If so, then we have to assure
1229 * consistency between YY_CURRENT_BUFFER and our
1230 * globals. Here is the right place to do so, because
1231 * this is the first action (other than possibly a
1232 * back-up) that will match for the new input source.
1234 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1235 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1236 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1239 /* Note that here we test for yy_c_buf_p "<=" to the position
1240 * of the first EOB in the buffer, since yy_c_buf_p will
1241 * already have been incremented past the NUL character
1242 * (since all states make transitions on EOB to the
1243 * end-of-buffer state). Contrast this with the test
1244 * in input().
1246 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1247 { /* This was really a NUL. */
1248 yy_state_type yy_next_state;
1250 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1252 yy_current_state = yy_get_previous_state( );
1254 /* Okay, we're now positioned to make the NUL
1255 * transition. We couldn't have
1256 * yy_get_previous_state() go ahead and do it
1257 * for us because it doesn't know how to deal
1258 * with the possibility of jamming (and we don't
1259 * want to build jamming into it because then it
1260 * will run more slowly).
1263 yy_next_state = yy_try_NUL_trans( yy_current_state );
1265 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1267 if ( yy_next_state )
1269 /* Consume the NUL. */
1270 yy_cp = ++(yy_c_buf_p);
1271 yy_current_state = yy_next_state;
1272 goto yy_match;
1275 else
1277 yy_cp = (yy_last_accepting_cpos);
1278 yy_current_state = (yy_last_accepting_state);
1279 goto yy_find_action;
1283 else switch ( yy_get_next_buffer( ) )
1285 case EOB_ACT_END_OF_FILE:
1287 (yy_did_buffer_switch_on_eof) = 0;
1289 if ( yywrap( ) )
1291 /* Note: because we've taken care in
1292 * yy_get_next_buffer() to have set up
1293 * yytext, we can now set up
1294 * yy_c_buf_p so that if some total
1295 * hoser (like flex itself) wants to
1296 * call the scanner after we return the
1297 * YY_NULL, it'll still work - another
1298 * YY_NULL will get returned.
1300 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1302 yy_act = YY_STATE_EOF(YY_START);
1303 goto do_action;
1306 else
1308 if ( ! (yy_did_buffer_switch_on_eof) )
1309 YY_NEW_FILE;
1311 break;
1314 case EOB_ACT_CONTINUE_SCAN:
1315 (yy_c_buf_p) =
1316 (yytext_ptr) + yy_amount_of_matched_text;
1318 yy_current_state = yy_get_previous_state( );
1320 yy_cp = (yy_c_buf_p);
1321 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1322 goto yy_match;
1324 case EOB_ACT_LAST_MATCH:
1325 (yy_c_buf_p) =
1326 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1328 yy_current_state = yy_get_previous_state( );
1330 yy_cp = (yy_c_buf_p);
1331 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1332 goto yy_find_action;
1334 break;
1337 default:
1338 YY_FATAL_ERROR(
1339 "fatal flex scanner internal error--no action found" );
1340 } /* end of action switch */
1341 } /* end of scanning one token */
1342 } /* end of yylex */
1344 /* yy_get_next_buffer - try to read in a new buffer
1346 * Returns a code representing an action:
1347 * EOB_ACT_LAST_MATCH -
1348 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1349 * EOB_ACT_END_OF_FILE - end of file
1351 static int yy_get_next_buffer (void)
1353 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1354 register char *source = (yytext_ptr);
1355 register int number_to_move, i;
1356 int ret_val;
1358 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1359 YY_FATAL_ERROR(
1360 "fatal flex scanner internal error--end of buffer missed" );
1362 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1363 { /* Don't try to fill the buffer, so this is an EOF. */
1364 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1366 /* We matched a single character, the EOB, so
1367 * treat this as a final EOF.
1369 return EOB_ACT_END_OF_FILE;
1372 else
1374 /* We matched some text prior to the EOB, first
1375 * process it.
1377 return EOB_ACT_LAST_MATCH;
1381 /* Try to read more data. */
1383 /* First move last chars to start of buffer. */
1384 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1386 for ( i = 0; i < number_to_move; ++i )
1387 *(dest++) = *(source++);
1389 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1390 /* don't do the read, it's not guaranteed to return an EOF,
1391 * just force an EOF
1393 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1395 else
1397 int num_to_read =
1398 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1400 while ( num_to_read <= 0 )
1401 { /* Not enough room in the buffer - grow it. */
1403 /* just a shorter name for the current buffer */
1404 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1406 int yy_c_buf_p_offset =
1407 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1409 if ( b->yy_is_our_buffer )
1411 int new_size = b->yy_buf_size * 2;
1413 if ( new_size <= 0 )
1414 b->yy_buf_size += b->yy_buf_size / 8;
1415 else
1416 b->yy_buf_size *= 2;
1418 b->yy_ch_buf = (char *)
1419 /* Include room in for 2 EOB chars. */
1420 yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1422 else
1423 /* Can't grow it, we don't own it. */
1424 b->yy_ch_buf = 0;
1426 if ( ! b->yy_ch_buf )
1427 YY_FATAL_ERROR(
1428 "fatal error - scanner input buffer overflow" );
1430 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1432 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1433 number_to_move - 1;
1437 if ( num_to_read > YY_READ_BUF_SIZE )
1438 num_to_read = YY_READ_BUF_SIZE;
1440 /* Read in more data. */
1441 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1442 (yy_n_chars), (size_t) num_to_read );
1444 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1447 if ( (yy_n_chars) == 0 )
1449 if ( number_to_move == YY_MORE_ADJ )
1451 ret_val = EOB_ACT_END_OF_FILE;
1452 yyrestart(yyin );
1455 else
1457 ret_val = EOB_ACT_LAST_MATCH;
1458 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1459 YY_BUFFER_EOF_PENDING;
1463 else
1464 ret_val = EOB_ACT_CONTINUE_SCAN;
1466 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1467 /* Extend the array by 50%, plus the number we really need. */
1468 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1469 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1470 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1471 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1474 (yy_n_chars) += number_to_move;
1475 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1476 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1478 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1480 return ret_val;
1483 /* yy_get_previous_state - get the state just before the EOB char was reached */
1485 static yy_state_type yy_get_previous_state (void)
1487 register yy_state_type yy_current_state;
1488 register char *yy_cp;
1490 yy_current_state = (yy_start);
1491 yy_current_state += YY_AT_BOL();
1493 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1495 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1496 if ( yy_accept[yy_current_state] )
1498 (yy_last_accepting_state) = yy_current_state;
1499 (yy_last_accepting_cpos) = yy_cp;
1501 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1503 yy_current_state = (int) yy_def[yy_current_state];
1504 if ( yy_current_state >= 111 )
1505 yy_c = yy_meta[(unsigned int) yy_c];
1507 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1510 return yy_current_state;
1513 /* yy_try_NUL_trans - try to make a transition on the NUL character
1515 * synopsis
1516 * next_state = yy_try_NUL_trans( current_state );
1518 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1520 register int yy_is_jam;
1521 register char *yy_cp = (yy_c_buf_p);
1523 register YY_CHAR yy_c = 1;
1524 if ( yy_accept[yy_current_state] )
1526 (yy_last_accepting_state) = yy_current_state;
1527 (yy_last_accepting_cpos) = yy_cp;
1529 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1531 yy_current_state = (int) yy_def[yy_current_state];
1532 if ( yy_current_state >= 111 )
1533 yy_c = yy_meta[(unsigned int) yy_c];
1535 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1536 yy_is_jam = (yy_current_state == 110);
1538 return yy_is_jam ? 0 : yy_current_state;
1541 static void yyunput (int c, register char * yy_bp )
1543 register char *yy_cp;
1545 yy_cp = (yy_c_buf_p);
1547 /* undo effects of setting up yytext */
1548 *yy_cp = (yy_hold_char);
1550 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1551 { /* need to shift things up to make room */
1552 /* +2 for EOB chars. */
1553 register int number_to_move = (yy_n_chars) + 2;
1554 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1555 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1556 register char *source =
1557 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1559 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1560 *--dest = *--source;
1562 yy_cp += (int) (dest - source);
1563 yy_bp += (int) (dest - source);
1564 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1565 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1567 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1568 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1571 *--yy_cp = (char) c;
1573 (yytext_ptr) = yy_bp;
1574 (yy_hold_char) = *yy_cp;
1575 (yy_c_buf_p) = yy_cp;
1578 #ifndef YY_NO_INPUT
1579 #ifdef __cplusplus
1580 static int yyinput (void)
1581 #else
1582 static int input (void)
1583 #endif
1586 int c;
1588 *(yy_c_buf_p) = (yy_hold_char);
1590 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1592 /* yy_c_buf_p now points to the character we want to return.
1593 * If this occurs *before* the EOB characters, then it's a
1594 * valid NUL; if not, then we've hit the end of the buffer.
1596 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1597 /* This was really a NUL. */
1598 *(yy_c_buf_p) = '\0';
1600 else
1601 { /* need more input */
1602 int offset = (yy_c_buf_p) - (yytext_ptr);
1603 ++(yy_c_buf_p);
1605 switch ( yy_get_next_buffer( ) )
1607 case EOB_ACT_LAST_MATCH:
1608 /* This happens because yy_g_n_b()
1609 * sees that we've accumulated a
1610 * token and flags that we need to
1611 * try matching the token before
1612 * proceeding. But for input(),
1613 * there's no matching to consider.
1614 * So convert the EOB_ACT_LAST_MATCH
1615 * to EOB_ACT_END_OF_FILE.
1618 /* Reset buffer status. */
1619 yyrestart(yyin );
1621 /*FALLTHROUGH*/
1623 case EOB_ACT_END_OF_FILE:
1625 if ( yywrap( ) )
1626 return EOF;
1628 if ( ! (yy_did_buffer_switch_on_eof) )
1629 YY_NEW_FILE;
1630 #ifdef __cplusplus
1631 return yyinput();
1632 #else
1633 return input();
1634 #endif
1637 case EOB_ACT_CONTINUE_SCAN:
1638 (yy_c_buf_p) = (yytext_ptr) + offset;
1639 break;
1644 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1645 *(yy_c_buf_p) = '\0'; /* preserve yytext */
1646 (yy_hold_char) = *++(yy_c_buf_p);
1648 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
1650 return c;
1652 #endif /* ifndef YY_NO_INPUT */
1654 /** Immediately switch to a different input stream.
1655 * @param input_file A readable stream.
1657 * @note This function does not reset the start condition to @c INITIAL .
1659 void yyrestart (FILE * input_file )
1662 if ( ! YY_CURRENT_BUFFER ){
1663 yyensure_buffer_stack ();
1664 YY_CURRENT_BUFFER_LVALUE =
1665 yy_create_buffer(yyin,YY_BUF_SIZE );
1668 yy_init_buffer(YY_CURRENT_BUFFER,input_file );
1669 yy_load_buffer_state( );
1672 /** Switch to a different input buffer.
1673 * @param new_buffer The new input buffer.
1676 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1679 /* TODO. We should be able to replace this entire function body
1680 * with
1681 * yypop_buffer_state();
1682 * yypush_buffer_state(new_buffer);
1684 yyensure_buffer_stack ();
1685 if ( YY_CURRENT_BUFFER == new_buffer )
1686 return;
1688 if ( YY_CURRENT_BUFFER )
1690 /* Flush out information for old buffer. */
1691 *(yy_c_buf_p) = (yy_hold_char);
1692 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1693 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1696 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1697 yy_load_buffer_state( );
1699 /* We don't actually know whether we did this switch during
1700 * EOF (yywrap()) processing, but the only time this flag
1701 * is looked at is after yywrap() is called, so it's safe
1702 * to go ahead and always set it.
1704 (yy_did_buffer_switch_on_eof) = 1;
1707 static void yy_load_buffer_state (void)
1709 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1710 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1711 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1712 (yy_hold_char) = *(yy_c_buf_p);
1715 /** Allocate and initialize an input buffer state.
1716 * @param file A readable stream.
1717 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1719 * @return the allocated buffer state.
1721 YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
1723 YY_BUFFER_STATE b;
1725 b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
1726 if ( ! b )
1727 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1729 b->yy_buf_size = size;
1731 /* yy_ch_buf has to be 2 characters longer than the size given because
1732 * we need to put in 2 end-of-buffer characters.
1734 b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
1735 if ( ! b->yy_ch_buf )
1736 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1738 b->yy_is_our_buffer = 1;
1740 yy_init_buffer(b,file );
1742 return b;
1745 /** Destroy the buffer.
1746 * @param b a buffer created with yy_create_buffer()
1749 void yy_delete_buffer (YY_BUFFER_STATE b )
1752 if ( ! b )
1753 return;
1755 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1756 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1758 if ( b->yy_is_our_buffer )
1759 yyfree((void *) b->yy_ch_buf );
1761 yyfree((void *) b );
1764 #ifndef _UNISTD_H /* assume unistd.h has isatty() for us */
1765 #ifdef __cplusplus
1766 extern "C" {
1767 #endif
1768 #ifdef __THROW /* this is a gnuism */
1769 extern int isatty (int ) __THROW;
1770 #else
1771 extern int isatty (int );
1772 #endif
1773 #ifdef __cplusplus
1775 #endif
1776 #endif
1778 /* Initializes or reinitializes a buffer.
1779 * This function is sometimes called more than once on the same buffer,
1780 * such as during a yyrestart() or at EOF.
1782 static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
1785 int oerrno = errno;
1787 yy_flush_buffer(b );
1789 b->yy_input_file = file;
1790 b->yy_fill_buffer = 1;
1792 /* If b is the current buffer, then yy_init_buffer was _probably_
1793 * called from yyrestart() or through yy_get_next_buffer.
1794 * In that case, we don't want to reset the lineno or column.
1796 if (b != YY_CURRENT_BUFFER){
1797 b->yy_bs_lineno = 1;
1798 b->yy_bs_column = 0;
1801 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1803 errno = oerrno;
1806 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1807 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1810 void yy_flush_buffer (YY_BUFFER_STATE b )
1812 if ( ! b )
1813 return;
1815 b->yy_n_chars = 0;
1817 /* We always need two end-of-buffer characters. The first causes
1818 * a transition to the end-of-buffer state. The second causes
1819 * a jam in that state.
1821 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1822 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1824 b->yy_buf_pos = &b->yy_ch_buf[0];
1826 b->yy_at_bol = 1;
1827 b->yy_buffer_status = YY_BUFFER_NEW;
1829 if ( b == YY_CURRENT_BUFFER )
1830 yy_load_buffer_state( );
1833 /** Pushes the new state onto the stack. The new state becomes
1834 * the current state. This function will allocate the stack
1835 * if necessary.
1836 * @param new_buffer The new state.
1839 void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
1841 if (new_buffer == NULL)
1842 return;
1844 yyensure_buffer_stack();
1846 /* This block is copied from yy_switch_to_buffer. */
1847 if ( YY_CURRENT_BUFFER )
1849 /* Flush out information for old buffer. */
1850 *(yy_c_buf_p) = (yy_hold_char);
1851 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1852 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1855 /* Only push if top exists. Otherwise, replace top. */
1856 if (YY_CURRENT_BUFFER)
1857 (yy_buffer_stack_top)++;
1858 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1860 /* copied from yy_switch_to_buffer. */
1861 yy_load_buffer_state( );
1862 (yy_did_buffer_switch_on_eof) = 1;
1865 /** Removes and deletes the top of the stack, if present.
1866 * The next element becomes the new top.
1869 void yypop_buffer_state (void)
1871 if (!YY_CURRENT_BUFFER)
1872 return;
1874 yy_delete_buffer(YY_CURRENT_BUFFER );
1875 YY_CURRENT_BUFFER_LVALUE = NULL;
1876 if ((yy_buffer_stack_top) > 0)
1877 --(yy_buffer_stack_top);
1879 if (YY_CURRENT_BUFFER) {
1880 yy_load_buffer_state( );
1881 (yy_did_buffer_switch_on_eof) = 1;
1885 /* Allocates the stack if it does not exist.
1886 * Guarantees space for at least one push.
1888 static void yyensure_buffer_stack (void)
1890 int num_to_alloc;
1892 if (!(yy_buffer_stack)) {
1894 /* First allocation is just for 2 elements, since we don't know if this
1895 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1896 * immediate realloc on the next call.
1898 num_to_alloc = 1;
1899 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1900 (num_to_alloc * sizeof(struct yy_buffer_state*)
1902 if ( ! (yy_buffer_stack) )
1903 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1905 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1907 (yy_buffer_stack_max) = num_to_alloc;
1908 (yy_buffer_stack_top) = 0;
1909 return;
1912 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1914 /* Increase the buffer to prepare for a possible push. */
1915 int grow_size = 8 /* arbitrary grow size */;
1917 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1918 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
1919 ((yy_buffer_stack),
1920 num_to_alloc * sizeof(struct yy_buffer_state*)
1922 if ( ! (yy_buffer_stack) )
1923 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1925 /* zero only the new slots.*/
1926 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1927 (yy_buffer_stack_max) = num_to_alloc;
1931 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1932 * @param base the character buffer
1933 * @param size the size in bytes of the character buffer
1935 * @return the newly allocated buffer state object.
1937 YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
1939 YY_BUFFER_STATE b;
1941 if ( size < 2 ||
1942 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1943 base[size-1] != YY_END_OF_BUFFER_CHAR )
1944 /* They forgot to leave room for the EOB's. */
1945 return 0;
1947 b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
1948 if ( ! b )
1949 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1951 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1952 b->yy_buf_pos = b->yy_ch_buf = base;
1953 b->yy_is_our_buffer = 0;
1954 b->yy_input_file = 0;
1955 b->yy_n_chars = b->yy_buf_size;
1956 b->yy_is_interactive = 0;
1957 b->yy_at_bol = 1;
1958 b->yy_fill_buffer = 0;
1959 b->yy_buffer_status = YY_BUFFER_NEW;
1961 yy_switch_to_buffer(b );
1963 return b;
1966 /** Setup the input buffer state to scan a string. The next call to yylex() will
1967 * scan from a @e copy of @a str.
1968 * @param yystr a NUL-terminated string to scan
1970 * @return the newly allocated buffer state object.
1971 * @note If you want to scan bytes that may contain NUL values, then use
1972 * yy_scan_bytes() instead.
1974 YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
1977 return yy_scan_bytes(yystr,strlen(yystr) );
1980 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1981 * scan from a @e copy of @a bytes.
1982 * @param bytes the byte buffer to scan
1983 * @param len the number of bytes in the buffer pointed to by @a bytes.
1985 * @return the newly allocated buffer state object.
1987 YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
1989 YY_BUFFER_STATE b;
1990 char *buf;
1991 yy_size_t n;
1992 int i;
1994 /* Get memory for full buffer, including space for trailing EOB's. */
1995 n = _yybytes_len + 2;
1996 buf = (char *) yyalloc(n );
1997 if ( ! buf )
1998 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
2000 for ( i = 0; i < _yybytes_len; ++i )
2001 buf[i] = yybytes[i];
2003 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2005 b = yy_scan_buffer(buf,n );
2006 if ( ! b )
2007 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
2009 /* It's okay to grow etc. this buffer, and we should throw it
2010 * away when we're done.
2012 b->yy_is_our_buffer = 1;
2014 return b;
2017 #ifndef YY_EXIT_FAILURE
2018 #define YY_EXIT_FAILURE 2
2019 #endif
2021 static void yy_fatal_error (yyconst char* msg )
2023 (void) fprintf( stderr, "%s\n", msg );
2024 exit( YY_EXIT_FAILURE );
2027 /* Redefine yyless() so it works in section 3 code. */
2029 #undef yyless
2030 #define yyless(n) \
2031 do \
2033 /* Undo effects of setting up yytext. */ \
2034 int yyless_macro_arg = (n); \
2035 YY_LESS_LINENO(yyless_macro_arg);\
2036 yytext[yyleng] = (yy_hold_char); \
2037 (yy_c_buf_p) = yytext + yyless_macro_arg; \
2038 (yy_hold_char) = *(yy_c_buf_p); \
2039 *(yy_c_buf_p) = '\0'; \
2040 yyleng = yyless_macro_arg; \
2042 while ( 0 )
2044 /* Accessor methods (get/set functions) to struct members. */
2046 /** Get the current line number.
2049 int yyget_lineno (void)
2052 return yylineno;
2055 /** Get the input stream.
2058 FILE *yyget_in (void)
2060 return yyin;
2063 /** Get the output stream.
2066 FILE *yyget_out (void)
2068 return yyout;
2071 /** Get the length of the current token.
2074 int yyget_leng (void)
2076 return yyleng;
2079 /** Get the current token.
2083 char *yyget_text (void)
2085 return yytext;
2088 /** Set the current line number.
2089 * @param line_number
2092 void yyset_lineno (int line_number )
2095 yylineno = line_number;
2098 /** Set the input stream. This does not discard the current
2099 * input buffer.
2100 * @param in_str A readable stream.
2102 * @see yy_switch_to_buffer
2104 void yyset_in (FILE * in_str )
2106 yyin = in_str ;
2109 void yyset_out (FILE * out_str )
2111 yyout = out_str ;
2114 int yyget_debug (void)
2116 return yy_flex_debug;
2119 void yyset_debug (int bdebug )
2121 yy_flex_debug = bdebug ;
2124 static int yy_init_globals (void)
2126 /* Initialization is the same as for the non-reentrant scanner.
2127 * This function is called from yylex_destroy(), so don't allocate here.
2130 (yy_buffer_stack) = 0;
2131 (yy_buffer_stack_top) = 0;
2132 (yy_buffer_stack_max) = 0;
2133 (yy_c_buf_p) = (char *) 0;
2134 (yy_init) = 0;
2135 (yy_start) = 0;
2137 /* Defined in main.c */
2138 #ifdef YY_STDINIT
2139 yyin = stdin;
2140 yyout = stdout;
2141 #else
2142 yyin = (FILE *) 0;
2143 yyout = (FILE *) 0;
2144 #endif
2146 /* For future reference: Set errno on error, since we are called by
2147 * yylex_init()
2149 return 0;
2152 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
2153 int yylex_destroy (void)
2156 /* Pop the buffer stack, destroying each element. */
2157 while(YY_CURRENT_BUFFER){
2158 yy_delete_buffer(YY_CURRENT_BUFFER );
2159 YY_CURRENT_BUFFER_LVALUE = NULL;
2160 yypop_buffer_state();
2163 /* Destroy the stack itself. */
2164 yyfree((yy_buffer_stack) );
2165 (yy_buffer_stack) = NULL;
2167 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2168 * yylex() is called, initialization will occur. */
2169 yy_init_globals( );
2171 return 0;
2175 * Internal utility routines.
2178 #ifndef yytext_ptr
2179 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
2181 register int i;
2182 for ( i = 0; i < n; ++i )
2183 s1[i] = s2[i];
2185 #endif
2187 #ifdef YY_NEED_STRLEN
2188 static int yy_flex_strlen (yyconst char * s )
2190 register int n;
2191 for ( n = 0; s[n]; ++n )
2194 return n;
2196 #endif
2198 void *yyalloc (yy_size_t size )
2200 return (void *) malloc( size );
2203 void *yyrealloc (void * ptr, yy_size_t size )
2205 /* The cast to (char *) in the following accommodates both
2206 * implementations that use char* generic pointers, and those
2207 * that use void* generic pointers. It works with the latter
2208 * because both ANSI C and C++ allow castless assignment from
2209 * any pointer type to void*, and deal with argument conversions
2210 * as though doing an assignment.
2212 return (void *) realloc( (char *) ptr, size );
2215 void yyfree (void * ptr )
2217 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
2220 #define YYTABLES_NAME "yytables"
2222 #line 270 "parser.lex"
2226 int yywrap()
2228 return 1;
2231 void freeTokens(struct token_t*file)
2233 mem_clear(&strings);
2234 mem_clear(&tokens);
2237 struct token_t* generateTokens(char*filename)
2239 FILE*fi;
2240 int t;
2241 struct token_t*result;
2242 int num;
2244 if(!filename)
2245 return 0;
2247 if(!strcmp(filename,"-"))
2248 fi = stdin;
2249 else
2250 fi = fopen(filename, "rb");
2252 if(!fi) {
2253 printf("Couldn't find file %s\n", filename);
2254 return 0;
2256 yyin = fi;
2258 mem_init(&strings);
2259 mem_init(&tokens);
2260 mem_put(&strings, &t, 1); //hack- make all valid strings start at position >0
2262 line=1;
2263 column=1;
2265 yylex();
2266 #ifdef YY_CURRENT_BUFFER
2267 // some newer flex versions require it like this:
2268 yy_delete_buffer(YY_CURRENT_BUFFER);
2269 #else
2270 yy_delete_buffer(yy_current_buffer);
2271 #endif
2273 result = (struct token_t*)tokens.buffer;
2274 num = tokens.pos/sizeof(struct token_t);
2276 for(t=0;t<tokens.pos/sizeof(struct token_t);t++) {
2277 if(result[t].text_pos) {
2278 result[t].text = &strings.buffer[result[t].text_pos];
2282 if(fi!=stdin)
2283 fclose(fi);
2284 return result;