fixed bug in jpeg2000 decoding
[swftools.git] / src / parser.yy.c
1 #line 2 "parser.yy.c"
2
3 #line 4 "parser.yy.c"
4
5 #define  YY_INT_ALIGNED short int
6
7 /* A lexical scanner generated by flex */
8
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
16
17 /* First, we deal with  platform-specific or compiler-specific issues. */
18
19 /* begin standard C headers. */
20 #include <stdio.h>
21 #include <string.h>
22 #include <errno.h>
23 #include <stdlib.h>
24
25 /* end standard C headers. */
26
27 /* flex integer type definitions */
28
29 #ifndef FLEXINT_H
30 #define FLEXINT_H
31
32 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
33
34 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
35
36 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
37  * if you want the limit (max/min) macros for int types. 
38  */
39 #ifndef __STDC_LIMIT_MACROS
40 #define __STDC_LIMIT_MACROS 1
41 #endif
42
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 */
58
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
87
88 #endif /* ! FLEXINT_H */
89
90 #ifdef __cplusplus
91
92 /* The "const" storage-class-modifier is valid. */
93 #define YY_USE_CONST
94
95 #else   /* ! __cplusplus */
96
97 /* C99 requires __STDC__ to be defined as 1. */
98 #if defined (__STDC__)
99
100 #define YY_USE_CONST
101
102 #endif  /* defined (__STDC__) */
103 #endif  /* ! __cplusplus */
104
105 #ifdef YY_USE_CONST
106 #define yyconst const
107 #else
108 #define yyconst
109 #endif
110
111 /* Returned upon end-of-file. */
112 #define YY_NULL 0
113
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.
118  */
119 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
120
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.
124  */
125 #define BEGIN (yy_start) = 1 + 2 *
126
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.
130  */
131 #define YY_START (((yy_start) - 1) / 2)
132 #define YYSTATE YY_START
133
134 /* Action number for EOF rule of a given start state. */
135 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
136
137 /* Special action meaning "start processing a new file". */
138 #define YY_NEW_FILE yyrestart(yyin  )
139
140 #define YY_END_OF_BUFFER_CHAR 0
141
142 /* Size of default input buffer. */
143 #ifndef YY_BUF_SIZE
144 #define YY_BUF_SIZE 16384
145 #endif
146
147 /* The state buf must be large enough to hold one state per character in the main buffer.
148  */
149 #define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
150
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
155
156 extern int yyleng;
157
158 extern FILE *yyin, *yyout;
159
160 #define EOB_ACT_CONTINUE_SCAN 0
161 #define EOB_ACT_END_OF_FILE 1
162 #define EOB_ACT_LAST_MATCH 2
163
164     #define YY_LESS_LINENO(n)
165     
166 /* Return all but the first "n" matched characters back to the input stream. */
167 #define yyless(n) \
168         do \
169                 { \
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 */ \
177                 } \
178         while ( 0 )
179
180 #define unput(c) yyunput( c, (yytext_ptr)  )
181
182 #ifndef YY_TYPEDEF_YY_SIZE_T
183 #define YY_TYPEDEF_YY_SIZE_T
184 typedef size_t yy_size_t;
185 #endif
186
187 #ifndef YY_STRUCT_YY_BUFFER_STATE
188 #define YY_STRUCT_YY_BUFFER_STATE
189 struct yy_buffer_state
190         {
191         FILE *yy_input_file;
192
193         char *yy_ch_buf;                /* input buffer */
194         char *yy_buf_pos;               /* current position in input buffer */
195
196         /* Size of input buffer in bytes, not including room for EOB
197          * characters.
198          */
199         yy_size_t yy_buf_size;
200
201         /* Number of characters read into yy_ch_buf, not including EOB
202          * characters.
203          */
204         int yy_n_chars;
205
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.
209          */
210         int yy_is_our_buffer;
211
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.
216          */
217         int yy_is_interactive;
218
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.
222          */
223         int yy_at_bol;
224
225     int yy_bs_lineno; /**< The line count. */
226     int yy_bs_column; /**< The column count. */
227     
228         /* Whether to try to fill the input buffer when we reach the
229          * end of it.
230          */
231         int yy_fill_buffer;
232
233         int yy_buffer_status;
234
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.
242          *
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.
246          */
247 #define YY_BUFFER_EOF_PENDING 2
248
249         };
250 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
251
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. */
256
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".
260  *
261  * Returns the top of the stack, or NULL.
262  */
263 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
264                           ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
265                           : NULL)
266
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.
269  */
270 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
271
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;
276
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 */
281
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 ...
284  */
285 static int yy_did_buffer_switch_on_eof;
286
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 );
294
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  );
298
299 #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
300
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  );
304
305 void *yyalloc (yy_size_t  );
306 void *yyrealloc (void *,yy_size_t  );
307 void yyfree (void *  );
308
309 #define yy_new_buffer yy_create_buffer
310
311 #define yy_set_interactive(is_interactive) \
312         { \
313         if ( ! YY_CURRENT_BUFFER ){ \
314         yyensure_buffer_stack (); \
315                 YY_CURRENT_BUFFER_LVALUE =    \
316             yy_create_buffer(yyin,YY_BUF_SIZE ); \
317         } \
318         YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
319         }
320
321 #define yy_set_bol(at_bol) \
322         { \
323         if ( ! YY_CURRENT_BUFFER ){\
324         yyensure_buffer_stack (); \
325                 YY_CURRENT_BUFFER_LVALUE =    \
326             yy_create_buffer(yyin,YY_BUF_SIZE ); \
327         } \
328         YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
329         }
330
331 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
332
333 /* Begin user sect3 */
334
335 typedef unsigned char YY_CHAR;
336
337 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
338
339 typedef int yy_state_type;
340
341 extern int yylineno;
342
343 int yylineno = 1;
344
345 extern char *yytext;
346 #define yytext_ptr yytext
347
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[]  );
352
353 /* Done after the current pattern has been matched and before the
354  * corresponding action - sets up yytext.
355  */
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;
362
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
368         {
369         flex_int32_t yy_verify;
370         flex_int32_t yy_nxt;
371         };
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,
384
385         0,    0,   14,    0,    0,   12,   14,   10,   11,    0
386     } ;
387
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,
400
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,
411
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
418     } ;
419
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
425     } ;
426
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,
439
440        99,  342,    0,  164,  188,   74,  395,   62,   46,  395,
441       355,  359,  362,  365,  369,  373,  376,  380,  384,  387,
442       390
443     } ;
444
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,
457
458       121,  121,   36,  121,  121,  121,  110,  121,  121,    0,
459       110,  110,  110,  110,  110,  110,  110,  110,  110,  110,
460       110
461     } ;
462
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,
475
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,
486
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,
497
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,
508
509       110,  110,  110,  110,  110,  110,  110,  110,  110,  110,
510       110,  110,  110,  110,  110,  110,  110,  110
511     } ;
512
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,
525
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,
536
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,
547
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,
558
559       110,  110,  110,  110,  110,  110,  110,  110,  110,  110,
560       110,  110,  110,  110,  110,  110,  110,  110
561     } ;
562
563 static yy_state_type yy_last_accepting_state;
564 static char *yy_last_accepting_cpos;
565
566 extern int yy_flex_debug;
567 int yy_flex_debug = 0;
568
569 /* The intent behind this definition is that it'll catch
570  * any uses of REJECT which flex missed.
571  */
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"
579
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"
586
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;
593
594 mem_t strings;
595 mem_t tokens;
596
597 static void count(char*text, int len, int condition)
598 {
599     int t;
600     for(t=0;t<len;t++) {
601         if(text[t]=='\n') {
602             line++;
603             column=1;
604         } else {
605             column++;
606         }
607     }
608 }
609
610 static char*prefix = 0;
611
612 static void unescapeString(string_t * tmp)
613 {
614     char *p, *p1;
615     /* fixme - this routine expects the string to be
616        null-terminated */
617
618     for (p1=(char*)tmp->str; (p=strchr(p1, '\\')); p1 = p+1) 
619     {
620         int nr=2;
621         int new=1;
622         switch(p[1])
623         {
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++;
640                 }
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++;
647                 }
648                 if(bracket && p[nr]=='}') {
649                     bracket = 0;
650                     nr++;
651                 }
652                 utf8 = getUTF8(num);
653                 new = strlen(utf8);
654                 memcpy(p, utf8, new); // do not copy the terminating zero
655                 break;
656             }
657             default:
658                 continue;
659         }
660         tmp->len -= (nr-new); 
661         {
662             int t;
663             char*to=p+new,*from=p+nr;
664             while(*from) {
665                 *to = *from;
666                 to++;
667                 from++;
668             }
669         }
670     }
671 }
672
673 static void store(enum type_t type, int line, int column, char*text, int length)
674 {
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);
681
682     token.text = 0;
683     switch(type) {
684         case END:
685             string_set2(&tmp, "", 0);
686             token.text = (char*)mem_putstring(&strings, tmp);
687         break;
688         case STRING:
689             string_set2(&tmp, text+1, length-2);
690             unescapeString(&tmp);
691             token.text = (char*)mem_putstring(&strings, tmp);
692         break;
693         case TWIP: 
694         case NUMBER: 
695         case IDENTIFIER:
696             string_set2(&tmp, text, length);
697             if(prefix) {
698                 //strcat
699                 token.text = (char*)mem_put(&strings, prefix, strlen(prefix));
700                 mem_putstring(&strings, tmp);
701             } else {
702                 token.text = (char*)mem_putstring(&strings, tmp);
703             }
704             prefix = 0;
705         break;
706         case RAWDATA:
707             string_set2(&tmp, text+1/*:*/, length-5/*.end*/);
708             token.text = (char*)mem_putstring(&strings, tmp);
709         break;
710         case COMMAND:
711             string_set2(&tmp, text+1, length-1);
712             token.text = (char*)mem_putstring(&strings, tmp);
713         break;
714         case ASSIGNMENT: {
715             char*x = &text[length-1];
716             if(x[-1] == '-' || x[-1] == '+')
717                 x--;
718             do{x--;} while(*x==32 || *x==10 || *x==13 || *x=='\t');
719             x++; //first space
720             string_set2(&tmp, text, x-text);
721             token.text = (char*)mem_putstring(&strings, tmp);
722             /*char*y,*x = strchr(text, '=');
723             if(!x) exit(1);
724             y=x;
725             do{y--;} while(*y==32 || *y==10 || *y==13 || *y=='\t');
726             do{x++;} while(*x==32 || *x==10 || *x==13 || *x=='\t');
727             token.text1 = (char*)put(&strings, text, y-text + 1, 1);
728             token.text2 = (char*)put(&strings, x, length-(x-text), 1);*/
729         } break;
730     }
731
732     mem_put(&tokens, &token, sizeof(struct token_t));
733     prefix = 0;
734 }
735
736 #define MAX_INCLUDE_DEPTH 16
737 static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
738 static int line_stack[MAX_INCLUDE_DEPTH];
739 static int column_stack[MAX_INCLUDE_DEPTH];
740 static int include_stack_ptr = 0;
741
742 static void handleInclude(char*text, int len)
743 {
744     text+=9;len-=9;
745     while(len >=1 && (text[0] == ' ' || text[0] == '\t')) {
746         text++;len--;
747     }
748     while(len >= 1 && 
749           (text[len-1] == ' ' || 
750            text[len-1] == '\r' || 
751            text[len-1] == '\n')) {
752         len--;
753     }
754     if(len >= 2 && text[0] == '"' && text[len-1] == '"') {
755         text++; len-=2;
756     }
757     text[len] = 0;
758     if(include_stack_ptr >= MAX_INCLUDE_DEPTH) {
759         fprintf( stderr, "Includes nested too deeply" );
760         exit( 1 );
761     }
762     include_stack[include_stack_ptr] = YY_CURRENT_BUFFER;
763     line_stack[include_stack_ptr] = line;
764     column_stack[include_stack_ptr] = column;
765     include_stack_ptr++;
766     yyin = fopen(text, "rb");
767     if (!yyin) {
768         fprintf(stderr, "Couldn't open %s\n", text);
769         exit(1);
770     }
771     yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE ) );
772
773 #ifdef INITIAL
774     BEGIN(INITIAL);
775 #else
776     // best guess
777     BEGIN(0);
778 #endif
779 }
780
781 #define c() {count(yytext, yyleng, YY_START);}
782 #define s(type) {store(type, line, column, yytext, yyleng);}
783
784
785 #line 786 "parser.yy.c"
786
787 #define INITIAL 0
788 #define R 1
789 #define BINARY 2
790
791 #ifndef YY_NO_UNISTD_H
792 /* Special case for "unistd.h", since it is non-ANSI. We include it way
793  * down here because we want the user's section 1 to have been scanned first.
794  * The user has a chance to override it with an option.
795  */
796 #include <unistd.h>
797 #endif
798
799 #ifndef YY_EXTRA_TYPE
800 #define YY_EXTRA_TYPE void *
801 #endif
802
803 static int yy_init_globals (void );
804
805 /* Accessor methods to globals.
806    These are made visible to non-reentrant scanners for convenience. */
807
808 int yylex_destroy (void );
809
810 int yyget_debug (void );
811
812 void yyset_debug (int debug_flag  );
813
814 YY_EXTRA_TYPE yyget_extra (void );
815
816 void yyset_extra (YY_EXTRA_TYPE user_defined  );
817
818 FILE *yyget_in (void );
819
820 void yyset_in  (FILE * in_str  );
821
822 FILE *yyget_out (void );
823
824 void yyset_out  (FILE * out_str  );
825
826 int yyget_leng (void );
827
828 char *yyget_text (void );
829
830 int yyget_lineno (void );
831
832 void yyset_lineno (int line_number  );
833
834 /* Macros after this point can all be overridden by user definitions in
835  * section 1.
836  */
837
838 #ifndef YY_SKIP_YYWRAP
839 #ifdef __cplusplus
840 extern "C" int yywrap (void );
841 #else
842 extern int yywrap (void );
843 #endif
844 #endif
845
846     static void yyunput (int c,char *buf_ptr  );
847     
848 #ifndef yytext_ptr
849 static void yy_flex_strncpy (char *,yyconst char *,int );
850 #endif
851
852 #ifdef YY_NEED_STRLEN
853 static int yy_flex_strlen (yyconst char * );
854 #endif
855
856 #ifndef YY_NO_INPUT
857
858 #ifdef __cplusplus
859 static int yyinput (void );
860 #else
861 static int input (void );
862 #endif
863
864 #endif
865
866 /* Amount of stuff to slurp up with each read. */
867 #ifndef YY_READ_BUF_SIZE
868 #define YY_READ_BUF_SIZE 8192
869 #endif
870
871 /* Copy whatever the last rule matched to the standard output. */
872 #ifndef ECHO
873 /* This used to be an fputs(), but since the string might contain NUL's,
874  * we now use fwrite().
875  */
876 #define ECHO fwrite( yytext, yyleng, 1, yyout )
877 #endif
878
879 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
880  * is returned in "result".
881  */
882 #ifndef YY_INPUT
883 #define YY_INPUT(buf,result,max_size) \
884         if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
885                 { \
886                 int c = '*'; \
887                 int n; \
888                 for ( n = 0; n < max_size && \
889                              (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
890                         buf[n] = (char) c; \
891                 if ( c == '\n' ) \
892                         buf[n++] = (char) c; \
893                 if ( c == EOF && ferror( yyin ) ) \
894                         YY_FATAL_ERROR( "input in flex scanner failed" ); \
895                 result = n; \
896                 } \
897         else \
898                 { \
899                 errno=0; \
900                 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
901                         { \
902                         if( errno != EINTR) \
903                                 { \
904                                 YY_FATAL_ERROR( "input in flex scanner failed" ); \
905                                 break; \
906                                 } \
907                         errno=0; \
908                         clearerr(yyin); \
909                         } \
910                 }\
911 \
912
913 #endif
914
915 /* No semi-colon after return; correct usage is to write "yyterminate();" -
916  * we don't want an extra ';' after the "return" because that will cause
917  * some compilers to complain about unreachable statements.
918  */
919 #ifndef yyterminate
920 #define yyterminate() return YY_NULL
921 #endif
922
923 /* Number of entries by which start-condition stack grows. */
924 #ifndef YY_START_STACK_INCR
925 #define YY_START_STACK_INCR 25
926 #endif
927
928 /* Report a fatal error. */
929 #ifndef YY_FATAL_ERROR
930 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
931 #endif
932
933 /* end tables serialization structures and prototypes */
934
935 /* Default declaration of generated scanner - a define so the user can
936  * easily add parameters.
937  */
938 #ifndef YY_DECL
939 #define YY_DECL_IS_OURS 1
940
941 extern int yylex (void);
942
943 #define YY_DECL int yylex (void)
944 #endif /* !YY_DECL */
945
946 /* Code executed at the beginning of each rule, after yytext and yyleng
947  * have been set up.
948  */
949 #ifndef YY_USER_ACTION
950 #define YY_USER_ACTION
951 #endif
952
953 /* Code executed at the end of each rule. */
954 #ifndef YY_BREAK
955 #define YY_BREAK break;
956 #endif
957
958 #define YY_RULE_SETUP \
959         if ( yyleng > 0 ) \
960                 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
961                                 (yytext[yyleng - 1] == '\n'); \
962         YY_USER_ACTION
963
964 /** The main scanner function which does all the work.
965  */
966 YY_DECL
967 {
968         register yy_state_type yy_current_state;
969         register char *yy_cp, *yy_bp;
970         register int yy_act;
971     
972 #line 219 "parser.lex"
973
974
975 #line 976 "parser.yy.c"
976
977         if ( !(yy_init) )
978                 {
979                 (yy_init) = 1;
980
981 #ifdef YY_USER_INIT
982                 YY_USER_INIT;
983 #endif
984
985                 if ( ! (yy_start) )
986                         (yy_start) = 1; /* first start state */
987
988                 if ( ! yyin )
989                         yyin = stdin;
990
991                 if ( ! yyout )
992                         yyout = stdout;
993
994                 if ( ! YY_CURRENT_BUFFER ) {
995                         yyensure_buffer_stack ();
996                         YY_CURRENT_BUFFER_LVALUE =
997                                 yy_create_buffer(yyin,YY_BUF_SIZE );
998                 }
999
1000                 yy_load_buffer_state( );
1001                 }
1002
1003         while ( 1 )             /* loops until end-of-file is reached */
1004                 {
1005                 yy_cp = (yy_c_buf_p);
1006
1007                 /* Support of yytext. */
1008                 *yy_cp = (yy_hold_char);
1009
1010                 /* yy_bp points to the position in yy_ch_buf of the start of
1011                  * the current run.
1012                  */
1013                 yy_bp = yy_cp;
1014
1015                 yy_current_state = (yy_start);
1016                 yy_current_state += YY_AT_BOL();
1017 yy_match:
1018                 do
1019                         {
1020                         register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
1021                         if ( yy_accept[yy_current_state] )
1022                                 {
1023                                 (yy_last_accepting_state) = yy_current_state;
1024                                 (yy_last_accepting_cpos) = yy_cp;
1025                                 }
1026                         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1027                                 {
1028                                 yy_current_state = (int) yy_def[yy_current_state];
1029                                 if ( yy_current_state >= 111 )
1030                                         yy_c = yy_meta[(unsigned int) yy_c];
1031                                 }
1032                         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1033                         ++yy_cp;
1034                         }
1035                 while ( yy_current_state != 110 );
1036                 yy_cp = (yy_last_accepting_cpos);
1037                 yy_current_state = (yy_last_accepting_state);
1038
1039 yy_find_action:
1040                 yy_act = yy_accept[yy_current_state];
1041
1042                 YY_DO_BEFORE_ACTION;
1043
1044 do_action:      /* This label is used only to access EOF actions. */
1045
1046                 switch ( yy_act )
1047         { /* beginning of action switch */
1048                         case 0: /* must back up */
1049                         /* undo the effects of YY_DO_BEFORE_ACTION */
1050                         *yy_cp = (yy_hold_char);
1051                         yy_cp = (yy_last_accepting_cpos);
1052                         yy_current_state = (yy_last_accepting_state);
1053                         goto yy_find_action;
1054
1055 case 1:
1056 YY_RULE_SETUP
1057 #line 221 "parser.lex"
1058 {c();BEGIN(0);}
1059         YY_BREAK
1060 case 2:
1061 YY_RULE_SETUP
1062 #line 222 "parser.lex"
1063 {c();}
1064         YY_BREAK
1065 case 3:
1066 /* rule 3 can match eol */
1067 YY_RULE_SETUP
1068 #line 223 "parser.lex"
1069 {c();}
1070         YY_BREAK
1071 case 4:
1072 /* rule 4 can match eol */
1073 *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */
1074 (yy_c_buf_p) = yy_cp -= 1;
1075 YY_DO_BEFORE_ACTION; /* set up yytext again */
1076 YY_RULE_SETUP
1077 #line 224 "parser.lex"
1078 {s(TWIP);c();BEGIN(0);}
1079         YY_BREAK
1080 case 5:
1081 /* rule 5 can match eol */
1082 *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */
1083 (yy_c_buf_p) = yy_cp -= 1;
1084 YY_DO_BEFORE_ACTION; /* set up yytext again */
1085 YY_RULE_SETUP
1086 #line 225 "parser.lex"
1087 {s(NUMBER);c();BEGIN(0);}
1088         YY_BREAK
1089 case 6:
1090 /* rule 6 can match eol */
1091 YY_RULE_SETUP
1092 #line 226 "parser.lex"
1093 {c();}
1094         YY_BREAK
1095 case 7:
1096 /* rule 7 can match eol */
1097 YY_RULE_SETUP
1098 #line 227 "parser.lex"
1099 {c();}
1100         YY_BREAK
1101 case 8:
1102 YY_RULE_SETUP
1103 #line 228 "parser.lex"
1104 {s(STRING);c();BEGIN(0);}
1105         YY_BREAK
1106 case 9:
1107 *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */
1108 (yy_c_buf_p) = yy_cp -= 1;
1109 YY_DO_BEFORE_ACTION; /* set up yytext again */
1110 YY_RULE_SETUP
1111 #line 229 "parser.lex"
1112 {c();printf("unterminated string in line %d: %s\n", line, yytext);exit(1);yyterminate();}
1113         YY_BREAK
1114 case 10:
1115 /* rule 10 can match eol */
1116 YY_RULE_SETUP
1117 #line 230 "parser.lex"
1118 {s(ASSIGNMENT);prefix="<plus>";c();BEGIN(R);}
1119         YY_BREAK
1120 case 11:
1121 /* rule 11 can match eol */
1122 YY_RULE_SETUP
1123 #line 231 "parser.lex"
1124 {s(ASSIGNMENT);prefix="<minus>";c();BEGIN(R);}
1125         YY_BREAK
1126 case 12:
1127 /* rule 12 can match eol */
1128 YY_RULE_SETUP
1129 #line 232 "parser.lex"
1130 {s(ASSIGNMENT);c();BEGIN(R);}
1131         YY_BREAK
1132 /* values which appear only on the right-hand side of assignments, like: x=50% */
1133 case 13:
1134 YY_RULE_SETUP
1135 #line 234 "parser.lex"
1136 {s(IDENTIFIER);c();BEGIN(0);}
1137         YY_BREAK
1138
1139 case 14:
1140 /* rule 14 can match eol */
1141 YY_RULE_SETUP
1142 #line 236 "parser.lex"
1143 {handleInclude(yytext, yyleng);}
1144         YY_BREAK
1145 case 15:
1146 YY_RULE_SETUP
1147 #line 237 "parser.lex"
1148 {s(COMMAND);c();}
1149         YY_BREAK
1150 case 16:
1151 /* rule 16 can match eol */
1152 YY_RULE_SETUP
1153 #line 238 "parser.lex"
1154 {s(RAWDATA);c();}
1155         YY_BREAK
1156 case 17:
1157 YY_RULE_SETUP
1158 #line 239 "parser.lex"
1159 {s(IDENTIFIER);c();}
1160         YY_BREAK
1161 case 18:
1162 YY_RULE_SETUP
1163 #line 240 "parser.lex"
1164 {c();BEGIN(BINARY);}
1165         YY_BREAK
1166 case 19:
1167 /* rule 19 can match eol */
1168 YY_RULE_SETUP
1169 #line 241 "parser.lex"
1170 {c();}
1171         YY_BREAK
1172 case 20:
1173 YY_RULE_SETUP
1174 #line 242 "parser.lex"
1175 {char c,c1=yytext[0];
1176                              printf("Syntax error in line %d, %d: %s", line, column, yytext);
1177                              while(1) {
1178                                  c=input();
1179                                  if(c=='\n' || c==EOF) 
1180                                      break;
1181                                 printf("%c", c);
1182                              }
1183                              if(c1>='0' && c1<='9')
1184                                  printf(" (identifiers must not start with a digit)");
1185                              printf("\n");
1186                              exit(1);
1187                              yyterminate();
1188                             }
1189         YY_BREAK
1190 case YY_STATE_EOF(INITIAL):
1191 case YY_STATE_EOF(R):
1192 case YY_STATE_EOF(BINARY):
1193 #line 256 "parser.lex"
1194 {c();
1195                              if ( --include_stack_ptr < 0 ) {
1196                                 s(END);
1197                                 yyterminate();
1198                              } else {
1199                                  yy_delete_buffer(YY_CURRENT_BUFFER );
1200                                  yy_switch_to_buffer(include_stack[include_stack_ptr] );
1201                                  column = column_stack[include_stack_ptr];
1202                                  line = line_stack[include_stack_ptr];
1203                              }
1204                             }
1205         YY_BREAK
1206 case 21:
1207 YY_RULE_SETUP
1208 #line 269 "parser.lex"
1209 YY_FATAL_ERROR( "flex scanner jammed" );
1210         YY_BREAK
1211 #line 1212 "parser.yy.c"
1212
1213         case YY_END_OF_BUFFER:
1214                 {
1215                 /* Amount of text matched not including the EOB char. */
1216                 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1217
1218                 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1219                 *yy_cp = (yy_hold_char);
1220                 YY_RESTORE_YY_MORE_OFFSET
1221
1222                 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1223                         {
1224                         /* We're scanning a new file or input source.  It's
1225                          * possible that this happened because the user
1226                          * just pointed yyin at a new source and called
1227                          * yylex().  If so, then we have to assure
1228                          * consistency between YY_CURRENT_BUFFER and our
1229                          * globals.  Here is the right place to do so, because
1230                          * this is the first action (other than possibly a
1231                          * back-up) that will match for the new input source.
1232                          */
1233                         (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1234                         YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1235                         YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1236                         }
1237
1238                 /* Note that here we test for yy_c_buf_p "<=" to the position
1239                  * of the first EOB in the buffer, since yy_c_buf_p will
1240                  * already have been incremented past the NUL character
1241                  * (since all states make transitions on EOB to the
1242                  * end-of-buffer state).  Contrast this with the test
1243                  * in input().
1244                  */
1245                 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1246                         { /* This was really a NUL. */
1247                         yy_state_type yy_next_state;
1248
1249                         (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1250
1251                         yy_current_state = yy_get_previous_state(  );
1252
1253                         /* Okay, we're now positioned to make the NUL
1254                          * transition.  We couldn't have
1255                          * yy_get_previous_state() go ahead and do it
1256                          * for us because it doesn't know how to deal
1257                          * with the possibility of jamming (and we don't
1258                          * want to build jamming into it because then it
1259                          * will run more slowly).
1260                          */
1261
1262                         yy_next_state = yy_try_NUL_trans( yy_current_state );
1263
1264                         yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1265
1266                         if ( yy_next_state )
1267                                 {
1268                                 /* Consume the NUL. */
1269                                 yy_cp = ++(yy_c_buf_p);
1270                                 yy_current_state = yy_next_state;
1271                                 goto yy_match;
1272                                 }
1273
1274                         else
1275                                 {
1276                                 yy_cp = (yy_last_accepting_cpos);
1277                                 yy_current_state = (yy_last_accepting_state);
1278                                 goto yy_find_action;
1279                                 }
1280                         }
1281
1282                 else switch ( yy_get_next_buffer(  ) )
1283                         {
1284                         case EOB_ACT_END_OF_FILE:
1285                                 {
1286                                 (yy_did_buffer_switch_on_eof) = 0;
1287
1288                                 if ( yywrap( ) )
1289                                         {
1290                                         /* Note: because we've taken care in
1291                                          * yy_get_next_buffer() to have set up
1292                                          * yytext, we can now set up
1293                                          * yy_c_buf_p so that if some total
1294                                          * hoser (like flex itself) wants to
1295                                          * call the scanner after we return the
1296                                          * YY_NULL, it'll still work - another
1297                                          * YY_NULL will get returned.
1298                                          */
1299                                         (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1300
1301                                         yy_act = YY_STATE_EOF(YY_START);
1302                                         goto do_action;
1303                                         }
1304
1305                                 else
1306                                         {
1307                                         if ( ! (yy_did_buffer_switch_on_eof) )
1308                                                 YY_NEW_FILE;
1309                                         }
1310                                 break;
1311                                 }
1312
1313                         case EOB_ACT_CONTINUE_SCAN:
1314                                 (yy_c_buf_p) =
1315                                         (yytext_ptr) + yy_amount_of_matched_text;
1316
1317                                 yy_current_state = yy_get_previous_state(  );
1318
1319                                 yy_cp = (yy_c_buf_p);
1320                                 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1321                                 goto yy_match;
1322
1323                         case EOB_ACT_LAST_MATCH:
1324                                 (yy_c_buf_p) =
1325                                 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1326
1327                                 yy_current_state = yy_get_previous_state(  );
1328
1329                                 yy_cp = (yy_c_buf_p);
1330                                 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1331                                 goto yy_find_action;
1332                         }
1333                 break;
1334                 }
1335
1336         default:
1337                 YY_FATAL_ERROR(
1338                         "fatal flex scanner internal error--no action found" );
1339         } /* end of action switch */
1340                 } /* end of scanning one token */
1341 } /* end of yylex */
1342
1343 /* yy_get_next_buffer - try to read in a new buffer
1344  *
1345  * Returns a code representing an action:
1346  *      EOB_ACT_LAST_MATCH -
1347  *      EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1348  *      EOB_ACT_END_OF_FILE - end of file
1349  */
1350 static int yy_get_next_buffer (void)
1351 {
1352         register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1353         register char *source = (yytext_ptr);
1354         register int number_to_move, i;
1355         int ret_val;
1356
1357         if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1358                 YY_FATAL_ERROR(
1359                 "fatal flex scanner internal error--end of buffer missed" );
1360
1361         if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1362                 { /* Don't try to fill the buffer, so this is an EOF. */
1363                 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1364                         {
1365                         /* We matched a single character, the EOB, so
1366                          * treat this as a final EOF.
1367                          */
1368                         return EOB_ACT_END_OF_FILE;
1369                         }
1370
1371                 else
1372                         {
1373                         /* We matched some text prior to the EOB, first
1374                          * process it.
1375                          */
1376                         return EOB_ACT_LAST_MATCH;
1377                         }
1378                 }
1379
1380         /* Try to read more data. */
1381
1382         /* First move last chars to start of buffer. */
1383         number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1384
1385         for ( i = 0; i < number_to_move; ++i )
1386                 *(dest++) = *(source++);
1387
1388         if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1389                 /* don't do the read, it's not guaranteed to return an EOF,
1390                  * just force an EOF
1391                  */
1392                 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1393
1394         else
1395                 {
1396                         int num_to_read =
1397                         YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1398
1399                 while ( num_to_read <= 0 )
1400                         { /* Not enough room in the buffer - grow it. */
1401
1402                         /* just a shorter name for the current buffer */
1403                         YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1404
1405                         int yy_c_buf_p_offset =
1406                                 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1407
1408                         if ( b->yy_is_our_buffer )
1409                                 {
1410                                 int new_size = b->yy_buf_size * 2;
1411
1412                                 if ( new_size <= 0 )
1413                                         b->yy_buf_size += b->yy_buf_size / 8;
1414                                 else
1415                                         b->yy_buf_size *= 2;
1416
1417                                 b->yy_ch_buf = (char *)
1418                                         /* Include room in for 2 EOB chars. */
1419                                         yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
1420                                 }
1421                         else
1422                                 /* Can't grow it, we don't own it. */
1423                                 b->yy_ch_buf = 0;
1424
1425                         if ( ! b->yy_ch_buf )
1426                                 YY_FATAL_ERROR(
1427                                 "fatal error - scanner input buffer overflow" );
1428
1429                         (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1430
1431                         num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1432                                                 number_to_move - 1;
1433
1434                         }
1435
1436                 if ( num_to_read > YY_READ_BUF_SIZE )
1437                         num_to_read = YY_READ_BUF_SIZE;
1438
1439                 /* Read in more data. */
1440                 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1441                         (yy_n_chars), (size_t) num_to_read );
1442
1443                 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1444                 }
1445
1446         if ( (yy_n_chars) == 0 )
1447                 {
1448                 if ( number_to_move == YY_MORE_ADJ )
1449                         {
1450                         ret_val = EOB_ACT_END_OF_FILE;
1451                         yyrestart(yyin  );
1452                         }
1453
1454                 else
1455                         {
1456                         ret_val = EOB_ACT_LAST_MATCH;
1457                         YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1458                                 YY_BUFFER_EOF_PENDING;
1459                         }
1460                 }
1461
1462         else
1463                 ret_val = EOB_ACT_CONTINUE_SCAN;
1464
1465         if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1466                 /* Extend the array by 50%, plus the number we really need. */
1467                 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1468                 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
1469                 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1470                         YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1471         }
1472
1473         (yy_n_chars) += number_to_move;
1474         YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1475         YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1476
1477         (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1478
1479         return ret_val;
1480 }
1481
1482 /* yy_get_previous_state - get the state just before the EOB char was reached */
1483
1484     static yy_state_type yy_get_previous_state (void)
1485 {
1486         register yy_state_type yy_current_state;
1487         register char *yy_cp;
1488     
1489         yy_current_state = (yy_start);
1490         yy_current_state += YY_AT_BOL();
1491
1492         for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1493                 {
1494                 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1495                 if ( yy_accept[yy_current_state] )
1496                         {
1497                         (yy_last_accepting_state) = yy_current_state;
1498                         (yy_last_accepting_cpos) = yy_cp;
1499                         }
1500                 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1501                         {
1502                         yy_current_state = (int) yy_def[yy_current_state];
1503                         if ( yy_current_state >= 111 )
1504                                 yy_c = yy_meta[(unsigned int) yy_c];
1505                         }
1506                 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1507                 }
1508
1509         return yy_current_state;
1510 }
1511
1512 /* yy_try_NUL_trans - try to make a transition on the NUL character
1513  *
1514  * synopsis
1515  *      next_state = yy_try_NUL_trans( current_state );
1516  */
1517     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
1518 {
1519         register int yy_is_jam;
1520         register char *yy_cp = (yy_c_buf_p);
1521
1522         register YY_CHAR yy_c = 1;
1523         if ( yy_accept[yy_current_state] )
1524                 {
1525                 (yy_last_accepting_state) = yy_current_state;
1526                 (yy_last_accepting_cpos) = yy_cp;
1527                 }
1528         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1529                 {
1530                 yy_current_state = (int) yy_def[yy_current_state];
1531                 if ( yy_current_state >= 111 )
1532                         yy_c = yy_meta[(unsigned int) yy_c];
1533                 }
1534         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1535         yy_is_jam = (yy_current_state == 110);
1536
1537         return yy_is_jam ? 0 : yy_current_state;
1538 }
1539
1540     static void yyunput (int c, register char * yy_bp )
1541 {
1542         register char *yy_cp;
1543     
1544     yy_cp = (yy_c_buf_p);
1545
1546         /* undo effects of setting up yytext */
1547         *yy_cp = (yy_hold_char);
1548
1549         if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1550                 { /* need to shift things up to make room */
1551                 /* +2 for EOB chars. */
1552                 register int number_to_move = (yy_n_chars) + 2;
1553                 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1554                                         YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1555                 register char *source =
1556                                 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1557
1558                 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1559                         *--dest = *--source;
1560
1561                 yy_cp += (int) (dest - source);
1562                 yy_bp += (int) (dest - source);
1563                 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1564                         (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1565
1566                 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1567                         YY_FATAL_ERROR( "flex scanner push-back overflow" );
1568                 }
1569
1570         *--yy_cp = (char) c;
1571
1572         (yytext_ptr) = yy_bp;
1573         (yy_hold_char) = *yy_cp;
1574         (yy_c_buf_p) = yy_cp;
1575 }
1576
1577 #ifndef YY_NO_INPUT
1578 #ifdef __cplusplus
1579     static int yyinput (void)
1580 #else
1581     static int input  (void)
1582 #endif
1583
1584 {
1585         int c;
1586     
1587         *(yy_c_buf_p) = (yy_hold_char);
1588
1589         if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1590                 {
1591                 /* yy_c_buf_p now points to the character we want to return.
1592                  * If this occurs *before* the EOB characters, then it's a
1593                  * valid NUL; if not, then we've hit the end of the buffer.
1594                  */
1595                 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1596                         /* This was really a NUL. */
1597                         *(yy_c_buf_p) = '\0';
1598
1599                 else
1600                         { /* need more input */
1601                         int offset = (yy_c_buf_p) - (yytext_ptr);
1602                         ++(yy_c_buf_p);
1603
1604                         switch ( yy_get_next_buffer(  ) )
1605                                 {
1606                                 case EOB_ACT_LAST_MATCH:
1607                                         /* This happens because yy_g_n_b()
1608                                          * sees that we've accumulated a
1609                                          * token and flags that we need to
1610                                          * try matching the token before
1611                                          * proceeding.  But for input(),
1612                                          * there's no matching to consider.
1613                                          * So convert the EOB_ACT_LAST_MATCH
1614                                          * to EOB_ACT_END_OF_FILE.
1615                                          */
1616
1617                                         /* Reset buffer status. */
1618                                         yyrestart(yyin );
1619
1620                                         /*FALLTHROUGH*/
1621
1622                                 case EOB_ACT_END_OF_FILE:
1623                                         {
1624                                         if ( yywrap( ) )
1625                                                 return EOF;
1626
1627                                         if ( ! (yy_did_buffer_switch_on_eof) )
1628                                                 YY_NEW_FILE;
1629 #ifdef __cplusplus
1630                                         return yyinput();
1631 #else
1632                                         return input();
1633 #endif
1634                                         }
1635
1636                                 case EOB_ACT_CONTINUE_SCAN:
1637                                         (yy_c_buf_p) = (yytext_ptr) + offset;
1638                                         break;
1639                                 }
1640                         }
1641                 }
1642
1643         c = *(unsigned char *) (yy_c_buf_p);    /* cast for 8-bit char's */
1644         *(yy_c_buf_p) = '\0';   /* preserve yytext */
1645         (yy_hold_char) = *++(yy_c_buf_p);
1646
1647         YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
1648
1649         return c;
1650 }
1651 #endif  /* ifndef YY_NO_INPUT */
1652
1653 /** Immediately switch to a different input stream.
1654  * @param input_file A readable stream.
1655  * 
1656  * @note This function does not reset the start condition to @c INITIAL .
1657  */
1658     void yyrestart  (FILE * input_file )
1659 {
1660     
1661         if ( ! YY_CURRENT_BUFFER ){
1662         yyensure_buffer_stack ();
1663                 YY_CURRENT_BUFFER_LVALUE =
1664             yy_create_buffer(yyin,YY_BUF_SIZE );
1665         }
1666
1667         yy_init_buffer(YY_CURRENT_BUFFER,input_file );
1668         yy_load_buffer_state( );
1669 }
1670
1671 /** Switch to a different input buffer.
1672  * @param new_buffer The new input buffer.
1673  * 
1674  */
1675     void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
1676 {
1677     
1678         /* TODO. We should be able to replace this entire function body
1679          * with
1680          *              yypop_buffer_state();
1681          *              yypush_buffer_state(new_buffer);
1682      */
1683         yyensure_buffer_stack ();
1684         if ( YY_CURRENT_BUFFER == new_buffer )
1685                 return;
1686
1687         if ( YY_CURRENT_BUFFER )
1688                 {
1689                 /* Flush out information for old buffer. */
1690                 *(yy_c_buf_p) = (yy_hold_char);
1691                 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1692                 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1693                 }
1694
1695         YY_CURRENT_BUFFER_LVALUE = new_buffer;
1696         yy_load_buffer_state( );
1697
1698         /* We don't actually know whether we did this switch during
1699          * EOF (yywrap()) processing, but the only time this flag
1700          * is looked at is after yywrap() is called, so it's safe
1701          * to go ahead and always set it.
1702          */
1703         (yy_did_buffer_switch_on_eof) = 1;
1704 }
1705
1706 static void yy_load_buffer_state  (void)
1707 {
1708         (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1709         (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1710         yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1711         (yy_hold_char) = *(yy_c_buf_p);
1712 }
1713
1714 /** Allocate and initialize an input buffer state.
1715  * @param file A readable stream.
1716  * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1717  * 
1718  * @return the allocated buffer state.
1719  */
1720     YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size )
1721 {
1722         YY_BUFFER_STATE b;
1723     
1724         b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
1725         if ( ! b )
1726                 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1727
1728         b->yy_buf_size = size;
1729
1730         /* yy_ch_buf has to be 2 characters longer than the size given because
1731          * we need to put in 2 end-of-buffer characters.
1732          */
1733         b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2  );
1734         if ( ! b->yy_ch_buf )
1735                 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1736
1737         b->yy_is_our_buffer = 1;
1738
1739         yy_init_buffer(b,file );
1740
1741         return b;
1742 }
1743
1744 /** Destroy the buffer.
1745  * @param b a buffer created with yy_create_buffer()
1746  * 
1747  */
1748     void yy_delete_buffer (YY_BUFFER_STATE  b )
1749 {
1750     
1751         if ( ! b )
1752                 return;
1753
1754         if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1755                 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1756
1757         if ( b->yy_is_our_buffer )
1758                 yyfree((void *) b->yy_ch_buf  );
1759
1760         yyfree((void *) b  );
1761 }
1762
1763 #ifndef _UNISTD_H /* assume unistd.h has isatty() for us */
1764 #ifdef __cplusplus
1765 extern "C" {
1766 #endif
1767 #ifdef __THROW /* this is a gnuism */
1768 extern int isatty (int ) __THROW;
1769 #else
1770 extern int isatty (int );
1771 #endif
1772 #ifdef __cplusplus
1773 }
1774 #endif
1775 #endif
1776     
1777 /* Initializes or reinitializes a buffer.
1778  * This function is sometimes called more than once on the same buffer,
1779  * such as during a yyrestart() or at EOF.
1780  */
1781     static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file )
1782
1783 {
1784         int oerrno = errno;
1785     
1786         yy_flush_buffer(b );
1787
1788         b->yy_input_file = file;
1789         b->yy_fill_buffer = 1;
1790
1791     /* If b is the current buffer, then yy_init_buffer was _probably_
1792      * called from yyrestart() or through yy_get_next_buffer.
1793      * In that case, we don't want to reset the lineno or column.
1794      */
1795     if (b != YY_CURRENT_BUFFER){
1796         b->yy_bs_lineno = 1;
1797         b->yy_bs_column = 0;
1798     }
1799
1800         b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1801     
1802         errno = oerrno;
1803 }
1804
1805 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1806  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1807  * 
1808  */
1809     void yy_flush_buffer (YY_BUFFER_STATE  b )
1810 {
1811         if ( ! b )
1812                 return;
1813
1814         b->yy_n_chars = 0;
1815
1816         /* We always need two end-of-buffer characters.  The first causes
1817          * a transition to the end-of-buffer state.  The second causes
1818          * a jam in that state.
1819          */
1820         b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1821         b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1822
1823         b->yy_buf_pos = &b->yy_ch_buf[0];
1824
1825         b->yy_at_bol = 1;
1826         b->yy_buffer_status = YY_BUFFER_NEW;
1827
1828         if ( b == YY_CURRENT_BUFFER )
1829                 yy_load_buffer_state( );
1830 }
1831
1832 /** Pushes the new state onto the stack. The new state becomes
1833  *  the current state. This function will allocate the stack
1834  *  if necessary.
1835  *  @param new_buffer The new state.
1836  *  
1837  */
1838 void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
1839 {
1840         if (new_buffer == NULL)
1841                 return;
1842
1843         yyensure_buffer_stack();
1844
1845         /* This block is copied from yy_switch_to_buffer. */
1846         if ( YY_CURRENT_BUFFER )
1847                 {
1848                 /* Flush out information for old buffer. */
1849                 *(yy_c_buf_p) = (yy_hold_char);
1850                 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1851                 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1852                 }
1853
1854         /* Only push if top exists. Otherwise, replace top. */
1855         if (YY_CURRENT_BUFFER)
1856                 (yy_buffer_stack_top)++;
1857         YY_CURRENT_BUFFER_LVALUE = new_buffer;
1858
1859         /* copied from yy_switch_to_buffer. */
1860         yy_load_buffer_state( );
1861         (yy_did_buffer_switch_on_eof) = 1;
1862 }
1863
1864 /** Removes and deletes the top of the stack, if present.
1865  *  The next element becomes the new top.
1866  *  
1867  */
1868 void yypop_buffer_state (void)
1869 {
1870         if (!YY_CURRENT_BUFFER)
1871                 return;
1872
1873         yy_delete_buffer(YY_CURRENT_BUFFER );
1874         YY_CURRENT_BUFFER_LVALUE = NULL;
1875         if ((yy_buffer_stack_top) > 0)
1876                 --(yy_buffer_stack_top);
1877
1878         if (YY_CURRENT_BUFFER) {
1879                 yy_load_buffer_state( );
1880                 (yy_did_buffer_switch_on_eof) = 1;
1881         }
1882 }
1883
1884 /* Allocates the stack if it does not exist.
1885  *  Guarantees space for at least one push.
1886  */
1887 static void yyensure_buffer_stack (void)
1888 {
1889         int num_to_alloc;
1890     
1891         if (!(yy_buffer_stack)) {
1892
1893                 /* First allocation is just for 2 elements, since we don't know if this
1894                  * scanner will even need a stack. We use 2 instead of 1 to avoid an
1895                  * immediate realloc on the next call.
1896          */
1897                 num_to_alloc = 1;
1898                 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1899                                                                 (num_to_alloc * sizeof(struct yy_buffer_state*)
1900                                                                 );
1901                 if ( ! (yy_buffer_stack) )
1902                         YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1903                                                                   
1904                 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1905                                 
1906                 (yy_buffer_stack_max) = num_to_alloc;
1907                 (yy_buffer_stack_top) = 0;
1908                 return;
1909         }
1910
1911         if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1912
1913                 /* Increase the buffer to prepare for a possible push. */
1914                 int grow_size = 8 /* arbitrary grow size */;
1915
1916                 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1917                 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
1918                                                                 ((yy_buffer_stack),
1919                                                                 num_to_alloc * sizeof(struct yy_buffer_state*)
1920                                                                 );
1921                 if ( ! (yy_buffer_stack) )
1922                         YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1923
1924                 /* zero only the new slots.*/
1925                 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1926                 (yy_buffer_stack_max) = num_to_alloc;
1927         }
1928 }
1929
1930 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1931  * @param base the character buffer
1932  * @param size the size in bytes of the character buffer
1933  * 
1934  * @return the newly allocated buffer state object. 
1935  */
1936 YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size )
1937 {
1938         YY_BUFFER_STATE b;
1939     
1940         if ( size < 2 ||
1941              base[size-2] != YY_END_OF_BUFFER_CHAR ||
1942              base[size-1] != YY_END_OF_BUFFER_CHAR )
1943                 /* They forgot to leave room for the EOB's. */
1944                 return 0;
1945
1946         b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
1947         if ( ! b )
1948                 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1949
1950         b->yy_buf_size = size - 2;      /* "- 2" to take care of EOB's */
1951         b->yy_buf_pos = b->yy_ch_buf = base;
1952         b->yy_is_our_buffer = 0;
1953         b->yy_input_file = 0;
1954         b->yy_n_chars = b->yy_buf_size;
1955         b->yy_is_interactive = 0;
1956         b->yy_at_bol = 1;
1957         b->yy_fill_buffer = 0;
1958         b->yy_buffer_status = YY_BUFFER_NEW;
1959
1960         yy_switch_to_buffer(b  );
1961
1962         return b;
1963 }
1964
1965 /** Setup the input buffer state to scan a string. The next call to yylex() will
1966  * scan from a @e copy of @a str.
1967  * @param yystr a NUL-terminated string to scan
1968  * 
1969  * @return the newly allocated buffer state object.
1970  * @note If you want to scan bytes that may contain NUL values, then use
1971  *       yy_scan_bytes() instead.
1972  */
1973 YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
1974 {
1975     
1976         return yy_scan_bytes(yystr,strlen(yystr) );
1977 }
1978
1979 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1980  * scan from a @e copy of @a bytes.
1981  * @param bytes the byte buffer to scan
1982  * @param len the number of bytes in the buffer pointed to by @a bytes.
1983  * 
1984  * @return the newly allocated buffer state object.
1985  */
1986 YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len )
1987 {
1988         YY_BUFFER_STATE b;
1989         char *buf;
1990         yy_size_t n;
1991         int i;
1992     
1993         /* Get memory for full buffer, including space for trailing EOB's. */
1994         n = _yybytes_len + 2;
1995         buf = (char *) yyalloc(n  );
1996         if ( ! buf )
1997                 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1998
1999         for ( i = 0; i < _yybytes_len; ++i )
2000                 buf[i] = yybytes[i];
2001
2002         buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2003
2004         b = yy_scan_buffer(buf,n );
2005         if ( ! b )
2006                 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
2007
2008         /* It's okay to grow etc. this buffer, and we should throw it
2009          * away when we're done.
2010          */
2011         b->yy_is_our_buffer = 1;
2012
2013         return b;
2014 }
2015
2016 #ifndef YY_EXIT_FAILURE
2017 #define YY_EXIT_FAILURE 2
2018 #endif
2019
2020 static void yy_fatal_error (yyconst char* msg )
2021 {
2022         (void) fprintf( stderr, "%s\n", msg );
2023         exit( YY_EXIT_FAILURE );
2024 }
2025
2026 /* Redefine yyless() so it works in section 3 code. */
2027
2028 #undef yyless
2029 #define yyless(n) \
2030         do \
2031                 { \
2032                 /* Undo effects of setting up yytext. */ \
2033         int yyless_macro_arg = (n); \
2034         YY_LESS_LINENO(yyless_macro_arg);\
2035                 yytext[yyleng] = (yy_hold_char); \
2036                 (yy_c_buf_p) = yytext + yyless_macro_arg; \
2037                 (yy_hold_char) = *(yy_c_buf_p); \
2038                 *(yy_c_buf_p) = '\0'; \
2039                 yyleng = yyless_macro_arg; \
2040                 } \
2041         while ( 0 )
2042
2043 /* Accessor  methods (get/set functions) to struct members. */
2044
2045 /** Get the current line number.
2046  * 
2047  */
2048 int yyget_lineno  (void)
2049 {
2050         
2051     return yylineno;
2052 }
2053
2054 /** Get the input stream.
2055  * 
2056  */
2057 FILE *yyget_in  (void)
2058 {
2059         return yyin;
2060 }
2061
2062 /** Get the output stream.
2063  * 
2064  */
2065 FILE *yyget_out  (void)
2066 {
2067         return yyout;
2068 }
2069
2070 /** Get the length of the current token.
2071  * 
2072  */
2073 int yyget_leng  (void)
2074 {
2075         return yyleng;
2076 }
2077
2078 /** Get the current token.
2079  * 
2080  */
2081
2082 char *yyget_text  (void)
2083 {
2084         return yytext;
2085 }
2086
2087 /** Set the current line number.
2088  * @param line_number
2089  * 
2090  */
2091 void yyset_lineno (int  line_number )
2092 {
2093     
2094     yylineno = line_number;
2095 }
2096
2097 /** Set the input stream. This does not discard the current
2098  * input buffer.
2099  * @param in_str A readable stream.
2100  * 
2101  * @see yy_switch_to_buffer
2102  */
2103 void yyset_in (FILE *  in_str )
2104 {
2105         yyin = in_str ;
2106 }
2107
2108 void yyset_out (FILE *  out_str )
2109 {
2110         yyout = out_str ;
2111 }
2112
2113 int yyget_debug  (void)
2114 {
2115         return yy_flex_debug;
2116 }
2117
2118 void yyset_debug (int  bdebug )
2119 {
2120         yy_flex_debug = bdebug ;
2121 }
2122
2123 static int yy_init_globals (void)
2124 {
2125         /* Initialization is the same as for the non-reentrant scanner.
2126      * This function is called from yylex_destroy(), so don't allocate here.
2127      */
2128
2129     (yy_buffer_stack) = 0;
2130     (yy_buffer_stack_top) = 0;
2131     (yy_buffer_stack_max) = 0;
2132     (yy_c_buf_p) = (char *) 0;
2133     (yy_init) = 0;
2134     (yy_start) = 0;
2135
2136 /* Defined in main.c */
2137 #ifdef YY_STDINIT
2138     yyin = stdin;
2139     yyout = stdout;
2140 #else
2141     yyin = (FILE *) 0;
2142     yyout = (FILE *) 0;
2143 #endif
2144
2145     /* For future reference: Set errno on error, since we are called by
2146      * yylex_init()
2147      */
2148     return 0;
2149 }
2150
2151 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
2152 int yylex_destroy  (void)
2153 {
2154     
2155     /* Pop the buffer stack, destroying each element. */
2156         while(YY_CURRENT_BUFFER){
2157                 yy_delete_buffer(YY_CURRENT_BUFFER  );
2158                 YY_CURRENT_BUFFER_LVALUE = NULL;
2159                 yypop_buffer_state();
2160         }
2161
2162         /* Destroy the stack itself. */
2163         yyfree((yy_buffer_stack) );
2164         (yy_buffer_stack) = NULL;
2165
2166     /* Reset the globals. This is important in a non-reentrant scanner so the next time
2167      * yylex() is called, initialization will occur. */
2168     yy_init_globals( );
2169
2170     return 0;
2171 }
2172
2173 /*
2174  * Internal utility routines.
2175  */
2176
2177 #ifndef yytext_ptr
2178 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
2179 {
2180         register int i;
2181         for ( i = 0; i < n; ++i )
2182                 s1[i] = s2[i];
2183 }
2184 #endif
2185
2186 #ifdef YY_NEED_STRLEN
2187 static int yy_flex_strlen (yyconst char * s )
2188 {
2189         register int n;
2190         for ( n = 0; s[n]; ++n )
2191                 ;
2192
2193         return n;
2194 }
2195 #endif
2196
2197 void *yyalloc (yy_size_t  size )
2198 {
2199         return (void *) malloc( size );
2200 }
2201
2202 void *yyrealloc  (void * ptr, yy_size_t  size )
2203 {
2204         /* The cast to (char *) in the following accommodates both
2205          * implementations that use char* generic pointers, and those
2206          * that use void* generic pointers.  It works with the latter
2207          * because both ANSI C and C++ allow castless assignment from
2208          * any pointer type to void*, and deal with argument conversions
2209          * as though doing an assignment.
2210          */
2211         return (void *) realloc( (char *) ptr, size );
2212 }
2213
2214 void yyfree (void * ptr )
2215 {
2216         free( (char *) ptr );   /* see yyrealloc() for (char *) cast */
2217 }
2218
2219 #define YYTABLES_NAME "yytables"
2220
2221 #line 269 "parser.lex"
2222
2223
2224
2225 int yywrap()
2226 {
2227     return 1;
2228 }
2229
2230 void freeTokens(struct token_t*file)
2231 {
2232     mem_clear(&strings);
2233     mem_clear(&tokens);
2234 }
2235
2236 struct token_t* generateTokens(char*filename)
2237 {
2238     FILE*fi;
2239     int t;
2240     struct token_t*result;
2241     int num;
2242
2243     if(!filename)
2244         return 0;
2245
2246     if(!strcmp(filename,"-"))
2247         fi = stdin;
2248     else
2249         fi = fopen(filename, "rb");
2250
2251     if(!fi) {
2252         printf("Couldn't find file %s\n", filename);
2253         return 0;
2254     }
2255     yyin = fi;
2256
2257     mem_init(&strings);
2258     mem_init(&tokens);
2259     mem_put(&strings, &t, 1); //hack- make all valid strings start at position >0
2260
2261     line=1;
2262     column=1;
2263
2264     yylex();
2265 #ifdef YY_CURRENT_BUFFER
2266     // some newer flex versions require it like this:
2267     yy_delete_buffer(YY_CURRENT_BUFFER);
2268 #else
2269     yy_delete_buffer(yy_current_buffer);
2270 #endif
2271
2272     result = (struct token_t*)tokens.buffer;
2273     num = tokens.pos/sizeof(struct token_t);
2274
2275     for(t=0;t<tokens.pos/sizeof(struct token_t);t++) {
2276         if(result[t].text)
2277             result[t].text += (int)strings.buffer;
2278     }
2279
2280     if(fi!=stdin)
2281         fclose(fi);
2282     return result;
2283 }
2284
2285