1#line 1 "src/scan-code.c"
2
3#line 3 "src/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/* %if-c-only */
11/* %if-not-reentrant */
12#define yy_create_buffer code__create_buffer
13#define yy_delete_buffer code__delete_buffer
14#define yy_scan_buffer code__scan_buffer
15#define yy_scan_string code__scan_string
16#define yy_scan_bytes code__scan_bytes
17#define yy_init_buffer code__init_buffer
18#define yy_flush_buffer code__flush_buffer
19#define yy_load_buffer_state code__load_buffer_state
20#define yy_switch_to_buffer code__switch_to_buffer
21#define yypush_buffer_state code_push_buffer_state
22#define yypop_buffer_state code_pop_buffer_state
23#define yyensure_buffer_stack code_ensure_buffer_stack
24#define yy_flex_debug code__flex_debug
25#define yyin code_in
26#define yyleng code_leng
27#define yylex code_lex
28#define yylineno code_lineno
29#define yyout code_out
30#define yyrestart code_restart
31#define yytext code_text
32#define yywrap code_wrap
33#define yyalloc code_alloc
34#define yyrealloc code_realloc
35#define yyfree code_free
36
37/* %endif */
38/* %endif */
39/* %ok-for-header */
40
41#define FLEX_SCANNER
42#define YY_FLEX_MAJOR_VERSION 2
43#define YY_FLEX_MINOR_VERSION 6
44#define YY_FLEX_SUBMINOR_VERSION 4
45#if YY_FLEX_SUBMINOR_VERSION > 0
46#define FLEX_BETA
47#endif
48
49/* %if-c++-only */
50/* %endif */
51
52/* %if-c-only */
53#ifdef yy_create_buffer
54#define code__create_buffer_ALREADY_DEFINED
55#else
56#define yy_create_buffer code__create_buffer
57#endif
58
59#ifdef yy_delete_buffer
60#define code__delete_buffer_ALREADY_DEFINED
61#else
62#define yy_delete_buffer code__delete_buffer
63#endif
64
65#ifdef yy_scan_buffer
66#define code__scan_buffer_ALREADY_DEFINED
67#else
68#define yy_scan_buffer code__scan_buffer
69#endif
70
71#ifdef yy_scan_string
72#define code__scan_string_ALREADY_DEFINED
73#else
74#define yy_scan_string code__scan_string
75#endif
76
77#ifdef yy_scan_bytes
78#define code__scan_bytes_ALREADY_DEFINED
79#else
80#define yy_scan_bytes code__scan_bytes
81#endif
82
83#ifdef yy_init_buffer
84#define code__init_buffer_ALREADY_DEFINED
85#else
86#define yy_init_buffer code__init_buffer
87#endif
88
89#ifdef yy_flush_buffer
90#define code__flush_buffer_ALREADY_DEFINED
91#else
92#define yy_flush_buffer code__flush_buffer
93#endif
94
95#ifdef yy_load_buffer_state
96#define code__load_buffer_state_ALREADY_DEFINED
97#else
98#define yy_load_buffer_state code__load_buffer_state
99#endif
100
101#ifdef yy_switch_to_buffer
102#define code__switch_to_buffer_ALREADY_DEFINED
103#else
104#define yy_switch_to_buffer code__switch_to_buffer
105#endif
106
107#ifdef yypush_buffer_state
108#define code_push_buffer_state_ALREADY_DEFINED
109#else
110#define yypush_buffer_state code_push_buffer_state
111#endif
112
113#ifdef yypop_buffer_state
114#define code_pop_buffer_state_ALREADY_DEFINED
115#else
116#define yypop_buffer_state code_pop_buffer_state
117#endif
118
119#ifdef yyensure_buffer_stack
120#define code_ensure_buffer_stack_ALREADY_DEFINED
121#else
122#define yyensure_buffer_stack code_ensure_buffer_stack
123#endif
124
125#ifdef yylex
126#define code_lex_ALREADY_DEFINED
127#else
128#define yylex code_lex
129#endif
130
131#ifdef yyrestart
132#define code_restart_ALREADY_DEFINED
133#else
134#define yyrestart code_restart
135#endif
136
137#ifdef yylex_init
138#define code_lex_init_ALREADY_DEFINED
139#else
140#define yylex_init code_lex_init
141#endif
142
143#ifdef yylex_init_extra
144#define code_lex_init_extra_ALREADY_DEFINED
145#else
146#define yylex_init_extra code_lex_init_extra
147#endif
148
149#ifdef yylex_destroy
150#define code_lex_destroy_ALREADY_DEFINED
151#else
152#define yylex_destroy code_lex_destroy
153#endif
154
155#ifdef yyget_debug
156#define code_get_debug_ALREADY_DEFINED
157#else
158#define yyget_debug code_get_debug
159#endif
160
161#ifdef yyset_debug
162#define code_set_debug_ALREADY_DEFINED
163#else
164#define yyset_debug code_set_debug
165#endif
166
167#ifdef yyget_extra
168#define code_get_extra_ALREADY_DEFINED
169#else
170#define yyget_extra code_get_extra
171#endif
172
173#ifdef yyset_extra
174#define code_set_extra_ALREADY_DEFINED
175#else
176#define yyset_extra code_set_extra
177#endif
178
179#ifdef yyget_in
180#define code_get_in_ALREADY_DEFINED
181#else
182#define yyget_in code_get_in
183#endif
184
185#ifdef yyset_in
186#define code_set_in_ALREADY_DEFINED
187#else
188#define yyset_in code_set_in
189#endif
190
191#ifdef yyget_out
192#define code_get_out_ALREADY_DEFINED
193#else
194#define yyget_out code_get_out
195#endif
196
197#ifdef yyset_out
198#define code_set_out_ALREADY_DEFINED
199#else
200#define yyset_out code_set_out
201#endif
202
203#ifdef yyget_leng
204#define code_get_leng_ALREADY_DEFINED
205#else
206#define yyget_leng code_get_leng
207#endif
208
209#ifdef yyget_text
210#define code_get_text_ALREADY_DEFINED
211#else
212#define yyget_text code_get_text
213#endif
214
215#ifdef yyget_lineno
216#define code_get_lineno_ALREADY_DEFINED
217#else
218#define yyget_lineno code_get_lineno
219#endif
220
221#ifdef yyset_lineno
222#define code_set_lineno_ALREADY_DEFINED
223#else
224#define yyset_lineno code_set_lineno
225#endif
226
227#ifdef yywrap
228#define code_wrap_ALREADY_DEFINED
229#else
230#define yywrap code_wrap
231#endif
232
233/* %endif */
234
235#ifdef yyalloc
236#define code_alloc_ALREADY_DEFINED
237#else
238#define yyalloc code_alloc
239#endif
240
241#ifdef yyrealloc
242#define code_realloc_ALREADY_DEFINED
243#else
244#define yyrealloc code_realloc
245#endif
246
247#ifdef yyfree
248#define code_free_ALREADY_DEFINED
249#else
250#define yyfree code_free
251#endif
252
253/* %if-c-only */
254
255#ifdef yytext
256#define code_text_ALREADY_DEFINED
257#else
258#define yytext code_text
259#endif
260
261#ifdef yyleng
262#define code_leng_ALREADY_DEFINED
263#else
264#define yyleng code_leng
265#endif
266
267#ifdef yyin
268#define code_in_ALREADY_DEFINED
269#else
270#define yyin code_in
271#endif
272
273#ifdef yyout
274#define code_out_ALREADY_DEFINED
275#else
276#define yyout code_out
277#endif
278
279#ifdef yy_flex_debug
280#define code__flex_debug_ALREADY_DEFINED
281#else
282#define yy_flex_debug code__flex_debug
283#endif
284
285#ifdef yylineno
286#define code_lineno_ALREADY_DEFINED
287#else
288#define yylineno code_lineno
289#endif
290
291/* %endif */
292
293/* First, we deal with platform-specific or compiler-specific issues. */
294
295/* begin standard C headers. */
296/* %if-c-only */
297#include <stdio.h>
298#include <string.h>
299#include <errno.h>
300#include <stdlib.h>
301/* %endif */
302
303/* %if-tables-serialization */
304/* %endif */
305/* end standard C headers. */
306
307/* %if-c-or-c++ */
308/* flex integer type definitions */
309
310#ifndef FLEXINT_H
311#define FLEXINT_H
312
313/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
314
315#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
316
317/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
318 * if you want the limit (max/min) macros for int types.
319 */
320#ifndef __STDC_LIMIT_MACROS
321#define __STDC_LIMIT_MACROS 1
322#endif
323
324#include <inttypes.h>
325typedef int8_t flex_int8_t;
326typedef uint8_t flex_uint8_t;
327typedef int16_t flex_int16_t;
328typedef uint16_t flex_uint16_t;
329typedef int32_t flex_int32_t;
330typedef uint32_t flex_uint32_t;
331#else
332typedef signed char flex_int8_t;
333typedef short int flex_int16_t;
334typedef int flex_int32_t;
335typedef unsigned char flex_uint8_t;
336typedef unsigned short int flex_uint16_t;
337typedef unsigned int flex_uint32_t;
338
339/* Limits of integral types. */
340#ifndef INT8_MIN
341#define INT8_MIN (-128)
342#endif
343#ifndef INT16_MIN
344#define INT16_MIN (-32767-1)
345#endif
346#ifndef INT32_MIN
347#define INT32_MIN (-2147483647-1)
348#endif
349#ifndef INT8_MAX
350#define INT8_MAX (127)
351#endif
352#ifndef INT16_MAX
353#define INT16_MAX (32767)
354#endif
355#ifndef INT32_MAX
356#define INT32_MAX (2147483647)
357#endif
358#ifndef UINT8_MAX
359#define UINT8_MAX (255U)
360#endif
361#ifndef UINT16_MAX
362#define UINT16_MAX (65535U)
363#endif
364#ifndef UINT32_MAX
365#define UINT32_MAX (4294967295U)
366#endif
367
368#ifndef SIZE_MAX
369#define SIZE_MAX (~(size_t)0)
370#endif
371
372#endif /* ! C99 */
373
374#endif /* ! FLEXINT_H */
375
376/* %endif */
377
378/* begin standard C++ headers. */
379/* %if-c++-only */
380/* %endif */
381
382/* TODO: this is always defined, so inline it */
383#define yyconst const
384
385#if defined(__GNUC__) && __GNUC__ >= 3
386#define yynoreturn __attribute__((__noreturn__))
387#else
388#define yynoreturn
389#endif
390
391/* %not-for-header */
392/* Returned upon end-of-file. */
393#define YY_NULL 0
394/* %ok-for-header */
395
396/* %not-for-header */
397/* Promotes a possibly negative, possibly signed char to an
398 * integer in range [0..255] for use as an array index.
399 */
400#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
401/* %ok-for-header */
402
403/* %if-reentrant */
404/* %endif */
405
406/* %if-not-reentrant */
407
408/* %endif */
409
410/* Enter a start condition. This macro really ought to take a parameter,
411 * but we do it the disgusting crufty way forced on us by the ()-less
412 * definition of BEGIN.
413 */
414#define BEGIN (yy_start) = 1 + 2 *
415/* Translate the current start state into a value that can be later handed
416 * to BEGIN to return to the state. The YYSTATE alias is for lex
417 * compatibility.
418 */
419#define YY_START (((yy_start) - 1) / 2)
420#define YYSTATE YY_START
421/* Action number for EOF rule of a given start state. */
422#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
423/* Special action meaning "start processing a new file". */
424#define YY_NEW_FILE yyrestart( yyin )
425#define YY_END_OF_BUFFER_CHAR 0
426
427/* Size of default input buffer. */
428#ifndef YY_BUF_SIZE
429#ifdef __ia64__
430/* On IA-64, the buffer size is 16k, not 8k.
431 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
432 * Ditto for the __ia64__ case accordingly.
433 */
434#define YY_BUF_SIZE 32768
435#else
436#define YY_BUF_SIZE 16384
437#endif /* __ia64__ */
438#endif
439
440/* The state buf must be large enough to hold one state per character in the main buffer.
441 */
442#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
443
444#ifndef YY_TYPEDEF_YY_BUFFER_STATE
445#define YY_TYPEDEF_YY_BUFFER_STATE
446typedef struct yy_buffer_state *YY_BUFFER_STATE;
447#endif
448
449#ifndef YY_TYPEDEF_YY_SIZE_T
450#define YY_TYPEDEF_YY_SIZE_T
451typedef size_t yy_size_t;
452#endif
453
454/* %if-not-reentrant */
455extern int yyleng;
456/* %endif */
457
458/* %if-c-only */
459/* %if-not-reentrant */
460extern FILE *yyin, *yyout;
461/* %endif */
462/* %endif */
463
464#define EOB_ACT_CONTINUE_SCAN 0
465#define EOB_ACT_END_OF_FILE 1
466#define EOB_ACT_LAST_MATCH 2
467
468 #define YY_LESS_LINENO(n)
469 #define YY_LINENO_REWIND_TO(ptr)
470
471/* Return all but the first "n" matched characters back to the input stream. */
472#define yyless(n) \
473 do \
474 { \
475 /* Undo effects of setting up yytext. */ \
476 int yyless_macro_arg = (n); \
477 YY_LESS_LINENO(yyless_macro_arg);\
478 *yy_cp = (yy_hold_char); \
479 YY_RESTORE_YY_MORE_OFFSET \
480 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
481 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
482 } \
483 while ( 0 )
484#define unput(c) yyunput( c, (yytext_ptr) )
485
486#ifndef YY_STRUCT_YY_BUFFER_STATE
487#define YY_STRUCT_YY_BUFFER_STATE
488struct yy_buffer_state
489 {
490/* %if-c-only */
491 FILE *yy_input_file;
492/* %endif */
493
494/* %if-c++-only */
495/* %endif */
496
497 char *yy_ch_buf; /* input buffer */
498 char *yy_buf_pos; /* current position in input buffer */
499
500 /* Size of input buffer in bytes, not including room for EOB
501 * characters.
502 */
503 int yy_buf_size;
504
505 /* Number of characters read into yy_ch_buf, not including EOB
506 * characters.
507 */
508 int yy_n_chars;
509
510 /* Whether we "own" the buffer - i.e., we know we created it,
511 * and can realloc() it to grow it, and should free() it to
512 * delete it.
513 */
514 int yy_is_our_buffer;
515
516 /* Whether this is an "interactive" input source; if so, and
517 * if we're using stdio for input, then we want to use getc()
518 * instead of fread(), to make sure we stop fetching input after
519 * each newline.
520 */
521 int yy_is_interactive;
522
523 /* Whether we're considered to be at the beginning of a line.
524 * If so, '^' rules will be active on the next match, otherwise
525 * not.
526 */
527 int yy_at_bol;
528
529 int yy_bs_lineno; /**< The line count. */
530 int yy_bs_column; /**< The column count. */
531
532 /* Whether to try to fill the input buffer when we reach the
533 * end of it.
534 */
535 int yy_fill_buffer;
536
537 int yy_buffer_status;
538
539#define YY_BUFFER_NEW 0
540#define YY_BUFFER_NORMAL 1
541 /* When an EOF's been seen but there's still some text to process
542 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
543 * shouldn't try reading from the input source any more. We might
544 * still have a bunch of tokens to match, though, because of
545 * possible backing-up.
546 *
547 * When we actually see the EOF, we change the status to "new"
548 * (via yyrestart()), so that the user can continue scanning by
549 * just pointing yyin at a new input file.
550 */
551#define YY_BUFFER_EOF_PENDING 2
552
553 };
554#endif /* !YY_STRUCT_YY_BUFFER_STATE */
555
556/* %if-c-only Standard (non-C++) definition */
557/* %not-for-header */
558/* %if-not-reentrant */
559
560/* Stack of input buffers. */
561static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
562static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
563static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
564/* %endif */
565/* %ok-for-header */
566
567/* %endif */
568
569/* We provide macros for accessing buffer states in case in the
570 * future we want to put the buffer states in a more general
571 * "scanner state".
572 *
573 * Returns the top of the stack, or NULL.
574 */
575#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
576 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
577 : NULL)
578/* Same as previous macro, but useful when we know that the buffer stack is not
579 * NULL or when we need an lvalue. For internal use only.
580 */
581#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
582
583/* %if-c-only Standard (non-C++) definition */
584
585/* %if-not-reentrant */
586/* %not-for-header */
587/* yy_hold_char holds the character lost when yytext is formed. */
588static char yy_hold_char;
589static int yy_n_chars; /* number of characters read into yy_ch_buf */
590int yyleng;
591
592/* Points to current character in buffer. */
593static char *yy_c_buf_p = NULL;
594static int yy_init = 0; /* whether we need to initialize */
595static int yy_start = 0; /* start state number */
596
597/* Flag which is used to allow yywrap()'s to do buffer switches
598 * instead of setting up a fresh yyin. A bit of a hack ...
599 */
600static int yy_did_buffer_switch_on_eof;
601/* %ok-for-header */
602
603/* %endif */
604
605void yyrestart ( FILE *input_file );
606void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer );
607YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size );
608void yy_delete_buffer ( YY_BUFFER_STATE b );
609void yy_flush_buffer ( YY_BUFFER_STATE b );
610void yypush_buffer_state ( YY_BUFFER_STATE new_buffer );
611void yypop_buffer_state ( void );
612
613static void yyensure_buffer_stack ( void );
614static void yy_load_buffer_state ( void );
615static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file );
616#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER )
617
618YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size );
619YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
620YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
621
622/* %endif */
623
624void *yyalloc ( yy_size_t );
625void *yyrealloc ( void *, yy_size_t );
626void yyfree ( void * );
627
628#define yy_new_buffer yy_create_buffer
629#define yy_set_interactive(is_interactive) \
630 { \
631 if ( ! YY_CURRENT_BUFFER ){ \
632 yyensure_buffer_stack (); \
633 YY_CURRENT_BUFFER_LVALUE = \
634 yy_create_buffer( yyin, YY_BUF_SIZE ); \
635 } \
636 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
637 }
638#define yy_set_bol(at_bol) \
639 { \
640 if ( ! YY_CURRENT_BUFFER ){\
641 yyensure_buffer_stack (); \
642 YY_CURRENT_BUFFER_LVALUE = \
643 yy_create_buffer( yyin, YY_BUF_SIZE ); \
644 } \
645 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
646 }
647#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
648
649/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */
650/* Begin user sect3 */
651
652#define code_wrap() (/*CONSTCOND*/1)
653#define YY_SKIP_YYWRAP
654
655#define FLEX_DEBUG
656typedef flex_uint8_t YY_CHAR;
657
658FILE *yyin = NULL, *yyout = NULL;
659
660typedef int yy_state_type;
661
662extern int yylineno;
663int yylineno = 1;
664
665extern char *yytext;
666#ifdef yytext_ptr
667#undef yytext_ptr
668#endif
669#define yytext_ptr yytext
670
671/* %% [1.5] DFA */
672
673/* %if-c-only Standard (non-C++) definition */
674
675static yy_state_type yy_get_previous_state ( void );
676static yy_state_type yy_try_NUL_trans ( yy_state_type current_state );
677static int yy_get_next_buffer ( void );
678static void yynoreturn yy_fatal_error ( const char* msg );
679
680/* %endif */
681
682/* Done after the current pattern has been matched and before the
683 * corresponding action - sets up yytext.
684 */
685#define YY_DO_BEFORE_ACTION \
686 (yytext_ptr) = yy_bp; \
687/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\
688 yyleng = (int) (yy_cp - yy_bp); \
689 (yy_hold_char) = *yy_cp; \
690 *yy_cp = '\0'; \
691/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\
692 (yy_c_buf_p) = yy_cp;
693/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
694#define YY_NUM_RULES 18
695#define YY_END_OF_BUFFER 19
696/* This struct is not used in this scanner,
697 but its presence is necessary. */
698struct yy_trans_info
699 {
700 flex_int32_t yy_verify;
701 flex_int32_t yy_nxt;
702 };
703static const flex_int16_t yy_accept[91] =
704 { 0,
705 0, 0, 0, 0, 3, 3, 4, 4, 4, 4,
706 0, 0, 0, 0, 19, 17, 16, 17, 2, 17,
707 6, 17, 5, 8, 11, 7, 17, 11, 11, 11,
708 1, 0, 0, 3, 4, 4, 4, 4, 12, 0,
709 12, 12, 0, 0, 9, 10, 0, 13, 0, 13,
710 13, 0, 14, 0, 15, 0, 0, 0, 0, 0,
711 0, 0, 12, 0, 0, 0, 0, 0, 13, 0,
712 0, 0, 0, 0, 0, 0, 0, 0, 12, 0,
713 12, 12, 0, 14, 12, 12, 0, 0, 0, 0
714 } ;
715
716static const YY_CHAR yy_ec[256] =
717 { 0,
718 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
719 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
720 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
721 1, 2, 1, 4, 1, 5, 1, 1, 6, 1,
722 1, 7, 1, 1, 8, 9, 10, 11, 11, 11,
723 11, 11, 11, 11, 11, 11, 11, 1, 1, 12,
724 1, 13, 1, 14, 9, 9, 9, 9, 9, 9,
725 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
726 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
727 15, 16, 17, 1, 9, 1, 9, 9, 9, 9,
728
729 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
730 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
731 9, 9, 1, 1, 1, 1, 1, 1, 1, 1,
732 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
733 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
734 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
735 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
736 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
737 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
738 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
739
740 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
741 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
742 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
743 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
744 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
745 1, 1, 1, 1, 1
746 } ;
747
748static const YY_CHAR yy_meta[19] =
749 { 0,
750 1, 1, 2, 1, 1, 1, 1, 3, 3, 1,
751 3, 1, 2, 1, 1, 1, 1, 2
752 } ;
753
754static const flex_int16_t yy_base[97] =
755 { 0,
756 0, 13, 121, 120, 0, 3, 4, 5, 6, 7,
757 27, 0, 20, 21, 125, 178, 178, 26, 178, 8,
758 178, 41, 178, 178, 53, 178, 62, 74, 33, 119,
759 178, 37, 44, 105, 178, 46, 101, 48, 178, 99,
760 0, 96, 98, 91, 178, 178, 50, 178, 87, 0,
761 86, 87, 178, 76, 178, 52, 50, 68, 71, 73,
762 78, 74, 0, 16, 78, 84, 85, 0, 0, 94,
763 86, 96, 55, 107, 0, 0, 58, 118, 100, 124,
764 130, 136, 142, 106, 46, 0, 148, 43, 0, 178,
765 165, 168, 4, 171, 1, 174
766
767 } ;
768
769static const flex_int16_t yy_def[97] =
770 { 0,
771 91, 91, 2, 2, 2, 2, 2, 2, 2, 2,
772 2, 11, 11, 11, 90, 90, 90, 90, 90, 90,
773 90, 92, 90, 90, 90, 90, 90, 90, 90, 90,
774 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
775 93, 90, 94, 90, 90, 90, 90, 90, 90, 95,
776 90, 90, 90, 96, 90, 90, 90, 90, 90, 90,
777 90, 92, 93, 94, 94, 90, 90, 27, 95, 90,
778 96, 96, 25, 94, 66, 70, 90, 96, 94, 94,
779 94, 94, 94, 96, 81, 81, 81, 87, 87, 0,
780 90, 90, 90, 90, 90, 90
781
782 } ;
783
784static const flex_int16_t yy_nxt[197] =
785 { 0,
786 90, 90, 19, 69, 17, 19, 63, 21, 21, 33,
787 34, 23, 23, 17, 17, 20, 17, 17, 20, 22,
788 22, 22, 22, 65, 29, 29, 17, 17, 73, 17,
789 24, 25, 26, 30, 30, 31, 27, 53, 56, 57,
790 28, 32, 36, 37, 54, 33, 34, 59, 37, 61,
791 62, 67, 68, 56, 57, 74, 38, 39, 74, 31,
792 40, 41, 53, 42, 43, 32, 90, 44, 45, 33,
793 34, 46, 59, 37, 59, 37, 90, 47, 48, 61,
794 62, 49, 50, 72, 51, 65, 67, 68, 52, 38,
795 74, 75, 75, 72, 75, 70, 51, 51, 77, 66,
796
797 39, 76, 76, 72, 76, 65, 42, 65, 78, 42,
798 48, 79, 73, 72, 80, 81, 60, 82, 77, 73,
799 58, 83, 84, 55, 90, 72, 18, 18, 90, 90,
800 77, 65, 90, 90, 82, 90, 74, 85, 86, 90,
801 86, 90, 73, 65, 90, 90, 82, 90, 73, 65,
802 87, 90, 90, 90, 73, 88, 89, 90, 89, 90,
803 90, 90, 90, 90, 79, 16, 16, 16, 35, 35,
804 35, 64, 90, 64, 71, 90, 71, 15, 90, 90,
805 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
806 90, 90, 90, 90, 90, 90
807
808 } ;
809
810static const flex_int16_t yy_chk[197] =
811 { 0,
812 0, 0, 5, 95, 1, 6, 93, 7, 8, 20,
813 20, 9, 10, 1, 1, 5, 1, 2, 6, 7,
814 8, 9, 10, 64, 13, 14, 2, 2, 64, 2,
815 11, 11, 11, 13, 14, 18, 11, 29, 32, 32,
816 11, 18, 22, 22, 29, 33, 33, 36, 36, 38,
817 38, 47, 47, 56, 56, 88, 22, 25, 85, 57,
818 25, 25, 77, 25, 25, 57, 73, 25, 27, 58,
819 58, 27, 59, 59, 60, 60, 62, 27, 28, 61,
820 61, 28, 28, 54, 28, 65, 67, 67, 28, 62,
821 65, 66, 66, 71, 66, 52, 51, 49, 71, 44,
822
823 66, 70, 70, 72, 70, 43, 42, 79, 72, 40,
824 70, 74, 79, 84, 74, 74, 37, 74, 84, 74,
825 34, 74, 78, 30, 15, 78, 4, 3, 0, 0,
826 78, 80, 0, 0, 80, 0, 80, 81, 81, 0,
827 81, 0, 81, 82, 0, 0, 82, 0, 82, 83,
828 83, 0, 0, 0, 83, 87, 87, 0, 87, 0,
829 0, 0, 0, 0, 87, 91, 91, 91, 92, 92,
830 92, 94, 0, 94, 96, 0, 96, 90, 90, 90,
831 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
832 90, 90, 90, 90, 90, 90
833
834 } ;
835
836static yy_state_type yy_last_accepting_state;
837static char *yy_last_accepting_cpos;
838
839extern int yy_flex_debug;
840int yy_flex_debug = 1;
841
842static const flex_int16_t yy_rule_linenum[18] =
843 { 0,
844 115, 125, 126, 136, 141, 146, 152, 153, 154, 155,
845 157, 165, 171, 181, 189, 199, 202
846 } ;
847
848/* The intent behind this definition is that it'll catch
849 * any uses of REJECT which flex missed.
850 */
851#define REJECT reject_used_but_not_detected
852#define yymore() yymore_used_but_not_detected
853#define YY_MORE_ADJ 0
854#define YY_RESTORE_YY_MORE_OFFSET
855char *yytext;
856#line 1 "/Users/akim/src/gnu/bison/src/scan-code.l"
857/* Bison Action Scanner -*- C -*-
858
859 Copyright (C) 2006-2015, 2018-2019 Free Software Foundation, Inc.
860
861 This file is part of Bison, the GNU Compiler Compiler.
862
863 This program is free software: you can redistribute it and/or modify
864 it under the terms of the GNU General Public License as published by
865 the Free Software Foundation, either version 3 of the License, or
866 (at your option) any later version.
867
868 This program is distributed in the hope that it will be useful,
869 but WITHOUT ANY WARRANTY; without even the implied warranty of
870 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
871 GNU General Public License for more details.
872
873 You should have received a copy of the GNU General Public License
874 along with this program. If not, see <http://www.gnu.org/licenses/>. */
875#define YY_NO_INPUT 1
876#line 24 "/Users/akim/src/gnu/bison/src/scan-code.l"
877#include <c-ctype.h>
878#include <get-errno.h>
879#include <quote.h>
880
881#include <src/complain.h>
882#include <src/getargs.h>
883#include <src/muscle-tab.h>
884#include <src/reader.h>
885#include <src/scan-code.h>
886#include <src/symlist.h>
887
888#define FLEX_PREFIX(Id) code_ ## Id
889#include <src/flex-scanner.h>
890
891/* Work around a bug in flex 2.5.31. See Debian bug 333231
892 <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>. */
893#undef code_wrap
894#define code_wrap() 1
895
896/* The current calling start condition: SC_RULE_ACTION or
897 SC_SYMBOL_ACTION. */
898# define YY_DECL static char *code_lex (code_props *self, int sc_context)
899YY_DECL;
900
901#define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng);
902
903static char *fetch_type_name (char *cp, char const **type_name,
904 location dollar_loc);
905
906static void handle_action_dollar (symbol_list *rule, char *cp,
907 location dollar_loc);
908static void handle_action_at (symbol_list *rule, char *cp, location at_loc);
909
910/* A string to be pushed to obstack after dollar/at has been handled. */
911static char *ref_tail_fields;
912
913static location current_loc;
914static location *loc = &current_loc;
915
916/* A string representing the most recent translation. */
917static char *last_string;
918
919/* True if an untyped $$ or $n was seen. */
920static bool untyped_var_seen;
921
922#line 922 "src/scan-code.c"
923#line 71 "/Users/akim/src/gnu/bison/src/scan-code.l"
924 /* C and C++ comments in code. */
925
926 /* Strings and characters in code. */
927
928 /* Whether in a rule or symbol action. Specifies the translation
929 of $ and @. */
930
931/* POSIX says that a tag must be both an id and a C union member, but
932 historically almost any character is allowed in a tag. We disallow
933 NUL and newline, as this simplifies our implementation. We allow
934 "->" as a means to dereference a pointer. */
935/* Zero or more instances of backslash-newline. Following GCC, allow
936 white space between the backslash and the newline. */
937/* C style identifier. Must start with letter. Will be used for
938 named symbol references. Shall be kept synchronized with
939 scan-gram.l "letter" and "id". */
940#line 940 "src/scan-code.c"
941
942#define INITIAL 0
943#define SC_COMMENT 1
944#define SC_LINE_COMMENT 2
945#define SC_STRING 3
946#define SC_CHARACTER 4
947#define SC_RULE_ACTION 5
948#define SC_SYMBOL_ACTION 6
949
950#ifndef YY_NO_UNISTD_H
951/* Special case for "unistd.h", since it is non-ANSI. We include it way
952 * down here because we want the user's section 1 to have been scanned first.
953 * The user has a chance to override it with an option.
954 */
955/* %if-c-only */
956#include <unistd.h>
957/* %endif */
958/* %if-c++-only */
959/* %endif */
960#endif
961
962#ifndef YY_EXTRA_TYPE
963#define YY_EXTRA_TYPE void *
964#endif
965
966/* %if-c-only Reentrant structure and macros (non-C++). */
967/* %if-reentrant */
968/* %if-c-only */
969
970static int yy_init_globals ( void );
971
972/* %endif */
973/* %if-reentrant */
974/* %endif */
975/* %endif End reentrant structures and macros. */
976
977/* Accessor methods to globals.
978 These are made visible to non-reentrant scanners for convenience. */
979
980int yylex_destroy ( void );
981
982int yyget_debug ( void );
983
984void yyset_debug ( int debug_flag );
985
986YY_EXTRA_TYPE yyget_extra ( void );
987
988void yyset_extra ( YY_EXTRA_TYPE user_defined );
989
990FILE *yyget_in ( void );
991
992void yyset_in ( FILE * _in_str );
993
994FILE *yyget_out ( void );
995
996void yyset_out ( FILE * _out_str );
997
998 int yyget_leng ( void );
999
1000char *yyget_text ( void );
1001
1002int yyget_lineno ( void );
1003
1004void yyset_lineno ( int _line_number );
1005
1006/* %if-bison-bridge */
1007/* %endif */
1008
1009/* Macros after this point can all be overridden by user definitions in
1010 * section 1.
1011 */
1012
1013#ifndef YY_SKIP_YYWRAP
1014#ifdef __cplusplus
1015extern "C" int yywrap ( void );
1016#else
1017extern int yywrap ( void );
1018#endif
1019#endif
1020
1021/* %not-for-header */
1022#ifndef YY_NO_UNPUT
1023
1024#endif
1025/* %ok-for-header */
1026
1027/* %endif */
1028
1029#ifndef yytext_ptr
1030static void yy_flex_strncpy ( char *, const char *, int );
1031#endif
1032
1033#ifdef YY_NEED_STRLEN
1034static int yy_flex_strlen ( const char * );
1035#endif
1036
1037#ifndef YY_NO_INPUT
1038/* %if-c-only Standard (non-C++) definition */
1039/* %not-for-header */
1040#ifdef __cplusplus
1041static int yyinput ( void );
1042#else
1043static int input ( void );
1044#endif
1045/* %ok-for-header */
1046
1047/* %endif */
1048#endif
1049
1050/* %if-c-only */
1051
1052/* %endif */
1053
1054/* Amount of stuff to slurp up with each read. */
1055#ifndef YY_READ_BUF_SIZE
1056#ifdef __ia64__
1057/* On IA-64, the buffer size is 16k, not 8k */
1058#define YY_READ_BUF_SIZE 16384
1059#else
1060#define YY_READ_BUF_SIZE 8192
1061#endif /* __ia64__ */
1062#endif
1063
1064/* Copy whatever the last rule matched to the standard output. */
1065#ifndef ECHO
1066/* %if-c-only Standard (non-C++) definition */
1067/* This used to be an fputs(), but since the string might contain NUL's,
1068 * we now use fwrite().
1069 */
1070#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
1071/* %endif */
1072/* %if-c++-only C++ definition */
1073/* %endif */
1074#endif
1075
1076/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
1077 * is returned in "result".
1078 */
1079#ifndef YY_INPUT
1080#define YY_INPUT(buf,result,max_size) \
1081/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
1082 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
1083 { \
1084 int c = '*'; \
1085 int n; \
1086 for ( n = 0; n < max_size && \
1087 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
1088 buf[n] = (char) c; \
1089 if ( c == '\n' ) \
1090 buf[n++] = (char) c; \
1091 if ( c == EOF && ferror( yyin ) ) \
1092 YY_FATAL_ERROR( "input in flex scanner failed" ); \
1093 result = n; \
1094 } \
1095 else \
1096 { \
1097 errno=0; \
1098 while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
1099 { \
1100 if( errno != EINTR) \
1101 { \
1102 YY_FATAL_ERROR( "input in flex scanner failed" ); \
1103 break; \
1104 } \
1105 errno=0; \
1106 clearerr(yyin); \
1107 } \
1108 }\
1109\
1110/* %if-c++-only C++ definition \ */\
1111/* %endif */
1112
1113#endif
1114
1115/* No semi-colon after return; correct usage is to write "yyterminate();" -
1116 * we don't want an extra ';' after the "return" because that will cause
1117 * some compilers to complain about unreachable statements.
1118 */
1119#ifndef yyterminate
1120#define yyterminate() return YY_NULL
1121#endif
1122
1123/* Number of entries by which start-condition stack grows. */
1124#ifndef YY_START_STACK_INCR
1125#define YY_START_STACK_INCR 25
1126#endif
1127
1128/* Report a fatal error. */
1129#ifndef YY_FATAL_ERROR
1130/* %if-c-only */
1131#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
1132/* %endif */
1133/* %if-c++-only */
1134/* %endif */
1135#endif
1136
1137/* %if-tables-serialization structures and prototypes */
1138/* %not-for-header */
1139/* %ok-for-header */
1140
1141/* %not-for-header */
1142/* %tables-yydmap generated elements */
1143/* %endif */
1144/* end tables serialization structures and prototypes */
1145
1146/* %ok-for-header */
1147
1148/* Default declaration of generated scanner - a define so the user can
1149 * easily add parameters.
1150 */
1151#ifndef YY_DECL
1152#define YY_DECL_IS_OURS 1
1153/* %if-c-only Standard (non-C++) definition */
1154
1155extern int yylex (void);
1156
1157#define YY_DECL int yylex (void)
1158/* %endif */
1159/* %if-c++-only C++ definition */
1160/* %endif */
1161#endif /* !YY_DECL */
1162
1163/* Code executed at the beginning of each rule, after yytext and yyleng
1164 * have been set up.
1165 */
1166#ifndef YY_USER_ACTION
1167#define YY_USER_ACTION
1168#endif
1169
1170/* Code executed at the end of each rule. */
1171#ifndef YY_BREAK
1172#define YY_BREAK /*LINTED*/break;
1173#endif
1174
1175/* %% [6.0] YY_RULE_SETUP definition goes here */
1176#define YY_RULE_SETUP \
1177 YY_USER_ACTION
1178
1179/* %not-for-header */
1180/** The main scanner function which does all the work.
1181 */
1182YY_DECL
1183{
1184 yy_state_type yy_current_state;
1185 char *yy_cp, *yy_bp;
1186 int yy_act;
1187
1188 if ( !(yy_init) )
1189 {
1190 (yy_init) = 1;
1191
1192#ifdef YY_USER_INIT
1193 YY_USER_INIT;
1194#endif
1195
1196 if ( ! (yy_start) )
1197 (yy_start) = 1; /* first start state */
1198
1199 if ( ! yyin )
1200/* %if-c-only */
1201 yyin = stdin;
1202/* %endif */
1203/* %if-c++-only */
1204/* %endif */
1205
1206 if ( ! yyout )
1207/* %if-c-only */
1208 yyout = stdout;
1209/* %endif */
1210/* %if-c++-only */
1211/* %endif */
1212
1213 if ( ! YY_CURRENT_BUFFER ) {
1214 yyensure_buffer_stack ();
1215 YY_CURRENT_BUFFER_LVALUE =
1216 yy_create_buffer( yyin, YY_BUF_SIZE );
1217 }
1218
1219 yy_load_buffer_state( );
1220 }
1221
1222 {
1223/* %% [7.0] user's declarations go here */
1224#line 97 "/Users/akim/src/gnu/bison/src/scan-code.l"
1225
1226
1227
1228 /* This scanner is special: it is invoked only once, henceforth
1229 is expected to return only once. This initialization is
1230 therefore done once per action to translate. */
1231 aver (sc_context == SC_SYMBOL_ACTION
1232 || sc_context == SC_RULE_ACTION
1233 || sc_context == INITIAL);
1234 BEGIN sc_context;
1235
1236
1237 /*------------------------------------------------------------.
1238 | Scanning a C comment. The initial '/ *' is already eaten. |
1239 `------------------------------------------------------------*/
1240
1241#line 1241 "src/scan-code.c"
1242
1243 while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
1244 {
1245/* %% [8.0] yymore()-related code goes here */
1246 yy_cp = (yy_c_buf_p);
1247
1248 /* Support of yytext. */
1249 *yy_cp = (yy_hold_char);
1250
1251 /* yy_bp points to the position in yy_ch_buf of the start of
1252 * the current run.
1253 */
1254 yy_bp = yy_cp;
1255
1256/* %% [9.0] code to set up and find next match goes here */
1257 yy_current_state = (yy_start);
1258yy_match:
1259 do
1260 {
1261 YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
1262 if ( yy_accept[yy_current_state] )
1263 {
1264 (yy_last_accepting_state) = yy_current_state;
1265 (yy_last_accepting_cpos) = yy_cp;
1266 }
1267 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1268 {
1269 yy_current_state = (int) yy_def[yy_current_state];
1270 if ( yy_current_state >= 91 )
1271 yy_c = yy_meta[yy_c];
1272 }
1273 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1274 ++yy_cp;
1275 }
1276 while ( yy_current_state != 90 );
1277 yy_cp = (yy_last_accepting_cpos);
1278 yy_current_state = (yy_last_accepting_state);
1279
1280yy_find_action:
1281/* %% [10.0] code to find the action number goes here */
1282 yy_act = yy_accept[yy_current_state];
1283
1284 YY_DO_BEFORE_ACTION;
1285
1286/* %% [11.0] code for yylineno update goes here */
1287
1288do_action: /* This label is used only to access EOF actions. */
1289
1290/* %% [12.0] debug code goes here */
1291 if ( yy_flex_debug )
1292 {
1293 if ( yy_act == 0 )
1294 fprintf( stderr, "--scanner backing up\n" );
1295 else if ( yy_act < 18 )
1296 fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n",
1297 (long)yy_rule_linenum[yy_act], yytext );
1298 else if ( yy_act == 18 )
1299 fprintf( stderr, "--accepting default rule (\"%s\")\n",
1300 yytext );
1301 else if ( yy_act == 19 )
1302 fprintf( stderr, "--(end of buffer or a NUL)\n" );
1303 else
1304 fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
1305 }
1306
1307 switch ( yy_act )
1308 { /* beginning of action switch */
1309/* %% [13.0] actions go here */
1310 case 0: /* must back up */
1311 /* undo the effects of YY_DO_BEFORE_ACTION */
1312 *yy_cp = (yy_hold_char);
1313 yy_cp = (yy_last_accepting_cpos);
1314 yy_current_state = (yy_last_accepting_state);
1315 goto yy_find_action;
1316
1317case 1:
1318/* rule 1 can match eol */
1319YY_RULE_SETUP
1320#line 115 "/Users/akim/src/gnu/bison/src/scan-code.l"
1321STRING_GROW; BEGIN sc_context;
1322 YY_BREAK
1323
1324/*--------------------------------------------------------------.
1325 | Scanning a line comment. The initial '//' is already eaten. |
1326 `--------------------------------------------------------------*/
1327
1328
1329case 2:
1330/* rule 2 can match eol */
1331YY_RULE_SETUP
1332#line 125 "/Users/akim/src/gnu/bison/src/scan-code.l"
1333STRING_GROW; BEGIN sc_context;
1334 YY_BREAK
1335case 3:
1336/* rule 3 can match eol */
1337YY_RULE_SETUP
1338#line 126 "/Users/akim/src/gnu/bison/src/scan-code.l"
1339STRING_GROW;
1340 YY_BREAK
1341
1342/*--------------------------------------------.
1343 | Scanning user-code characters and strings. |
1344 `--------------------------------------------*/
1345
1346
1347case 4:
1348/* rule 4 can match eol */
1349YY_RULE_SETUP
1350#line 136 "/Users/akim/src/gnu/bison/src/scan-code.l"
1351STRING_GROW;
1352 YY_BREAK
1353
1354
1355
1356case 5:
1357YY_RULE_SETUP
1358#line 141 "/Users/akim/src/gnu/bison/src/scan-code.l"
1359STRING_GROW; BEGIN sc_context;
1360 YY_BREAK
1361
1362
1363
1364case 6:
1365YY_RULE_SETUP
1366#line 146 "/Users/akim/src/gnu/bison/src/scan-code.l"
1367STRING_GROW; BEGIN sc_context;
1368 YY_BREAK
1369
1370
1371
1372case 7:
1373YY_RULE_SETUP
1374#line 152 "/Users/akim/src/gnu/bison/src/scan-code.l"
1375STRING_GROW; BEGIN SC_CHARACTER;
1376 YY_BREAK
1377case 8:
1378YY_RULE_SETUP
1379#line 153 "/Users/akim/src/gnu/bison/src/scan-code.l"
1380STRING_GROW; BEGIN SC_STRING;
1381 YY_BREAK
1382case 9:
1383/* rule 9 can match eol */
1384YY_RULE_SETUP
1385#line 154 "/Users/akim/src/gnu/bison/src/scan-code.l"
1386STRING_GROW; BEGIN SC_COMMENT;
1387 YY_BREAK
1388case 10:
1389/* rule 10 can match eol */
1390YY_RULE_SETUP
1391#line 155 "/Users/akim/src/gnu/bison/src/scan-code.l"
1392STRING_GROW; BEGIN SC_LINE_COMMENT;
1393 YY_BREAK
1394case 11:
1395YY_RULE_SETUP
1396#line 157 "/Users/akim/src/gnu/bison/src/scan-code.l"
1397{
1398 complain (loc, Wother, _("stray '%s'"), yytext);
1399 obstack_escape (&obstack_for_string, yytext);
1400 }
1401 YY_BREAK
1402
1403
1404
1405case 12:
1406YY_RULE_SETUP
1407#line 165 "/Users/akim/src/gnu/bison/src/scan-code.l"
1408{
1409 ref_tail_fields = NULL;
1410 handle_action_dollar (self->rule, yytext, *loc);
1411 if (ref_tail_fields)
1412 obstack_sgrow (&obstack_for_string, ref_tail_fields);
1413 }
1414 YY_BREAK
1415case 13:
1416YY_RULE_SETUP
1417#line 171 "/Users/akim/src/gnu/bison/src/scan-code.l"
1418{
1419 ref_tail_fields = NULL;
1420 handle_action_at (self->rule, yytext, *loc);
1421 if (ref_tail_fields)
1422 obstack_sgrow (&obstack_for_string, ref_tail_fields);
1423 }
1424 YY_BREAK
1425
1426
1427
1428case 14:
1429YY_RULE_SETUP
1430#line 181 "/Users/akim/src/gnu/bison/src/scan-code.l"
1431{
1432 const char *type_name = NULL;
1433 fetch_type_name (yytext + 1, &type_name, *loc)[-1] = 0;
1434 obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar(");
1435 obstack_quote (&obstack_for_string, type_name);
1436 obstack_sgrow (&obstack_for_string, ")[");
1437 self->is_value_used = true;
1438 }
1439 YY_BREAK
1440case 15:
1441YY_RULE_SETUP
1442#line 189 "/Users/akim/src/gnu/bison/src/scan-code.l"
1443{
1444 obstack_sgrow (&obstack_for_string, "]b4_at_dollar[");
1445 muscle_percent_define_ensure("locations", *loc, true);
1446 }
1447 YY_BREAK
1448
1449
1450
1451/* Escape M4 quoting characters in C code. */
1452case 16:
1453YY_RULE_SETUP
1454#line 199 "/Users/akim/src/gnu/bison/src/scan-code.l"
1455obstack_escape (&obstack_for_string, yytext);
1456 YY_BREAK
1457/* By default, grow the string obstack with the input. */
1458case 17:
1459/* rule 17 can match eol */
1460YY_RULE_SETUP
1461#line 202 "/Users/akim/src/gnu/bison/src/scan-code.l"
1462STRING_GROW;
1463 YY_BREAK
1464/* End of processing. */
1465case YY_STATE_EOF(INITIAL):
1466case YY_STATE_EOF(SC_COMMENT):
1467case YY_STATE_EOF(SC_LINE_COMMENT):
1468case YY_STATE_EOF(SC_STRING):
1469case YY_STATE_EOF(SC_CHARACTER):
1470case YY_STATE_EOF(SC_RULE_ACTION):
1471case YY_STATE_EOF(SC_SYMBOL_ACTION):
1472#line 205 "/Users/akim/src/gnu/bison/src/scan-code.l"
1473STRING_FINISH; return last_string;
1474 YY_BREAK
1475
1476case 18:
1477YY_RULE_SETUP
1478#line 208 "/Users/akim/src/gnu/bison/src/scan-code.l"
1479YY_FATAL_ERROR( "flex scanner jammed" );
1480 YY_BREAK
1481#line 1481 "src/scan-code.c"
1482
1483 case YY_END_OF_BUFFER:
1484 {
1485 /* Amount of text matched not including the EOB char. */
1486 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1487
1488 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1489 *yy_cp = (yy_hold_char);
1490 YY_RESTORE_YY_MORE_OFFSET
1491
1492 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1493 {
1494 /* We're scanning a new file or input source. It's
1495 * possible that this happened because the user
1496 * just pointed yyin at a new source and called
1497 * yylex(). If so, then we have to assure
1498 * consistency between YY_CURRENT_BUFFER and our
1499 * globals. Here is the right place to do so, because
1500 * this is the first action (other than possibly a
1501 * back-up) that will match for the new input source.
1502 */
1503 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1504/* %if-c-only */
1505 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1506/* %endif */
1507/* %if-c++-only */
1508/* %endif */
1509 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1510 }
1511
1512 /* Note that here we test for yy_c_buf_p "<=" to the position
1513 * of the first EOB in the buffer, since yy_c_buf_p will
1514 * already have been incremented past the NUL character
1515 * (since all states make transitions on EOB to the
1516 * end-of-buffer state). Contrast this with the test
1517 * in input().
1518 */
1519 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1520 { /* This was really a NUL. */
1521 yy_state_type yy_next_state;
1522
1523 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1524
1525 yy_current_state = yy_get_previous_state( );
1526
1527 /* Okay, we're now positioned to make the NUL
1528 * transition. We couldn't have
1529 * yy_get_previous_state() go ahead and do it
1530 * for us because it doesn't know how to deal
1531 * with the possibility of jamming (and we don't
1532 * want to build jamming into it because then it
1533 * will run more slowly).
1534 */
1535
1536 yy_next_state = yy_try_NUL_trans( yy_current_state );
1537
1538 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1539
1540 if ( yy_next_state )
1541 {
1542 /* Consume the NUL. */
1543 yy_cp = ++(yy_c_buf_p);
1544 yy_current_state = yy_next_state;
1545 goto yy_match;
1546 }
1547
1548 else
1549 {
1550/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */
1551 yy_cp = (yy_last_accepting_cpos);
1552 yy_current_state = (yy_last_accepting_state);
1553 goto yy_find_action;
1554 }
1555 }
1556
1557 else switch ( yy_get_next_buffer( ) )
1558 {
1559 case EOB_ACT_END_OF_FILE:
1560 {
1561 (yy_did_buffer_switch_on_eof) = 0;
1562
1563 if ( yywrap( ) )
1564 {
1565 /* Note: because we've taken care in
1566 * yy_get_next_buffer() to have set up
1567 * yytext, we can now set up
1568 * yy_c_buf_p so that if some total
1569 * hoser (like flex itself) wants to
1570 * call the scanner after we return the
1571 * YY_NULL, it'll still work - another
1572 * YY_NULL will get returned.
1573 */
1574 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1575
1576 yy_act = YY_STATE_EOF(YY_START);
1577 goto do_action;
1578 }
1579
1580 else
1581 {
1582 if ( ! (yy_did_buffer_switch_on_eof) )
1583 YY_NEW_FILE;
1584 }
1585 break;
1586 }
1587
1588 case EOB_ACT_CONTINUE_SCAN:
1589 (yy_c_buf_p) =
1590 (yytext_ptr) + yy_amount_of_matched_text;
1591
1592 yy_current_state = yy_get_previous_state( );
1593
1594 yy_cp = (yy_c_buf_p);
1595 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1596 goto yy_match;
1597
1598 case EOB_ACT_LAST_MATCH:
1599 (yy_c_buf_p) =
1600 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1601
1602 yy_current_state = yy_get_previous_state( );
1603
1604 yy_cp = (yy_c_buf_p);
1605 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1606 goto yy_find_action;
1607 }
1608 break;
1609 }
1610
1611 default:
1612 YY_FATAL_ERROR(
1613 "fatal flex scanner internal error--no action found" );
1614 } /* end of action switch */
1615 } /* end of scanning one token */
1616 } /* end of user's declarations */
1617} /* end of yylex */
1618/* %ok-for-header */
1619
1620/* %if-c++-only */
1621/* %not-for-header */
1622/* %ok-for-header */
1623
1624/* %endif */
1625
1626/* yy_get_next_buffer - try to read in a new buffer
1627 *
1628 * Returns a code representing an action:
1629 * EOB_ACT_LAST_MATCH -
1630 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1631 * EOB_ACT_END_OF_FILE - end of file
1632 */
1633/* %if-c-only */
1634static int yy_get_next_buffer (void)
1635/* %endif */
1636/* %if-c++-only */
1637/* %endif */
1638{
1639 char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1640 char *source = (yytext_ptr);
1641 int number_to_move, i;
1642 int ret_val;
1643
1644 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1645 YY_FATAL_ERROR(
1646 "fatal flex scanner internal error--end of buffer missed" );
1647
1648 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1649 { /* Don't try to fill the buffer, so this is an EOF. */
1650 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1651 {
1652 /* We matched a single character, the EOB, so
1653 * treat this as a final EOF.
1654 */
1655 return EOB_ACT_END_OF_FILE;
1656 }
1657
1658 else
1659 {
1660 /* We matched some text prior to the EOB, first
1661 * process it.
1662 */
1663 return EOB_ACT_LAST_MATCH;
1664 }
1665 }
1666
1667 /* Try to read more data. */
1668
1669 /* First move last chars to start of buffer. */
1670 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
1671
1672 for ( i = 0; i < number_to_move; ++i )
1673 *(dest++) = *(source++);
1674
1675 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1676 /* don't do the read, it's not guaranteed to return an EOF,
1677 * just force an EOF
1678 */
1679 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1680
1681 else
1682 {
1683 int num_to_read =
1684 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1685
1686 while ( num_to_read <= 0 )
1687 { /* Not enough room in the buffer - grow it. */
1688
1689 /* just a shorter name for the current buffer */
1690 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1691
1692 int yy_c_buf_p_offset =
1693 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1694
1695 if ( b->yy_is_our_buffer )
1696 {
1697 int new_size = b->yy_buf_size * 2;
1698
1699 if ( new_size <= 0 )
1700 b->yy_buf_size += b->yy_buf_size / 8;
1701 else
1702 b->yy_buf_size *= 2;
1703
1704 b->yy_ch_buf = (char *)
1705 /* Include room in for 2 EOB chars. */
1706 yyrealloc( (void *) b->yy_ch_buf,
1707 (yy_size_t) (b->yy_buf_size + 2) );
1708 }
1709 else
1710 /* Can't grow it, we don't own it. */
1711 b->yy_ch_buf = NULL;
1712
1713 if ( ! b->yy_ch_buf )
1714 YY_FATAL_ERROR(
1715 "fatal error - scanner input buffer overflow" );
1716
1717 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1718
1719 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1720 number_to_move - 1;
1721
1722 }
1723
1724 if ( num_to_read > YY_READ_BUF_SIZE )
1725 num_to_read = YY_READ_BUF_SIZE;
1726
1727 /* Read in more data. */
1728 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1729 (yy_n_chars), num_to_read );
1730
1731 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1732 }
1733
1734 if ( (yy_n_chars) == 0 )
1735 {
1736 if ( number_to_move == YY_MORE_ADJ )
1737 {
1738 ret_val = EOB_ACT_END_OF_FILE;
1739 yyrestart( yyin );
1740 }
1741
1742 else
1743 {
1744 ret_val = EOB_ACT_LAST_MATCH;
1745 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1746 YY_BUFFER_EOF_PENDING;
1747 }
1748 }
1749
1750 else
1751 ret_val = EOB_ACT_CONTINUE_SCAN;
1752
1753 if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1754 /* Extend the array by 50%, plus the number we really need. */
1755 int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1756 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
1757 (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size );
1758 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1759 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1760 /* "- 2" to take care of EOB's */
1761 YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
1762 }
1763
1764 (yy_n_chars) += number_to_move;
1765 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1766 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1767
1768 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1769
1770 return ret_val;
1771}
1772
1773/* yy_get_previous_state - get the state just before the EOB char was reached */
1774
1775/* %if-c-only */
1776/* %not-for-header */
1777 static yy_state_type yy_get_previous_state (void)
1778/* %endif */
1779/* %if-c++-only */
1780/* %endif */
1781{
1782 yy_state_type yy_current_state;
1783 char *yy_cp;
1784
1785/* %% [15.0] code to get the start state into yy_current_state goes here */
1786 yy_current_state = (yy_start);
1787
1788 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1789 {
1790/* %% [16.0] code to find the next state goes here */
1791 YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 18);
1792 if ( yy_accept[yy_current_state] )
1793 {
1794 (yy_last_accepting_state) = yy_current_state;
1795 (yy_last_accepting_cpos) = yy_cp;
1796 }
1797 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1798 {
1799 yy_current_state = (int) yy_def[yy_current_state];
1800 if ( yy_current_state >= 91 )
1801 yy_c = yy_meta[yy_c];
1802 }
1803 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1804 }
1805
1806 return yy_current_state;
1807}
1808
1809/* yy_try_NUL_trans - try to make a transition on the NUL character
1810 *
1811 * synopsis
1812 * next_state = yy_try_NUL_trans( current_state );
1813 */
1814/* %if-c-only */
1815 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1816/* %endif */
1817/* %if-c++-only */
1818/* %endif */
1819{
1820 int yy_is_jam;
1821 /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
1822 char *yy_cp = (yy_c_buf_p);
1823
1824 YY_CHAR yy_c = 18;
1825 if ( yy_accept[yy_current_state] )
1826 {
1827 (yy_last_accepting_state) = yy_current_state;
1828 (yy_last_accepting_cpos) = yy_cp;
1829 }
1830 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1831 {
1832 yy_current_state = (int) yy_def[yy_current_state];
1833 if ( yy_current_state >= 91 )
1834 yy_c = yy_meta[yy_c];
1835 }
1836 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1837 yy_is_jam = (yy_current_state == 90);
1838
1839 return yy_is_jam ? 0 : yy_current_state;
1840}
1841
1842#ifndef YY_NO_UNPUT
1843/* %if-c-only */
1844
1845/* %endif */
1846#endif
1847
1848/* %if-c-only */
1849#ifndef YY_NO_INPUT
1850#ifdef __cplusplus
1851 static int yyinput (void)
1852#else
1853 static int input (void)
1854#endif
1855
1856/* %endif */
1857/* %if-c++-only */
1858/* %endif */
1859{
1860 int c;
1861
1862 *(yy_c_buf_p) = (yy_hold_char);
1863
1864 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1865 {
1866 /* yy_c_buf_p now points to the character we want to return.
1867 * If this occurs *before* the EOB characters, then it's a
1868 * valid NUL; if not, then we've hit the end of the buffer.
1869 */
1870 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1871 /* This was really a NUL. */
1872 *(yy_c_buf_p) = '\0';
1873
1874 else
1875 { /* need more input */
1876 int offset = (int) ((yy_c_buf_p) - (yytext_ptr));
1877 ++(yy_c_buf_p);
1878
1879 switch ( yy_get_next_buffer( ) )
1880 {
1881 case EOB_ACT_LAST_MATCH:
1882 /* This happens because yy_g_n_b()
1883 * sees that we've accumulated a
1884 * token and flags that we need to
1885 * try matching the token before
1886 * proceeding. But for input(),
1887 * there's no matching to consider.
1888 * So convert the EOB_ACT_LAST_MATCH
1889 * to EOB_ACT_END_OF_FILE.
1890 */
1891
1892 /* Reset buffer status. */
1893 yyrestart( yyin );
1894
1895 /*FALLTHROUGH*/
1896
1897 case EOB_ACT_END_OF_FILE:
1898 {
1899 if ( yywrap( ) )
1900 return 0;
1901
1902 if ( ! (yy_did_buffer_switch_on_eof) )
1903 YY_NEW_FILE;
1904#ifdef __cplusplus
1905 return yyinput();
1906#else
1907 return input();
1908#endif
1909 }
1910
1911 case EOB_ACT_CONTINUE_SCAN:
1912 (yy_c_buf_p) = (yytext_ptr) + offset;
1913 break;
1914 }
1915 }
1916 }
1917
1918 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1919 *(yy_c_buf_p) = '\0'; /* preserve yytext */
1920 (yy_hold_char) = *++(yy_c_buf_p);
1921
1922/* %% [19.0] update BOL and yylineno */
1923
1924 return c;
1925}
1926/* %if-c-only */
1927#endif /* ifndef YY_NO_INPUT */
1928/* %endif */
1929
1930/** Immediately switch to a different input stream.
1931 * @param input_file A readable stream.
1932 *
1933 * @note This function does not reset the start condition to @c INITIAL .
1934 */
1935/* %if-c-only */
1936 void yyrestart (FILE * input_file )
1937/* %endif */
1938/* %if-c++-only */
1939/* %endif */
1940{
1941
1942 if ( ! YY_CURRENT_BUFFER ){
1943 yyensure_buffer_stack ();
1944 YY_CURRENT_BUFFER_LVALUE =
1945 yy_create_buffer( yyin, YY_BUF_SIZE );
1946 }
1947
1948 yy_init_buffer( YY_CURRENT_BUFFER, input_file );
1949 yy_load_buffer_state( );
1950}
1951
1952/* %if-c++-only */
1953/* %endif */
1954
1955/** Switch to a different input buffer.
1956 * @param new_buffer The new input buffer.
1957 *
1958 */
1959/* %if-c-only */
1960 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1961/* %endif */
1962/* %if-c++-only */
1963/* %endif */
1964{
1965
1966 /* TODO. We should be able to replace this entire function body
1967 * with
1968 * yypop_buffer_state();
1969 * yypush_buffer_state(new_buffer);
1970 */
1971 yyensure_buffer_stack ();
1972 if ( YY_CURRENT_BUFFER == new_buffer )
1973 return;
1974
1975 if ( YY_CURRENT_BUFFER )
1976 {
1977 /* Flush out information for old buffer. */
1978 *(yy_c_buf_p) = (yy_hold_char);
1979 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1980 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1981 }
1982
1983 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1984 yy_load_buffer_state( );
1985
1986 /* We don't actually know whether we did this switch during
1987 * EOF (yywrap()) processing, but the only time this flag
1988 * is looked at is after yywrap() is called, so it's safe
1989 * to go ahead and always set it.
1990 */
1991 (yy_did_buffer_switch_on_eof) = 1;
1992}
1993
1994/* %if-c-only */
1995static void yy_load_buffer_state (void)
1996/* %endif */
1997/* %if-c++-only */
1998/* %endif */
1999{
2000 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2001 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
2002/* %if-c-only */
2003 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
2004/* %endif */
2005/* %if-c++-only */
2006/* %endif */
2007 (yy_hold_char) = *(yy_c_buf_p);
2008}
2009
2010/** Allocate and initialize an input buffer state.
2011 * @param file A readable stream.
2012 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
2013 *
2014 * @return the allocated buffer state.
2015 */
2016/* %if-c-only */
2017 YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
2018/* %endif */
2019/* %if-c++-only */
2020/* %endif */
2021{
2022 YY_BUFFER_STATE b;
2023
2024 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
2025 if ( ! b )
2026 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
2027
2028 b->yy_buf_size = size;
2029
2030 /* yy_ch_buf has to be 2 characters longer than the size given because
2031 * we need to put in 2 end-of-buffer characters.
2032 */
2033 b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) );
2034 if ( ! b->yy_ch_buf )
2035 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
2036
2037 b->yy_is_our_buffer = 1;
2038
2039 yy_init_buffer( b, file );
2040
2041 return b;
2042}
2043
2044/* %if-c++-only */
2045/* %endif */
2046
2047/** Destroy the buffer.
2048 * @param b a buffer created with yy_create_buffer()
2049 *
2050 */
2051/* %if-c-only */
2052 void yy_delete_buffer (YY_BUFFER_STATE b )
2053/* %endif */
2054/* %if-c++-only */
2055/* %endif */
2056{
2057
2058 if ( ! b )
2059 return;
2060
2061 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
2062 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
2063
2064 if ( b->yy_is_our_buffer )
2065 yyfree( (void *) b->yy_ch_buf );
2066
2067 yyfree( (void *) b );
2068}
2069
2070/* Initializes or reinitializes a buffer.
2071 * This function is sometimes called more than once on the same buffer,
2072 * such as during a yyrestart() or at EOF.
2073 */
2074/* %if-c-only */
2075 static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
2076/* %endif */
2077/* %if-c++-only */
2078/* %endif */
2079
2080{
2081 int oerrno = errno;
2082
2083 yy_flush_buffer( b );
2084
2085/* %if-c-only */
2086 b->yy_input_file = file;
2087/* %endif */
2088/* %if-c++-only */
2089/* %endif */
2090 b->yy_fill_buffer = 1;
2091
2092 /* If b is the current buffer, then yy_init_buffer was _probably_
2093 * called from yyrestart() or through yy_get_next_buffer.
2094 * In that case, we don't want to reset the lineno or column.
2095 */
2096 if (b != YY_CURRENT_BUFFER){
2097 b->yy_bs_lineno = 1;
2098 b->yy_bs_column = 0;
2099 }
2100
2101/* %if-c-only */
2102
2103 b->yy_is_interactive = 0;
2104
2105/* %endif */
2106/* %if-c++-only */
2107/* %endif */
2108 errno = oerrno;
2109}
2110
2111/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2112 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2113 *
2114 */
2115/* %if-c-only */
2116 void yy_flush_buffer (YY_BUFFER_STATE b )
2117/* %endif */
2118/* %if-c++-only */
2119/* %endif */
2120{
2121 if ( ! b )
2122 return;
2123
2124 b->yy_n_chars = 0;
2125
2126 /* We always need two end-of-buffer characters. The first causes
2127 * a transition to the end-of-buffer state. The second causes
2128 * a jam in that state.
2129 */
2130 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2131 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2132
2133 b->yy_buf_pos = &b->yy_ch_buf[0];
2134
2135 b->yy_at_bol = 1;
2136 b->yy_buffer_status = YY_BUFFER_NEW;
2137
2138 if ( b == YY_CURRENT_BUFFER )
2139 yy_load_buffer_state( );
2140}
2141
2142/* %if-c-or-c++ */
2143/** Pushes the new state onto the stack. The new state becomes
2144 * the current state. This function will allocate the stack
2145 * if necessary.
2146 * @param new_buffer The new state.
2147 *
2148 */
2149/* %if-c-only */
2150void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
2151/* %endif */
2152/* %if-c++-only */
2153/* %endif */
2154{
2155 if (new_buffer == NULL)
2156 return;
2157
2158 yyensure_buffer_stack();
2159
2160 /* This block is copied from yy_switch_to_buffer. */
2161 if ( YY_CURRENT_BUFFER )
2162 {
2163 /* Flush out information for old buffer. */
2164 *(yy_c_buf_p) = (yy_hold_char);
2165 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
2166 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
2167 }
2168
2169 /* Only push if top exists. Otherwise, replace top. */
2170 if (YY_CURRENT_BUFFER)
2171 (yy_buffer_stack_top)++;
2172 YY_CURRENT_BUFFER_LVALUE = new_buffer;
2173
2174 /* copied from yy_switch_to_buffer. */
2175 yy_load_buffer_state( );
2176 (yy_did_buffer_switch_on_eof) = 1;
2177}
2178/* %endif */
2179
2180/* %if-c-or-c++ */
2181/** Removes and deletes the top of the stack, if present.
2182 * The next element becomes the new top.
2183 *
2184 */
2185/* %if-c-only */
2186void yypop_buffer_state (void)
2187/* %endif */
2188/* %if-c++-only */
2189/* %endif */
2190{
2191 if (!YY_CURRENT_BUFFER)
2192 return;
2193
2194 yy_delete_buffer(YY_CURRENT_BUFFER );
2195 YY_CURRENT_BUFFER_LVALUE = NULL;
2196 if ((yy_buffer_stack_top) > 0)
2197 --(yy_buffer_stack_top);
2198
2199 if (YY_CURRENT_BUFFER) {
2200 yy_load_buffer_state( );
2201 (yy_did_buffer_switch_on_eof) = 1;
2202 }
2203}
2204/* %endif */
2205
2206/* %if-c-or-c++ */
2207/* Allocates the stack if it does not exist.
2208 * Guarantees space for at least one push.
2209 */
2210/* %if-c-only */
2211static void yyensure_buffer_stack (void)
2212/* %endif */
2213/* %if-c++-only */
2214/* %endif */
2215{
2216 yy_size_t num_to_alloc;
2217
2218 if (!(yy_buffer_stack)) {
2219
2220 /* First allocation is just for 2 elements, since we don't know if this
2221 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2222 * immediate realloc on the next call.
2223 */
2224 num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
2225 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
2226 (num_to_alloc * sizeof(struct yy_buffer_state*)
2227 );
2228 if ( ! (yy_buffer_stack) )
2229 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2230
2231 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2232
2233 (yy_buffer_stack_max) = num_to_alloc;
2234 (yy_buffer_stack_top) = 0;
2235 return;
2236 }
2237
2238 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
2239
2240 /* Increase the buffer to prepare for a possible push. */
2241 yy_size_t grow_size = 8 /* arbitrary grow size */;
2242
2243 num_to_alloc = (yy_buffer_stack_max) + grow_size;
2244 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
2245 ((yy_buffer_stack),
2246 num_to_alloc * sizeof(struct yy_buffer_state*)
2247 );
2248 if ( ! (yy_buffer_stack) )
2249 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2250
2251 /* zero only the new slots.*/
2252 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
2253 (yy_buffer_stack_max) = num_to_alloc;
2254 }
2255}
2256/* %endif */
2257
2258/* %if-c-only */
2259/** Setup the input buffer state to scan directly from a user-specified character buffer.
2260 * @param base the character buffer
2261 * @param size the size in bytes of the character buffer
2262 *
2263 * @return the newly allocated buffer state object.
2264 */
2265YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
2266{
2267 YY_BUFFER_STATE b;
2268
2269 if ( size < 2 ||
2270 base[size-2] != YY_END_OF_BUFFER_CHAR ||
2271 base[size-1] != YY_END_OF_BUFFER_CHAR )
2272 /* They forgot to leave room for the EOB's. */
2273 return NULL;
2274
2275 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
2276 if ( ! b )
2277 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
2278
2279 b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
2280 b->yy_buf_pos = b->yy_ch_buf = base;
2281 b->yy_is_our_buffer = 0;
2282 b->yy_input_file = NULL;
2283 b->yy_n_chars = b->yy_buf_size;
2284 b->yy_is_interactive = 0;
2285 b->yy_at_bol = 1;
2286 b->yy_fill_buffer = 0;
2287 b->yy_buffer_status = YY_BUFFER_NEW;
2288
2289 yy_switch_to_buffer( b );
2290
2291 return b;
2292}
2293/* %endif */
2294
2295/* %if-c-only */
2296/** Setup the input buffer state to scan a string. The next call to yylex() will
2297 * scan from a @e copy of @a str.
2298 * @param yystr a NUL-terminated string to scan
2299 *
2300 * @return the newly allocated buffer state object.
2301 * @note If you want to scan bytes that may contain NUL values, then use
2302 * yy_scan_bytes() instead.
2303 */
2304YY_BUFFER_STATE yy_scan_string (const char * yystr )
2305{
2306
2307 return yy_scan_bytes( yystr, (int) strlen(yystr) );
2308}
2309/* %endif */
2310
2311/* %if-c-only */
2312/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
2313 * scan from a @e copy of @a bytes.
2314 * @param yybytes the byte buffer to scan
2315 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2316 *
2317 * @return the newly allocated buffer state object.
2318 */
2319YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
2320{
2321 YY_BUFFER_STATE b;
2322 char *buf;
2323 yy_size_t n;
2324 int i;
2325
2326 /* Get memory for full buffer, including space for trailing EOB's. */
2327 n = (yy_size_t) (_yybytes_len + 2);
2328 buf = (char *) yyalloc( n );
2329 if ( ! buf )
2330 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
2331
2332 for ( i = 0; i < _yybytes_len; ++i )
2333 buf[i] = yybytes[i];
2334
2335 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2336
2337 b = yy_scan_buffer( buf, n );
2338 if ( ! b )
2339 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
2340
2341 /* It's okay to grow etc. this buffer, and we should throw it
2342 * away when we're done.
2343 */
2344 b->yy_is_our_buffer = 1;
2345
2346 return b;
2347}
2348/* %endif */
2349
2350#ifndef YY_EXIT_FAILURE
2351#define YY_EXIT_FAILURE 2
2352#endif
2353
2354/* %if-c-only */
2355static void yynoreturn yy_fatal_error (const char* msg )
2356{
2357 fprintf( stderr, "%s\n", msg );
2358 exit( YY_EXIT_FAILURE );
2359}
2360/* %endif */
2361/* %if-c++-only */
2362/* %endif */
2363
2364/* Redefine yyless() so it works in section 3 code. */
2365
2366#undef yyless
2367#define yyless(n) \
2368 do \
2369 { \
2370 /* Undo effects of setting up yytext. */ \
2371 int yyless_macro_arg = (n); \
2372 YY_LESS_LINENO(yyless_macro_arg);\
2373 yytext[yyleng] = (yy_hold_char); \
2374 (yy_c_buf_p) = yytext + yyless_macro_arg; \
2375 (yy_hold_char) = *(yy_c_buf_p); \
2376 *(yy_c_buf_p) = '\0'; \
2377 yyleng = yyless_macro_arg; \
2378 } \
2379 while ( 0 )
2380
2381/* Accessor methods (get/set functions) to struct members. */
2382
2383/* %if-c-only */
2384/* %if-reentrant */
2385/* %endif */
2386
2387/** Get the current line number.
2388 *
2389 */
2390int yyget_lineno (void)
2391{
2392
2393 return yylineno;
2394}
2395
2396/** Get the input stream.
2397 *
2398 */
2399FILE *yyget_in (void)
2400{
2401 return yyin;
2402}
2403
2404/** Get the output stream.
2405 *
2406 */
2407FILE *yyget_out (void)
2408{
2409 return yyout;
2410}
2411
2412/** Get the length of the current token.
2413 *
2414 */
2415int yyget_leng (void)
2416{
2417 return yyleng;
2418}
2419
2420/** Get the current token.
2421 *
2422 */
2423
2424char *yyget_text (void)
2425{
2426 return yytext;
2427}
2428
2429/* %if-reentrant */
2430/* %endif */
2431
2432/** Set the current line number.
2433 * @param _line_number line number
2434 *
2435 */
2436void yyset_lineno (int _line_number )
2437{
2438
2439 yylineno = _line_number;
2440}
2441
2442/** Set the input stream. This does not discard the current
2443 * input buffer.
2444 * @param _in_str A readable stream.
2445 *
2446 * @see yy_switch_to_buffer
2447 */
2448void yyset_in (FILE * _in_str )
2449{
2450 yyin = _in_str ;
2451}
2452
2453void yyset_out (FILE * _out_str )
2454{
2455 yyout = _out_str ;
2456}
2457
2458int yyget_debug (void)
2459{
2460 return yy_flex_debug;
2461}
2462
2463void yyset_debug (int _bdebug )
2464{
2465 yy_flex_debug = _bdebug ;
2466}
2467
2468/* %endif */
2469
2470/* %if-reentrant */
2471/* %if-bison-bridge */
2472/* %endif */
2473/* %endif if-c-only */
2474
2475/* %if-c-only */
2476static int yy_init_globals (void)
2477{
2478 /* Initialization is the same as for the non-reentrant scanner.
2479 * This function is called from yylex_destroy(), so don't allocate here.
2480 */
2481
2482 (yy_buffer_stack) = NULL;
2483 (yy_buffer_stack_top) = 0;
2484 (yy_buffer_stack_max) = 0;
2485 (yy_c_buf_p) = NULL;
2486 (yy_init) = 0;
2487 (yy_start) = 0;
2488
2489/* Defined in main.c */
2490#ifdef YY_STDINIT
2491 yyin = stdin;
2492 yyout = stdout;
2493#else
2494 yyin = NULL;
2495 yyout = NULL;
2496#endif
2497
2498 /* For future reference: Set errno on error, since we are called by
2499 * yylex_init()
2500 */
2501 return 0;
2502}
2503/* %endif */
2504
2505/* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */
2506/* yylex_destroy is for both reentrant and non-reentrant scanners. */
2507int yylex_destroy (void)
2508{
2509
2510 /* Pop the buffer stack, destroying each element. */
2511 while(YY_CURRENT_BUFFER){
2512 yy_delete_buffer( YY_CURRENT_BUFFER );
2513 YY_CURRENT_BUFFER_LVALUE = NULL;
2514 yypop_buffer_state();
2515 }
2516
2517 /* Destroy the stack itself. */
2518 yyfree((yy_buffer_stack) );
2519 (yy_buffer_stack) = NULL;
2520
2521 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2522 * yylex() is called, initialization will occur. */
2523 yy_init_globals( );
2524
2525/* %if-reentrant */
2526/* %endif */
2527 return 0;
2528}
2529/* %endif */
2530
2531/*
2532 * Internal utility routines.
2533 */
2534
2535#ifndef yytext_ptr
2536static void yy_flex_strncpy (char* s1, const char * s2, int n )
2537{
2538
2539 int i;
2540 for ( i = 0; i < n; ++i )
2541 s1[i] = s2[i];
2542}
2543#endif
2544
2545#ifdef YY_NEED_STRLEN
2546static int yy_flex_strlen (const char * s )
2547{
2548 int n;
2549 for ( n = 0; s[n]; ++n )
2550 ;
2551
2552 return n;
2553}
2554#endif
2555
2556void *yyalloc (yy_size_t size )
2557{
2558 return malloc(size);
2559}
2560
2561void *yyrealloc (void * ptr, yy_size_t size )
2562{
2563
2564 /* The cast to (char *) in the following accommodates both
2565 * implementations that use char* generic pointers, and those
2566 * that use void* generic pointers. It works with the latter
2567 * because both ANSI C and C++ allow castless assignment from
2568 * any pointer type to void*, and deal with argument conversions
2569 * as though doing an assignment.
2570 */
2571 return realloc(ptr, size);
2572}
2573
2574void yyfree (void * ptr )
2575{
2576 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
2577}
2578
2579/* %if-tables-serialization definitions */
2580/* %define-yytables The name for this specific scanner's tables. */
2581#define YYTABLES_NAME "yytables"
2582/* %endif */
2583
2584/* %ok-for-header */
2585
2586#line 208 "/Users/akim/src/gnu/bison/src/scan-code.l"
2587
2588
2589static inline bool
2590is_dot_or_dash (char ch)
2591{
2592 return ch == '.' || ch == '-';
2593}
2594
2595static inline bool
2596contains_dot_or_dash (const char* p)
2597{
2598 return strpbrk(p, ".-");
2599}
2600
2601/* Defines a variant of a symbolic name resolution. */
2602typedef struct
2603{
2604 /* Index in symbol list. */
2605 unsigned symbol_index;
2606
2607 /* Matched symbol id and loc. */
2608 uniqstr id;
2609 location loc;
2610
2611 /* Hiding named reference. */
2612 named_ref* hidden_by;
2613
2614 /* Error flags. May contain zero (no errors) or
2615 a combination of VARIANT_* values. */
2616 unsigned err;
2617} variant;
2618
2619/* Set when the variant refers to a symbol hidden
2620 by an explicit symbol reference. */
2621#define VARIANT_HIDDEN (1 << 0)
2622
2623/* Set when the variant refers to a symbol containing
2624 dots or dashes. Will require explicit bracketing. */
2625#define VARIANT_BAD_BRACKETING (1 << 1)
2626
2627/* Set when the variant refers to a symbol which is
2628 not visible from current midrule. */
2629#define VARIANT_NOT_VISIBLE_FROM_MIDRULE (1 << 2)
2630
2631static variant *variant_table = NULL;
2632static unsigned variant_table_size = 0;
2633static unsigned variant_count = 0;
2634
2635static variant *
2636variant_table_grow (void)
2637{
2638 ++variant_count;
2639 if (variant_count > variant_table_size)
2640 {
2641 while (variant_count > variant_table_size)
2642 variant_table_size = 2 * variant_table_size + 3;
2643 variant_table = xnrealloc (variant_table, variant_table_size,
2644 sizeof *variant_table);
2645 }
2646 return &variant_table[variant_count - 1];
2647}
2648
2649static void
2650variant_table_free (void)
2651{
2652 free (variant_table);
2653 variant_table = NULL;
2654 variant_table_size = variant_count = 0;
2655}
2656
2657static char const *
2658find_prefix_end (char const *prefix, char const *cp, char const *end)
2659{
2660 for (; *prefix && cp != end; ++prefix, ++cp)
2661 if (*prefix != *cp)
2662 return NULL;
2663
2664 return *prefix ? NULL : cp;
2665}
2666
2667static variant *
2668variant_add (uniqstr id, location id_loc, unsigned symbol_index,
2669 char const *cp, char const *cp_end, bool explicit_bracketing)
2670{
2671 char const *prefix_end = find_prefix_end (id, cp, cp_end);
2672 if (prefix_end &&
2673 (prefix_end == cp_end ||
2674 (!explicit_bracketing && is_dot_or_dash (*prefix_end))))
2675 {
2676 variant *r = variant_table_grow ();
2677 r->symbol_index = symbol_index;
2678 r->id = id;
2679 r->loc = id_loc;
2680 r->hidden_by = NULL;
2681 r->err = 0;
2682 return r;
2683 }
2684 else
2685 return NULL;
2686}
2687
2688static const char *
2689get_at_spec(unsigned symbol_index)
2690{
2691 static char at_buf[20];
2692 if (symbol_index == 0)
2693 strcpy (at_buf, "$$");
2694 else
2695 snprintf (at_buf, sizeof at_buf, "$%u", symbol_index);
2696 return at_buf;
2697}
2698
2699static void
2700show_sub_message (warnings warning,
2701 const char* cp, bool explicit_bracketing,
2702 int midrule_rhs_index, char dollar_or_at,
2703 unsigned indent, const variant *var)
2704{
2705 const char *at_spec = get_at_spec (var->symbol_index);
2706
2707 if (var->err == 0)
2708 complain_indent (&var->loc, warning, &indent,
2709 _("refers to: %c%s at %s"), dollar_or_at,
2710 var->id, at_spec);
2711 else
2712 {
2713 const char *id;
2714 location id_loc;
2715
2716 if (var->hidden_by)
2717 {
2718 id = var->hidden_by->id;
2719 id_loc = var->hidden_by->loc;
2720 }
2721 else
2722 {
2723 id = var->id;
2724 id_loc = var->loc;
2725 }
2726
2727 const char *tail = explicit_bracketing ? "" : cp + strlen (var->id);
2728
2729 /* Create the explanation message. */
2730 static struct obstack msg_buf;
2731 obstack_init (&msg_buf);
2732
2733 obstack_printf (&msg_buf, _("possibly meant: %c"), dollar_or_at);
2734 if (contains_dot_or_dash (id))
2735 obstack_printf (&msg_buf, "[%s]", id);
2736 else
2737 obstack_sgrow (&msg_buf, id);
2738 obstack_sgrow (&msg_buf, tail);
2739
2740 if (var->err & VARIANT_HIDDEN)
2741 {
2742 obstack_printf (&msg_buf, _(", hiding %c"), dollar_or_at);
2743 if (contains_dot_or_dash (var->id))
2744 obstack_printf (&msg_buf, "[%s]", var->id);
2745 else
2746 obstack_sgrow (&msg_buf, var->id);
2747 obstack_sgrow (&msg_buf, tail);
2748 }
2749
2750 obstack_printf (&msg_buf, _(" at %s"), at_spec);
2751
2752 if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
2753 obstack_printf (&msg_buf,
2754 _(", cannot be accessed from midrule action at $%d"),
2755 midrule_rhs_index);
2756
2757 complain_indent (&id_loc, warning, &indent, "%s",
2758 obstack_finish0 (&msg_buf));
2759 obstack_free (&msg_buf, 0);
2760 }
2761}
2762
2763static void
2764show_sub_messages (warnings warning,
2765 const char* cp, bool explicit_bracketing,
2766 int midrule_rhs_index, char dollar_or_at,
2767 unsigned indent)
2768{
2769 for (unsigned i = 0; i < variant_count; ++i)
2770 show_sub_message (warning | silent,
2771 cp, explicit_bracketing,
2772 midrule_rhs_index, dollar_or_at,
2773 indent, &variant_table[i]);
2774}
2775
2776/* Returned from "parse_ref" when the reference
2777 is inappropriate. */
2778#define INVALID_REF (INT_MIN)
2779
2780/* Returned from "parse_ref" when the reference
2781 points to LHS ($$) of the current rule or midrule. */
2782#define LHS_REF (INT_MIN + 1)
2783
2784/* Parse named or positional reference. In case of positional
2785 references, can return negative values for $-n "deep" stack
2786 accesses. */
2787static long
2788parse_ref (char *cp, symbol_list *rule, int rule_length,
2789 int midrule_rhs_index, char *text, location text_loc,
2790 char dollar_or_at)
2791{
2792 if ('$' == *cp)
2793 return LHS_REF;
2794
2795 if (c_isdigit (*cp) || (*cp == '-' && c_isdigit (* (cp + 1))))
2796 {
2797 long num = strtol (cp, &cp, 10);
2798 if (1 - INT_MAX + rule_length <= num && num <= rule_length)
2799 return num;
2800 else
2801 {
2802 complain (&text_loc, complaint, _("integer out of range: %s"),
2803 quote (text));
2804 return INVALID_REF;
2805 }
2806 }
2807
2808 bool const explicit_bracketing = *cp == '[';
2809
2810 if (explicit_bracketing)
2811 ++cp;
2812 else
2813 ref_tail_fields = strpbrk (cp, ".-");
2814
2815 char const *cp_end = strchr (cp, explicit_bracketing ? ']' : '\0');
2816
2817 /* Add all relevant variants. */
2818 {
2819 unsigned symbol_index;
2820 symbol_list *l;
2821 variant_count = 0;
2822 for (symbol_index = 0, l = rule; !symbol_list_null (l);
2823 ++symbol_index, l = l->next)
2824 {
2825 if (l->content_type != SYMLIST_SYMBOL)
2826 continue;
2827
2828 variant *var
2829 = variant_add (l->content.sym->tag, l->sym_loc,
2830 symbol_index, cp, cp_end, explicit_bracketing);
2831 if (var && l->named_ref)
2832 var->hidden_by = l->named_ref;
2833
2834 if (l->named_ref)
2835 variant_add (l->named_ref->id, l->named_ref->loc,
2836 symbol_index, cp, cp_end, explicit_bracketing);
2837 }
2838 }
2839
2840 /* Check errors. */
2841 unsigned valid_variants = 0;
2842 unsigned valid_variant_index = 0;
2843 for (unsigned i = 0; i < variant_count; ++i)
2844 {
2845 variant *var = &variant_table[i];
2846 unsigned symbol_index = var->symbol_index;
2847
2848 /* Check visibility from midrule actions. */
2849 if (midrule_rhs_index != 0
2850 && (symbol_index == 0 || midrule_rhs_index < symbol_index))
2851 var->err |= VARIANT_NOT_VISIBLE_FROM_MIDRULE;
2852
2853 /* Check correct bracketing. */
2854 if (!explicit_bracketing && contains_dot_or_dash (var->id))
2855 var->err |= VARIANT_BAD_BRACKETING;
2856
2857 /* Check using of hidden symbols. */
2858 if (var->hidden_by)
2859 var->err |= VARIANT_HIDDEN;
2860
2861 if (!var->err)
2862 {
2863 valid_variant_index = i;
2864 ++valid_variants;
2865 }
2866 }
2867
2868 switch (valid_variants)
2869 {
2870 case 0:
2871 {
2872 unsigned len = (explicit_bracketing || !ref_tail_fields) ?
2873 cp_end - cp : ref_tail_fields - cp;
2874 unsigned indent = 0;
2875
2876 complain_indent (&text_loc, complaint, &indent,
2877 _("invalid reference: %s"), quote (text));
2878 indent += SUB_INDENT;
2879 if (len == 0)
2880 {
2881 location sym_loc = text_loc;
2882 sym_loc.start.column += 1;
2883 sym_loc.end = sym_loc.start;
2884 complain_indent (&sym_loc, complaint, &indent,
2885 _("syntax error after '%c', expecting integer, "
2886 "letter, '_', '[', or '$'"),
2887 dollar_or_at);
2888 }
2889 else if (midrule_rhs_index)
2890 complain_indent (&rule->rhs_loc, complaint, &indent,
2891 _("symbol not found in production before $%d: "
2892 "%.*s"),
2893 midrule_rhs_index, len, cp);
2894 else
2895 complain_indent (&rule->rhs_loc, complaint, &indent,
2896 _("symbol not found in production: %.*s"),
2897 len, cp);
2898
2899 if (variant_count > 0)
2900 show_sub_messages (complaint,
2901 cp, explicit_bracketing, midrule_rhs_index,
2902 dollar_or_at, indent);
2903 return INVALID_REF;
2904 }
2905 case 1:
2906 {
2907 unsigned indent = 0;
2908 if (variant_count > 1)
2909 {
2910 complain_indent (&text_loc, Wother, &indent,
2911 _("misleading reference: %s"), quote (text));
2912 show_sub_messages (Wother,
2913 cp, explicit_bracketing, midrule_rhs_index,
2914 dollar_or_at, indent + SUB_INDENT);
2915 }
2916 {
2917 unsigned symbol_index =
2918 variant_table[valid_variant_index].symbol_index;
2919 return (symbol_index == midrule_rhs_index) ? LHS_REF : symbol_index;
2920 }
2921 }
2922 case 2:
2923 default:
2924 {
2925 unsigned indent = 0;
2926 complain_indent (&text_loc, complaint, &indent,
2927 _("ambiguous reference: %s"), quote (text));
2928 show_sub_messages (complaint,
2929 cp, explicit_bracketing, midrule_rhs_index,
2930 dollar_or_at, indent + SUB_INDENT);
2931 return INVALID_REF;
2932 }
2933 }
2934}
2935
2936/* Keeps track of the maximum number of semantic values to the left of
2937 a handle (those referenced by $0, $-1, etc.) are required by the
2938 semantic actions of this grammar. */
2939int max_left_semantic_context = 0;
2940
2941
2942/* If CP points to a typename (i.e., <.*?>), set TYPE_NAME to its
2943 beginning (i.e., after the opening "<", and return the pointer
2944 immediately after it. */
2945
2946static
2947char *
2948fetch_type_name (char *cp, char const **type_name,
2949 location dollar_loc)
2950{
2951 if (*cp == '<')
2952 {
2953 *type_name = ++cp;
2954 /* Series of non-'>' or "->". */
2955 while (*cp != '>' || cp[-1] == '-')
2956 ++cp;
2957
2958 /* The '>' symbol will be later replaced by '\0'. Original
2959 'text' is needed for error messages. */
2960 ++cp;
2961 if (untyped_var_seen)
2962 complain (&dollar_loc, complaint,
2963 _("explicit type given in untyped grammar"));
2964 tag_seen = true;
2965 }
2966 return cp;
2967}
2968
2969/*------------------------------------------------------------------.
2970| TEXT is pointing to a wannabee semantic value (i.e., a '$'). |
2971| |
2972| Possible inputs: $[<TYPENAME>]($|integer) |
2973| |
2974| Output to OBSTACK_FOR_STRING a reference to this semantic value. |
2975`------------------------------------------------------------------*/
2976
2977static void
2978handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
2979{
2980 symbol_list *effective_rule;
2981 int effective_rule_length;
2982
2983 if (rule->midrule_parent_rule)
2984 {
2985 effective_rule = rule->midrule_parent_rule;
2986 effective_rule_length = rule->midrule_parent_rhs_index - 1;
2987 }
2988 else
2989 {
2990 effective_rule = rule;
2991 effective_rule_length = symbol_list_length (rule->next);
2992 }
2993
2994 /* The type name if explicit, otherwise left null. */
2995 char const *type_name = NULL;
2996 char *cp = fetch_type_name (text + 1, &type_name, dollar_loc);
2997 int n = parse_ref (cp, effective_rule, effective_rule_length,
2998 rule->midrule_parent_rhs_index, text, dollar_loc, '$');
2999 /* End type_name. Don't do it ealier: parse_ref depends on TEXT. */
3000 if (type_name)
3001 cp[-1] = '\0';
3002
3003 switch (n)
3004 {
3005 case INVALID_REF:
3006 break;
3007
3008 case LHS_REF:
3009 {
3010 symbol_list *sym = symbol_list_n_get (rule, 0);
3011 if (!type_name
3012 && !sym->content.sym->content->type_name)
3013 {
3014 if (union_seen || tag_seen)
3015 {
3016 if (rule->midrule_parent_rule)
3017 complain (&dollar_loc, complaint,
3018 _("$$ for the midrule at $%d of %s"
3019 " has no declared type"),
3020 rule->midrule_parent_rhs_index,
3021 quote (effective_rule->content.sym->tag));
3022 else
3023 complain (&dollar_loc, complaint,
3024 _("$$ of %s has no declared type"),
3025 quote (rule->content.sym->tag));
3026 }
3027 else
3028 untyped_var_seen = true;
3029 }
3030
3031 obstack_printf (&obstack_for_string, "]b4_lhs_value(orig %d, ",
3032 sym->content.sym->content->number);
3033 obstack_quote (&obstack_for_string, type_name);
3034 obstack_sgrow (&obstack_for_string, ")[");
3035 rule->action_props.is_value_used = true;
3036 }
3037 break;
3038
3039 /* Reference to a RHS symbol. */
3040 default:
3041 {
3042 if (max_left_semantic_context < 1 - n)
3043 max_left_semantic_context = 1 - n;
3044 symbol_list *sym = 0 < n ? symbol_list_n_get (effective_rule, n) : NULL;
3045 if (!type_name
3046 && (!sym || !sym->content.sym->content->type_name))
3047 {
3048 if (union_seen || tag_seen)
3049 complain (&dollar_loc, complaint,
3050 _("$%s of %s has no declared type"), cp,
3051 quote (effective_rule->content.sym->tag));
3052 else
3053 untyped_var_seen = true;
3054 }
3055
3056 obstack_printf (&obstack_for_string,
3057 "]b4_rhs_value(%d, %d, ",
3058 effective_rule_length, n);
3059 if (sym)
3060 obstack_printf (&obstack_for_string, "%s%d, ",
3061 sym->content.sym->content->class == nterm_sym ? "orig " : "",
3062 sym->content.sym->content->number);
3063 else
3064 obstack_sgrow (&obstack_for_string, "[], ");
3065
3066 obstack_quote (&obstack_for_string, type_name);
3067 obstack_sgrow (&obstack_for_string, ")[");
3068 if (0 < n)
3069 {
3070 if (muscle_percent_define_ifdef ("api.value.automove")
3071 && sym->action_props.is_value_used)
3072 complain (&dollar_loc, Wother,
3073 _("multiple occurrences of $%d with api.value.automove"),
3074 n);
3075 sym->action_props.is_value_used = true;
3076 }
3077 }
3078 break;
3079 }
3080}
3081
3082
3083/*------------------------------------------------------.
3084| TEXT is a location token (i.e., a '@...'). Output to |
3085| OBSTACK_FOR_STRING a reference to this location. |
3086`------------------------------------------------------*/
3087
3088static void
3089handle_action_at (symbol_list *rule, char *text, location at_loc)
3090{
3091 symbol_list *effective_rule;
3092 int effective_rule_length;
3093
3094 if (rule->midrule_parent_rule)
3095 {
3096 effective_rule = rule->midrule_parent_rule;
3097 effective_rule_length = rule->midrule_parent_rhs_index - 1;
3098 }
3099 else
3100 {
3101 effective_rule = rule;
3102 effective_rule_length = symbol_list_length (rule->next);
3103 }
3104
3105 muscle_percent_define_ensure("locations", at_loc, true);
3106
3107 int n = parse_ref (text + 1, effective_rule, effective_rule_length,
3108 rule->midrule_parent_rhs_index, text, at_loc, '@');
3109 switch (n)
3110 {
3111 case INVALID_REF:
3112 break;
3113
3114 case LHS_REF:
3115 obstack_sgrow (&obstack_for_string, "]b4_lhs_location[");
3116 break;
3117
3118 default:
3119 obstack_printf (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
3120 effective_rule_length, n);
3121 break;
3122 }
3123}
3124
3125
3126/*-------------------------.
3127| Initialize the scanner. |
3128`-------------------------*/
3129
3130/* Translate the '$...' and '@...' in \a self, in the context \a
3131 sc_context (SC_RULE_ACTION, SC_SYMBOL_ACTION, INITIAL). */
3132
3133static char const *
3134translate_action (code_props *self, int sc_context)
3135{
3136 static bool initialized = false;
3137 if (!initialized)
3138 {
3139 obstack_init (&obstack_for_string);
3140 yy_flex_debug = 0;
3141 initialized = true;
3142 }
3143
3144 loc->start = loc->end = self->location.start;
3145 yy_switch_to_buffer (yy_scan_string (self->code));
3146 char *res = code_lex (self, sc_context);
3147 yy_delete_buffer (YY_CURRENT_BUFFER);
3148
3149 return res;
3150}
3151
3152/*------------------------------------------------------------------------.
3153| Implementation of the public interface as documented in "scan-code.h". |
3154`------------------------------------------------------------------------*/
3155
3156void
3157code_props_none_init (code_props *self)
3158{
3159 *self = code_props_none;
3160}
3161
3162code_props code_props_none = CODE_PROPS_NONE_INIT;
3163
3164void
3165code_props_plain_init (code_props *self, char const *code,
3166 location code_loc)
3167{
3168 code_props_none_init (self);
3169 self->kind = CODE_PROPS_PLAIN;
3170 self->code = code;
3171 self->location = code_loc;
3172}
3173
3174void
3175code_props_symbol_action_init (code_props *self, char const *code,
3176 location code_loc)
3177{
3178 code_props_none_init (self);
3179 self->kind = CODE_PROPS_SYMBOL_ACTION;
3180 self->code = code;
3181 self->location = code_loc;
3182}
3183
3184void
3185code_props_rule_action_init (code_props *self, char const *code,
3186 location code_loc, symbol_list *rule,
3187 named_ref *name, uniqstr type,
3188 bool is_predicate)
3189{
3190 code_props_none_init (self);
3191 self->kind = CODE_PROPS_RULE_ACTION;
3192 self->code = code;
3193 self->location = code_loc;
3194 self->rule = rule;
3195 self->named_ref = name;
3196 self->type = type;
3197 self->is_predicate = is_predicate;
3198}
3199
3200void
3201code_props_translate_code (code_props *self)
3202{
3203 switch (self->kind)
3204 {
3205 case CODE_PROPS_NONE:
3206 break;
3207 case CODE_PROPS_PLAIN:
3208 self->code = translate_action (self, INITIAL);
3209 break;
3210 case CODE_PROPS_SYMBOL_ACTION:
3211 self->code = translate_action (self, SC_SYMBOL_ACTION);
3212 break;
3213 case CODE_PROPS_RULE_ACTION:
3214 self->code = translate_action (self, SC_RULE_ACTION);
3215 break;
3216 }
3217}
3218
3219void
3220code_scanner_last_string_free (void)
3221{
3222 STRING_FREE;
3223}
3224
3225void
3226code_scanner_free (void)
3227{
3228 obstack_free (&obstack_for_string, 0);
3229 variant_table_free ();
3230
3231 /* Reclaim Flex's buffers. */
3232 yylex_destroy ();
3233}
3234
3235