Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: bison/src/bison/2.4.1/bison-2.4.1-src/src/scan-code.c

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

Powered by Google App Engine
This is Rietveld 408576698