1 #line 2 "psqlscanslash.c"
2 /*-------------------------------------------------------------------------
3  *
4  * psqlscanslash.l
5  *	  lexical scanner for psql backslash commands
6  *
7  * XXX Avoid creating backtracking cases --- see the backend lexer for info.
8  *
9  * See fe_utils/psqlscan_int.h for additional commentary.
10  *
11  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
12  * Portions Copyright (c) 1994, Regents of the University of California
13  *
14  * IDENTIFICATION
15  *	  src/bin/psql/psqlscanslash.l
16  *
17  *-------------------------------------------------------------------------
18  */
19 #include "postgres_fe.h"
20 
21 #include "psqlscanslash.h"
22 #include "common/logging.h"
23 #include "fe_utils/conditional.h"
24 
25 #include "libpq-fe.h"
26 
27 #line 28 "psqlscanslash.c"
28 
29 #define  YY_INT_ALIGNED short int
30 
31 /* A lexical scanner generated by flex */
32 
33 #define FLEX_SCANNER
34 #define YY_FLEX_MAJOR_VERSION 2
35 #define YY_FLEX_MINOR_VERSION 6
36 #define YY_FLEX_SUBMINOR_VERSION 4
37 #if YY_FLEX_SUBMINOR_VERSION > 0
38 #define FLEX_BETA
39 #endif
40 
41 #ifdef yy_create_buffer
42 #define slash_yy_create_buffer_ALREADY_DEFINED
43 #else
44 #define yy_create_buffer slash_yy_create_buffer
45 #endif
46 
47 #ifdef yy_delete_buffer
48 #define slash_yy_delete_buffer_ALREADY_DEFINED
49 #else
50 #define yy_delete_buffer slash_yy_delete_buffer
51 #endif
52 
53 #ifdef yy_scan_buffer
54 #define slash_yy_scan_buffer_ALREADY_DEFINED
55 #else
56 #define yy_scan_buffer slash_yy_scan_buffer
57 #endif
58 
59 #ifdef yy_scan_string
60 #define slash_yy_scan_string_ALREADY_DEFINED
61 #else
62 #define yy_scan_string slash_yy_scan_string
63 #endif
64 
65 #ifdef yy_scan_bytes
66 #define slash_yy_scan_bytes_ALREADY_DEFINED
67 #else
68 #define yy_scan_bytes slash_yy_scan_bytes
69 #endif
70 
71 #ifdef yy_init_buffer
72 #define slash_yy_init_buffer_ALREADY_DEFINED
73 #else
74 #define yy_init_buffer slash_yy_init_buffer
75 #endif
76 
77 #ifdef yy_flush_buffer
78 #define slash_yy_flush_buffer_ALREADY_DEFINED
79 #else
80 #define yy_flush_buffer slash_yy_flush_buffer
81 #endif
82 
83 #ifdef yy_load_buffer_state
84 #define slash_yy_load_buffer_state_ALREADY_DEFINED
85 #else
86 #define yy_load_buffer_state slash_yy_load_buffer_state
87 #endif
88 
89 #ifdef yy_switch_to_buffer
90 #define slash_yy_switch_to_buffer_ALREADY_DEFINED
91 #else
92 #define yy_switch_to_buffer slash_yy_switch_to_buffer
93 #endif
94 
95 #ifdef yypush_buffer_state
96 #define slash_yypush_buffer_state_ALREADY_DEFINED
97 #else
98 #define yypush_buffer_state slash_yypush_buffer_state
99 #endif
100 
101 #ifdef yypop_buffer_state
102 #define slash_yypop_buffer_state_ALREADY_DEFINED
103 #else
104 #define yypop_buffer_state slash_yypop_buffer_state
105 #endif
106 
107 #ifdef yyensure_buffer_stack
108 #define slash_yyensure_buffer_stack_ALREADY_DEFINED
109 #else
110 #define yyensure_buffer_stack slash_yyensure_buffer_stack
111 #endif
112 
113 #ifdef yylex
114 #define slash_yylex_ALREADY_DEFINED
115 #else
116 #define yylex slash_yylex
117 #endif
118 
119 #ifdef yyrestart
120 #define slash_yyrestart_ALREADY_DEFINED
121 #else
122 #define yyrestart slash_yyrestart
123 #endif
124 
125 #ifdef yylex_init
126 #define slash_yylex_init_ALREADY_DEFINED
127 #else
128 #define yylex_init slash_yylex_init
129 #endif
130 
131 #ifdef yylex_init_extra
132 #define slash_yylex_init_extra_ALREADY_DEFINED
133 #else
134 #define yylex_init_extra slash_yylex_init_extra
135 #endif
136 
137 #ifdef yylex_destroy
138 #define slash_yylex_destroy_ALREADY_DEFINED
139 #else
140 #define yylex_destroy slash_yylex_destroy
141 #endif
142 
143 #ifdef yyget_debug
144 #define slash_yyget_debug_ALREADY_DEFINED
145 #else
146 #define yyget_debug slash_yyget_debug
147 #endif
148 
149 #ifdef yyset_debug
150 #define slash_yyset_debug_ALREADY_DEFINED
151 #else
152 #define yyset_debug slash_yyset_debug
153 #endif
154 
155 #ifdef yyget_extra
156 #define slash_yyget_extra_ALREADY_DEFINED
157 #else
158 #define yyget_extra slash_yyget_extra
159 #endif
160 
161 #ifdef yyset_extra
162 #define slash_yyset_extra_ALREADY_DEFINED
163 #else
164 #define yyset_extra slash_yyset_extra
165 #endif
166 
167 #ifdef yyget_in
168 #define slash_yyget_in_ALREADY_DEFINED
169 #else
170 #define yyget_in slash_yyget_in
171 #endif
172 
173 #ifdef yyset_in
174 #define slash_yyset_in_ALREADY_DEFINED
175 #else
176 #define yyset_in slash_yyset_in
177 #endif
178 
179 #ifdef yyget_out
180 #define slash_yyget_out_ALREADY_DEFINED
181 #else
182 #define yyget_out slash_yyget_out
183 #endif
184 
185 #ifdef yyset_out
186 #define slash_yyset_out_ALREADY_DEFINED
187 #else
188 #define yyset_out slash_yyset_out
189 #endif
190 
191 #ifdef yyget_leng
192 #define slash_yyget_leng_ALREADY_DEFINED
193 #else
194 #define yyget_leng slash_yyget_leng
195 #endif
196 
197 #ifdef yyget_text
198 #define slash_yyget_text_ALREADY_DEFINED
199 #else
200 #define yyget_text slash_yyget_text
201 #endif
202 
203 #ifdef yyget_lineno
204 #define slash_yyget_lineno_ALREADY_DEFINED
205 #else
206 #define yyget_lineno slash_yyget_lineno
207 #endif
208 
209 #ifdef yyset_lineno
210 #define slash_yyset_lineno_ALREADY_DEFINED
211 #else
212 #define yyset_lineno slash_yyset_lineno
213 #endif
214 
215 #ifdef yyget_column
216 #define slash_yyget_column_ALREADY_DEFINED
217 #else
218 #define yyget_column slash_yyget_column
219 #endif
220 
221 #ifdef yyset_column
222 #define slash_yyset_column_ALREADY_DEFINED
223 #else
224 #define yyset_column slash_yyset_column
225 #endif
226 
227 #ifdef yywrap
228 #define slash_yywrap_ALREADY_DEFINED
229 #else
230 #define yywrap slash_yywrap
231 #endif
232 
233 #ifdef yyget_lval
234 #define slash_yyget_lval_ALREADY_DEFINED
235 #else
236 #define yyget_lval slash_yyget_lval
237 #endif
238 
239 #ifdef yyset_lval
240 #define slash_yyset_lval_ALREADY_DEFINED
241 #else
242 #define yyset_lval slash_yyset_lval
243 #endif
244 
245 #ifdef yyalloc
246 #define slash_yyalloc_ALREADY_DEFINED
247 #else
248 #define yyalloc slash_yyalloc
249 #endif
250 
251 #ifdef yyrealloc
252 #define slash_yyrealloc_ALREADY_DEFINED
253 #else
254 #define yyrealloc slash_yyrealloc
255 #endif
256 
257 #ifdef yyfree
258 #define slash_yyfree_ALREADY_DEFINED
259 #else
260 #define yyfree slash_yyfree
261 #endif
262 
263 /* First, we deal with  platform-specific or compiler-specific issues. */
264 
265 /* begin standard C headers. */
266 #include <stdio.h>
267 #include <string.h>
268 #include <errno.h>
269 #include <stdlib.h>
270 
271 /* end standard C headers. */
272 
273 /* flex integer type definitions */
274 
275 #ifndef FLEXINT_H
276 #define FLEXINT_H
277 
278 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
279 
280 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
281 
282 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
283  * if you want the limit (max/min) macros for int types.
284  */
285 #ifndef __STDC_LIMIT_MACROS
286 #define __STDC_LIMIT_MACROS 1
287 #endif
288 
289 #include <inttypes.h>
290 typedef int8_t flex_int8_t;
291 typedef uint8_t flex_uint8_t;
292 typedef int16_t flex_int16_t;
293 typedef uint16_t flex_uint16_t;
294 typedef int32_t flex_int32_t;
295 typedef uint32_t flex_uint32_t;
296 #else
297 typedef signed char flex_int8_t;
298 typedef short int flex_int16_t;
299 typedef int flex_int32_t;
300 typedef unsigned char flex_uint8_t;
301 typedef unsigned short int flex_uint16_t;
302 typedef unsigned int flex_uint32_t;
303 
304 /* Limits of integral types. */
305 #ifndef INT8_MIN
306 #define INT8_MIN               (-128)
307 #endif
308 #ifndef INT16_MIN
309 #define INT16_MIN              (-32767-1)
310 #endif
311 #ifndef INT32_MIN
312 #define INT32_MIN              (-2147483647-1)
313 #endif
314 #ifndef INT8_MAX
315 #define INT8_MAX               (127)
316 #endif
317 #ifndef INT16_MAX
318 #define INT16_MAX              (32767)
319 #endif
320 #ifndef INT32_MAX
321 #define INT32_MAX              (2147483647)
322 #endif
323 #ifndef UINT8_MAX
324 #define UINT8_MAX              (255U)
325 #endif
326 #ifndef UINT16_MAX
327 #define UINT16_MAX             (65535U)
328 #endif
329 #ifndef UINT32_MAX
330 #define UINT32_MAX             (4294967295U)
331 #endif
332 
333 #ifndef SIZE_MAX
334 #define SIZE_MAX               (~(size_t)0)
335 #endif
336 
337 #endif /* ! C99 */
338 
339 #endif /* ! FLEXINT_H */
340 
341 /* begin standard C++ headers. */
342 
343 /* TODO: this is always defined, so inline it */
344 #define yyconst const
345 
346 #if defined(__GNUC__) && __GNUC__ >= 3
347 #define yynoreturn __attribute__((__noreturn__))
348 #else
349 #define yynoreturn
350 #endif
351 
352 /* Returned upon end-of-file. */
353 #define YY_NULL 0
354 
355 /* Promotes a possibly negative, possibly signed char to an
356  *   integer in range [0..255] for use as an array index.
357  */
358 #define YY_SC_TO_UI(c) ((YY_CHAR) (c))
359 
360 /* An opaque pointer. */
361 #ifndef YY_TYPEDEF_YY_SCANNER_T
362 #define YY_TYPEDEF_YY_SCANNER_T
363 typedef void* yyscan_t;
364 #endif
365 
366 /* For convenience, these vars (plus the bison vars far below)
367    are macros in the reentrant scanner. */
368 #define yyin yyg->yyin_r
369 #define yyout yyg->yyout_r
370 #define yyextra yyg->yyextra_r
371 #define yyleng yyg->yyleng_r
372 #define yytext yyg->yytext_r
373 #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
374 #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
375 #define yy_flex_debug yyg->yy_flex_debug_r
376 
377 /* Enter a start condition.  This macro really ought to take a parameter,
378  * but we do it the disgusting crufty way forced on us by the ()-less
379  * definition of BEGIN.
380  */
381 #define BEGIN yyg->yy_start = 1 + 2 *
382 /* Translate the current start state into a value that can be later handed
383  * to BEGIN to return to the state.  The YYSTATE alias is for lex
384  * compatibility.
385  */
386 #define YY_START ((yyg->yy_start - 1) / 2)
387 #define YYSTATE YY_START
388 /* Action number for EOF rule of a given start state. */
389 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
390 /* Special action meaning "start processing a new file". */
391 #define YY_NEW_FILE yyrestart( yyin , yyscanner )
392 #define YY_END_OF_BUFFER_CHAR 0
393 
394 /* Size of default input buffer. */
395 #ifndef YY_BUF_SIZE
396 #ifdef __ia64__
397 /* On IA-64, the buffer size is 16k, not 8k.
398  * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
399  * Ditto for the __ia64__ case accordingly.
400  */
401 #define YY_BUF_SIZE 32768
402 #else
403 #define YY_BUF_SIZE 16384
404 #endif /* __ia64__ */
405 #endif
406 
407 /* The state buf must be large enough to hold one state per character in the main buffer.
408  */
409 #define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
410 
411 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
412 #define YY_TYPEDEF_YY_BUFFER_STATE
413 typedef struct yy_buffer_state *YY_BUFFER_STATE;
414 #endif
415 
416 #ifndef YY_TYPEDEF_YY_SIZE_T
417 #define YY_TYPEDEF_YY_SIZE_T
418 typedef size_t yy_size_t;
419 #endif
420 
421 #define EOB_ACT_CONTINUE_SCAN 0
422 #define EOB_ACT_END_OF_FILE 1
423 #define EOB_ACT_LAST_MATCH 2
424 
425     #define YY_LESS_LINENO(n)
426     #define YY_LINENO_REWIND_TO(ptr)
427 
428 /* Return all but the first "n" matched characters back to the input stream. */
429 #define yyless(n) \
430 	do \
431 		{ \
432 		/* Undo effects of setting up yytext. */ \
433         int yyless_macro_arg = (n); \
434         YY_LESS_LINENO(yyless_macro_arg);\
435 		*yy_cp = yyg->yy_hold_char; \
436 		YY_RESTORE_YY_MORE_OFFSET \
437 		yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
438 		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
439 		} \
440 	while ( 0 )
441 #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
442 
443 #ifndef YY_STRUCT_YY_BUFFER_STATE
444 #define YY_STRUCT_YY_BUFFER_STATE
445 struct yy_buffer_state
446 	{
447 	FILE *yy_input_file;
448 
449 	char *yy_ch_buf;		/* input buffer */
450 	char *yy_buf_pos;		/* current position in input buffer */
451 
452 	/* Size of input buffer in bytes, not including room for EOB
453 	 * characters.
454 	 */
455 	int yy_buf_size;
456 
457 	/* Number of characters read into yy_ch_buf, not including EOB
458 	 * characters.
459 	 */
460 	int yy_n_chars;
461 
462 	/* Whether we "own" the buffer - i.e., we know we created it,
463 	 * and can realloc() it to grow it, and should free() it to
464 	 * delete it.
465 	 */
466 	int yy_is_our_buffer;
467 
468 	/* Whether this is an "interactive" input source; if so, and
469 	 * if we're using stdio for input, then we want to use getc()
470 	 * instead of fread(), to make sure we stop fetching input after
471 	 * each newline.
472 	 */
473 	int yy_is_interactive;
474 
475 	/* Whether we're considered to be at the beginning of a line.
476 	 * If so, '^' rules will be active on the next match, otherwise
477 	 * not.
478 	 */
479 	int yy_at_bol;
480 
481     int yy_bs_lineno; /**< The line count. */
482     int yy_bs_column; /**< The column count. */
483 
484 	/* Whether to try to fill the input buffer when we reach the
485 	 * end of it.
486 	 */
487 	int yy_fill_buffer;
488 
489 	int yy_buffer_status;
490 
491 #define YY_BUFFER_NEW 0
492 #define YY_BUFFER_NORMAL 1
493 	/* When an EOF's been seen but there's still some text to process
494 	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
495 	 * shouldn't try reading from the input source any more.  We might
496 	 * still have a bunch of tokens to match, though, because of
497 	 * possible backing-up.
498 	 *
499 	 * When we actually see the EOF, we change the status to "new"
500 	 * (via yyrestart()), so that the user can continue scanning by
501 	 * just pointing yyin at a new input file.
502 	 */
503 #define YY_BUFFER_EOF_PENDING 2
504 
505 	};
506 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
507 
508 /* We provide macros for accessing buffer states in case in the
509  * future we want to put the buffer states in a more general
510  * "scanner state".
511  *
512  * Returns the top of the stack, or NULL.
513  */
514 #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
515                           ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
516                           : NULL)
517 /* Same as previous macro, but useful when we know that the buffer stack is not
518  * NULL or when we need an lvalue. For internal use only.
519  */
520 #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
521 
522 void yyrestart ( FILE *input_file , yyscan_t yyscanner );
523 void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
524 YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
525 void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
526 void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
527 void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
528 void yypop_buffer_state ( yyscan_t yyscanner );
529 
530 static void yyensure_buffer_stack ( yyscan_t yyscanner );
531 static void yy_load_buffer_state ( yyscan_t yyscanner );
532 static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
533 #define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)
534 
535 YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
536 YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
537 YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
538 
539 void *yyalloc ( yy_size_t , yyscan_t yyscanner );
540 void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
541 void yyfree ( void * , yyscan_t yyscanner );
542 
543 #define yy_new_buffer yy_create_buffer
544 #define yy_set_interactive(is_interactive) \
545 	{ \
546 	if ( ! YY_CURRENT_BUFFER ){ \
547         yyensure_buffer_stack (yyscanner); \
548 		YY_CURRENT_BUFFER_LVALUE =    \
549             yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
550 	} \
551 	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
552 	}
553 #define yy_set_bol(at_bol) \
554 	{ \
555 	if ( ! YY_CURRENT_BUFFER ){\
556         yyensure_buffer_stack (yyscanner); \
557 		YY_CURRENT_BUFFER_LVALUE =    \
558             yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
559 	} \
560 	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
561 	}
562 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
563 
564 /* Begin user sect3 */
565 
566 #define slash_yywrap(yyscanner) (/*CONSTCOND*/1)
567 #define YY_SKIP_YYWRAP
568 typedef flex_uint8_t YY_CHAR;
569 
570 typedef int yy_state_type;
571 
572 #define yytext_ptr yytext_r
573 
574 static const flex_int16_t yy_nxt[][22] =
575     {
576     {
577         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
578         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
579         0,    0
580     },
581 
582     {
583        19,   20,   20,   20,   20,   20,   20,   20,   20,   20,
584        20,   20,   20,   20,   20,   20,   20,   20,   20,   20,
585        20,   20
586     },
587 
588     {
589        19,   20,   20,   20,   20,   20,   20,   20,   20,   20,
590        20,   20,   20,   20,   20,   20,   20,   20,   20,   20,
591        20,   20
592     },
593 
594     {
595        19,   21,   22,   23,   21,   21,   21,   21,   21,   21,
596 
597        21,   22,   21,   21,   21,   21,   21,   21,   21,   21,
598        21,   21
599     },
600 
601     {
602        19,   21,   22,   23,   21,   21,   21,   21,   21,   21,
603        21,   22,   21,   21,   21,   21,   21,   21,   21,   21,
604        21,   21
605     },
606 
607     {
608        19,   24,   25,   26,   24,   24,   24,   24,   24,   24,
609        24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
610        27,   24
611     },
612 
613     {
614        19,   24,   25,   26,   24,   24,   24,   24,   24,   24,
615        24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
616 
617        27,   24
618     },
619 
620     {
621        19,   28,   29,   30,   31,   32,   28,   28,   33,   28,
622        28,   29,   34,   28,   28,   28,   28,   28,   28,   28,
623        28,   28
624     },
625 
626     {
627        19,   28,   29,   30,   31,   32,   28,   28,   33,   28,
628        28,   29,   34,   28,   28,   28,   28,   28,   28,   28,
629        28,   28
630     },
631 
632     {
633        19,   35,   35,   35,   35,   36,   35,   35,   35,   35,
634        35,   37,   35,   35,   35,   35,   35,   35,   35,   35,
635        35,   35
636 
637     },
638 
639     {
640        19,   35,   35,   35,   35,   36,   35,   35,   35,   35,
641        35,   37,   35,   35,   35,   35,   35,   35,   35,   35,
642        35,   35
643     },
644 
645     {
646        19,   38,   38,   38,   38,   38,   38,   38,   39,   38,
647        38,   38,   40,   38,   38,   38,   38,   38,   38,   38,
648        38,   38
649     },
650 
651     {
652        19,   38,   38,   38,   38,   38,   38,   38,   39,   38,
653        38,   38,   40,   38,   38,   38,   38,   38,   38,   38,
654        38,   38
655     },
656 
657     {
658        19,   41,   41,   41,   42,   41,   41,   41,   41,   41,
659 
660        41,   41,   41,   41,   41,   41,   41,   41,   41,   41,
661        41,   41
662     },
663 
664     {
665        19,   41,   41,   41,   42,   41,   41,   41,   41,   41,
666        41,   41,   41,   41,   41,   41,   41,   41,   41,   41,
667        41,   41
668     },
669 
670     {
671        19,   43,   44,   45,   43,   43,   43,   43,   43,   43,
672        43,   43,   43,   43,   43,   43,   43,   43,   43,   43,
673        43,   43
674     },
675 
676     {
677        19,   43,   44,   45,   43,   43,   43,   43,   43,   43,
678        43,   43,   43,   43,   43,   43,   43,   43,   43,   43,
679 
680        43,   43
681     },
682 
683     {
684        19,   46,   46,   46,   46,   46,   46,   46,   46,   46,
685        46,   47,   46,   46,   46,   46,   46,   46,   46,   46,
686        46,   46
687     },
688 
689     {
690        19,   46,   46,   46,   46,   46,   46,   46,   46,   46,
691        46,   47,   46,   46,   46,   46,   46,   46,   46,   46,
692        46,   46
693     },
694 
695     {
696       -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,
697       -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,
698       -19,  -19
699 
700     },
701 
702     {
703        19,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,
704       -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,
705       -20,  -20
706     },
707 
708     {
709        19,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,
710       -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,
711       -21,  -21
712     },
713 
714     {
715        19,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,
716       -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,
717       -22,  -22
718     },
719 
720     {
721        19,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,
722 
723       -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,
724       -23,  -23
725     },
726 
727     {
728        19,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
729       -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
730       -24,  -24
731     },
732 
733     {
734        19,  -25,   48,   48,  -25,  -25,  -25,  -25,  -25,  -25,
735       -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
736       -25,  -25
737     },
738 
739     {
740        19,  -26,   48,   48,  -26,  -26,  -26,  -26,  -26,  -26,
741       -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,
742 
743       -26,  -26
744     },
745 
746     {
747        19,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
748       -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
749       -27,  -27
750     },
751 
752     {
753        19,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,
754       -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,
755       -28,  -28
756     },
757 
758     {
759        19,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,
760       -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,
761       -29,  -29
762 
763     },
764 
765     {
766        19,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,
767       -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,
768       -30,  -30
769     },
770 
771     {
772        19,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,
773       -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,
774       -31,  -31
775     },
776 
777     {
778        19,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,
779       -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,
780       -32,  -32
781     },
782 
783     {
784        19,  -33,  -33,  -33,   49,   50,   51,   51,  -33,  -33,
785 
786        51,  -33,  -33,   51,   51,   51,   51,   51,   51,   52,
787       -33,  -33
788     },
789 
790     {
791        19,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
792       -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
793       -34,  -34
794     },
795 
796     {
797        19,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
798       -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
799       -35,  -35
800     },
801 
802     {
803        19,  -36,  -36,  -36,  -36,   53,  -36,  -36,  -36,  -36,
804       -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,
805 
806       -36,  -36
807     },
808 
809     {
810        19,   54,   54,  -37,   54,   54,   55,   54,   54,   54,
811        54,   54,   54,   56,   57,   58,   59,   60,   61,   54,
812        54,   54
813     },
814 
815     {
816        19,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
817       -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
818       -38,  -38
819     },
820 
821     {
822        19,  -39,  -39,  -39,  -39,   62,   63,   63,  -39,  -39,
823        63,  -39,  -39,   63,   63,   63,   63,   63,   63,  -39,
824       -39,  -39
825 
826     },
827 
828     {
829        19,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,
830       -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,
831       -40,  -40
832     },
833 
834     {
835        19,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
836       -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
837       -41,  -41
838     },
839 
840     {
841        19,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
842       -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
843       -42,  -42
844     },
845 
846     {
847        19,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
848 
849       -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
850       -43,  -43
851     },
852 
853     {
854        19,  -44,   64,   64,  -44,  -44,  -44,  -44,  -44,  -44,
855       -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,
856       -44,  -44
857     },
858 
859     {
860        19,  -45,   64,   64,  -45,  -45,  -45,  -45,  -45,  -45,
861       -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,
862       -45,  -45
863     },
864 
865     {
866        19,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
867       -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
868 
869       -46,  -46
870     },
871 
872     {
873        19,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,
874       -47,   65,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,
875       -47,  -47
876     },
877 
878     {
879        19,  -48,   48,   48,  -48,  -48,  -48,  -48,  -48,  -48,
880       -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,
881       -48,  -48
882     },
883 
884     {
885        19,  -49,  -49,  -49,  -49,  -49,   66,   66,  -49,  -49,
886        66,  -49,  -49,   66,   66,   66,   66,   66,   66,  -49,
887       -49,  -49
888 
889     },
890 
891     {
892        19,  -50,  -50,  -50,  -50,  -50,   67,   67,  -50,  -50,
893        67,  -50,  -50,   67,   67,   67,   67,   67,   67,  -50,
894       -50,  -50
895     },
896 
897     {
898        19,  -51,  -51,  -51,  -51,  -51,   51,   51,  -51,  -51,
899        51,  -51,  -51,   51,   51,   51,   51,   51,   51,  -51,
900       -51,  -51
901     },
902 
903     {
904        19,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,   68,
905       -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,
906       -52,  -52
907     },
908 
909     {
910        19,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,
911 
912       -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,
913       -53,  -53
914     },
915 
916     {
917        19,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,
918       -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,
919       -54,  -54
920     },
921 
922     {
923        19,  -55,  -55,  -55,  -55,  -55,   69,  -55,  -55,  -55,
924       -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,
925       -55,  -55
926     },
927 
928     {
929        19,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
930       -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
931 
932       -56,  -56
933     },
934 
935     {
936        19,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,
937       -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,
938       -57,  -57
939     },
940 
941     {
942        19,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,
943       -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,
944       -58,  -58
945     },
946 
947     {
948        19,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,
949       -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,
950       -59,  -59
951 
952     },
953 
954     {
955        19,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,
956       -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,
957       -60,  -60
958     },
959 
960     {
961        19,  -61,  -61,  -61,  -61,  -61,   70,   70,  -61,  -61,
962       -61,  -61,  -61,   70,   70,  -61,  -61,  -61,  -61,  -61,
963       -61,  -61
964     },
965 
966     {
967        19,  -62,  -62,  -62,  -62,  -62,   71,   71,  -62,  -62,
968        71,  -62,  -62,   71,   71,   71,   71,   71,   71,  -62,
969       -62,  -62
970     },
971 
972     {
973        19,  -63,  -63,  -63,  -63,  -63,   63,   63,  -63,  -63,
974 
975        63,  -63,  -63,   63,   63,   63,   63,   63,   63,  -63,
976       -63,  -63
977     },
978 
979     {
980        19,  -64,   64,   64,  -64,  -64,  -64,  -64,  -64,  -64,
981       -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,
982       -64,  -64
983     },
984 
985     {
986        19,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,
987       -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,
988       -65,  -65
989     },
990 
991     {
992        19,  -66,  -66,  -66,   72,  -66,   66,   66,  -66,  -66,
993        66,  -66,  -66,   66,   66,   66,   66,   66,   66,  -66,
994 
995       -66,  -66
996     },
997 
998     {
999        19,  -67,  -67,  -67,  -67,   73,   67,   67,  -67,  -67,
1000        67,  -67,  -67,   67,   67,   67,   67,   67,   67,  -67,
1001       -67,  -67
1002     },
1003 
1004     {
1005        19,  -68,  -68,  -68,  -68,  -68,   74,   74,  -68,  -68,
1006        74,  -68,  -68,   74,   74,   74,   74,   74,   74,  -68,
1007       -68,  -68
1008     },
1009 
1010     {
1011        19,  -69,  -69,  -69,  -69,  -69,   75,  -69,  -69,  -69,
1012       -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,
1013       -69,  -69
1014 
1015     },
1016 
1017     {
1018        19,  -70,  -70,  -70,  -70,  -70,   76,   76,  -70,  -70,
1019       -70,  -70,  -70,   76,   76,  -70,  -70,  -70,  -70,  -70,
1020       -70,  -70
1021     },
1022 
1023     {
1024        19,  -71,  -71,  -71,  -71,   77,   71,   71,  -71,  -71,
1025        71,  -71,  -71,   71,   71,   71,   71,   71,   71,  -71,
1026       -71,  -71
1027     },
1028 
1029     {
1030        19,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,
1031       -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,
1032       -72,  -72
1033     },
1034 
1035     {
1036        19,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,
1037 
1038       -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,
1039       -73,  -73
1040     },
1041 
1042     {
1043        19,  -74,  -74,  -74,  -74,  -74,   74,   74,  -74,  -74,
1044        74,  -74,  -74,   74,   74,   74,   74,   74,   74,  -74,
1045       -74,   78
1046     },
1047 
1048     {
1049        19,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,
1050       -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,
1051       -75,  -75
1052     },
1053 
1054     {
1055        19,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,
1056       -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,
1057 
1058       -76,  -76
1059     },
1060 
1061     {
1062        19,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,
1063       -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,
1064       -77,  -77
1065     },
1066 
1067     {
1068        19,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,
1069       -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,
1070       -78,  -78
1071     },
1072 
1073     } ;
1074 
1075 static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
1076 static yy_state_type yy_try_NUL_trans ( yy_state_type current_state  , yyscan_t yyscanner);
1077 static int yy_get_next_buffer ( yyscan_t yyscanner );
1078 static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
1079 
1080 /* Done after the current pattern has been matched and before the
1081  * corresponding action - sets up yytext.
1082  */
1083 #define YY_DO_BEFORE_ACTION \
1084 	yyg->yytext_ptr = yy_bp; \
1085 	yyleng = (int) (yy_cp - yy_bp); \
1086 	yyg->yy_hold_char = *yy_cp; \
1087 	*yy_cp = '\0'; \
1088 	yyg->yy_c_buf_p = yy_cp;
1089 #define YY_NUM_RULES 42
1090 #define YY_END_OF_BUFFER 43
1091 /* This struct is not used in this scanner,
1092    but its presence is necessary. */
1093 struct yy_trans_info
1094 	{
1095 	flex_int32_t yy_verify;
1096 	flex_int32_t yy_nxt;
1097 	};
1098 static const flex_int16_t yy_accept[79] =
1099     {   0,
1100         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
1101         0,    0,    0,    0,    0,    0,    0,    0,   43,    1,
1102         3,    2,    2,    6,    4,    4,    5,   19,    7,    7,
1103        10,    8,   19,    9,   30,   20,   30,   35,   35,   31,
1104        37,   36,   39,   38,   38,   41,   41,    4,   16,   15,
1105        11,   18,   21,   29,   27,   24,   26,   22,   25,   23,
1106        29,   34,   32,   38,   40,   16,   15,   17,   27,   28,
1107        34,   13,   12,   17,   27,   28,   33,   14
1108     } ;
1109 
1110 static const YY_CHAR yy_ec[256] =
1111     {   0,
1112         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
1113         1,    2,    2,    1,    1,    1,    1,    1,    1,    1,
1114         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
1115         1,    2,    1,    4,    1,    1,    1,    1,    5,    1,
1116         1,    1,    1,    1,    1,    1,    1,    6,    6,    6,
1117         6,    6,    6,    6,    6,    7,    7,    8,    1,    1,
1118         1,    1,    9,    1,    7,    7,    7,    7,    7,    7,
1119        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
1120        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
1121         1,   11,    1,    1,   10,   12,    7,   13,    7,    7,
1122 
1123         7,   14,   10,   10,   10,   10,   10,   10,   10,   15,
1124        10,   10,   10,   16,   10,   17,   10,   10,   10,   18,
1125        10,   10,   19,   20,   21,    1,    1,   10,   10,   10,
1126        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
1127        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
1128        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
1129        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
1130        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
1131        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
1132        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
1133 
1134        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
1135        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
1136        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
1137        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
1138        10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
1139        10,   10,   10,   10,   10
1140     } ;
1141 
1142 /* The intent behind this definition is that it'll catch
1143  * any uses of REJECT which flex missed.
1144  */
1145 #define REJECT reject_used_but_not_detected
1146 #define yymore() yymore_used_but_not_detected
1147 #define YY_MORE_ADJ 0
1148 #define YY_RESTORE_YY_MORE_OFFSET
1149 #line 1 "psqlscanslash.l"
1150 
1151 #line 29 "psqlscanslash.l"
1152 #include "fe_utils/psqlscan_int.h"
1153 
1154 #define PQmblenBounded(s, e)  strnlen(s, PQmblen(s, e))
1155 
1156 /*
1157  * We must have a typedef YYSTYPE for yylex's first argument, but this lexer
1158  * doesn't presently make use of that argument, so just declare it as int.
1159  */
1160 typedef int YYSTYPE;
1161 
1162 /*
1163  * Set the type of yyextra; we use it as a pointer back to the containing
1164  * PsqlScanState.
1165  */
1166 #define YY_EXTRA_TYPE PsqlScanState
1167 
1168 /*
1169  * These variables do not need to be saved across calls.  Yeah, it's a bit
1170  * of a hack, but putting them into PsqlScanStateData would be klugy too.
1171  */
1172 static enum slash_option_type option_type;
1173 static char *option_quote;
1174 static int	unquoted_option_chars;
1175 static int	backtick_start_offset;
1176 
1177 
1178 /* Return values from yylex() */
1179 #define LEXRES_EOL			0	/* end of input */
1180 #define LEXRES_OK			1	/* OK completion of backslash argument */
1181 
1182 
1183 static void evaluate_backtick(PsqlScanState state);
1184 
1185 #define ECHO psqlscan_emit(cur_state, yytext, yyleng)
1186 
1187 /*
1188  * Work around a bug in flex 2.5.35: it emits a couple of functions that
1189  * it forgets to emit declarations for.  Since we use -Wmissing-prototypes,
1190  * this would cause warnings.  Providing our own declarations should be
1191  * harmless even when the bug gets fixed.
1192  */
1193 extern int	slash_yyget_column(yyscan_t yyscanner);
1194 extern void slash_yyset_column(int column_no, yyscan_t yyscanner);
1195 
1196 /* LCOV_EXCL_START */
1197 
1198 #line 1199 "psqlscanslash.c"
1199 /* Except for the prefix, these options should match psqlscan.l */
1200 #define YY_NO_INPUT 1
1201 /*
1202  * OK, here is a short description of lex/flex rules behavior.
1203  * The longest pattern which matches an input string is always chosen.
1204  * For equal-length patterns, the first occurring in the rules list is chosen.
1205  * INITIAL is the starting state, to which all non-conditional rules apply.
1206  * Exclusive states change parsing rules while the state is active.  When in
1207  * an exclusive state, only those rules defined for that state apply.
1208  */
1209 /* Exclusive states for lexing backslash commands */
1210 
1211 /*
1212  * Assorted character class definitions that should match psqlscan.l.
1213  */
1214 #line 1215 "psqlscanslash.c"
1215 
1216 #define INITIAL 0
1217 #define xslashcmd 1
1218 #define xslashargstart 2
1219 #define xslasharg 3
1220 #define xslashquote 4
1221 #define xslashbackquote 5
1222 #define xslashdquote 6
1223 #define xslashwholeline 7
1224 #define xslashend 8
1225 
1226 #ifndef YY_NO_UNISTD_H
1227 /* Special case for "unistd.h", since it is non-ANSI. We include it way
1228  * down here because we want the user's section 1 to have been scanned first.
1229  * The user has a chance to override it with an option.
1230  */
1231 #include <unistd.h>
1232 #endif
1233 
1234 #ifndef YY_EXTRA_TYPE
1235 #define YY_EXTRA_TYPE void *
1236 #endif
1237 
1238 /* Holds the entire state of the reentrant scanner. */
1239 struct yyguts_t
1240     {
1241 
1242     /* User-defined. Not touched by flex. */
1243     YY_EXTRA_TYPE yyextra_r;
1244 
1245     /* The rest are the same as the globals declared in the non-reentrant scanner. */
1246     FILE *yyin_r, *yyout_r;
1247     size_t yy_buffer_stack_top; /**< index of top of stack. */
1248     size_t yy_buffer_stack_max; /**< capacity of stack. */
1249     YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
1250     char yy_hold_char;
1251     int yy_n_chars;
1252     int yyleng_r;
1253     char *yy_c_buf_p;
1254     int yy_init;
1255     int yy_start;
1256     int yy_did_buffer_switch_on_eof;
1257     int yy_start_stack_ptr;
1258     int yy_start_stack_depth;
1259     int *yy_start_stack;
1260     yy_state_type yy_last_accepting_state;
1261     char* yy_last_accepting_cpos;
1262 
1263     int yylineno_r;
1264     int yy_flex_debug_r;
1265 
1266     char *yytext_r;
1267     int yy_more_flag;
1268     int yy_more_len;
1269 
1270     YYSTYPE * yylval_r;
1271 
1272     }; /* end struct yyguts_t */
1273 
1274 static int yy_init_globals ( yyscan_t yyscanner );
1275 
1276     /* This must go here because YYSTYPE and YYLTYPE are included
1277      * from bison output in section 1.*/
1278     #    define yylval yyg->yylval_r
1279 
1280 int yylex_init (yyscan_t* scanner);
1281 
1282 int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
1283 
1284 /* Accessor methods to globals.
1285    These are made visible to non-reentrant scanners for convenience. */
1286 
1287 int yylex_destroy ( yyscan_t yyscanner );
1288 
1289 int yyget_debug ( yyscan_t yyscanner );
1290 
1291 void yyset_debug ( int debug_flag , yyscan_t yyscanner );
1292 
1293 YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
1294 
1295 void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
1296 
1297 FILE *yyget_in ( yyscan_t yyscanner );
1298 
1299 void yyset_in  ( FILE * _in_str , yyscan_t yyscanner );
1300 
1301 FILE *yyget_out ( yyscan_t yyscanner );
1302 
1303 void yyset_out  ( FILE * _out_str , yyscan_t yyscanner );
1304 
1305 			int yyget_leng ( yyscan_t yyscanner );
1306 
1307 char *yyget_text ( yyscan_t yyscanner );
1308 
1309 int yyget_lineno ( yyscan_t yyscanner );
1310 
1311 void yyset_lineno ( int _line_number , yyscan_t yyscanner );
1312 
1313 int yyget_column  ( yyscan_t yyscanner );
1314 
1315 void yyset_column ( int _column_no , yyscan_t yyscanner );
1316 
1317 YYSTYPE * yyget_lval ( yyscan_t yyscanner );
1318 
1319 void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );
1320 
1321 /* Macros after this point can all be overridden by user definitions in
1322  * section 1.
1323  */
1324 
1325 #ifndef YY_SKIP_YYWRAP
1326 #ifdef __cplusplus
1327 extern "C" int yywrap ( yyscan_t yyscanner );
1328 #else
1329 extern int yywrap ( yyscan_t yyscanner );
1330 #endif
1331 #endif
1332 
1333 #ifndef YY_NO_UNPUT
1334 
1335 #endif
1336 
1337 #ifndef yytext_ptr
1338 static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
1339 #endif
1340 
1341 #ifdef YY_NEED_STRLEN
1342 static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
1343 #endif
1344 
1345 #ifndef YY_NO_INPUT
1346 #ifdef __cplusplus
1347 static int yyinput ( yyscan_t yyscanner );
1348 #else
1349 static int input ( yyscan_t yyscanner );
1350 #endif
1351 
1352 #endif
1353 
1354 /* Amount of stuff to slurp up with each read. */
1355 #ifndef YY_READ_BUF_SIZE
1356 #ifdef __ia64__
1357 /* On IA-64, the buffer size is 16k, not 8k */
1358 #define YY_READ_BUF_SIZE 16384
1359 #else
1360 #define YY_READ_BUF_SIZE 8192
1361 #endif /* __ia64__ */
1362 #endif
1363 
1364 /* Copy whatever the last rule matched to the standard output. */
1365 #ifndef ECHO
1366 /* This used to be an fputs(), but since the string might contain NUL's,
1367  * we now use fwrite().
1368  */
1369 #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
1370 #endif
1371 
1372 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
1373  * is returned in "result".
1374  */
1375 #ifndef YY_INPUT
1376 #define YY_INPUT(buf,result,max_size) \
1377 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
1378 		{ \
1379 		int c = '*'; \
1380 		int n; \
1381 		for ( n = 0; n < max_size && \
1382 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
1383 			buf[n] = (char) c; \
1384 		if ( c == '\n' ) \
1385 			buf[n++] = (char) c; \
1386 		if ( c == EOF && ferror( yyin ) ) \
1387 			YY_FATAL_ERROR( "input in flex scanner failed" ); \
1388 		result = n; \
1389 		} \
1390 	else \
1391 		{ \
1392 		errno=0; \
1393 		while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
1394 			{ \
1395 			if( errno != EINTR) \
1396 				{ \
1397 				YY_FATAL_ERROR( "input in flex scanner failed" ); \
1398 				break; \
1399 				} \
1400 			errno=0; \
1401 			clearerr(yyin); \
1402 			} \
1403 		}\
1404 \
1405 
1406 #endif
1407 
1408 /* No semi-colon after return; correct usage is to write "yyterminate();" -
1409  * we don't want an extra ';' after the "return" because that will cause
1410  * some compilers to complain about unreachable statements.
1411  */
1412 #ifndef yyterminate
1413 #define yyterminate() return YY_NULL
1414 #endif
1415 
1416 /* Number of entries by which start-condition stack grows. */
1417 #ifndef YY_START_STACK_INCR
1418 #define YY_START_STACK_INCR 25
1419 #endif
1420 
1421 /* Report a fatal error. */
1422 #ifndef YY_FATAL_ERROR
1423 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
1424 #endif
1425 
1426 /* end tables serialization structures and prototypes */
1427 
1428 /* Default declaration of generated scanner - a define so the user can
1429  * easily add parameters.
1430  */
1431 #ifndef YY_DECL
1432 #define YY_DECL_IS_OURS 1
1433 
1434 extern int yylex \
1435                (YYSTYPE * yylval_param , yyscan_t yyscanner);
1436 
1437 #define YY_DECL int yylex \
1438                (YYSTYPE * yylval_param , yyscan_t yyscanner)
1439 #endif /* !YY_DECL */
1440 
1441 /* Code executed at the beginning of each rule, after yytext and yyleng
1442  * have been set up.
1443  */
1444 #ifndef YY_USER_ACTION
1445 #define YY_USER_ACTION
1446 #endif
1447 
1448 /* Code executed at the end of each rule. */
1449 #ifndef YY_BREAK
1450 #define YY_BREAK /*LINTED*/break;
1451 #endif
1452 
1453 #define YY_RULE_SETUP \
1454 	YY_USER_ACTION
1455 
1456 /** The main scanner function which does all the work.
1457  */
1458 YY_DECL
1459 {
1460 	yy_state_type yy_current_state;
1461 	char *yy_cp, *yy_bp;
1462 	int yy_act;
1463     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1464 
1465     yylval = yylval_param;
1466 
1467 	if ( !yyg->yy_init )
1468 		{
1469 		yyg->yy_init = 1;
1470 
1471 #ifdef YY_USER_INIT
1472 		YY_USER_INIT;
1473 #endif
1474 
1475 		if ( ! yyg->yy_start )
1476 			yyg->yy_start = 1;	/* first start state */
1477 
1478 		if ( ! yyin )
1479 			yyin = stdin;
1480 
1481 		if ( ! yyout )
1482 			yyout = stdout;
1483 
1484 		if ( ! YY_CURRENT_BUFFER ) {
1485 			yyensure_buffer_stack (yyscanner);
1486 			YY_CURRENT_BUFFER_LVALUE =
1487 				yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
1488 		}
1489 
1490 		yy_load_buffer_state( yyscanner );
1491 		}
1492 
1493 	{
1494 #line 121 "psqlscanslash.l"
1495 
1496 
1497 
1498 #line 125 "psqlscanslash.l"
1499 		/* Declare some local variables inside yylex(), for convenience */
1500 		PsqlScanState cur_state = yyextra;
1501 		PQExpBuffer output_buf = cur_state->output_buf;
1502 
1503 		/*
1504 		 * Force flex into the state indicated by start_state.  This has a
1505 		 * couple of purposes: it lets some of the functions below set a new
1506 		 * starting state without ugly direct access to flex variables, and it
1507 		 * allows us to transition from one flex lexer to another so that we
1508 		 * can lex different parts of the source string using separate lexers.
1509 		 */
1510 		BEGIN(cur_state->start_state);
1511 
1512 
1513 	/*
1514 	 * We don't really expect to be invoked in the INITIAL state in this
1515 	 * lexer; but if we are, just spit data to the output_buf until EOF.
1516 	 */
1517 
1518 #line 1519 "psqlscanslash.c"
1519 
1520 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
1521 		{
1522 		yy_cp = yyg->yy_c_buf_p;
1523 
1524 		/* Support of yytext. */
1525 		*yy_cp = yyg->yy_hold_char;
1526 
1527 		/* yy_bp points to the position in yy_ch_buf of the start of
1528 		 * the current run.
1529 		 */
1530 		yy_bp = yy_cp;
1531 
1532 		yy_current_state = yyg->yy_start;
1533 yy_match:
1534 		while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)]  ]) > 0 )
1535 			++yy_cp;
1536 
1537 		yy_current_state = -yy_current_state;
1538 
1539 yy_find_action:
1540 		yy_act = yy_accept[yy_current_state];
1541 
1542 		YY_DO_BEFORE_ACTION;
1543 
1544 do_action:	/* This label is used only to access EOF actions. */
1545 
1546 		switch ( yy_act )
1547 	{ /* beginning of action switch */
1548 case 1:
1549 /* rule 1 can match eol */
1550 YY_RULE_SETUP
1551 #line 144 "psqlscanslash.l"
1552 { ECHO; }
1553 	YY_BREAK
1554 /*
1555 	 * Exclusive lexer states to handle backslash command lexing
1556 	 */
1557 
1558 /* command name ends at whitespace or backslash; eat all else */
1559 case 2:
1560 /* rule 2 can match eol */
1561 YY_RULE_SETUP
1562 #line 153 "psqlscanslash.l"
1563 {
1564 					yyless(0);
1565 					cur_state->start_state = YY_START;
1566 					return LEXRES_OK;
1567 				}
1568 	YY_BREAK
1569 case 3:
1570 YY_RULE_SETUP
1571 #line 159 "psqlscanslash.l"
1572 { ECHO; }
1573 	YY_BREAK
1574 
1575 
1576 /*
1577 	 * Discard any whitespace before argument, then go to xslasharg state.
1578 	 * An exception is that "|" is only special at start of argument, so we
1579 	 * check for it here.
1580 	 */
1581 case 4:
1582 /* rule 4 can match eol */
1583 YY_RULE_SETUP
1584 #line 170 "psqlscanslash.l"
1585 { }
1586 	YY_BREAK
1587 case 5:
1588 YY_RULE_SETUP
1589 #line 172 "psqlscanslash.l"
1590 {
1591 					if (option_type == OT_FILEPIPE)
1592 					{
1593 						/* treat like whole-string case */
1594 						ECHO;
1595 						BEGIN(xslashwholeline);
1596 					}
1597 					else
1598 					{
1599 						/* vertical bar is not special otherwise */
1600 						yyless(0);
1601 						BEGIN(xslasharg);
1602 					}
1603 				}
1604 	YY_BREAK
1605 case 6:
1606 YY_RULE_SETUP
1607 #line 187 "psqlscanslash.l"
1608 {
1609 					yyless(0);
1610 					BEGIN(xslasharg);
1611 				}
1612 	YY_BREAK
1613 
1614 
1615 /*
1616 	 * Default processing of text in a slash command's argument.
1617 	 *
1618 	 * Note: unquoted_option_chars counts the number of characters at the
1619 	 * end of the argument that were not subject to any form of quoting.
1620 	 * psql_scan_slash_option needs this to strip trailing semicolons safely.
1621 	 */
1622 case 7:
1623 /* rule 7 can match eol */
1624 YY_RULE_SETUP
1625 #line 203 "psqlscanslash.l"
1626 {
1627 					/*
1628 					 * Unquoted space is end of arg; do not eat.  Likewise
1629 					 * backslash is end of command or next command, do not eat
1630 					 *
1631 					 * XXX this means we can't conveniently accept options
1632 					 * that include unquoted backslashes; therefore, option
1633 					 * processing that encourages use of backslashes is rather
1634 					 * broken.
1635 					 */
1636 					yyless(0);
1637 					cur_state->start_state = YY_START;
1638 					return LEXRES_OK;
1639 				}
1640 	YY_BREAK
1641 case 8:
1642 YY_RULE_SETUP
1643 #line 218 "psqlscanslash.l"
1644 {
1645 					*option_quote = '\'';
1646 					unquoted_option_chars = 0;
1647 					BEGIN(xslashquote);
1648 				}
1649 	YY_BREAK
1650 case 9:
1651 YY_RULE_SETUP
1652 #line 224 "psqlscanslash.l"
1653 {
1654 					backtick_start_offset = output_buf->len;
1655 					*option_quote = '`';
1656 					unquoted_option_chars = 0;
1657 					BEGIN(xslashbackquote);
1658 				}
1659 	YY_BREAK
1660 case 10:
1661 YY_RULE_SETUP
1662 #line 231 "psqlscanslash.l"
1663 {
1664 					ECHO;
1665 					*option_quote = '"';
1666 					unquoted_option_chars = 0;
1667 					BEGIN(xslashdquote);
1668 				}
1669 	YY_BREAK
1670 case 11:
1671 YY_RULE_SETUP
1672 #line 238 "psqlscanslash.l"
1673 {
1674 					/* Possible psql variable substitution */
1675 					if (cur_state->callbacks->get_variable == NULL)
1676 						ECHO;
1677 					else
1678 					{
1679 						char	   *varname;
1680 						char	   *value;
1681 
1682 						varname = psqlscan_extract_substring(cur_state,
1683 															 yytext + 1,
1684 															 yyleng - 1);
1685 						value = cur_state->callbacks->get_variable(varname,
1686 																   PQUOTE_PLAIN,
1687 																   cur_state->cb_passthrough);
1688 						free(varname);
1689 
1690 						/*
1691 						 * The variable value is just emitted without any
1692 						 * further examination.  This is consistent with the
1693 						 * pre-8.0 code behavior, if not with the way that
1694 						 * variables are handled outside backslash commands.
1695 						 * Note that we needn't guard against recursion here.
1696 						 */
1697 						if (value)
1698 						{
1699 							appendPQExpBufferStr(output_buf, value);
1700 							free(value);
1701 						}
1702 						else
1703 							ECHO;
1704 
1705 						*option_quote = ':';
1706 					}
1707 					unquoted_option_chars = 0;
1708 				}
1709 	YY_BREAK
1710 case 12:
1711 YY_RULE_SETUP
1712 #line 275 "psqlscanslash.l"
1713 {
1714 					psqlscan_escape_variable(cur_state, yytext, yyleng,
1715 											 PQUOTE_SQL_LITERAL);
1716 					*option_quote = ':';
1717 					unquoted_option_chars = 0;
1718 				}
1719 	YY_BREAK
1720 case 13:
1721 YY_RULE_SETUP
1722 #line 283 "psqlscanslash.l"
1723 {
1724 					psqlscan_escape_variable(cur_state, yytext, yyleng,
1725 											 PQUOTE_SQL_IDENT);
1726 					*option_quote = ':';
1727 					unquoted_option_chars = 0;
1728 				}
1729 	YY_BREAK
1730 case 14:
1731 YY_RULE_SETUP
1732 #line 290 "psqlscanslash.l"
1733 {
1734 					psqlscan_test_variable(cur_state, yytext, yyleng);
1735 				}
1736 	YY_BREAK
1737 case 15:
1738 YY_RULE_SETUP
1739 #line 294 "psqlscanslash.l"
1740 {
1741 					/* Throw back everything but the colon */
1742 					yyless(1);
1743 					unquoted_option_chars++;
1744 					ECHO;
1745 				}
1746 	YY_BREAK
1747 case 16:
1748 YY_RULE_SETUP
1749 #line 301 "psqlscanslash.l"
1750 {
1751 					/* Throw back everything but the colon */
1752 					yyless(1);
1753 					unquoted_option_chars++;
1754 					ECHO;
1755 				}
1756 	YY_BREAK
1757 case 17:
1758 YY_RULE_SETUP
1759 #line 308 "psqlscanslash.l"
1760 {
1761 					/* Throw back everything but the colon */
1762 					yyless(1);
1763 					unquoted_option_chars++;
1764 					ECHO;
1765 				}
1766 	YY_BREAK
1767 case 18:
1768 YY_RULE_SETUP
1769 #line 315 "psqlscanslash.l"
1770 {
1771 					/* Throw back everything but the colon */
1772 					yyless(1);
1773 					unquoted_option_chars++;
1774 					ECHO;
1775 				}
1776 	YY_BREAK
1777 case 19:
1778 YY_RULE_SETUP
1779 #line 322 "psqlscanslash.l"
1780 {
1781 					unquoted_option_chars++;
1782 					ECHO;
1783 				}
1784 	YY_BREAK
1785 
1786 
1787 /*
1788 	 * single-quoted text: copy literally except for '' and backslash
1789 	 * sequences
1790 	 */
1791 case 20:
1792 YY_RULE_SETUP
1793 #line 335 "psqlscanslash.l"
1794 { BEGIN(xslasharg); }
1795 	YY_BREAK
1796 case 21:
1797 YY_RULE_SETUP
1798 #line 337 "psqlscanslash.l"
1799 { appendPQExpBufferChar(output_buf, '\''); }
1800 	YY_BREAK
1801 case 22:
1802 YY_RULE_SETUP
1803 #line 339 "psqlscanslash.l"
1804 { appendPQExpBufferChar(output_buf, '\n'); }
1805 	YY_BREAK
1806 case 23:
1807 YY_RULE_SETUP
1808 #line 340 "psqlscanslash.l"
1809 { appendPQExpBufferChar(output_buf, '\t'); }
1810 	YY_BREAK
1811 case 24:
1812 YY_RULE_SETUP
1813 #line 341 "psqlscanslash.l"
1814 { appendPQExpBufferChar(output_buf, '\b'); }
1815 	YY_BREAK
1816 case 25:
1817 YY_RULE_SETUP
1818 #line 342 "psqlscanslash.l"
1819 { appendPQExpBufferChar(output_buf, '\r'); }
1820 	YY_BREAK
1821 case 26:
1822 YY_RULE_SETUP
1823 #line 343 "psqlscanslash.l"
1824 { appendPQExpBufferChar(output_buf, '\f'); }
1825 	YY_BREAK
1826 case 27:
1827 YY_RULE_SETUP
1828 #line 345 "psqlscanslash.l"
1829 {
1830 					/* octal case */
1831 					appendPQExpBufferChar(output_buf,
1832 										  (char) strtol(yytext + 1, NULL, 8));
1833 				}
1834 	YY_BREAK
1835 case 28:
1836 YY_RULE_SETUP
1837 #line 351 "psqlscanslash.l"
1838 {
1839 					/* hex case */
1840 					appendPQExpBufferChar(output_buf,
1841 										  (char) strtol(yytext + 2, NULL, 16));
1842 				}
1843 	YY_BREAK
1844 case 29:
1845 YY_RULE_SETUP
1846 #line 357 "psqlscanslash.l"
1847 { psqlscan_emit(cur_state, yytext + 1, 1); }
1848 	YY_BREAK
1849 case 30:
1850 /* rule 30 can match eol */
1851 YY_RULE_SETUP
1852 #line 359 "psqlscanslash.l"
1853 { ECHO; }
1854 	YY_BREAK
1855 
1856 
1857 /*
1858 	 * backticked text: copy everything until next backquote (expanding
1859 	 * variable references, but doing nought else), then evaluate.
1860 	 */
1861 case 31:
1862 YY_RULE_SETUP
1863 #line 369 "psqlscanslash.l"
1864 {
1865 					/* In an inactive \if branch, don't evaluate the command */
1866 					if (cur_state->cb_passthrough == NULL ||
1867 						conditional_active((ConditionalStack) cur_state->cb_passthrough))
1868 						evaluate_backtick(cur_state);
1869 					BEGIN(xslasharg);
1870 				}
1871 	YY_BREAK
1872 case 32:
1873 YY_RULE_SETUP
1874 #line 377 "psqlscanslash.l"
1875 {
1876 					/* Possible psql variable substitution */
1877 					if (cur_state->callbacks->get_variable == NULL)
1878 						ECHO;
1879 					else
1880 					{
1881 						char	   *varname;
1882 						char	   *value;
1883 
1884 						varname = psqlscan_extract_substring(cur_state,
1885 															 yytext + 1,
1886 															 yyleng - 1);
1887 						value = cur_state->callbacks->get_variable(varname,
1888 																   PQUOTE_PLAIN,
1889 																   cur_state->cb_passthrough);
1890 						free(varname);
1891 
1892 						if (value)
1893 						{
1894 							appendPQExpBufferStr(output_buf, value);
1895 							free(value);
1896 						}
1897 						else
1898 							ECHO;
1899 					}
1900 				}
1901 	YY_BREAK
1902 case 33:
1903 YY_RULE_SETUP
1904 #line 404 "psqlscanslash.l"
1905 {
1906 					psqlscan_escape_variable(cur_state, yytext, yyleng,
1907 											 PQUOTE_SHELL_ARG);
1908 				}
1909 	YY_BREAK
1910 case 34:
1911 YY_RULE_SETUP
1912 #line 409 "psqlscanslash.l"
1913 {
1914 					/* Throw back everything but the colon */
1915 					yyless(1);
1916 					ECHO;
1917 				}
1918 	YY_BREAK
1919 case 35:
1920 /* rule 35 can match eol */
1921 YY_RULE_SETUP
1922 #line 415 "psqlscanslash.l"
1923 { ECHO; }
1924 	YY_BREAK
1925 
1926 
1927 /* double-quoted text: copy verbatim, including the double quotes */
1928 case 36:
1929 YY_RULE_SETUP
1930 #line 422 "psqlscanslash.l"
1931 {
1932 					ECHO;
1933 					BEGIN(xslasharg);
1934 				}
1935 	YY_BREAK
1936 case 37:
1937 /* rule 37 can match eol */
1938 YY_RULE_SETUP
1939 #line 427 "psqlscanslash.l"
1940 { ECHO; }
1941 	YY_BREAK
1942 
1943 
1944 /* copy everything until end of input line */
1945 /* but suppress leading whitespace */
1946 case 38:
1947 /* rule 38 can match eol */
1948 YY_RULE_SETUP
1949 #line 435 "psqlscanslash.l"
1950 {
1951 					if (output_buf->len > 0)
1952 						ECHO;
1953 				}
1954 	YY_BREAK
1955 case 39:
1956 YY_RULE_SETUP
1957 #line 440 "psqlscanslash.l"
1958 { ECHO; }
1959 	YY_BREAK
1960 
1961 
1962 /* at end of command, eat a double backslash, but not anything else */
1963 case 40:
1964 YY_RULE_SETUP
1965 #line 447 "psqlscanslash.l"
1966 {
1967 					cur_state->start_state = YY_START;
1968 					return LEXRES_OK;
1969 				}
1970 	YY_BREAK
1971 case 41:
1972 /* rule 41 can match eol */
1973 YY_RULE_SETUP
1974 #line 452 "psqlscanslash.l"
1975 {
1976 					yyless(0);
1977 					cur_state->start_state = YY_START;
1978 					return LEXRES_OK;
1979 				}
1980 	YY_BREAK
1981 
1982 case YY_STATE_EOF(INITIAL):
1983 case YY_STATE_EOF(xslashcmd):
1984 case YY_STATE_EOF(xslashargstart):
1985 case YY_STATE_EOF(xslasharg):
1986 case YY_STATE_EOF(xslashquote):
1987 case YY_STATE_EOF(xslashbackquote):
1988 case YY_STATE_EOF(xslashdquote):
1989 case YY_STATE_EOF(xslashwholeline):
1990 case YY_STATE_EOF(xslashend):
1991 #line 460 "psqlscanslash.l"
1992 {
1993 					if (cur_state->buffer_stack == NULL)
1994 					{
1995 						cur_state->start_state = YY_START;
1996 						return LEXRES_EOL;		/* end of input reached */
1997 					}
1998 
1999 					/*
2000 					 * We were expanding a variable, so pop the inclusion
2001 					 * stack and keep lexing
2002 					 */
2003 					psqlscan_pop_buffer_stack(cur_state);
2004 					psqlscan_select_top_buffer(cur_state);
2005 				}
2006 	YY_BREAK
2007 case 42:
2008 YY_RULE_SETUP
2009 #line 475 "psqlscanslash.l"
2010 YY_FATAL_ERROR( "flex scanner jammed" );
2011 	YY_BREAK
2012 #line 2013 "psqlscanslash.c"
2013 
2014 	case YY_END_OF_BUFFER:
2015 		{
2016 		/* Amount of text matched not including the EOB char. */
2017 		int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
2018 
2019 		/* Undo the effects of YY_DO_BEFORE_ACTION. */
2020 		*yy_cp = yyg->yy_hold_char;
2021 		YY_RESTORE_YY_MORE_OFFSET
2022 
2023 		if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
2024 			{
2025 			/* We're scanning a new file or input source.  It's
2026 			 * possible that this happened because the user
2027 			 * just pointed yyin at a new source and called
2028 			 * yylex().  If so, then we have to assure
2029 			 * consistency between YY_CURRENT_BUFFER and our
2030 			 * globals.  Here is the right place to do so, because
2031 			 * this is the first action (other than possibly a
2032 			 * back-up) that will match for the new input source.
2033 			 */
2034 			yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2035 			YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
2036 			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
2037 			}
2038 
2039 		/* Note that here we test for yy_c_buf_p "<=" to the position
2040 		 * of the first EOB in the buffer, since yy_c_buf_p will
2041 		 * already have been incremented past the NUL character
2042 		 * (since all states make transitions on EOB to the
2043 		 * end-of-buffer state).  Contrast this with the test
2044 		 * in input().
2045 		 */
2046 		if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
2047 			{ /* This was really a NUL. */
2048 			yy_state_type yy_next_state;
2049 
2050 			yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
2051 
2052 			yy_current_state = yy_get_previous_state( yyscanner );
2053 
2054 			/* Okay, we're now positioned to make the NUL
2055 			 * transition.  We couldn't have
2056 			 * yy_get_previous_state() go ahead and do it
2057 			 * for us because it doesn't know how to deal
2058 			 * with the possibility of jamming (and we don't
2059 			 * want to build jamming into it because then it
2060 			 * will run more slowly).
2061 			 */
2062 
2063 			yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
2064 
2065 			yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
2066 
2067 			if ( yy_next_state )
2068 				{
2069 				/* Consume the NUL. */
2070 				yy_cp = ++yyg->yy_c_buf_p;
2071 				yy_current_state = yy_next_state;
2072 				goto yy_match;
2073 				}
2074 
2075 			else
2076 				{
2077 				yy_cp = yyg->yy_c_buf_p;
2078 				goto yy_find_action;
2079 				}
2080 			}
2081 
2082 		else switch ( yy_get_next_buffer( yyscanner ) )
2083 			{
2084 			case EOB_ACT_END_OF_FILE:
2085 				{
2086 				yyg->yy_did_buffer_switch_on_eof = 0;
2087 
2088 				if ( yywrap( yyscanner ) )
2089 					{
2090 					/* Note: because we've taken care in
2091 					 * yy_get_next_buffer() to have set up
2092 					 * yytext, we can now set up
2093 					 * yy_c_buf_p so that if some total
2094 					 * hoser (like flex itself) wants to
2095 					 * call the scanner after we return the
2096 					 * YY_NULL, it'll still work - another
2097 					 * YY_NULL will get returned.
2098 					 */
2099 					yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
2100 
2101 					yy_act = YY_STATE_EOF(YY_START);
2102 					goto do_action;
2103 					}
2104 
2105 				else
2106 					{
2107 					if ( ! yyg->yy_did_buffer_switch_on_eof )
2108 						YY_NEW_FILE;
2109 					}
2110 				break;
2111 				}
2112 
2113 			case EOB_ACT_CONTINUE_SCAN:
2114 				yyg->yy_c_buf_p =
2115 					yyg->yytext_ptr + yy_amount_of_matched_text;
2116 
2117 				yy_current_state = yy_get_previous_state( yyscanner );
2118 
2119 				yy_cp = yyg->yy_c_buf_p;
2120 				yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
2121 				goto yy_match;
2122 
2123 			case EOB_ACT_LAST_MATCH:
2124 				yyg->yy_c_buf_p =
2125 				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
2126 
2127 				yy_current_state = yy_get_previous_state( yyscanner );
2128 
2129 				yy_cp = yyg->yy_c_buf_p;
2130 				yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
2131 				goto yy_find_action;
2132 			}
2133 		break;
2134 		}
2135 
2136 	default:
2137 		YY_FATAL_ERROR(
2138 			"fatal flex scanner internal error--no action found" );
2139 	} /* end of action switch */
2140 		} /* end of scanning one token */
2141 	} /* end of user's declarations */
2142 } /* end of yylex */
2143 
2144 /* yy_get_next_buffer - try to read in a new buffer
2145  *
2146  * Returns a code representing an action:
2147  *	EOB_ACT_LAST_MATCH -
2148  *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
2149  *	EOB_ACT_END_OF_FILE - end of file
2150  */
yy_get_next_buffer(yyscan_t yyscanner)2151 static int yy_get_next_buffer (yyscan_t yyscanner)
2152 {
2153     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2154 	char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
2155 	char *source = yyg->yytext_ptr;
2156 	int number_to_move, i;
2157 	int ret_val;
2158 
2159 	if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
2160 		YY_FATAL_ERROR(
2161 		"fatal flex scanner internal error--end of buffer missed" );
2162 
2163 	if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
2164 		{ /* Don't try to fill the buffer, so this is an EOF. */
2165 		if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
2166 			{
2167 			/* We matched a single character, the EOB, so
2168 			 * treat this as a final EOF.
2169 			 */
2170 			return EOB_ACT_END_OF_FILE;
2171 			}
2172 
2173 		else
2174 			{
2175 			/* We matched some text prior to the EOB, first
2176 			 * process it.
2177 			 */
2178 			return EOB_ACT_LAST_MATCH;
2179 			}
2180 		}
2181 
2182 	/* Try to read more data. */
2183 
2184 	/* First move last chars to start of buffer. */
2185 	number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
2186 
2187 	for ( i = 0; i < number_to_move; ++i )
2188 		*(dest++) = *(source++);
2189 
2190 	if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
2191 		/* don't do the read, it's not guaranteed to return an EOF,
2192 		 * just force an EOF
2193 		 */
2194 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
2195 
2196 	else
2197 		{
2198 			int num_to_read =
2199 			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
2200 
2201 		while ( num_to_read <= 0 )
2202 			{ /* Not enough room in the buffer - grow it. */
2203 
2204 			/* just a shorter name for the current buffer */
2205 			YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
2206 
2207 			int yy_c_buf_p_offset =
2208 				(int) (yyg->yy_c_buf_p - b->yy_ch_buf);
2209 
2210 			if ( b->yy_is_our_buffer )
2211 				{
2212 				int new_size = b->yy_buf_size * 2;
2213 
2214 				if ( new_size <= 0 )
2215 					b->yy_buf_size += b->yy_buf_size / 8;
2216 				else
2217 					b->yy_buf_size *= 2;
2218 
2219 				b->yy_ch_buf = (char *)
2220 					/* Include room in for 2 EOB chars. */
2221 					yyrealloc( (void *) b->yy_ch_buf,
2222 							 (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
2223 				}
2224 			else
2225 				/* Can't grow it, we don't own it. */
2226 				b->yy_ch_buf = NULL;
2227 
2228 			if ( ! b->yy_ch_buf )
2229 				YY_FATAL_ERROR(
2230 				"fatal error - scanner input buffer overflow" );
2231 
2232 			yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
2233 
2234 			num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
2235 						number_to_move - 1;
2236 
2237 			}
2238 
2239 		if ( num_to_read > YY_READ_BUF_SIZE )
2240 			num_to_read = YY_READ_BUF_SIZE;
2241 
2242 		/* Read in more data. */
2243 		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
2244 			yyg->yy_n_chars, num_to_read );
2245 
2246 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2247 		}
2248 
2249 	if ( yyg->yy_n_chars == 0 )
2250 		{
2251 		if ( number_to_move == YY_MORE_ADJ )
2252 			{
2253 			ret_val = EOB_ACT_END_OF_FILE;
2254 			yyrestart( yyin  , yyscanner);
2255 			}
2256 
2257 		else
2258 			{
2259 			ret_val = EOB_ACT_LAST_MATCH;
2260 			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
2261 				YY_BUFFER_EOF_PENDING;
2262 			}
2263 		}
2264 
2265 	else
2266 		ret_val = EOB_ACT_CONTINUE_SCAN;
2267 
2268 	if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
2269 		/* Extend the array by 50%, plus the number we really need. */
2270 		int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
2271 		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
2272 			(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
2273 		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
2274 			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
2275 		/* "- 2" to take care of EOB's */
2276 		YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
2277 	}
2278 
2279 	yyg->yy_n_chars += number_to_move;
2280 	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
2281 	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
2282 
2283 	yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
2284 
2285 	return ret_val;
2286 }
2287 
2288 /* yy_get_previous_state - get the state just before the EOB char was reached */
2289 
yy_get_previous_state(yyscan_t yyscanner)2290     static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
2291 {
2292 	yy_state_type yy_current_state;
2293 	char *yy_cp;
2294     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2295 
2296 	yy_current_state = yyg->yy_start;
2297 
2298 	for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
2299 		{
2300 		yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)];
2301 		}
2302 
2303 	return yy_current_state;
2304 }
2305 
2306 /* yy_try_NUL_trans - try to make a transition on the NUL character
2307  *
2308  * synopsis
2309  *	next_state = yy_try_NUL_trans( current_state );
2310  */
yy_try_NUL_trans(yy_state_type yy_current_state,yyscan_t yyscanner)2311     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
2312 {
2313 	int yy_is_jam;
2314     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
2315 
2316 	yy_current_state = yy_nxt[yy_current_state][1];
2317 	yy_is_jam = (yy_current_state <= 0);
2318 
2319 	(void)yyg;
2320 	return yy_is_jam ? 0 : yy_current_state;
2321 }
2322 
2323 #ifndef YY_NO_UNPUT
2324 
2325 #endif
2326 
2327 #ifndef YY_NO_INPUT
2328 #ifdef __cplusplus
yyinput(yyscan_t yyscanner)2329     static int yyinput (yyscan_t yyscanner)
2330 #else
2331     static int input  (yyscan_t yyscanner)
2332 #endif
2333 
2334 {
2335 	int c;
2336     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2337 
2338 	*yyg->yy_c_buf_p = yyg->yy_hold_char;
2339 
2340 	if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
2341 		{
2342 		/* yy_c_buf_p now points to the character we want to return.
2343 		 * If this occurs *before* the EOB characters, then it's a
2344 		 * valid NUL; if not, then we've hit the end of the buffer.
2345 		 */
2346 		if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
2347 			/* This was really a NUL. */
2348 			*yyg->yy_c_buf_p = '\0';
2349 
2350 		else
2351 			{ /* need more input */
2352 			int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
2353 			++yyg->yy_c_buf_p;
2354 
2355 			switch ( yy_get_next_buffer( yyscanner ) )
2356 				{
2357 				case EOB_ACT_LAST_MATCH:
2358 					/* This happens because yy_g_n_b()
2359 					 * sees that we've accumulated a
2360 					 * token and flags that we need to
2361 					 * try matching the token before
2362 					 * proceeding.  But for input(),
2363 					 * there's no matching to consider.
2364 					 * So convert the EOB_ACT_LAST_MATCH
2365 					 * to EOB_ACT_END_OF_FILE.
2366 					 */
2367 
2368 					/* Reset buffer status. */
2369 					yyrestart( yyin , yyscanner);
2370 
2371 					/*FALLTHROUGH*/
2372 
2373 				case EOB_ACT_END_OF_FILE:
2374 					{
2375 					if ( yywrap( yyscanner ) )
2376 						return 0;
2377 
2378 					if ( ! yyg->yy_did_buffer_switch_on_eof )
2379 						YY_NEW_FILE;
2380 #ifdef __cplusplus
2381 					return yyinput(yyscanner);
2382 #else
2383 					return input(yyscanner);
2384 #endif
2385 					}
2386 
2387 				case EOB_ACT_CONTINUE_SCAN:
2388 					yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
2389 					break;
2390 				}
2391 			}
2392 		}
2393 
2394 	c = *(unsigned char *) yyg->yy_c_buf_p;	/* cast for 8-bit char's */
2395 	*yyg->yy_c_buf_p = '\0';	/* preserve yytext */
2396 	yyg->yy_hold_char = *++yyg->yy_c_buf_p;
2397 
2398 	return c;
2399 }
2400 #endif	/* ifndef YY_NO_INPUT */
2401 
2402 /** Immediately switch to a different input stream.
2403  * @param input_file A readable stream.
2404  * @param yyscanner The scanner object.
2405  * @note This function does not reset the start condition to @c INITIAL .
2406  */
yyrestart(FILE * input_file,yyscan_t yyscanner)2407     void yyrestart  (FILE * input_file , yyscan_t yyscanner)
2408 {
2409     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2410 
2411 	if ( ! YY_CURRENT_BUFFER ){
2412         yyensure_buffer_stack (yyscanner);
2413 		YY_CURRENT_BUFFER_LVALUE =
2414             yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
2415 	}
2416 
2417 	yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
2418 	yy_load_buffer_state( yyscanner );
2419 }
2420 
2421 /** Switch to a different input buffer.
2422  * @param new_buffer The new input buffer.
2423  * @param yyscanner The scanner object.
2424  */
yy_switch_to_buffer(YY_BUFFER_STATE new_buffer,yyscan_t yyscanner)2425     void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
2426 {
2427     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2428 
2429 	/* TODO. We should be able to replace this entire function body
2430 	 * with
2431 	 *		yypop_buffer_state();
2432 	 *		yypush_buffer_state(new_buffer);
2433      */
2434 	yyensure_buffer_stack (yyscanner);
2435 	if ( YY_CURRENT_BUFFER == new_buffer )
2436 		return;
2437 
2438 	if ( YY_CURRENT_BUFFER )
2439 		{
2440 		/* Flush out information for old buffer. */
2441 		*yyg->yy_c_buf_p = yyg->yy_hold_char;
2442 		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2443 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2444 		}
2445 
2446 	YY_CURRENT_BUFFER_LVALUE = new_buffer;
2447 	yy_load_buffer_state( yyscanner );
2448 
2449 	/* We don't actually know whether we did this switch during
2450 	 * EOF (yywrap()) processing, but the only time this flag
2451 	 * is looked at is after yywrap() is called, so it's safe
2452 	 * to go ahead and always set it.
2453 	 */
2454 	yyg->yy_did_buffer_switch_on_eof = 1;
2455 }
2456 
yy_load_buffer_state(yyscan_t yyscanner)2457 static void yy_load_buffer_state  (yyscan_t yyscanner)
2458 {
2459     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2460 	yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2461 	yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
2462 	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
2463 	yyg->yy_hold_char = *yyg->yy_c_buf_p;
2464 }
2465 
2466 /** Allocate and initialize an input buffer state.
2467  * @param file A readable stream.
2468  * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
2469  * @param yyscanner The scanner object.
2470  * @return the allocated buffer state.
2471  */
yy_create_buffer(FILE * file,int size,yyscan_t yyscanner)2472     YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
2473 {
2474 	YY_BUFFER_STATE b;
2475 
2476 	b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
2477 	if ( ! b )
2478 		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
2479 
2480 	b->yy_buf_size = size;
2481 
2482 	/* yy_ch_buf has to be 2 characters longer than the size given because
2483 	 * we need to put in 2 end-of-buffer characters.
2484 	 */
2485 	b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
2486 	if ( ! b->yy_ch_buf )
2487 		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
2488 
2489 	b->yy_is_our_buffer = 1;
2490 
2491 	yy_init_buffer( b, file , yyscanner);
2492 
2493 	return b;
2494 }
2495 
2496 /** Destroy the buffer.
2497  * @param b a buffer created with yy_create_buffer()
2498  * @param yyscanner The scanner object.
2499  */
yy_delete_buffer(YY_BUFFER_STATE b,yyscan_t yyscanner)2500     void yy_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
2501 {
2502     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2503 
2504 	if ( ! b )
2505 		return;
2506 
2507 	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
2508 		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
2509 
2510 	if ( b->yy_is_our_buffer )
2511 		yyfree( (void *) b->yy_ch_buf , yyscanner );
2512 
2513 	yyfree( (void *) b , yyscanner );
2514 }
2515 
2516 /* Initializes or reinitializes a buffer.
2517  * This function is sometimes called more than once on the same buffer,
2518  * such as during a yyrestart() or at EOF.
2519  */
yy_init_buffer(YY_BUFFER_STATE b,FILE * file,yyscan_t yyscanner)2520     static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
2521 
2522 {
2523 	int oerrno = errno;
2524     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2525 
2526 	yy_flush_buffer( b , yyscanner);
2527 
2528 	b->yy_input_file = file;
2529 	b->yy_fill_buffer = 1;
2530 
2531     /* If b is the current buffer, then yy_init_buffer was _probably_
2532      * called from yyrestart() or through yy_get_next_buffer.
2533      * In that case, we don't want to reset the lineno or column.
2534      */
2535     if (b != YY_CURRENT_BUFFER){
2536         b->yy_bs_lineno = 1;
2537         b->yy_bs_column = 0;
2538     }
2539 
2540         b->yy_is_interactive = 0;
2541 
2542 	errno = oerrno;
2543 }
2544 
2545 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2546  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2547  * @param yyscanner The scanner object.
2548  */
yy_flush_buffer(YY_BUFFER_STATE b,yyscan_t yyscanner)2549     void yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
2550 {
2551     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2552 	if ( ! b )
2553 		return;
2554 
2555 	b->yy_n_chars = 0;
2556 
2557 	/* We always need two end-of-buffer characters.  The first causes
2558 	 * a transition to the end-of-buffer state.  The second causes
2559 	 * a jam in that state.
2560 	 */
2561 	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2562 	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2563 
2564 	b->yy_buf_pos = &b->yy_ch_buf[0];
2565 
2566 	b->yy_at_bol = 1;
2567 	b->yy_buffer_status = YY_BUFFER_NEW;
2568 
2569 	if ( b == YY_CURRENT_BUFFER )
2570 		yy_load_buffer_state( yyscanner );
2571 }
2572 
2573 /** Pushes the new state onto the stack. The new state becomes
2574  *  the current state. This function will allocate the stack
2575  *  if necessary.
2576  *  @param new_buffer The new state.
2577  *  @param yyscanner The scanner object.
2578  */
yypush_buffer_state(YY_BUFFER_STATE new_buffer,yyscan_t yyscanner)2579 void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
2580 {
2581     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2582 	if (new_buffer == NULL)
2583 		return;
2584 
2585 	yyensure_buffer_stack(yyscanner);
2586 
2587 	/* This block is copied from yy_switch_to_buffer. */
2588 	if ( YY_CURRENT_BUFFER )
2589 		{
2590 		/* Flush out information for old buffer. */
2591 		*yyg->yy_c_buf_p = yyg->yy_hold_char;
2592 		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2593 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2594 		}
2595 
2596 	/* Only push if top exists. Otherwise, replace top. */
2597 	if (YY_CURRENT_BUFFER)
2598 		yyg->yy_buffer_stack_top++;
2599 	YY_CURRENT_BUFFER_LVALUE = new_buffer;
2600 
2601 	/* copied from yy_switch_to_buffer. */
2602 	yy_load_buffer_state( yyscanner );
2603 	yyg->yy_did_buffer_switch_on_eof = 1;
2604 }
2605 
2606 /** Removes and deletes the top of the stack, if present.
2607  *  The next element becomes the new top.
2608  *  @param yyscanner The scanner object.
2609  */
yypop_buffer_state(yyscan_t yyscanner)2610 void yypop_buffer_state (yyscan_t yyscanner)
2611 {
2612     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2613 	if (!YY_CURRENT_BUFFER)
2614 		return;
2615 
2616 	yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
2617 	YY_CURRENT_BUFFER_LVALUE = NULL;
2618 	if (yyg->yy_buffer_stack_top > 0)
2619 		--yyg->yy_buffer_stack_top;
2620 
2621 	if (YY_CURRENT_BUFFER) {
2622 		yy_load_buffer_state( yyscanner );
2623 		yyg->yy_did_buffer_switch_on_eof = 1;
2624 	}
2625 }
2626 
2627 /* Allocates the stack if it does not exist.
2628  *  Guarantees space for at least one push.
2629  */
yyensure_buffer_stack(yyscan_t yyscanner)2630 static void yyensure_buffer_stack (yyscan_t yyscanner)
2631 {
2632 	yy_size_t num_to_alloc;
2633     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2634 
2635 	if (!yyg->yy_buffer_stack) {
2636 
2637 		/* First allocation is just for 2 elements, since we don't know if this
2638 		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2639 		 * immediate realloc on the next call.
2640          */
2641       num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
2642 		yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
2643 								(num_to_alloc * sizeof(struct yy_buffer_state*)
2644 								, yyscanner);
2645 		if ( ! yyg->yy_buffer_stack )
2646 			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2647 
2648 		memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2649 
2650 		yyg->yy_buffer_stack_max = num_to_alloc;
2651 		yyg->yy_buffer_stack_top = 0;
2652 		return;
2653 	}
2654 
2655 	if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
2656 
2657 		/* Increase the buffer to prepare for a possible push. */
2658 		yy_size_t grow_size = 8 /* arbitrary grow size */;
2659 
2660 		num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
2661 		yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
2662 								(yyg->yy_buffer_stack,
2663 								num_to_alloc * sizeof(struct yy_buffer_state*)
2664 								, yyscanner);
2665 		if ( ! yyg->yy_buffer_stack )
2666 			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2667 
2668 		/* zero only the new slots.*/
2669 		memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
2670 		yyg->yy_buffer_stack_max = num_to_alloc;
2671 	}
2672 }
2673 
2674 /** Setup the input buffer state to scan directly from a user-specified character buffer.
2675  * @param base the character buffer
2676  * @param size the size in bytes of the character buffer
2677  * @param yyscanner The scanner object.
2678  * @return the newly allocated buffer state object.
2679  */
yy_scan_buffer(char * base,yy_size_t size,yyscan_t yyscanner)2680 YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
2681 {
2682 	YY_BUFFER_STATE b;
2683 
2684 	if ( size < 2 ||
2685 	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
2686 	     base[size-1] != YY_END_OF_BUFFER_CHAR )
2687 		/* They forgot to leave room for the EOB's. */
2688 		return NULL;
2689 
2690 	b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
2691 	if ( ! b )
2692 		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
2693 
2694 	b->yy_buf_size = (int) (size - 2);	/* "- 2" to take care of EOB's */
2695 	b->yy_buf_pos = b->yy_ch_buf = base;
2696 	b->yy_is_our_buffer = 0;
2697 	b->yy_input_file = NULL;
2698 	b->yy_n_chars = b->yy_buf_size;
2699 	b->yy_is_interactive = 0;
2700 	b->yy_at_bol = 1;
2701 	b->yy_fill_buffer = 0;
2702 	b->yy_buffer_status = YY_BUFFER_NEW;
2703 
2704 	yy_switch_to_buffer( b , yyscanner );
2705 
2706 	return b;
2707 }
2708 
2709 /** Setup the input buffer state to scan a string. The next call to yylex() will
2710  * scan from a @e copy of @a str.
2711  * @param yystr a NUL-terminated string to scan
2712  * @param yyscanner The scanner object.
2713  * @return the newly allocated buffer state object.
2714  * @note If you want to scan bytes that may contain NUL values, then use
2715  *       yy_scan_bytes() instead.
2716  */
yy_scan_string(const char * yystr,yyscan_t yyscanner)2717 YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
2718 {
2719 
2720 	return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
2721 }
2722 
2723 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
2724  * scan from a @e copy of @a bytes.
2725  * @param yybytes the byte buffer to scan
2726  * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2727  * @param yyscanner The scanner object.
2728  * @return the newly allocated buffer state object.
2729  */
yy_scan_bytes(const char * yybytes,int _yybytes_len,yyscan_t yyscanner)2730 YY_BUFFER_STATE yy_scan_bytes  (const char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
2731 {
2732 	YY_BUFFER_STATE b;
2733 	char *buf;
2734 	yy_size_t n;
2735 	int i;
2736 
2737 	/* Get memory for full buffer, including space for trailing EOB's. */
2738 	n = (yy_size_t) (_yybytes_len + 2);
2739 	buf = (char *) yyalloc( n , yyscanner );
2740 	if ( ! buf )
2741 		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
2742 
2743 	for ( i = 0; i < _yybytes_len; ++i )
2744 		buf[i] = yybytes[i];
2745 
2746 	buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2747 
2748 	b = yy_scan_buffer( buf, n , yyscanner);
2749 	if ( ! b )
2750 		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
2751 
2752 	/* It's okay to grow etc. this buffer, and we should throw it
2753 	 * away when we're done.
2754 	 */
2755 	b->yy_is_our_buffer = 1;
2756 
2757 	return b;
2758 }
2759 
2760 #ifndef YY_EXIT_FAILURE
2761 #define YY_EXIT_FAILURE 2
2762 #endif
2763 
yy_fatal_error(const char * msg,yyscan_t yyscanner)2764 static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
2765 {
2766 	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2767 	(void)yyg;
2768 	fprintf( stderr, "%s\n", msg );
2769 	exit( YY_EXIT_FAILURE );
2770 }
2771 
2772 /* Redefine yyless() so it works in section 3 code. */
2773 
2774 #undef yyless
2775 #define yyless(n) \
2776 	do \
2777 		{ \
2778 		/* Undo effects of setting up yytext. */ \
2779         int yyless_macro_arg = (n); \
2780         YY_LESS_LINENO(yyless_macro_arg);\
2781 		yytext[yyleng] = yyg->yy_hold_char; \
2782 		yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
2783 		yyg->yy_hold_char = *yyg->yy_c_buf_p; \
2784 		*yyg->yy_c_buf_p = '\0'; \
2785 		yyleng = yyless_macro_arg; \
2786 		} \
2787 	while ( 0 )
2788 
2789 /* Accessor  methods (get/set functions) to struct members. */
2790 
2791 /** Get the user-defined data for this scanner.
2792  * @param yyscanner The scanner object.
2793  */
yyget_extra(yyscan_t yyscanner)2794 YY_EXTRA_TYPE yyget_extra  (yyscan_t yyscanner)
2795 {
2796     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2797     return yyextra;
2798 }
2799 
2800 /** Get the current line number.
2801  * @param yyscanner The scanner object.
2802  */
yyget_lineno(yyscan_t yyscanner)2803 int yyget_lineno  (yyscan_t yyscanner)
2804 {
2805     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2806 
2807         if (! YY_CURRENT_BUFFER)
2808             return 0;
2809 
2810     return yylineno;
2811 }
2812 
2813 /** Get the current column number.
2814  * @param yyscanner The scanner object.
2815  */
yyget_column(yyscan_t yyscanner)2816 int yyget_column  (yyscan_t yyscanner)
2817 {
2818     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2819 
2820         if (! YY_CURRENT_BUFFER)
2821             return 0;
2822 
2823     return yycolumn;
2824 }
2825 
2826 /** Get the input stream.
2827  * @param yyscanner The scanner object.
2828  */
yyget_in(yyscan_t yyscanner)2829 FILE *yyget_in  (yyscan_t yyscanner)
2830 {
2831     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2832     return yyin;
2833 }
2834 
2835 /** Get the output stream.
2836  * @param yyscanner The scanner object.
2837  */
yyget_out(yyscan_t yyscanner)2838 FILE *yyget_out  (yyscan_t yyscanner)
2839 {
2840     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2841     return yyout;
2842 }
2843 
2844 /** Get the length of the current token.
2845  * @param yyscanner The scanner object.
2846  */
yyget_leng(yyscan_t yyscanner)2847 int yyget_leng  (yyscan_t yyscanner)
2848 {
2849     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2850     return yyleng;
2851 }
2852 
2853 /** Get the current token.
2854  * @param yyscanner The scanner object.
2855  */
2856 
yyget_text(yyscan_t yyscanner)2857 char *yyget_text  (yyscan_t yyscanner)
2858 {
2859     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2860     return yytext;
2861 }
2862 
2863 /** Set the user-defined data. This data is never touched by the scanner.
2864  * @param user_defined The data to be associated with this scanner.
2865  * @param yyscanner The scanner object.
2866  */
yyset_extra(YY_EXTRA_TYPE user_defined,yyscan_t yyscanner)2867 void yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
2868 {
2869     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2870     yyextra = user_defined ;
2871 }
2872 
2873 /** Set the current line number.
2874  * @param _line_number line number
2875  * @param yyscanner The scanner object.
2876  */
yyset_lineno(int _line_number,yyscan_t yyscanner)2877 void yyset_lineno (int  _line_number , yyscan_t yyscanner)
2878 {
2879     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2880 
2881         /* lineno is only valid if an input buffer exists. */
2882         if (! YY_CURRENT_BUFFER )
2883            YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
2884 
2885     yylineno = _line_number;
2886 }
2887 
2888 /** Set the current column.
2889  * @param _column_no column number
2890  * @param yyscanner The scanner object.
2891  */
yyset_column(int _column_no,yyscan_t yyscanner)2892 void yyset_column (int  _column_no , yyscan_t yyscanner)
2893 {
2894     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2895 
2896         /* column is only valid if an input buffer exists. */
2897         if (! YY_CURRENT_BUFFER )
2898            YY_FATAL_ERROR( "yyset_column called with no buffer" );
2899 
2900     yycolumn = _column_no;
2901 }
2902 
2903 /** Set the input stream. This does not discard the current
2904  * input buffer.
2905  * @param _in_str A readable stream.
2906  * @param yyscanner The scanner object.
2907  * @see yy_switch_to_buffer
2908  */
yyset_in(FILE * _in_str,yyscan_t yyscanner)2909 void yyset_in (FILE *  _in_str , yyscan_t yyscanner)
2910 {
2911     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2912     yyin = _in_str ;
2913 }
2914 
yyset_out(FILE * _out_str,yyscan_t yyscanner)2915 void yyset_out (FILE *  _out_str , yyscan_t yyscanner)
2916 {
2917     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2918     yyout = _out_str ;
2919 }
2920 
yyget_debug(yyscan_t yyscanner)2921 int yyget_debug  (yyscan_t yyscanner)
2922 {
2923     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2924     return yy_flex_debug;
2925 }
2926 
yyset_debug(int _bdebug,yyscan_t yyscanner)2927 void yyset_debug (int  _bdebug , yyscan_t yyscanner)
2928 {
2929     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2930     yy_flex_debug = _bdebug ;
2931 }
2932 
2933 /* Accessor methods for yylval and yylloc */
2934 
yyget_lval(yyscan_t yyscanner)2935 YYSTYPE * yyget_lval  (yyscan_t yyscanner)
2936 {
2937     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2938     return yylval;
2939 }
2940 
yyset_lval(YYSTYPE * yylval_param,yyscan_t yyscanner)2941 void yyset_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)
2942 {
2943     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2944     yylval = yylval_param;
2945 }
2946 
2947 /* User-visible API */
2948 
2949 /* yylex_init is special because it creates the scanner itself, so it is
2950  * the ONLY reentrant function that doesn't take the scanner as the last argument.
2951  * That's why we explicitly handle the declaration, instead of using our macros.
2952  */
yylex_init(yyscan_t * ptr_yy_globals)2953 int yylex_init(yyscan_t* ptr_yy_globals)
2954 {
2955     if (ptr_yy_globals == NULL){
2956         errno = EINVAL;
2957         return 1;
2958     }
2959 
2960     *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
2961 
2962     if (*ptr_yy_globals == NULL){
2963         errno = ENOMEM;
2964         return 1;
2965     }
2966 
2967     /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2968     memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2969 
2970     return yy_init_globals ( *ptr_yy_globals );
2971 }
2972 
2973 /* yylex_init_extra has the same functionality as yylex_init, but follows the
2974  * convention of taking the scanner as the last argument. Note however, that
2975  * this is a *pointer* to a scanner, as it will be allocated by this call (and
2976  * is the reason, too, why this function also must handle its own declaration).
2977  * The user defined value in the first argument will be available to yyalloc in
2978  * the yyextra field.
2979  */
yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t * ptr_yy_globals)2980 int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
2981 {
2982     struct yyguts_t dummy_yyguts;
2983 
2984     yyset_extra (yy_user_defined, &dummy_yyguts);
2985 
2986     if (ptr_yy_globals == NULL){
2987         errno = EINVAL;
2988         return 1;
2989     }
2990 
2991     *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2992 
2993     if (*ptr_yy_globals == NULL){
2994         errno = ENOMEM;
2995         return 1;
2996     }
2997 
2998     /* By setting to 0xAA, we expose bugs in
2999     yy_init_globals. Leave at 0x00 for releases. */
3000     memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
3001 
3002     yyset_extra (yy_user_defined, *ptr_yy_globals);
3003 
3004     return yy_init_globals ( *ptr_yy_globals );
3005 }
3006 
yy_init_globals(yyscan_t yyscanner)3007 static int yy_init_globals (yyscan_t yyscanner)
3008 {
3009     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3010     /* Initialization is the same as for the non-reentrant scanner.
3011      * This function is called from yylex_destroy(), so don't allocate here.
3012      */
3013 
3014     yyg->yy_buffer_stack = NULL;
3015     yyg->yy_buffer_stack_top = 0;
3016     yyg->yy_buffer_stack_max = 0;
3017     yyg->yy_c_buf_p = NULL;
3018     yyg->yy_init = 0;
3019     yyg->yy_start = 0;
3020 
3021     yyg->yy_start_stack_ptr = 0;
3022     yyg->yy_start_stack_depth = 0;
3023     yyg->yy_start_stack =  NULL;
3024 
3025 /* Defined in main.c */
3026 #ifdef YY_STDINIT
3027     yyin = stdin;
3028     yyout = stdout;
3029 #else
3030     yyin = NULL;
3031     yyout = NULL;
3032 #endif
3033 
3034     /* For future reference: Set errno on error, since we are called by
3035      * yylex_init()
3036      */
3037     return 0;
3038 }
3039 
3040 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
yylex_destroy(yyscan_t yyscanner)3041 int yylex_destroy  (yyscan_t yyscanner)
3042 {
3043     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3044 
3045     /* Pop the buffer stack, destroying each element. */
3046 	while(YY_CURRENT_BUFFER){
3047 		yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
3048 		YY_CURRENT_BUFFER_LVALUE = NULL;
3049 		yypop_buffer_state(yyscanner);
3050 	}
3051 
3052 	/* Destroy the stack itself. */
3053 	yyfree(yyg->yy_buffer_stack , yyscanner);
3054 	yyg->yy_buffer_stack = NULL;
3055 
3056     /* Destroy the start condition stack. */
3057         yyfree( yyg->yy_start_stack , yyscanner );
3058         yyg->yy_start_stack = NULL;
3059 
3060     /* Reset the globals. This is important in a non-reentrant scanner so the next time
3061      * yylex() is called, initialization will occur. */
3062     yy_init_globals( yyscanner);
3063 
3064     /* Destroy the main struct (reentrant only). */
3065     yyfree ( yyscanner , yyscanner );
3066     yyscanner = NULL;
3067     return 0;
3068 }
3069 
3070 /*
3071  * Internal utility routines.
3072  */
3073 
3074 #ifndef yytext_ptr
yy_flex_strncpy(char * s1,const char * s2,int n,yyscan_t yyscanner)3075 static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
3076 {
3077 	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3078 	(void)yyg;
3079 
3080 	int i;
3081 	for ( i = 0; i < n; ++i )
3082 		s1[i] = s2[i];
3083 }
3084 #endif
3085 
3086 #ifdef YY_NEED_STRLEN
yy_flex_strlen(const char * s,yyscan_t yyscanner)3087 static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
3088 {
3089 	int n;
3090 	for ( n = 0; s[n]; ++n )
3091 		;
3092 
3093 	return n;
3094 }
3095 #endif
3096 
yyalloc(yy_size_t size,yyscan_t yyscanner)3097 void *yyalloc (yy_size_t  size , yyscan_t yyscanner)
3098 {
3099 	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3100 	(void)yyg;
3101 	return malloc(size);
3102 }
3103 
yyrealloc(void * ptr,yy_size_t size,yyscan_t yyscanner)3104 void *yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
3105 {
3106 	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3107 	(void)yyg;
3108 
3109 	/* The cast to (char *) in the following accommodates both
3110 	 * implementations that use char* generic pointers, and those
3111 	 * that use void* generic pointers.  It works with the latter
3112 	 * because both ANSI C and C++ allow castless assignment from
3113 	 * any pointer type to void*, and deal with argument conversions
3114 	 * as though doing an assignment.
3115 	 */
3116 	return realloc(ptr, size);
3117 }
3118 
yyfree(void * ptr,yyscan_t yyscanner)3119 void yyfree (void * ptr , yyscan_t yyscanner)
3120 {
3121 	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3122 	(void)yyg;
3123 	free( (char *) ptr );	/* see yyrealloc() for (char *) cast */
3124 }
3125 
3126 #define YYTABLES_NAME "yytables"
3127 
3128 #line 475 "psqlscanslash.l"
3129 
3130 
3131 /* LCOV_EXCL_STOP */
3132 
3133 /*
3134  * Scan the command name of a psql backslash command.  This should be called
3135  * after psql_scan() returns PSCAN_BACKSLASH.  It is assumed that the input
3136  * has been consumed through the leading backslash.
3137  *
3138  * The return value is a malloc'd copy of the command name, as parsed off
3139  * from the input.
3140  */
3141 char *
psql_scan_slash_command(PsqlScanState state)3142 psql_scan_slash_command(PsqlScanState state)
3143 {
3144 	PQExpBufferData mybuf;
3145 
3146 	/* Must be scanning already */
3147 	Assert(state->scanbufhandle != NULL);
3148 
3149 	/* Build a local buffer that we'll return the data of */
3150 	initPQExpBuffer(&mybuf);
3151 
3152 	/* Set current output target */
3153 	state->output_buf = &mybuf;
3154 
3155 	/* Set input source */
3156 	if (state->buffer_stack != NULL)
3157 		yy_switch_to_buffer(state->buffer_stack->buf, state->scanner);
3158 	else
3159 		yy_switch_to_buffer(state->scanbufhandle, state->scanner);
3160 
3161 	/*
3162 	 * Set lexer start state.  Note that this is sufficient to switch
3163 	 * state->scanner over to using the tables in this lexer file.
3164 	 */
3165 	state->start_state = xslashcmd;
3166 
3167 	/* And lex. */
3168 	yylex(NULL, state->scanner);
3169 
3170 	/* There are no possible errors in this lex state... */
3171 
3172 	/*
3173 	 * In case the caller returns to using the regular SQL lexer, reselect the
3174 	 * appropriate initial state.
3175 	 */
3176 	psql_scan_reselect_sql_lexer(state);
3177 
3178 	return mybuf.data;
3179 }
3180 
3181 /*
3182  * Parse off the next argument for a backslash command, and return it as a
3183  * malloc'd string.  If there are no more arguments, returns NULL.
3184  *
3185  * type tells what processing, if any, to perform on the option string;
3186  * for example, if it's a SQL identifier, we want to downcase any unquoted
3187  * letters.
3188  *
3189  * if quote is not NULL, *quote is set to 0 if no quoting was found, else
3190  * the last quote symbol used in the argument.
3191  *
3192  * if semicolon is true, unquoted trailing semicolon(s) that would otherwise
3193  * be taken as part of the option string will be stripped.
3194  *
3195  * NOTE: the only possible syntax errors for backslash options are unmatched
3196  * quotes, which are detected when we run out of input.  Therefore, on a
3197  * syntax error we just throw away the string and return NULL; there is no
3198  * need to worry about flushing remaining input.
3199  */
3200 char *
psql_scan_slash_option(PsqlScanState state,enum slash_option_type type,char * quote,bool semicolon)3201 psql_scan_slash_option(PsqlScanState state,
3202 					   enum slash_option_type type,
3203 					   char *quote,
3204 					   bool semicolon)
3205 {
3206 	PQExpBufferData mybuf;
3207 	int			lexresult PG_USED_FOR_ASSERTS_ONLY;
3208 	int			final_state;
3209 	char		local_quote;
3210 
3211 	/* Must be scanning already */
3212 	Assert(state->scanbufhandle != NULL);
3213 
3214 	if (quote == NULL)
3215 		quote = &local_quote;
3216 	*quote = 0;
3217 
3218 	/* Build a local buffer that we'll return the data of */
3219 	initPQExpBuffer(&mybuf);
3220 
3221 	/* Set up static variables that will be used by yylex */
3222 	option_type = type;
3223 	option_quote = quote;
3224 	unquoted_option_chars = 0;
3225 
3226 	/* Set current output target */
3227 	state->output_buf = &mybuf;
3228 
3229 	/* Set input source */
3230 	if (state->buffer_stack != NULL)
3231 		yy_switch_to_buffer(state->buffer_stack->buf, state->scanner);
3232 	else
3233 		yy_switch_to_buffer(state->scanbufhandle, state->scanner);
3234 
3235 	/* Set lexer start state */
3236 	if (type == OT_WHOLE_LINE)
3237 		state->start_state = xslashwholeline;
3238 	else
3239 		state->start_state = xslashargstart;
3240 
3241 	/* And lex. */
3242 	lexresult = yylex(NULL, state->scanner);
3243 
3244 	/* Save final state for a moment... */
3245 	final_state = state->start_state;
3246 
3247 	/*
3248 	 * In case the caller returns to using the regular SQL lexer, reselect the
3249 	 * appropriate initial state.
3250 	 */
3251 	psql_scan_reselect_sql_lexer(state);
3252 
3253 	/*
3254 	 * Check the lex result: we should have gotten back either LEXRES_OK
3255 	 * or LEXRES_EOL (the latter indicating end of string).  If we were inside
3256 	 * a quoted string, as indicated by final_state, EOL is an error.
3257 	 */
3258 	Assert(lexresult == LEXRES_EOL || lexresult == LEXRES_OK);
3259 
3260 	switch (final_state)
3261 	{
3262 		case xslashargstart:
3263 			/* empty arg */
3264 			break;
3265 		case xslasharg:
3266 			/* Strip any unquoted trailing semi-colons if requested */
3267 			if (semicolon)
3268 			{
3269 				while (unquoted_option_chars-- > 0 &&
3270 					   mybuf.len > 0 &&
3271 					   mybuf.data[mybuf.len - 1] == ';')
3272 				{
3273 					mybuf.data[--mybuf.len] = '\0';
3274 				}
3275 			}
3276 
3277 			/*
3278 			 * If SQL identifier processing was requested, then we strip out
3279 			 * excess double quotes and optionally downcase unquoted letters.
3280 			 */
3281 			if (type == OT_SQLID || type == OT_SQLIDHACK)
3282 			{
3283 				dequote_downcase_identifier(mybuf.data,
3284 											(type != OT_SQLIDHACK),
3285 											state->encoding);
3286 				/* update mybuf.len for possible shortening */
3287 				mybuf.len = strlen(mybuf.data);
3288 			}
3289 			break;
3290 		case xslashquote:
3291 		case xslashbackquote:
3292 		case xslashdquote:
3293 			/* must have hit EOL inside quotes */
3294 			pg_log_error("unterminated quoted string");
3295 			termPQExpBuffer(&mybuf);
3296 			return NULL;
3297 		case xslashwholeline:
3298 			/* always okay */
3299 			break;
3300 		default:
3301 			/* can't get here */
3302 			fprintf(stderr, "invalid YY_START\n");
3303 			exit(1);
3304 	}
3305 
3306 	/*
3307 	 * An unquoted empty argument isn't possible unless we are at end of
3308 	 * command.  Return NULL instead.
3309 	 */
3310 	if (mybuf.len == 0 && *quote == 0)
3311 	{
3312 		termPQExpBuffer(&mybuf);
3313 		return NULL;
3314 	}
3315 
3316 	/* Else return the completed string. */
3317 	return mybuf.data;
3318 }
3319 
3320 /*
3321  * Eat up any unused \\ to complete a backslash command.
3322  */
3323 void
psql_scan_slash_command_end(PsqlScanState state)3324 psql_scan_slash_command_end(PsqlScanState state)
3325 {
3326 	/* Must be scanning already */
3327 	Assert(state->scanbufhandle != NULL);
3328 
3329 	/* Set current output target */
3330 	state->output_buf = NULL;	/* we won't output anything */
3331 
3332 	/* Set input source */
3333 	if (state->buffer_stack != NULL)
3334 		yy_switch_to_buffer(state->buffer_stack->buf, state->scanner);
3335 	else
3336 		yy_switch_to_buffer(state->scanbufhandle, state->scanner);
3337 
3338 	/* Set lexer start state */
3339 	state->start_state = xslashend;
3340 
3341 	/* And lex. */
3342 	yylex(NULL, state->scanner);
3343 
3344 	/* There are no possible errors in this lex state... */
3345 
3346 	/*
3347 	 * We expect the caller to return to using the regular SQL lexer, so
3348 	 * reselect the appropriate initial state.
3349 	 */
3350 	psql_scan_reselect_sql_lexer(state);
3351 }
3352 
3353 /*
3354  * Fetch current paren nesting depth
3355  */
3356 int
psql_scan_get_paren_depth(PsqlScanState state)3357 psql_scan_get_paren_depth(PsqlScanState state)
3358 {
3359 	return state->paren_depth;
3360 }
3361 
3362 /*
3363  * Set paren nesting depth
3364  */
3365 void
psql_scan_set_paren_depth(PsqlScanState state,int depth)3366 psql_scan_set_paren_depth(PsqlScanState state, int depth)
3367 {
3368 	Assert(depth >= 0);
3369 	state->paren_depth = depth;
3370 }
3371 
3372 /*
3373  * De-quote and optionally downcase a SQL identifier.
3374  *
3375  * The string at *str is modified in-place; it can become shorter,
3376  * but not longer.
3377  *
3378  * If downcase is true then non-quoted letters are folded to lower case.
3379  * Ideally this behavior will match the backend's downcase_identifier();
3380  * but note that it could differ if LC_CTYPE is different in the frontend.
3381  *
3382  * Note that a string like FOO"BAR"BAZ will be converted to fooBARbaz;
3383  * this is somewhat inconsistent with the SQL spec, which would have us
3384  * parse it as several identifiers.  But for psql's purposes, we want a
3385  * string like "foo"."bar" to be treated as one option, so there's little
3386  * choice; this routine doesn't get to change the token boundaries.
3387  */
3388 void
dequote_downcase_identifier(char * str,bool downcase,int encoding)3389 dequote_downcase_identifier(char *str, bool downcase, int encoding)
3390 {
3391 	bool		inquotes = false;
3392 	char	   *cp = str;
3393 
3394 	while (*cp)
3395 	{
3396 		if (*cp == '"')
3397 		{
3398 			if (inquotes && cp[1] == '"')
3399 			{
3400 				/* Keep the first quote, remove the second */
3401 				cp++;
3402 			}
3403 			else
3404 				inquotes = !inquotes;
3405 			/* Collapse out quote at *cp */
3406 			memmove(cp, cp + 1, strlen(cp));
3407 			/* do not advance cp */
3408 		}
3409 		else
3410 		{
3411 			if (downcase && !inquotes)
3412 				*cp = pg_tolower((unsigned char) *cp);
3413 			cp += PQmblenBounded(cp, encoding);
3414 		}
3415 	}
3416 }
3417 
3418 /*
3419  * Evaluate a backticked substring of a slash command's argument.
3420  *
3421  * The portion of output_buf starting at backtick_start_offset is evaluated
3422  * as a shell command and then replaced by the command's output.
3423  */
3424 static void
evaluate_backtick(PsqlScanState state)3425 evaluate_backtick(PsqlScanState state)
3426 {
3427 	PQExpBuffer output_buf = state->output_buf;
3428 	char	   *cmd = output_buf->data + backtick_start_offset;
3429 	PQExpBufferData cmd_output;
3430 	FILE	   *fd;
3431 	bool		error = false;
3432 	char		buf[512];
3433 	size_t		result;
3434 
3435 	initPQExpBuffer(&cmd_output);
3436 
3437 	fd = popen(cmd, "r");
3438 	if (!fd)
3439 	{
3440 		pg_log_error("%s: %m", cmd);
3441 		error = true;
3442 	}
3443 
3444 	if (!error)
3445 	{
3446 		do
3447 		{
3448 			result = fread(buf, 1, sizeof(buf), fd);
3449 			if (ferror(fd))
3450 			{
3451 				pg_log_error("%s: %m", cmd);
3452 				error = true;
3453 				break;
3454 			}
3455 			appendBinaryPQExpBuffer(&cmd_output, buf, result);
3456 		} while (!feof(fd));
3457 	}
3458 
3459 	if (fd && pclose(fd) == -1)
3460 	{
3461 		pg_log_error("%s: %m", cmd);
3462 		error = true;
3463 	}
3464 
3465 	if (PQExpBufferDataBroken(cmd_output))
3466 	{
3467 		pg_log_error("%s: out of memory", cmd);
3468 		error = true;
3469 	}
3470 
3471 	/* Now done with cmd, delete it from output_buf */
3472 	output_buf->len = backtick_start_offset;
3473 	output_buf->data[output_buf->len] = '\0';
3474 
3475 	/* If no error, transfer result to output_buf */
3476 	if (!error)
3477 	{
3478 		/* strip any trailing newline (but only one) */
3479 		if (cmd_output.len > 0 &&
3480 			cmd_output.data[cmd_output.len - 1] == '\n')
3481 			cmd_output.len--;
3482 		appendBinaryPQExpBuffer(output_buf, cmd_output.data, cmd_output.len);
3483 	}
3484 
3485 	termPQExpBuffer(&cmd_output);
3486 }
3487 
3488