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