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