1 #line 2 "scan.c"
2 #line 2 "scan.l"
3 /*-------------------------------------------------------------------------
4  *
5  * scan.l
6  *	  lexical scanner for PostgreSQL
7  *
8  * NOTE NOTE NOTE:
9  *
10  * The rules in this file must be kept in sync with src/fe_utils/psqlscan.l!
11  *
12  * The rules are designed so that the scanner never has to backtrack,
13  * in the sense that there is always a rule that can match the input
14  * consumed so far (the rule action may internally throw back some input
15  * with yyless(), however).  As explained in the flex manual, this makes
16  * for a useful speed increase --- about a third faster than a plain -CF
17  * lexer, in simple testing.  The extra complexity is mostly in the rules
18  * for handling float numbers and continued string literals.  If you change
19  * the lexical rules, verify that you haven't broken the no-backtrack
20  * property by running flex with the "-b" option and checking that the
21  * resulting "lex.backup" file says that no backing up is needed.  (As of
22  * Postgres 9.2, this check is made automatically by the Makefile.)
23  *
24  *
25  * Portions Copyright (c) 2003-2018, PgPool Global Development Group
26  * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
27  * Portions Copyright (c) 1994, Regents of the University of California
28  *
29  * IDENTIFICATION
30  *	  src/backend/parser/scan.l
31  *
32  *-------------------------------------------------------------------------
33  */
34 #include "pool_parser.h"
35 
36 #include <ctype.h>
37 #include <unistd.h>
38 
39 #include "parser.h"				/* only needed for GUC variables */
40 #include "scanner.h"
41 #include "gramparse.h"
42 #include "scansup.h"
43 #include "pg_wchar.h"
44 
45 #include "gram.h"
46 #include "utils/palloc.h"
47 #include "utils/elog.h"
48 
49 
50 
51 #line 52 "scan.c"
52 
53 #define  YY_INT_ALIGNED short int
54 
55 /* A lexical scanner generated by flex */
56 
57 #define FLEX_SCANNER
58 #define YY_FLEX_MAJOR_VERSION 2
59 #define YY_FLEX_MINOR_VERSION 5
60 #define YY_FLEX_SUBMINOR_VERSION 37
61 #if YY_FLEX_SUBMINOR_VERSION > 0
62 #define FLEX_BETA
63 #endif
64 
65 /* First, we deal with  platform-specific or compiler-specific issues. */
66 
67 /* begin standard C headers. */
68 #include <stdio.h>
69 #include <string.h>
70 #include <errno.h>
71 #include <stdlib.h>
72 
73 /* end standard C headers. */
74 
75 /* flex integer type definitions */
76 
77 #ifndef FLEXINT_H
78 #define FLEXINT_H
79 
80 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
81 
82 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
83 
84 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
85  * if you want the limit (max/min) macros for int types.
86  */
87 #ifndef __STDC_LIMIT_MACROS
88 #define __STDC_LIMIT_MACROS 1
89 #endif
90 
91 #include <inttypes.h>
92 typedef int8_t flex_int8_t;
93 typedef uint8_t flex_uint8_t;
94 typedef int16_t flex_int16_t;
95 typedef uint16_t flex_uint16_t;
96 typedef int32_t flex_int32_t;
97 typedef uint32_t flex_uint32_t;
98 #else
99 typedef signed char flex_int8_t;
100 typedef short int flex_int16_t;
101 typedef int flex_int32_t;
102 typedef unsigned char flex_uint8_t;
103 typedef unsigned short int flex_uint16_t;
104 typedef unsigned int flex_uint32_t;
105 
106 /* Limits of integral types. */
107 #ifndef INT8_MIN
108 #define INT8_MIN               (-128)
109 #endif
110 #ifndef INT16_MIN
111 #define INT16_MIN              (-32767-1)
112 #endif
113 #ifndef INT32_MIN
114 #define INT32_MIN              (-2147483647-1)
115 #endif
116 #ifndef INT8_MAX
117 #define INT8_MAX               (127)
118 #endif
119 #ifndef INT16_MAX
120 #define INT16_MAX              (32767)
121 #endif
122 #ifndef INT32_MAX
123 #define INT32_MAX              (2147483647)
124 #endif
125 #ifndef UINT8_MAX
126 #define UINT8_MAX              (255U)
127 #endif
128 #ifndef UINT16_MAX
129 #define UINT16_MAX             (65535U)
130 #endif
131 #ifndef UINT32_MAX
132 #define UINT32_MAX             (4294967295U)
133 #endif
134 
135 #endif /* ! C99 */
136 
137 #endif /* ! FLEXINT_H */
138 
139 #ifdef __cplusplus
140 
141 /* The "const" storage-class-modifier is valid. */
142 #define YY_USE_CONST
143 
144 #else	/* ! __cplusplus */
145 
146 /* C99 requires __STDC__ to be defined as 1. */
147 #if defined (__STDC__)
148 
149 #define YY_USE_CONST
150 
151 #endif	/* defined (__STDC__) */
152 #endif	/* ! __cplusplus */
153 
154 #ifdef YY_USE_CONST
155 #define yyconst const
156 #else
157 #define yyconst
158 #endif
159 
160 /* Returned upon end-of-file. */
161 #define YY_NULL 0
162 
163 /* Promotes a possibly negative, possibly signed char to an unsigned
164  * integer for use as an array index.  If the signed char is negative,
165  * we want to instead treat it as an 8-bit unsigned char, hence the
166  * double cast.
167  */
168 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
169 
170 /* An opaque pointer. */
171 #ifndef YY_TYPEDEF_YY_SCANNER_T
172 #define YY_TYPEDEF_YY_SCANNER_T
173 typedef void* yyscan_t;
174 #endif
175 
176 /* For convenience, these vars (plus the bison vars far below)
177    are macros in the reentrant scanner. */
178 #define yyin yyg->yyin_r
179 #define yyout yyg->yyout_r
180 #define yyextra yyg->yyextra_r
181 #define yyleng yyg->yyleng_r
182 #define yytext yyg->yytext_r
183 #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
184 #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
185 #define yy_flex_debug yyg->yy_flex_debug_r
186 
187 /* Enter a start condition.  This macro really ought to take a parameter,
188  * but we do it the disgusting crufty way forced on us by the ()-less
189  * definition of BEGIN.
190  */
191 #define BEGIN yyg->yy_start = 1 + 2 *
192 
193 /* Translate the current start state into a value that can be later handed
194  * to BEGIN to return to the state.  The YYSTATE alias is for lex
195  * compatibility.
196  */
197 #define YY_START ((yyg->yy_start - 1) / 2)
198 #define YYSTATE YY_START
199 
200 /* Action number for EOF rule of a given start state. */
201 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
202 
203 /* Special action meaning "start processing a new file". */
204 #define YY_NEW_FILE core_yyrestart(yyin ,yyscanner )
205 
206 #define YY_END_OF_BUFFER_CHAR 0
207 
208 /* Size of default input buffer. */
209 #ifndef YY_BUF_SIZE
210 #define YY_BUF_SIZE 16384
211 #endif
212 
213 /* The state buf must be large enough to hold one state per character in the main buffer.
214  */
215 #define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
216 
217 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
218 #define YY_TYPEDEF_YY_BUFFER_STATE
219 typedef struct yy_buffer_state *YY_BUFFER_STATE;
220 #endif
221 
222 #ifndef YY_TYPEDEF_YY_SIZE_T
223 #define YY_TYPEDEF_YY_SIZE_T
224 typedef size_t yy_size_t;
225 #endif
226 
227 #define EOB_ACT_CONTINUE_SCAN 0
228 #define EOB_ACT_END_OF_FILE 1
229 #define EOB_ACT_LAST_MATCH 2
230 
231     #define YY_LESS_LINENO(n)
232 
233 /* Return all but the first "n" matched characters back to the input stream. */
234 #define yyless(n) \
235 	do \
236 		{ \
237 		/* Undo effects of setting up yytext. */ \
238         int yyless_macro_arg = (n); \
239         YY_LESS_LINENO(yyless_macro_arg);\
240 		*yy_cp = yyg->yy_hold_char; \
241 		YY_RESTORE_YY_MORE_OFFSET \
242 		yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
243 		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
244 		} \
245 	while ( 0 )
246 
247 #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
248 
249 #ifndef YY_STRUCT_YY_BUFFER_STATE
250 #define YY_STRUCT_YY_BUFFER_STATE
251 struct yy_buffer_state
252 	{
253 	FILE *yy_input_file;
254 
255 	char *yy_ch_buf;		/* input buffer */
256 	char *yy_buf_pos;		/* current position in input buffer */
257 
258 	/* Size of input buffer in bytes, not including room for EOB
259 	 * characters.
260 	 */
261 	yy_size_t yy_buf_size;
262 
263 	/* Number of characters read into yy_ch_buf, not including EOB
264 	 * characters.
265 	 */
266 	yy_size_t yy_n_chars;
267 
268 	/* Whether we "own" the buffer - i.e., we know we created it,
269 	 * and can realloc() it to grow it, and should free() it to
270 	 * delete it.
271 	 */
272 	int yy_is_our_buffer;
273 
274 	/* Whether this is an "interactive" input source; if so, and
275 	 * if we're using stdio for input, then we want to use getc()
276 	 * instead of fread(), to make sure we stop fetching input after
277 	 * each newline.
278 	 */
279 	int yy_is_interactive;
280 
281 	/* Whether we're considered to be at the beginning of a line.
282 	 * If so, '^' rules will be active on the next match, otherwise
283 	 * not.
284 	 */
285 	int yy_at_bol;
286 
287     int yy_bs_lineno; /**< The line count. */
288     int yy_bs_column; /**< The column count. */
289 
290 	/* Whether to try to fill the input buffer when we reach the
291 	 * end of it.
292 	 */
293 	int yy_fill_buffer;
294 
295 	int yy_buffer_status;
296 
297 #define YY_BUFFER_NEW 0
298 #define YY_BUFFER_NORMAL 1
299 	/* When an EOF's been seen but there's still some text to process
300 	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
301 	 * shouldn't try reading from the input source any more.  We might
302 	 * still have a bunch of tokens to match, though, because of
303 	 * possible backing-up.
304 	 *
305 	 * When we actually see the EOF, we change the status to "new"
306 	 * (via core_yyrestart()), so that the user can continue scanning by
307 	 * just pointing yyin at a new input file.
308 	 */
309 #define YY_BUFFER_EOF_PENDING 2
310 
311 	};
312 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
313 
314 /* We provide macros for accessing buffer states in case in the
315  * future we want to put the buffer states in a more general
316  * "scanner state".
317  *
318  * Returns the top of the stack, or NULL.
319  */
320 #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
321                           ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
322                           : NULL)
323 
324 /* Same as previous macro, but useful when we know that the buffer stack is not
325  * NULL or when we need an lvalue. For internal use only.
326  */
327 #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
328 
329 void core_yyrestart (FILE *input_file ,yyscan_t yyscanner );
330 void core_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
331 YY_BUFFER_STATE core_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
332 void core_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
333 void core_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
334 void core_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
335 void core_yypop_buffer_state (yyscan_t yyscanner );
336 
337 static void core_yyensure_buffer_stack (yyscan_t yyscanner );
338 static void core_yy_load_buffer_state (yyscan_t yyscanner );
339 static void core_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
340 
341 #define YY_FLUSH_BUFFER core_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
342 
343 YY_BUFFER_STATE core_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
344 YY_BUFFER_STATE core_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
345 YY_BUFFER_STATE core_yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
346 
347 void *core_yyalloc (yy_size_t ,yyscan_t yyscanner );
348 void *core_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
349 void core_yyfree (void * ,yyscan_t yyscanner );
350 
351 #define yy_new_buffer core_yy_create_buffer
352 
353 #define yy_set_interactive(is_interactive) \
354 	{ \
355 	if ( ! YY_CURRENT_BUFFER ){ \
356         core_yyensure_buffer_stack (yyscanner); \
357 		YY_CURRENT_BUFFER_LVALUE =    \
358             core_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
359 	} \
360 	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
361 	}
362 
363 #define yy_set_bol(at_bol) \
364 	{ \
365 	if ( ! YY_CURRENT_BUFFER ){\
366         core_yyensure_buffer_stack (yyscanner); \
367 		YY_CURRENT_BUFFER_LVALUE =    \
368             core_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
369 	} \
370 	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
371 	}
372 
373 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
374 
375 /* Begin user sect3 */
376 
377 #define core_yywrap(yyscanner) 1
378 #define YY_SKIP_YYWRAP
379 
380 typedef unsigned char YY_CHAR;
381 
382 typedef int yy_state_type;
383 
384 #define yytext_ptr yytext_r
385 
386 static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
387 static yy_state_type yy_try_NUL_trans (yy_state_type current_state  ,yyscan_t yyscanner);
388 static int yy_get_next_buffer (yyscan_t yyscanner );
389 static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
390 
391 /* Done after the current pattern has been matched and before the
392  * corresponding action - sets up yytext.
393  */
394 #define YY_DO_BEFORE_ACTION \
395 	yyg->yytext_ptr = yy_bp; \
396 	yyleng = (size_t) (yy_cp - yy_bp); \
397 	yyg->yy_hold_char = *yy_cp; \
398 	*yy_cp = '\0'; \
399 	yyg->yy_c_buf_p = yy_cp;
400 
401 #define YY_NUM_RULES 79
402 #define YY_END_OF_BUFFER 80
403 /* This struct is not used in this scanner,
404    but its presence is necessary. */
405 struct yy_trans_info
406 	{
407 	flex_int32_t yy_verify;
408 	flex_int32_t yy_nxt;
409 	};
410 static yyconst flex_int16_t yy_accept[290] =
411     {   0,
412         0,    0,   12,   12,    0,    0,    0,    0,   11,   11,
413         0,    0,    0,    0,    0,    0,    0,    0,   55,   55,
414         0,    0,   28,   28,    0,    0,   80,   78,    1,    1,
415        69,   49,   69,   78,   68,   19,   68,   68,   68,   68,
416        71,   68,   68,   68,   68,   77,   77,   77,   77,   77,
417        77,   12,    9,    5,    5,    6,    6,   58,   51,   11,
418        16,   32,   32,   22,   42,   31,   22,   46,   46,   48,
419        52,   54,   53,   53,   54,   54,   24,   27,   26,   26,
420        27,   27,   35,   36,   35,    1,   69,   67,   43,   70,
421        44,    1,   61,   72,    2,   72,   71,   75,   60,   62,
422 
423        64,   66,   63,   65,   77,    8,   20,   18,   59,   15,
424        12,    9,    9,   10,    5,    7,    4,    3,   58,   57,
425        11,   16,   16,   17,   32,   22,   22,   30,   23,   38,
426        39,   37,   37,   38,   31,   46,   45,   47,   53,   53,
427        55,   24,   24,   25,   26,   26,   28,   37,   37,   44,
428         1,    1,    2,   73,   72,   76,   74,   50,   21,    9,
429        14,   10,    9,    3,   16,   13,   17,   16,   22,   41,
430        23,   22,   39,   37,   37,   40,   47,   53,   55,   24,
431        25,   24,   26,   28,   37,   37,    9,    9,    9,    9,
432        16,   16,   16,   16,   22,   22,   22,   22,   39,   37,
433 
434        37,   40,   55,   24,   24,   24,   24,   28,   37,   37,
435         9,    9,    9,    9,    9,   16,   16,   16,   16,   16,
436        22,   22,   22,   22,   22,   37,   37,   55,   24,   24,
437        24,   24,   24,   28,   37,   37,    9,   16,   22,   37,
438        33,   55,   24,   28,   37,   34,   37,   55,   28,   37,
439        37,   55,   55,   55,   28,   28,   28,   37,   37,   55,
440        55,   28,   28,   37,   56,   55,   55,   55,   55,   29,
441        28,   28,   28,   28,   55,   55,   55,   55,   55,   28,
442        28,   28,   28,   28,   55,   55,   28,   28,    0
443     } ;
444 
445 static yyconst flex_int32_t yy_ec[256] =
446     {   0,
447         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
448         1,    2,    4,    1,    1,    1,    1,    1,    1,    1,
449         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
450         1,    2,    5,    6,    7,    8,    9,   10,   11,   12,
451        12,   13,   14,   12,   15,   16,   17,   18,   18,   18,
452        18,   18,   18,   18,   18,   19,   19,   20,   12,   21,
453        22,   23,    7,    7,   24,   25,   26,   27,   28,   27,
454        29,   29,   29,   29,   29,   29,   29,   30,   29,   31,
455        29,   29,   32,   29,   33,   29,   29,   34,   29,   29,
456        12,   35,   12,    9,   29,    7,   24,   25,   26,   27,
457 
458        28,   27,   29,   29,   29,   29,   29,   29,   29,   30,
459        29,   31,   29,   29,   32,   29,   36,   29,   29,   37,
460        29,   29,    1,    7,    1,    7,    1,   29,   29,   29,
461        29,   29,   29,   29,   29,   29,   29,   29,   29,   29,
462        29,   29,   29,   29,   29,   29,   29,   29,   29,   29,
463        29,   29,   29,   29,   29,   29,   29,   29,   29,   29,
464        29,   29,   29,   29,   29,   29,   29,   29,   29,   29,
465        29,   29,   29,   29,   29,   29,   29,   29,   29,   29,
466        29,   29,   29,   29,   29,   29,   29,   29,   29,   29,
467        29,   29,   29,   29,   29,   29,   29,   29,   29,   29,
468 
469        29,   29,   29,   29,   29,   29,   29,   29,   29,   29,
470        29,   29,   29,   29,   29,   29,   29,   29,   29,   29,
471        29,   29,   29,   29,   29,   29,   29,   29,   29,   29,
472        29,   29,   29,   29,   29,   29,   29,   29,   29,   29,
473        29,   29,   29,   29,   29,   29,   29,   29,   29,   29,
474        29,   29,   29,   29,   29
475     } ;
476 
477 static yyconst flex_int32_t yy_meta[38] =
478     {   0,
479         1,    1,    2,    2,    3,    4,    3,    5,    3,    3,
480         6,    1,    7,    3,    3,    1,    7,    8,    8,    1,
481         3,    3,    3,    9,    9,    9,    9,    9,   10,   10,
482        10,   10,   10,   10,   11,   10,   10
483     } ;
484 
485 static yyconst flex_int16_t yy_base[357] =
486     {   0,
487         0,    0,  404,  403,   33,   52,  395,  394,  376,  375,
488        41,   42,  362,  361,   55,   75,  353,  352,   82,  117,
489       334,  333,  152,  187,   36,   46,  331, 1164,   85,   88,
490       308, 1164,    0,   85,    0, 1164, 1164,  310,   80,  311,
491        89,   48,   57,  300,  295,    0,  305,  300,  299,  299,
492       292,    0,   98,    0,    0,   47,  289,    0,  291,    0,
493       107,    0,    0,  122,   94,    0,  132,    0,    0,  288,
494       289, 1164,  136,  142,  268,  251,  155, 1164,  158,  161,
495       260,  245, 1164, 1164,  115,  169,    0,    0, 1164,   76,
496       262,  219, 1164,  150,    0,  158,  164,  179, 1164, 1164,
497 
498         0,    0,    0,    0,    0, 1164, 1164, 1164,  117, 1164,
499         0,  197,  202,  250,    0,  162, 1164,    0,    0, 1164,
500         0,  206,  235,  249,    0,  212,  241, 1164,  242, 1164,
501       233,    0,    0,    0,    0,    0, 1164,  227,  245,    0,
502       199,  251,  256,  215,  259,    0,  193,    0,    0,  214,
503         0,  267,    0, 1164,  250,  123,  177, 1164, 1164,  283,
504      1164,  204,  289,    0,  297, 1164,  203,  303,  311, 1164,
505       196,  317,  189,    0,    0,    0,  195,    0,  161,  325,
506       169,  331,    0,  155,    0,    0,  335,  339,  345,  349,
507       353,  359,  363,  367,  373,  377,  381,  387, 1164,    0,
508 
509         0, 1164,  128,  391,  395,  401,  405,  125,    0,    0,
510       409,  415,  423,  429,  433,  437,  443,  451,  457,  461,
511       465,  471,  479,  485,  489,    0,    0,   98,  493,  499,
512       507,  513,  517,   85,    0,    0,  521,  527,  531,    0,
513      1164,   86,  535,   78,    0, 1164,    0,  541,  551,    0,
514         0,  556,    0,   67,  561,    0,   57,    0,    0,   40,
515       566,   30,  571,    0, 1164,  576,  581,  586,  591, 1164,
516       596,  601,  606,  611,  616,  621,  626,  631,  636,  641,
517       646,  651,  656,  661,  666,    0,  671,    0, 1164,  686,
518       697,  708,  719,  730,  741,  752,  763,  774,  785,  794,
519 
520       797,  803,  813,  824,  835,  846,  857,  867,  878,  889,
521       896,  902,  912,  921,  926,  926,  928,  930,  935,  945,
522       956,  960,  962,  971,  982,  993,  997,  999, 1001, 1010,
523      1014, 1016, 1025, 1036, 1047, 1051, 1053, 1062, 1066, 1068,
524      1070, 1072, 1074, 1076, 1078, 1080, 1082, 1084, 1086, 1095,
525      1106, 1110, 1119, 1130, 1141, 1152
526     } ;
527 
528 static yyconst flex_int16_t yy_def[357] =
529     {   0,
530       289,    1,  290,  290,  291,  291,  292,  292,  293,  293,
531       294,  294,  295,  295,  296,  296,  292,  292,  297,  297,
532       295,  295,  298,  298,  299,  299,  289,  289,  289,  289,
533       300,  289,  300,  301,  300,  289,  289,  300,  289,  300,
534       289,  289,  300,  300,  300,  302,  302,  302,  302,  302,
535       302,  303,  289,  304,  304,  289,  289,  305,  289,  306,
536       289,  307,  307,  289,  308,  309,  289,  310,  310,  311,
537       289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
538       289,  289,  289,  289,  289,  289,  300,  300,  289,  289,
539       312,  313,  289,  289,  314,  289,  289,  289,  289,  289,
540 
541       300,  300,  300,  300,  302,  289,  289,  289,  289,  289,
542       303,  289,  289,  289,  304,  289,  289,  315,  305,  289,
543       306,  289,  289,  289,  307,  289,  289,  289,  289,  289,
544       289,  316,  317,  318,  309,  310,  289,  319,  289,  320,
545       289,  289,  289,  289,  289,  321,  289,  322,  323,  312,
546       313,  313,  314,  289,  289,  289,  289,  289,  289,  289,
547       289,  289,  324,  315,  289,  289,  289,  325,  289,  289,
548       289,  326,  289,  327,  328,  329,  319,  320,  289,  289,
549       289,  330,  321,  289,  331,  332,  333,  324,  324,  324,
550       334,  325,  325,  325,  335,  326,  326,  326,  289,  336,
551 
552       337,  289,  289,  338,  330,  330,  330,  289,  339,  340,
553       333,  333,  289,  333,  324,  334,  334,  289,  334,  325,
554       335,  335,  289,  335,  326,  341,  342,  289,  338,  338,
555       289,  338,  330,  289,  343,  344,  333,  334,  335,  345,
556       289,  289,  338,  289,  346,  289,  347,  289,  289,  348,
557       349,  289,  350,  289,  289,  351,  289,  352,  342,  289,
558       353,  289,  354,  344,  289,  353,  353,  355,  353,  289,
559       354,  354,  356,  354,  353,  353,  289,  353,  353,  354,
560       354,  289,  354,  354,  355,  350,  356,  351,    0,  289,
561       289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
562 
563       289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
564       289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
565       289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
566       289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
567       289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
568       289,  289,  289,  289,  289,  289
569     } ;
570 
571 static yyconst flex_int16_t yy_nxt[1202] =
572     {   0,
573        28,   29,   30,   29,   31,   32,   33,   34,   35,   33,
574        36,   37,   35,   35,   38,   39,   40,   41,   41,   42,
575        43,   44,   45,   46,   47,   46,   46,   48,   46,   49,
576        46,   46,   50,   51,   28,   50,   51,   55,   84,   55,
577       270,   55,   55,   63,   63,   56,   55,   55,   84,   57,
578       265,   64,   64,   55,   55,   55,   55,   69,   55,  116,
579        55,   55,   70,  117,   56,   55,   55,   99,   57,  100,
580        85,  263,   55,   55,   55,   65,   65,   69,  101,  102,
581        85,  261,   70,   73,   74,   73,   86,   86,   86,   86,
582        86,   86,   89,   90,   90,   93,   75,   94,   94,  112,
583 
584       113,  113,   90,   90,   96,  249,   97,   97,  122,  123,
585       123,  131,  114,  248,   76,  244,   98,   76,   73,   74,
586        73,  124,  158,  126,  127,  127,  132,  159,  242,  133,
587       134,   75,  128,  126,  127,  127,  129,  139,  139,  139,
588       157,  157,  128,  139,  139,  139,  129,  148,  234,   76,
589       149,  228,   76,   79,   80,   79,  142,  143,  143,  145,
590       145,  145,  145,  145,  145,  128,   81,   94,   94,  144,
591        86,   86,   86,  154,  116,  155,  155,   98,  117,   96,
592       208,   97,   97,  204,   82,   98,  203,   82,   79,   80,
593        79,   98,  156,  156,  157,  157,  157,  157,  112,  113,
594 
595       113,   81,  137,  160,  160,  160,  199,  122,  123,  123,
596       195,  114,  161,  126,  127,  127,  162,  191,  187,   82,
597       124,   89,   82,  152,  184,  152,  129,  152,  152,  182,
598       179,  152,  152,  152,  137,  152,  165,  165,  165,  152,
599       152,  152,  169,  169,  169,  166,  139,  139,  139,  167,
600       173,  170,  142,  143,  143,  171,  172,  180,  180,  180,
601       145,  145,  145,  168,  163,  144,  170,  155,  155,   89,
602       181,  152,  147,  152,  146,  152,  152,   98,  141,  152,
603       152,  152,  140,  152,  160,  160,  160,  152,  152,  152,
604       189,  113,  113,  161,  120,  137,  120,  162,  165,  165,
605 
606       165,  118,  110,  190,  193,  123,  123,  166,  109,  108,
607       107,  167,  169,  169,  169,  106,  104,  194,  197,  127,
608       127,  170,  103,   95,   92,  171,  180,  180,  180,   88,
609       289,  198,  206,  143,  143,  170,  212,  213,  213,  181,
610       189,  113,  113,   77,   77,  207,  189,  113,  113,  214,
611       189,  113,  113,  190,  217,  218,  218,   71,   71,  190,
612       193,  123,  123,  215,  193,  123,  123,  219,  193,  123,
613       123,   67,   67,  194,  222,  223,  223,  194,  197,  127,
614       127,  220,  197,  127,  127,   61,   61,  224,  197,  127,
615       127,  198,  230,  231,  231,  198,  206,  143,  143,   59,
616 
617        59,  225,  206,  143,  143,  232,  206,  143,  143,  207,
618       212,  213,  213,   53,   53,  207,  212,  213,  213,  233,
619       289,  289,  289,  214,  160,  160,  160,  289,  289,  214,
620       212,  213,  213,  161,  189,  113,  113,  162,  217,  218,
621       218,  289,  289,  237,  217,  218,  218,  215,  289,  289,
622       289,  219,  165,  165,  165,  289,  289,  219,  217,  218,
623       218,  166,  193,  123,  123,  167,  222,  223,  223,  289,
624       289,  238,  222,  223,  223,  220,  289,  289,  289,  224,
625       169,  169,  169,  289,  289,  224,  222,  223,  223,  170,
626       197,  127,  127,  171,  230,  231,  231,  289,  289,  239,
627 
628       230,  231,  231,  225,  289,  289,  289,  232,  180,  180,
629       180,  289,  289,  232,  230,  231,  231,  170,  206,  143,
630       143,  181,  212,  213,  213,  289,  289,  243,  217,  218,
631       218,  233,  222,  223,  223,  237,  230,  231,  231,  289,
632       289,  238,  252,  252,  252,  239,  289,  289,  289,  243,
633       289,  253,  255,  255,  255,  254,  289,  252,  252,  252,
634       289,  256,  255,  255,  255,  257,  253,  267,  252,  252,
635       254,  256,  272,  255,  255,  257,  268,  267,  252,  252,
636       269,  273,  267,  252,  252,  274,  268,  276,  277,  277,
637       269,  268,  267,  252,  252,  269,  268,  272,  255,  255,
638 
639       278,  268,  272,  255,  255,  279,  273,  281,  282,  282,
640       274,  273,  272,  255,  255,  274,  273,  267,  252,  252,
641       283,  273,  267,  252,  252,  284,  285,  252,  252,  252,
642       269,  285,  267,  252,  252,  269,  286,  267,  252,  252,
643       254,  285,  272,  255,  255,  279,  268,  272,  255,  255,
644       279,  287,  255,  255,  255,  274,  287,  272,  255,  255,
645       274,  288,  272,  255,  255,  257,  287,  276,  277,  277,
646       284,  273,  281,  282,  282,  284,  268,  289,  289,  289,
647       278,  273,  289,  289,  289,  283,   52,   52,   52,   52,
648        52,   52,   52,   52,   52,   52,   52,   54,   54,   54,
649 
650        54,   54,   54,   54,   54,   54,   54,   54,   58,   58,
651        58,   58,   58,   58,   58,   58,   58,   58,   58,   60,
652        60,   60,   60,   60,   60,   60,   60,   60,   60,   60,
653        62,   62,   62,   62,   62,   62,   62,   62,   62,   62,
654        62,   66,   66,   66,   66,   66,   66,   66,   66,   66,
655        66,   66,   68,   68,   68,   68,   68,   68,   68,   68,
656        68,   68,   68,   72,   72,   72,   72,   72,   72,   72,
657        72,   72,   72,   72,   78,   78,   78,   78,   78,   78,
658        78,   78,   78,   78,   78,   83,   83,   83,   83,   83,
659        83,   83,   83,   83,   83,   83,   87,  289,  289,  289,
660 
661        87,   91,  289,  289,   91,   91,   91,  105,  289,  289,
662       105,  105,  105,  111,  111,  111,  111,  111,  289,  111,
663       111,  111,  111,  111,  115,  115,  115,  115,  115,  115,
664       289,  115,  115,  115,  115,  119,  119,  119,  289,  119,
665       119,  119,  119,  119,  119,  119,  121,  121,  121,  121,
666       121,  289,  121,  121,  121,  121,  121,  125,  125,  125,
667       125,  125,  289,  125,  125,  125,  125,  130,  130,  130,
668       130,  130,  130,  130,  130,  130,  130,  130,  135,  135,
669       135,  135,  135,  289,  135,  135,  135,  135,  135,  136,
670       136,  136,  136,  289,  136,  136,  136,  136,  136,  136,
671 
672       138,  289,  289,  289,  138,  138,  150,  289,  289,  150,
673       150,  150,  151,  289,  151,  151,  151,  151,  151,  151,
674       151,  151,  151,  153,  289,  289,  289,  153,  164,  289,
675       289,  289,  164,  174,  174,  175,  175,  176,  176,  177,
676       289,  289,  177,  177,  177,  178,  289,  178,  178,  178,
677       178,  178,  178,  178,  178,  178,  183,  289,  183,  183,
678       183,  183,  183,  183,  183,  183,  183,  185,  185,  186,
679       186,  188,  188,  188,  188,  188,  188,  188,  188,  188,
680       188,  188,  192,  192,  192,  192,  192,  192,  192,  192,
681       192,  192,  192,  196,  196,  196,  196,  196,  196,  196,
682 
683       196,  196,  196,  196,  200,  200,  201,  201,  202,  202,
684       205,  205,  205,  205,  205,  205,  205,  205,  205,  205,
685       205,  209,  209,  210,  210,  211,  211,  211,  211,  211,
686       211,  211,  211,  211,  211,  211,  216,  216,  216,  216,
687       216,  216,  216,  216,  216,  216,  216,  221,  221,  221,
688       221,  221,  221,  221,  221,  221,  221,  221,  226,  226,
689       227,  227,  229,  229,  229,  229,  229,  229,  229,  229,
690       229,  229,  229,  235,  235,  236,  236,  240,  240,  241,
691       241,  245,  245,  246,  246,  247,  247,  250,  250,  251,
692       251,  258,  258,  259,  259,  260,  260,  260,  260,  260,
693 
694       289,  260,  260,  260,  260,  260,  262,  262,  262,  262,
695       262,  289,  262,  262,  262,  262,  262,  264,  264,  266,
696       266,  266,  266,  266,  266,  266,  266,  266,  266,  266,
697       271,  271,  271,  271,  271,  271,  271,  271,  271,  271,
698       271,  275,  275,  275,  275,  275,  275,  275,  275,  275,
699       275,  275,  280,  280,  280,  280,  280,  280,  280,  280,
700       280,  280,  280,   27,  289,  289,  289,  289,  289,  289,
701       289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
702       289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
703       289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
704 
705       289
706     } ;
707 
708 static yyconst flex_int16_t yy_chk[1202] =
709     {   0,
710         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
711         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
712         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
713         1,    1,    1,    1,    1,    1,    1,    5,   25,    5,
714       262,    5,    5,   11,   12,    5,    5,    5,   26,    5,
715       260,   11,   12,    5,    5,    5,    6,   15,    6,   56,
716         6,    6,   15,   56,    6,    6,    6,   42,    6,   42,
717        25,  257,    6,    6,    6,   11,   12,   16,   43,   43,
718        26,  254,   16,   19,   19,   19,   29,   29,   29,   30,
719        30,   30,   34,   90,   90,   39,   19,   39,   39,   53,
720 
721        53,   53,   34,   34,   41,  244,   41,   41,   61,   61,
722        61,   65,   53,  242,   19,  234,   41,   19,   20,   20,
723        20,   61,  109,   64,   64,   64,   65,  109,  228,   65,
724        65,   20,   64,   67,   67,   67,   64,   73,   73,   73,
725       156,  156,   67,   74,   74,   74,   67,   85,  208,   20,
726        85,  203,   20,   23,   23,   23,   77,   77,   77,   79,
727        79,   79,   80,   80,   80,   77,   23,   94,   94,   77,
728        86,   86,   86,   96,  116,   96,   96,   94,  116,   97,
729       184,   97,   97,  181,   23,   96,  179,   23,   24,   24,
730        24,   97,   98,   98,  157,  157,   98,   98,  112,  112,
731 
732       112,   24,  177,  113,  113,  113,  173,  122,  122,  122,
733       171,  112,  113,  126,  126,  126,  113,  167,  162,   24,
734       122,  150,   24,   92,  147,   92,  126,   92,   92,  144,
735       141,   92,   92,   92,  138,   92,  123,  123,  123,   92,
736        92,   92,  127,  127,  127,  123,  139,  139,  139,  123,
737       131,  127,  142,  142,  142,  127,  129,  143,  143,  143,
738       145,  145,  145,  124,  114,  142,  143,  155,  155,   91,
739       143,  152,   82,  152,   81,  152,  152,  155,   76,  152,
740       152,  152,   75,  152,  160,  160,  160,  152,  152,  152,
741       163,  163,  163,  160,   71,   70,   59,  160,  165,  165,
742 
743       165,   57,   51,  163,  168,  168,  168,  165,   50,   49,
744        48,  165,  169,  169,  169,   47,   45,  168,  172,  172,
745       172,  169,   44,   40,   38,  169,  180,  180,  180,   31,
746        27,  172,  182,  182,  182,  180,  187,  187,  187,  180,
747       188,  188,  188,   22,   21,  182,  189,  189,  189,  187,
748       190,  190,  190,  188,  191,  191,  191,   18,   17,  189,
749       192,  192,  192,  190,  193,  193,  193,  191,  194,  194,
750       194,   14,   13,  192,  195,  195,  195,  193,  196,  196,
751       196,  194,  197,  197,  197,   10,    9,  195,  198,  198,
752       198,  196,  204,  204,  204,  197,  205,  205,  205,    8,
753 
754         7,  198,  206,  206,  206,  204,  207,  207,  207,  205,
755       211,  211,  211,    4,    3,  206,  212,  212,  212,  207,
756         0,    0,    0,  211,  213,  213,  213,    0,    0,  212,
757       214,  214,  214,  213,  215,  215,  215,  213,  216,  216,
758       216,    0,    0,  214,  217,  217,  217,  215,    0,    0,
759         0,  216,  218,  218,  218,    0,    0,  217,  219,  219,
760       219,  218,  220,  220,  220,  218,  221,  221,  221,    0,
761         0,  219,  222,  222,  222,  220,    0,    0,    0,  221,
762       223,  223,  223,    0,    0,  222,  224,  224,  224,  223,
763       225,  225,  225,  223,  229,  229,  229,    0,    0,  224,
764 
765       230,  230,  230,  225,    0,    0,    0,  229,  231,  231,
766       231,    0,    0,  230,  232,  232,  232,  231,  233,  233,
767       233,  231,  237,  237,  237,    0,    0,  232,  238,  238,
768       238,  233,  239,  239,  239,  237,  243,  243,  243,    0,
769         0,  238,  248,  248,  248,  239,    0,    0,    0,  243,
770         0,  248,  249,  249,  249,  248,    0,  252,  252,  252,
771         0,  249,  255,  255,  255,  249,  252,  261,  261,  261,
772       252,  255,  263,  263,  263,  255,  261,  266,  266,  266,
773       261,  263,  267,  267,  267,  263,  266,  268,  268,  268,
774       266,  267,  269,  269,  269,  267,  268,  271,  271,  271,
775 
776       268,  269,  272,  272,  272,  269,  271,  273,  273,  273,
777       271,  272,  274,  274,  274,  272,  273,  275,  275,  275,
778       273,  274,  276,  276,  276,  274,  275,  277,  277,  277,
779       275,  276,  278,  278,  278,  276,  277,  279,  279,  279,
780       277,  278,  280,  280,  280,  278,  279,  281,  281,  281,
781       279,  280,  282,  282,  282,  280,  281,  283,  283,  283,
782       281,  282,  284,  284,  284,  282,  283,  285,  285,  285,
783       283,  284,  287,  287,  287,  284,  285,    0,    0,    0,
784       285,  287,    0,    0,    0,  287,  290,  290,  290,  290,
785       290,  290,  290,  290,  290,  290,  290,  291,  291,  291,
786 
787       291,  291,  291,  291,  291,  291,  291,  291,  292,  292,
788       292,  292,  292,  292,  292,  292,  292,  292,  292,  293,
789       293,  293,  293,  293,  293,  293,  293,  293,  293,  293,
790       294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
791       294,  295,  295,  295,  295,  295,  295,  295,  295,  295,
792       295,  295,  296,  296,  296,  296,  296,  296,  296,  296,
793       296,  296,  296,  297,  297,  297,  297,  297,  297,  297,
794       297,  297,  297,  297,  298,  298,  298,  298,  298,  298,
795       298,  298,  298,  298,  298,  299,  299,  299,  299,  299,
796       299,  299,  299,  299,  299,  299,  300,    0,    0,    0,
797 
798       300,  301,    0,    0,  301,  301,  301,  302,    0,    0,
799       302,  302,  302,  303,  303,  303,  303,  303,    0,  303,
800       303,  303,  303,  303,  304,  304,  304,  304,  304,  304,
801         0,  304,  304,  304,  304,  305,  305,  305,    0,  305,
802       305,  305,  305,  305,  305,  305,  306,  306,  306,  306,
803       306,    0,  306,  306,  306,  306,  306,  307,  307,  307,
804       307,  307,    0,  307,  307,  307,  307,  308,  308,  308,
805       308,  308,  308,  308,  308,  308,  308,  308,  309,  309,
806       309,  309,  309,    0,  309,  309,  309,  309,  309,  310,
807       310,  310,  310,    0,  310,  310,  310,  310,  310,  310,
808 
809       311,    0,    0,    0,  311,  311,  312,    0,    0,  312,
810       312,  312,  313,    0,  313,  313,  313,  313,  313,  313,
811       313,  313,  313,  314,    0,    0,    0,  314,  315,    0,
812         0,    0,  315,  316,  316,  317,  317,  318,  318,  319,
813         0,    0,  319,  319,  319,  320,    0,  320,  320,  320,
814       320,  320,  320,  320,  320,  320,  321,    0,  321,  321,
815       321,  321,  321,  321,  321,  321,  321,  322,  322,  323,
816       323,  324,  324,  324,  324,  324,  324,  324,  324,  324,
817       324,  324,  325,  325,  325,  325,  325,  325,  325,  325,
818       325,  325,  325,  326,  326,  326,  326,  326,  326,  326,
819 
820       326,  326,  326,  326,  327,  327,  328,  328,  329,  329,
821       330,  330,  330,  330,  330,  330,  330,  330,  330,  330,
822       330,  331,  331,  332,  332,  333,  333,  333,  333,  333,
823       333,  333,  333,  333,  333,  333,  334,  334,  334,  334,
824       334,  334,  334,  334,  334,  334,  334,  335,  335,  335,
825       335,  335,  335,  335,  335,  335,  335,  335,  336,  336,
826       337,  337,  338,  338,  338,  338,  338,  338,  338,  338,
827       338,  338,  338,  339,  339,  340,  340,  341,  341,  342,
828       342,  343,  343,  344,  344,  345,  345,  346,  346,  347,
829       347,  348,  348,  349,  349,  350,  350,  350,  350,  350,
830 
831         0,  350,  350,  350,  350,  350,  351,  351,  351,  351,
832       351,    0,  351,  351,  351,  351,  351,  352,  352,  353,
833       353,  353,  353,  353,  353,  353,  353,  353,  353,  353,
834       354,  354,  354,  354,  354,  354,  354,  354,  354,  354,
835       354,  355,  355,  355,  355,  355,  355,  355,  355,  355,
836       355,  355,  356,  356,  356,  356,  356,  356,  356,  356,
837       356,  356,  356,  289,  289,  289,  289,  289,  289,  289,
838       289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
839       289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
840       289,  289,  289,  289,  289,  289,  289,  289,  289,  289,
841 
842       289
843     } ;
844 
845 /* The intent behind this definition is that it'll catch
846  * any uses of REJECT which flex missed.
847  */
848 #define REJECT reject_used_but_not_detected
849 #define yymore() yymore_used_but_not_detected
850 #define YY_MORE_ADJ 0
851 #define YY_RESTORE_YY_MORE_OFFSET
852 #line 1 "scan.l"
853 
854 #line 50 "scan.l"
855 
856 /* LCOV_EXCL_START */
857 
858 /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
859 #undef fprintf
860 #define fprintf(file, fmt, msg)  fprintf_to_ereport(fmt, msg)
861 
862 static void
fprintf_to_ereport(const char * fmt,const char * msg)863 fprintf_to_ereport(const char *fmt, const char *msg)
864 {
865 	ereport(ERROR, (errmsg_internal("%s", msg)));
866 }
867 
868 /*
869  * GUC variables.  This is a DIRECT violation of the warning given at the
870  * head of gram.y, ie flex/bison code must not depend on any GUC variables;
871  * as such, changing their values can induce very unintuitive behavior.
872  * But we shall have to live with it until we can remove these variables.
873  */
874 int			backslash_quote = BACKSLASH_QUOTE_SAFE_ENCODING;
875 bool		escape_string_warning = true;
876 bool		standard_conforming_strings = true;
877 
878 /*
879  * Set the type of YYSTYPE.
880  */
881 #define YYSTYPE core_YYSTYPE
882 
883 /*
884  * Set the type of yyextra.  All state variables used by the scanner should
885  * be in yyextra, *not* statically allocated.
886  */
887 #define YY_EXTRA_TYPE core_yy_extra_type *
888 
889 /*
890  * Each call to core_yylex must set yylloc to the location of the found token
891  * (expressed as a byte offset from the start of the input text).
892  * When we parse a token that requires multiple lexer rules to process,
893  * this should be done in the first such rule, else yylloc will point
894  * into the middle of the token.
895  */
896 #define SET_YYLLOC()  (*(yylloc) = yytext - yyextra->scanbuf)
897 
898 /*
899  * Advance yylloc by the given number of bytes.
900  */
901 #define ADVANCE_YYLLOC(delta)  ( *(yylloc) += (delta) )
902 
903 #define startlit()	( yyextra->literallen = 0 )
904 static void addlit(char *ytext, int yleng, core_yyscan_t yyscanner);
905 static void addlitchar(unsigned char ychar, core_yyscan_t yyscanner);
906 static char *litbufdup(core_yyscan_t yyscanner);
907 static char *litbuf_udeescape(unsigned char escape, core_yyscan_t yyscanner);
908 static unsigned char unescape_single_char(unsigned char c, core_yyscan_t yyscanner);
909 static int	process_integer_literal(const char *token, YYSTYPE *lval);
910 static bool is_utf16_surrogate_first(pg_wchar c);
911 static bool is_utf16_surrogate_second(pg_wchar c);
912 static pg_wchar surrogate_pair_to_codepoint(pg_wchar first, pg_wchar second);
913 static void addunicode(pg_wchar c, yyscan_t yyscanner);
914 static bool check_uescapechar(unsigned char escape);
915 
916 #define yyerror(msg)  scanner_yyerror(msg, yyscanner)
917 
918 #define lexer_errposition()  scanner_errposition(*(yylloc), yyscanner)
919 
920 static void check_string_escape_warning(unsigned char ychar, core_yyscan_t yyscanner);
921 static void check_escape_warning(core_yyscan_t yyscanner);
922 
923 /*
924  * Work around a bug in flex 2.5.35: it emits a couple of functions that
925  * it forgets to emit declarations for.  Since we use -Wmissing-prototypes,
926  * this would cause warnings.  Providing our own declarations should be
927  * harmless even when the bug gets fixed.
928  */
929 extern int	core_yyget_column(yyscan_t yyscanner);
930 extern void core_yyset_column(int column_no, yyscan_t yyscanner);
931 
932 #define YY_NO_INPUT 1
933 /*
934  * OK, here is a short description of lex/flex rules behavior.
935  * The longest pattern which matches an input string is always chosen.
936  * For equal-length patterns, the first occurring in the rules list is chosen.
937  * INITIAL is the starting state, to which all non-conditional rules apply.
938  * Exclusive states change parsing rules while the state is active.  When in
939  * an exclusive state, only those rules defined for that state apply.
940  *
941  * We use exclusive states for quoted strings, extended comments,
942  * and to eliminate parsing troubles for numeric strings.
943  * Exclusive states:
944  *  <xb> bit string literal
945  *  <xc> extended C-style comments
946  *  <xd> delimited identifiers (double-quoted identifiers)
947  *  <xh> hexadecimal numeric string
948  *  <xq> standard quoted strings
949  *  <xe> extended quoted strings (support backslash escape sequences)
950  *  <xdolq> $foo$ quoted strings
951  *  <xui> quoted identifier with Unicode escapes
952  *  <xuiend> end of a quoted identifier with Unicode escapes, UESCAPE can follow
953  *  <xus> quoted string with Unicode escapes
954  *  <xusend> end of a quoted string with Unicode escapes, UESCAPE can follow
955  *  <xeu> Unicode surrogate pair in extended quoted string
956  *
957  * Remember to add an <<EOF>> case whenever you add a new exclusive state!
958  * The default one is probably not the right thing.
959  */
960 
961 
962 
963 
964 
965 
966 
967 
968 
969 
970 
971 
972 /*
973  * In order to make the world safe for Windows and Mac clients as well as
974  * Unix ones, we accept either \n or \r as a newline.  A DOS-style \r\n
975  * sequence will be seen as two successive newlines, but that doesn't cause
976  * any problems.  Comments that start with -- and extend to the next
977  * newline are treated as equivalent to a single whitespace character.
978  *
979  * NOTE a fine point: if there is no newline following --, we will absorb
980  * everything to the end of the input as a comment.  This is correct.  Older
981  * versions of Postgres failed to recognize -- as a comment if the input
982  * did not end with a newline.
983  *
984  * XXX perhaps \f (formfeed) should be treated as a newline as well?
985  *
986  * XXX if you change the set of whitespace characters, fix scanner_isspace()
987  * to agree, and see also the plpgsql lexer.
988  */
989 /*
990  * SQL requires at least one newline in the whitespace separating
991  * string literals that are to be concatenated.  Silly, but who are we
992  * to argue?  Note that {whitespace_with_newline} should not have * after
993  * it, whereas {whitespace} should generally have a * after it...
994  */
995 /*
996  * To ensure that {quotecontinue} can be scanned without having to back up
997  * if the full pattern isn't matched, we include trailing whitespace in
998  * {quotestop}.  This matches all cases where {quotecontinue} fails to match,
999  * except for {quote} followed by whitespace and just one "-" (not two,
1000  * which would start a {comment}).  To cover that we have {quotefail}.
1001  * The actions for {quotestop} and {quotefail} must throw back characters
1002  * beyond the quote proper.
1003  */
1004 /* Bit string
1005  * It is tempting to scan the string for only those characters
1006  * which are allowed. However, this leads to silently swallowed
1007  * characters if illegal characters are included in the string.
1008  * For example, if xbinside is [01] then B'ABCD' is interpreted
1009  * as a zero-length string, and the ABCD' is lost!
1010  * Better to pass the string forward and let the input routines
1011  * validate the contents.
1012  */
1013 /* Hexadecimal number */
1014 /* National character */
1015 /* Quoted string that allows backslash escapes */
1016 /* Extended quote
1017  * xqdouble implements embedded quote, ''''
1018  */
1019 /* $foo$ style quotes ("dollar quoting")
1020  * The quoted string starts with $foo$ where "foo" is an optional string
1021  * in the form of an identifier, except that it may not contain "$",
1022  * and extends to the first occurrence of an identical string.
1023  * There is *no* processing of the quoted text.
1024  *
1025  * {dolqfailed} is an error rule to avoid scanner backup when {dolqdelim}
1026  * fails to match its trailing "$".
1027  */
1028 /* Double quote
1029  * Allows embedded spaces and other special characters into identifiers.
1030  */
1031 /* Unicode escapes */
1032 /* error rule to avoid backup */
1033 /* Quoted identifier with Unicode escapes */
1034 /* Quoted string with Unicode escapes */
1035 /* Optional UESCAPE after a quoted string or identifier with Unicode escapes. */
1036 /* error rule to avoid backup */
1037 /* C-style comments
1038  *
1039  * The "extended comment" syntax closely resembles allowable operator syntax.
1040  * The tricky part here is to get lex to recognize a string starting with
1041  * slash-star as a comment, when interpreting it as an operator would produce
1042  * a longer match --- remember lex will prefer a longer match!  Also, if we
1043  * have something like plus-slash-star, lex will think this is a 3-character
1044  * operator whereas we want to see it as a + operator and a comment start.
1045  * The solution is two-fold:
1046  * 1. append {op_chars}* to xcstart so that it matches as much text as
1047  *    {operator} would. Then the tie-breaker (first matching rule of same
1048  *    length) ensures xcstart wins.  We put back the extra stuff with yyless()
1049  *    in case it contains a star-slash that should terminate the comment.
1050  * 2. In the operator rule, check for slash-star within the operator, and
1051  *    if found throw it back with yyless().  This handles the plus-slash-star
1052  *    problem.
1053  * Dash-dash comments have similar interactions with the operator rule.
1054  */
1055 /* Assorted special-case operators and operator-like tokens */
1056 /*
1057  * "self" is the set of chars that should be returned as single-character
1058  * tokens.  "op_chars" is the set of chars that can make up "Op" tokens,
1059  * which can be one or more characters long (but if a single-char token
1060  * appears in the "self" set, it is not to be returned as an Op).  Note
1061  * that the sets overlap, but each has some chars that are not in the other.
1062  *
1063  * If you change either set, adjust the character lists appearing in the
1064  * rule for "operator"!
1065  */
1066 /* we no longer allow unary minus in numbers.
1067  * instead we pass it separately to parser. there it gets
1068  * coerced via doNegate() -- Leon aug 20 1999
1069  *
1070  * {decimalfail} is used because we would like "1..10" to lex as 1, dot_dot, 10.
1071  *
1072  * {realfail1} and {realfail2} are added to prevent the need for scanner
1073  * backup when the {real} rule fails to match completely.
1074  */
1075 /*
1076  * Dollar quoted strings are totally opaque, and no escaping is done on them.
1077  * Other quoted strings must allow some special characters such as single-quote
1078  *  and newline.
1079  * Embedded single-quotes are implemented both in the SQL standard
1080  *  style of two adjacent single quotes "''" and in the Postgres/Java style
1081  *  of escaped-quote "\'".
1082  * Other embedded escaped characters are matched explicitly and the leading
1083  *  backslash is dropped from the string.
1084  * Note that xcstart must appear before operator, as explained above!
1085  *  Also whitespace (comment) must appear before operator.
1086  */
1087 #line 1088 "scan.c"
1088 
1089 #define INITIAL 0
1090 #define xb 1
1091 #define xc 2
1092 #define xd 3
1093 #define xh 4
1094 #define xe 5
1095 #define xq 6
1096 #define xdolq 7
1097 #define xui 8
1098 #define xuiend 9
1099 #define xus 10
1100 #define xusend 11
1101 #define xeu 12
1102 
1103 #ifndef YY_NO_UNISTD_H
1104 /* Special case for "unistd.h", since it is non-ANSI. We include it way
1105  * down here because we want the user's section 1 to have been scanned first.
1106  * The user has a chance to override it with an option.
1107  */
1108 #include <unistd.h>
1109 #endif
1110 
1111 #ifndef YY_EXTRA_TYPE
1112 #define YY_EXTRA_TYPE void *
1113 #endif
1114 
1115 /* Holds the entire state of the reentrant scanner. */
1116 struct yyguts_t
1117     {
1118 
1119     /* User-defined. Not touched by flex. */
1120     YY_EXTRA_TYPE yyextra_r;
1121 
1122     /* The rest are the same as the globals declared in the non-reentrant scanner. */
1123     FILE *yyin_r, *yyout_r;
1124     size_t yy_buffer_stack_top; /**< index of top of stack. */
1125     size_t yy_buffer_stack_max; /**< capacity of stack. */
1126     YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
1127     char yy_hold_char;
1128     yy_size_t yy_n_chars;
1129     yy_size_t yyleng_r;
1130     char *yy_c_buf_p;
1131     int yy_init;
1132     int yy_start;
1133     int yy_did_buffer_switch_on_eof;
1134     int yy_start_stack_ptr;
1135     int yy_start_stack_depth;
1136     int *yy_start_stack;
1137     yy_state_type yy_last_accepting_state;
1138     char* yy_last_accepting_cpos;
1139 
1140     int yylineno_r;
1141     int yy_flex_debug_r;
1142 
1143     char *yytext_r;
1144     int yy_more_flag;
1145     int yy_more_len;
1146 
1147     YYSTYPE * yylval_r;
1148 
1149     YYLTYPE * yylloc_r;
1150 
1151     }; /* end struct yyguts_t */
1152 
1153 static int yy_init_globals (yyscan_t yyscanner );
1154 
1155     /* This must go here because YYSTYPE and YYLTYPE are included
1156      * from bison output in section 1.*/
1157     #    define yylval yyg->yylval_r
1158 
1159     #    define yylloc yyg->yylloc_r
1160 
1161 int core_yylex_init (yyscan_t* scanner);
1162 
1163 int core_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
1164 
1165 /* Accessor methods to globals.
1166    These are made visible to non-reentrant scanners for convenience. */
1167 
1168 int core_yylex_destroy (yyscan_t yyscanner );
1169 
1170 int core_yyget_debug (yyscan_t yyscanner );
1171 
1172 void core_yyset_debug (int debug_flag ,yyscan_t yyscanner );
1173 
1174 YY_EXTRA_TYPE core_yyget_extra (yyscan_t yyscanner );
1175 
1176 void core_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
1177 
1178 FILE *core_yyget_in (yyscan_t yyscanner );
1179 
1180 void core_yyset_in  (FILE * in_str ,yyscan_t yyscanner );
1181 
1182 FILE *core_yyget_out (yyscan_t yyscanner );
1183 
1184 void core_yyset_out  (FILE * out_str ,yyscan_t yyscanner );
1185 
1186 yy_size_t core_yyget_leng (yyscan_t yyscanner );
1187 
1188 char *core_yyget_text (yyscan_t yyscanner );
1189 
1190 int core_yyget_lineno (yyscan_t yyscanner );
1191 
1192 void core_yyset_lineno (int line_number ,yyscan_t yyscanner );
1193 
1194 int core_yyget_column  (yyscan_t yyscanner );
1195 
1196 void core_yyset_column (int column_no ,yyscan_t yyscanner );
1197 
1198 YYSTYPE * core_yyget_lval (yyscan_t yyscanner );
1199 
1200 void core_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
1201 
1202        YYLTYPE *core_yyget_lloc (yyscan_t yyscanner );
1203 
1204         void core_yyset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner );
1205 
1206 /* Macros after this point can all be overridden by user definitions in
1207  * section 1.
1208  */
1209 
1210 #ifndef YY_SKIP_YYWRAP
1211 #ifdef __cplusplus
1212 extern "C" int core_yywrap (yyscan_t yyscanner );
1213 #else
1214 extern int core_yywrap (yyscan_t yyscanner );
1215 #endif
1216 #endif
1217 
1218 #ifndef yytext_ptr
1219 static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
1220 #endif
1221 
1222 #ifdef YY_NEED_STRLEN
1223 static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
1224 #endif
1225 
1226 #ifndef YY_NO_INPUT
1227 
1228 #ifdef __cplusplus
1229 static int yyinput (yyscan_t yyscanner );
1230 #else
1231 static int input (yyscan_t yyscanner );
1232 #endif
1233 
1234 #endif
1235 
1236 /* Amount of stuff to slurp up with each read. */
1237 #ifndef YY_READ_BUF_SIZE
1238 #define YY_READ_BUF_SIZE 8192
1239 #endif
1240 
1241 /* Copy whatever the last rule matched to the standard output. */
1242 #ifndef ECHO
1243 /* This used to be an fputs(), but since the string might contain NUL's,
1244  * we now use fwrite().
1245  */
1246 #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
1247 #endif
1248 
1249 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
1250  * is returned in "result".
1251  */
1252 #ifndef YY_INPUT
1253 #define YY_INPUT(buf,result,max_size) \
1254 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
1255 		{ \
1256 		int c = '*'; \
1257 		size_t n; \
1258 		for ( n = 0; n < max_size && \
1259 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
1260 			buf[n] = (char) c; \
1261 		if ( c == '\n' ) \
1262 			buf[n++] = (char) c; \
1263 		if ( c == EOF && ferror( yyin ) ) \
1264 			YY_FATAL_ERROR( "input in flex scanner failed" ); \
1265 		result = n; \
1266 		} \
1267 	else \
1268 		{ \
1269 		errno=0; \
1270 		while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
1271 			{ \
1272 			if( errno != EINTR) \
1273 				{ \
1274 				YY_FATAL_ERROR( "input in flex scanner failed" ); \
1275 				break; \
1276 				} \
1277 			errno=0; \
1278 			clearerr(yyin); \
1279 			} \
1280 		}\
1281 \
1282 
1283 #endif
1284 
1285 /* No semi-colon after return; correct usage is to write "yyterminate();" -
1286  * we don't want an extra ';' after the "return" because that will cause
1287  * some compilers to complain about unreachable statements.
1288  */
1289 #ifndef yyterminate
1290 #define yyterminate() return YY_NULL
1291 #endif
1292 
1293 /* Number of entries by which start-condition stack grows. */
1294 #ifndef YY_START_STACK_INCR
1295 #define YY_START_STACK_INCR 25
1296 #endif
1297 
1298 /* Report a fatal error. */
1299 #ifndef YY_FATAL_ERROR
1300 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
1301 #endif
1302 
1303 /* end tables serialization structures and prototypes */
1304 
1305 /* Default declaration of generated scanner - a define so the user can
1306  * easily add parameters.
1307  */
1308 #ifndef YY_DECL
1309 #define YY_DECL_IS_OURS 1
1310 
1311 extern int core_yylex \
1312                (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
1313 
1314 #define YY_DECL int core_yylex \
1315                (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
1316 #endif /* !YY_DECL */
1317 
1318 /* Code executed at the beginning of each rule, after yytext and yyleng
1319  * have been set up.
1320  */
1321 #ifndef YY_USER_ACTION
1322 #define YY_USER_ACTION
1323 #endif
1324 
1325 /* Code executed at the end of each rule. */
1326 #ifndef YY_BREAK
1327 #define YY_BREAK break;
1328 #endif
1329 
1330 #define YY_RULE_SETUP \
1331 	YY_USER_ACTION
1332 
1333 /** The main scanner function which does all the work.
1334  */
1335 YY_DECL
1336 {
1337 	register yy_state_type yy_current_state;
1338 	register char *yy_cp, *yy_bp;
1339 	register int yy_act;
1340     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1341 
1342 #line 401 "scan.l"
1343 
1344 
1345 #line 1346 "scan.c"
1346 
1347     yylval = yylval_param;
1348 
1349     yylloc = yylloc_param;
1350 
1351 	if ( !yyg->yy_init )
1352 		{
1353 		yyg->yy_init = 1;
1354 
1355 #ifdef YY_USER_INIT
1356 		YY_USER_INIT;
1357 #endif
1358 
1359 		if ( ! yyg->yy_start )
1360 			yyg->yy_start = 1;	/* first start state */
1361 
1362 		if ( ! yyin )
1363 			yyin = stdin;
1364 
1365 		if ( ! yyout )
1366 			yyout = stdout;
1367 
1368 		if ( ! YY_CURRENT_BUFFER ) {
1369 			core_yyensure_buffer_stack (yyscanner);
1370 			YY_CURRENT_BUFFER_LVALUE =
1371 				core_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
1372 		}
1373 
1374 		core_yy_load_buffer_state(yyscanner );
1375 		}
1376 
1377 	while ( 1 )		/* loops until end-of-file is reached */
1378 		{
1379 		yy_cp = yyg->yy_c_buf_p;
1380 
1381 		/* Support of yytext. */
1382 		*yy_cp = yyg->yy_hold_char;
1383 
1384 		/* yy_bp points to the position in yy_ch_buf of the start of
1385 		 * the current run.
1386 		 */
1387 		yy_bp = yy_cp;
1388 
1389 		yy_current_state = yyg->yy_start;
1390 yy_match:
1391 		do
1392 			{
1393 			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
1394 			if ( yy_accept[yy_current_state] )
1395 				{
1396 				yyg->yy_last_accepting_state = yy_current_state;
1397 				yyg->yy_last_accepting_cpos = yy_cp;
1398 				}
1399 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1400 				{
1401 				yy_current_state = (int) yy_def[yy_current_state];
1402 				if ( yy_current_state >= 290 )
1403 					yy_c = yy_meta[(unsigned int) yy_c];
1404 				}
1405 			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1406 			++yy_cp;
1407 			}
1408 		while ( yy_current_state != 289 );
1409 		yy_cp = yyg->yy_last_accepting_cpos;
1410 		yy_current_state = yyg->yy_last_accepting_state;
1411 
1412 yy_find_action:
1413 		yy_act = yy_accept[yy_current_state];
1414 
1415 		YY_DO_BEFORE_ACTION;
1416 
1417 do_action:	/* This label is used only to access EOF actions. */
1418 
1419 		switch ( yy_act )
1420 	{ /* beginning of action switch */
1421 			case 0: /* must back up */
1422 			/* undo the effects of YY_DO_BEFORE_ACTION */
1423 			*yy_cp = yyg->yy_hold_char;
1424 			yy_cp = yyg->yy_last_accepting_cpos;
1425 			yy_current_state = yyg->yy_last_accepting_state;
1426 			goto yy_find_action;
1427 
1428 case 1:
1429 /* rule 1 can match eol */
1430 YY_RULE_SETUP
1431 #line 403 "scan.l"
1432 {
1433 					/* ignore */
1434 				}
1435 	YY_BREAK
1436 case 2:
1437 YY_RULE_SETUP
1438 #line 407 "scan.l"
1439 {
1440 					/* Set location in case of syntax error in comment */
1441 					SET_YYLLOC();
1442 					yyextra->xcdepth = 0;
1443 					BEGIN(xc);
1444 					/* Put back any characters past slash-star; see above */
1445 					yyless(2);
1446 				}
1447 	YY_BREAK
1448 case 3:
1449 YY_RULE_SETUP
1450 #line 416 "scan.l"
1451 {
1452 					(yyextra->xcdepth)++;
1453 					/* Put back any characters past slash-star; see above */
1454 					yyless(2);
1455 				}
1456 	YY_BREAK
1457 case 4:
1458 YY_RULE_SETUP
1459 #line 422 "scan.l"
1460 {
1461 					if (yyextra->xcdepth <= 0)
1462 						BEGIN(INITIAL);
1463 					else
1464 						(yyextra->xcdepth)--;
1465 				}
1466 	YY_BREAK
1467 case 5:
1468 /* rule 5 can match eol */
1469 YY_RULE_SETUP
1470 #line 429 "scan.l"
1471 {
1472 					/* ignore */
1473 				}
1474 	YY_BREAK
1475 case 6:
1476 YY_RULE_SETUP
1477 #line 433 "scan.l"
1478 {
1479 					/* ignore */
1480 				}
1481 	YY_BREAK
1482 case 7:
1483 YY_RULE_SETUP
1484 #line 437 "scan.l"
1485 {
1486 					/* ignore */
1487 				}
1488 	YY_BREAK
1489 case YY_STATE_EOF(xc):
1490 #line 441 "scan.l"
1491 { yyerror("unterminated /* comment"); }
1492 	YY_BREAK
1493 case 8:
1494 YY_RULE_SETUP
1495 #line 443 "scan.l"
1496 {
1497 					/* Binary bit type.
1498 					 * At some point we should simply pass the string
1499 					 * forward to the parser and label it there.
1500 					 * In the meantime, place a leading "b" on the string
1501 					 * to mark it for the input routine as a binary string.
1502 					 */
1503 					SET_YYLLOC();
1504 					BEGIN(xb);
1505 					startlit();
1506 					addlitchar('b', yyscanner);
1507 				}
1508 	YY_BREAK
1509 case 9:
1510 /* rule 9 can match eol */
1511 #line 456 "scan.l"
1512 case 10:
1513 /* rule 10 can match eol */
1514 YY_RULE_SETUP
1515 #line 456 "scan.l"
1516 {
1517 					yyless(1);
1518 					BEGIN(INITIAL);
1519 					yylval->str = litbufdup(yyscanner);
1520 					return BCONST;
1521 				}
1522 	YY_BREAK
1523 case 11:
1524 /* rule 11 can match eol */
1525 #line 463 "scan.l"
1526 case 12:
1527 /* rule 12 can match eol */
1528 YY_RULE_SETUP
1529 #line 463 "scan.l"
1530 {
1531 					addlit(yytext, yyleng, yyscanner);
1532 				}
1533 	YY_BREAK
1534 case 13:
1535 /* rule 13 can match eol */
1536 #line 467 "scan.l"
1537 case 14:
1538 /* rule 14 can match eol */
1539 YY_RULE_SETUP
1540 #line 467 "scan.l"
1541 {
1542 					/* ignore */
1543 				}
1544 	YY_BREAK
1545 case YY_STATE_EOF(xb):
1546 #line 470 "scan.l"
1547 { yyerror("unterminated bit string literal"); }
1548 	YY_BREAK
1549 case 15:
1550 YY_RULE_SETUP
1551 #line 472 "scan.l"
1552 {
1553 					/* Hexadecimal bit type.
1554 					 * At some point we should simply pass the string
1555 					 * forward to the parser and label it there.
1556 					 * In the meantime, place a leading "x" on the string
1557 					 * to mark it for the input routine as a hex string.
1558 					 */
1559 					SET_YYLLOC();
1560 					BEGIN(xh);
1561 					startlit();
1562 					addlitchar('x', yyscanner);
1563 				}
1564 	YY_BREAK
1565 case 16:
1566 /* rule 16 can match eol */
1567 #line 485 "scan.l"
1568 case 17:
1569 /* rule 17 can match eol */
1570 YY_RULE_SETUP
1571 #line 485 "scan.l"
1572 {
1573 					yyless(1);
1574 					BEGIN(INITIAL);
1575 					yylval->str = litbufdup(yyscanner);
1576 					return XCONST;
1577 				}
1578 	YY_BREAK
1579 case YY_STATE_EOF(xh):
1580 #line 491 "scan.l"
1581 { yyerror("unterminated hexadecimal string literal"); }
1582 	YY_BREAK
1583 case 18:
1584 YY_RULE_SETUP
1585 #line 493 "scan.l"
1586 {
1587 					/* National character.
1588 					 * We will pass this along as a normal character string,
1589 					 * but preceded with an internally-generated "NCHAR".
1590 					 */
1591 					const ScanKeyword *keyword;
1592 
1593 					SET_YYLLOC();
1594 					yyless(1);	/* eat only 'n' this time */
1595 
1596 					keyword = ScanKeywordLookup("nchar",
1597 												yyextra->keywords,
1598 												yyextra->num_keywords);
1599 					if (keyword != NULL)
1600 					{
1601 						yylval->keyword = keyword->name;
1602 						return keyword->value;
1603 					}
1604 					else
1605 					{
1606 						/* If NCHAR isn't a keyword, just return "n" */
1607 						yylval->str = pstrdup("n");
1608 						return IDENT;
1609 					}
1610 				}
1611 	YY_BREAK
1612 case 19:
1613 YY_RULE_SETUP
1614 #line 519 "scan.l"
1615 {
1616 					yyextra->warn_on_first_escape = true;
1617 					yyextra->saw_non_ascii = false;
1618 					SET_YYLLOC();
1619 					if (yyextra->standard_conforming_strings)
1620 						BEGIN(xq);
1621 					else
1622 						BEGIN(xe);
1623 					startlit();
1624 				}
1625 	YY_BREAK
1626 case 20:
1627 YY_RULE_SETUP
1628 #line 529 "scan.l"
1629 {
1630 					yyextra->warn_on_first_escape = false;
1631 					yyextra->saw_non_ascii = false;
1632 					SET_YYLLOC();
1633 					BEGIN(xe);
1634 					startlit();
1635 				}
1636 	YY_BREAK
1637 case 21:
1638 YY_RULE_SETUP
1639 #line 536 "scan.l"
1640 {
1641 					SET_YYLLOC();
1642 					if (!yyextra->standard_conforming_strings)
1643 						ereport(ERROR,
1644 								(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1645 								 errmsg("unsafe use of string constant with Unicode escapes"),
1646 								 errdetail("String constants with Unicode escapes cannot be used when standard_conforming_strings is off."),
1647 								 lexer_errposition()));
1648 					BEGIN(xus);
1649 					startlit();
1650 				}
1651 	YY_BREAK
1652 case 22:
1653 /* rule 22 can match eol */
1654 #line 548 "scan.l"
1655 case 23:
1656 /* rule 23 can match eol */
1657 YY_RULE_SETUP
1658 #line 548 "scan.l"
1659 {
1660 					yyless(1);
1661 					BEGIN(INITIAL);
1662 					/*
1663 					 * check that the data remains valid if it might have been
1664 					 * made invalid by unescaping any chars.
1665 					 */
1666 					if (yyextra->saw_non_ascii)
1667 						pg_verifymbstr(yyextra->literalbuf,
1668 									   yyextra->literallen,
1669 									   false);
1670 					yylval->str = litbufdup(yyscanner);
1671 					return SCONST;
1672 				}
1673 	YY_BREAK
1674 case 24:
1675 /* rule 24 can match eol */
1676 #line 563 "scan.l"
1677 case 25:
1678 /* rule 25 can match eol */
1679 YY_RULE_SETUP
1680 #line 563 "scan.l"
1681 {
1682 					/* throw back all but the quote */
1683 					yyless(1);
1684 					/* xusend state looks for possible UESCAPE */
1685 					BEGIN(xusend);
1686 				}
1687 	YY_BREAK
1688 case 26:
1689 /* rule 26 can match eol */
1690 YY_RULE_SETUP
1691 #line 569 "scan.l"
1692 {
1693 					/* stay in xusend state over whitespace */
1694 				}
1695 	YY_BREAK
1696 case YY_STATE_EOF(xusend):
1697 #line 572 "scan.l"
1698 case 27:
1699 /* rule 27 can match eol */
1700 #line 574 "scan.l"
1701 case 28:
1702 /* rule 28 can match eol */
1703 YY_RULE_SETUP
1704 #line 574 "scan.l"
1705 {
1706 					/* no UESCAPE after the quote, throw back everything */
1707 					yyless(0);
1708 					BEGIN(INITIAL);
1709 					yylval->str = litbuf_udeescape('\\', yyscanner);
1710 					return SCONST;
1711 				}
1712 	YY_BREAK
1713 case 29:
1714 /* rule 29 can match eol */
1715 YY_RULE_SETUP
1716 #line 581 "scan.l"
1717 {
1718 					/* found UESCAPE after the end quote */
1719 					BEGIN(INITIAL);
1720 					if (!check_uescapechar(yytext[yyleng - 2]))
1721 					{
1722 						SET_YYLLOC();
1723 						ADVANCE_YYLLOC(yyleng - 2);
1724 						yyerror("invalid Unicode escape character");
1725 					}
1726 					yylval->str = litbuf_udeescape(yytext[yyleng - 2],
1727 												   yyscanner);
1728 					return SCONST;
1729 				}
1730 	YY_BREAK
1731 case 30:
1732 YY_RULE_SETUP
1733 #line 594 "scan.l"
1734 {
1735 					addlitchar('\'', yyscanner);
1736 				}
1737 	YY_BREAK
1738 case 31:
1739 /* rule 31 can match eol */
1740 YY_RULE_SETUP
1741 #line 597 "scan.l"
1742 {
1743 					addlit(yytext, yyleng, yyscanner);
1744 				}
1745 	YY_BREAK
1746 case 32:
1747 /* rule 32 can match eol */
1748 YY_RULE_SETUP
1749 #line 600 "scan.l"
1750 {
1751 					addlit(yytext, yyleng, yyscanner);
1752 				}
1753 	YY_BREAK
1754 case 33:
1755 YY_RULE_SETUP
1756 #line 603 "scan.l"
1757 {
1758 					pg_wchar	c = strtoul(yytext + 2, NULL, 16);
1759 
1760 					check_escape_warning(yyscanner);
1761 
1762 					if (is_utf16_surrogate_first(c))
1763 					{
1764 						yyextra->utf16_first_part = c;
1765 						BEGIN(xeu);
1766 					}
1767 					else if (is_utf16_surrogate_second(c))
1768 						yyerror("invalid Unicode surrogate pair");
1769 					else
1770 						addunicode(c, yyscanner);
1771 				}
1772 	YY_BREAK
1773 case 34:
1774 YY_RULE_SETUP
1775 #line 618 "scan.l"
1776 {
1777 					pg_wchar	c = strtoul(yytext + 2, NULL, 16);
1778 
1779 					if (!is_utf16_surrogate_second(c))
1780 						yyerror("invalid Unicode surrogate pair");
1781 
1782 					c = surrogate_pair_to_codepoint(yyextra->utf16_first_part, c);
1783 
1784 					addunicode(c, yyscanner);
1785 
1786 					BEGIN(xe);
1787 				}
1788 	YY_BREAK
1789 case 35:
1790 YY_RULE_SETUP
1791 #line 630 "scan.l"
1792 { yyerror("invalid Unicode surrogate pair"); }
1793 	YY_BREAK
1794 case 36:
1795 /* rule 36 can match eol */
1796 YY_RULE_SETUP
1797 #line 631 "scan.l"
1798 { yyerror("invalid Unicode surrogate pair"); }
1799 	YY_BREAK
1800 case YY_STATE_EOF(xeu):
1801 #line 632 "scan.l"
1802 { yyerror("invalid Unicode surrogate pair"); }
1803 	YY_BREAK
1804 case 37:
1805 YY_RULE_SETUP
1806 #line 633 "scan.l"
1807 {
1808 					ereport(ERROR,
1809 							(errcode(ERRCODE_INVALID_ESCAPE_SEQUENCE),
1810 							 errmsg("invalid Unicode escape"),
1811 							 errhint("Unicode escapes must be \\uXXXX or \\UXXXXXXXX."),
1812 							 lexer_errposition()));
1813 				}
1814 	YY_BREAK
1815 case 38:
1816 /* rule 38 can match eol */
1817 YY_RULE_SETUP
1818 #line 640 "scan.l"
1819 {
1820 #ifdef PGPOOL_NOT_USED
1821 					if (yytext[1] == '\'')
1822 					{
1823 						if (yyextra->backslash_quote == BACKSLASH_QUOTE_OFF ||
1824 							(yyextra->backslash_quote == BACKSLASH_QUOTE_SAFE_ENCODING &&
1825 							 PG_ENCODING_IS_CLIENT_ONLY(pg_get_client_encoding())))
1826 							ereport(ERROR,
1827 									(errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
1828 									 errmsg("unsafe use of \\' in a string literal"),
1829 									 errhint("Use '' to write quotes in strings. \\' is insecure in client-only encodings."),
1830 									 lexer_errposition()));
1831 					}
1832 #endif
1833 					check_string_escape_warning(yytext[1], yyscanner);
1834 					addlitchar(unescape_single_char(yytext[1], yyscanner),
1835 							   yyscanner);
1836 				}
1837 	YY_BREAK
1838 case 39:
1839 YY_RULE_SETUP
1840 #line 658 "scan.l"
1841 {
1842 					unsigned char c = strtoul(yytext + 1, NULL, 8);
1843 
1844 					check_escape_warning(yyscanner);
1845 					addlitchar(c, yyscanner);
1846 					if (c == '\0' || IS_HIGHBIT_SET(c))
1847 						yyextra->saw_non_ascii = true;
1848 				}
1849 	YY_BREAK
1850 case 40:
1851 YY_RULE_SETUP
1852 #line 666 "scan.l"
1853 {
1854 					unsigned char c = strtoul(yytext + 2, NULL, 16);
1855 
1856 					check_escape_warning(yyscanner);
1857 					addlitchar(c, yyscanner);
1858 					if (c == '\0' || IS_HIGHBIT_SET(c))
1859 						yyextra->saw_non_ascii = true;
1860 				}
1861 	YY_BREAK
1862 case 41:
1863 /* rule 41 can match eol */
1864 YY_RULE_SETUP
1865 #line 674 "scan.l"
1866 {
1867 					/* ignore */
1868 				}
1869 	YY_BREAK
1870 case 42:
1871 YY_RULE_SETUP
1872 #line 677 "scan.l"
1873 {
1874 					/* This is only needed for \ just before EOF */
1875 					addlitchar(yytext[0], yyscanner);
1876 				}
1877 	YY_BREAK
1878 case YY_STATE_EOF(xq):
1879 case YY_STATE_EOF(xe):
1880 case YY_STATE_EOF(xus):
1881 #line 681 "scan.l"
1882 { yyerror("unterminated quoted string"); }
1883 	YY_BREAK
1884 case 43:
1885 YY_RULE_SETUP
1886 #line 683 "scan.l"
1887 {
1888 					SET_YYLLOC();
1889 					yyextra->dolqstart = pstrdup(yytext);
1890 					BEGIN(xdolq);
1891 					startlit();
1892 				}
1893 	YY_BREAK
1894 case 44:
1895 YY_RULE_SETUP
1896 #line 689 "scan.l"
1897 {
1898 					SET_YYLLOC();
1899 					/* throw back all but the initial "$" */
1900 					yyless(1);
1901 					/* and treat it as {other} */
1902 					return yytext[0];
1903 				}
1904 	YY_BREAK
1905 case 45:
1906 YY_RULE_SETUP
1907 #line 696 "scan.l"
1908 {
1909 					if (strcmp(yytext, yyextra->dolqstart) == 0)
1910 					{
1911 						pfree(yyextra->dolqstart);
1912 						yyextra->dolqstart = NULL;
1913 						BEGIN(INITIAL);
1914 						yylval->str = litbufdup(yyscanner);
1915 						return SCONST;
1916 					}
1917 					else
1918 					{
1919 						/*
1920 						 * When we fail to match $...$ to dolqstart, transfer
1921 						 * the $... part to the output, but put back the final
1922 						 * $ for rescanning.  Consider $delim$...$junk$delim$
1923 						 */
1924 						addlit(yytext, yyleng - 1, yyscanner);
1925 						yyless(yyleng - 1);
1926 					}
1927 				}
1928 	YY_BREAK
1929 case 46:
1930 /* rule 46 can match eol */
1931 YY_RULE_SETUP
1932 #line 716 "scan.l"
1933 {
1934 					addlit(yytext, yyleng, yyscanner);
1935 				}
1936 	YY_BREAK
1937 case 47:
1938 YY_RULE_SETUP
1939 #line 719 "scan.l"
1940 {
1941 					addlit(yytext, yyleng, yyscanner);
1942 				}
1943 	YY_BREAK
1944 case 48:
1945 YY_RULE_SETUP
1946 #line 722 "scan.l"
1947 {
1948 					/* This is only needed for $ inside the quoted text */
1949 					addlitchar(yytext[0], yyscanner);
1950 				}
1951 	YY_BREAK
1952 case YY_STATE_EOF(xdolq):
1953 #line 726 "scan.l"
1954 { yyerror("unterminated dollar-quoted string"); }
1955 	YY_BREAK
1956 case 49:
1957 YY_RULE_SETUP
1958 #line 728 "scan.l"
1959 {
1960 					SET_YYLLOC();
1961 					BEGIN(xd);
1962 					startlit();
1963 				}
1964 	YY_BREAK
1965 case 50:
1966 YY_RULE_SETUP
1967 #line 733 "scan.l"
1968 {
1969 					SET_YYLLOC();
1970 					BEGIN(xui);
1971 					startlit();
1972 				}
1973 	YY_BREAK
1974 case 51:
1975 YY_RULE_SETUP
1976 #line 738 "scan.l"
1977 {
1978 					char	   *ident;
1979 
1980 					BEGIN(INITIAL);
1981 					if (yyextra->literallen == 0)
1982 						yyerror("zero-length delimited identifier");
1983 					ident = litbufdup(yyscanner);
1984 					if (yyextra->literallen >= NAMEDATALEN)
1985 						truncate_identifier(ident, yyextra->literallen, true);
1986 					yylval->str = ident;
1987 					return IDENT;
1988 				}
1989 	YY_BREAK
1990 case 52:
1991 YY_RULE_SETUP
1992 #line 750 "scan.l"
1993 {
1994 					yyless(1);
1995 					/* xuiend state looks for possible UESCAPE */
1996 					BEGIN(xuiend);
1997 				}
1998 	YY_BREAK
1999 case 53:
2000 /* rule 53 can match eol */
2001 YY_RULE_SETUP
2002 #line 755 "scan.l"
2003 {
2004 					/* stay in xuiend state over whitespace */
2005 				}
2006 	YY_BREAK
2007 case YY_STATE_EOF(xuiend):
2008 #line 758 "scan.l"
2009 case 54:
2010 /* rule 54 can match eol */
2011 #line 760 "scan.l"
2012 case 55:
2013 /* rule 55 can match eol */
2014 YY_RULE_SETUP
2015 #line 760 "scan.l"
2016 {
2017 					/* no UESCAPE after the quote, throw back everything */
2018 					char	   *ident;
2019 					int			identlen;
2020 
2021 					yyless(0);
2022 
2023 					BEGIN(INITIAL);
2024 					if (yyextra->literallen == 0)
2025 						yyerror("zero-length delimited identifier");
2026 					ident = litbuf_udeescape('\\', yyscanner);
2027 					identlen = strlen(ident);
2028 					if (identlen >= NAMEDATALEN)
2029 						truncate_identifier(ident, identlen, true);
2030 					yylval->str = ident;
2031 					return IDENT;
2032 				}
2033 	YY_BREAK
2034 case 56:
2035 /* rule 56 can match eol */
2036 YY_RULE_SETUP
2037 #line 777 "scan.l"
2038 {
2039 					/* found UESCAPE after the end quote */
2040 					char	   *ident;
2041 					int			identlen;
2042 
2043 					BEGIN(INITIAL);
2044 					if (yyextra->literallen == 0)
2045 						yyerror("zero-length delimited identifier");
2046 					if (!check_uescapechar(yytext[yyleng - 2]))
2047 					{
2048 						SET_YYLLOC();
2049 						ADVANCE_YYLLOC(yyleng - 2);
2050 						yyerror("invalid Unicode escape character");
2051 					}
2052 					ident = litbuf_udeescape(yytext[yyleng - 2], yyscanner);
2053 					identlen = strlen(ident);
2054 					if (identlen >= NAMEDATALEN)
2055 						truncate_identifier(ident, identlen, true);
2056 					yylval->str = ident;
2057 					return IDENT;
2058 				}
2059 	YY_BREAK
2060 case 57:
2061 YY_RULE_SETUP
2062 #line 798 "scan.l"
2063 {
2064 					addlitchar('"', yyscanner);
2065 				}
2066 	YY_BREAK
2067 case 58:
2068 /* rule 58 can match eol */
2069 YY_RULE_SETUP
2070 #line 801 "scan.l"
2071 {
2072 					addlit(yytext, yyleng, yyscanner);
2073 				}
2074 	YY_BREAK
2075 case YY_STATE_EOF(xd):
2076 case YY_STATE_EOF(xui):
2077 #line 804 "scan.l"
2078 { yyerror("unterminated quoted identifier"); }
2079 	YY_BREAK
2080 case 59:
2081 YY_RULE_SETUP
2082 #line 806 "scan.l"
2083 {
2084 					char	   *ident;
2085 
2086 					SET_YYLLOC();
2087 					/* throw back all but the initial u/U */
2088 					yyless(1);
2089 					/* and treat it as {identifier} */
2090 					ident = downcase_truncate_identifier(yytext, yyleng, true);
2091 					yylval->str = ident;
2092 					return IDENT;
2093 				}
2094 	YY_BREAK
2095 case 60:
2096 YY_RULE_SETUP
2097 #line 818 "scan.l"
2098 {
2099 					SET_YYLLOC();
2100 					return TYPECAST;
2101 				}
2102 	YY_BREAK
2103 case 61:
2104 YY_RULE_SETUP
2105 #line 823 "scan.l"
2106 {
2107 					SET_YYLLOC();
2108 					return DOT_DOT;
2109 				}
2110 	YY_BREAK
2111 case 62:
2112 YY_RULE_SETUP
2113 #line 828 "scan.l"
2114 {
2115 					SET_YYLLOC();
2116 					return COLON_EQUALS;
2117 				}
2118 	YY_BREAK
2119 case 63:
2120 YY_RULE_SETUP
2121 #line 833 "scan.l"
2122 {
2123 					SET_YYLLOC();
2124 					return EQUALS_GREATER;
2125 				}
2126 	YY_BREAK
2127 case 64:
2128 YY_RULE_SETUP
2129 #line 838 "scan.l"
2130 {
2131 					SET_YYLLOC();
2132 					return LESS_EQUALS;
2133 				}
2134 	YY_BREAK
2135 case 65:
2136 YY_RULE_SETUP
2137 #line 843 "scan.l"
2138 {
2139 					SET_YYLLOC();
2140 					return GREATER_EQUALS;
2141 				}
2142 	YY_BREAK
2143 case 66:
2144 YY_RULE_SETUP
2145 #line 848 "scan.l"
2146 {
2147 					/* We accept both "<>" and "!=" as meaning NOT_EQUALS */
2148 					SET_YYLLOC();
2149 					return NOT_EQUALS;
2150 				}
2151 	YY_BREAK
2152 case 67:
2153 YY_RULE_SETUP
2154 #line 854 "scan.l"
2155 {
2156 					/* We accept both "<>" and "!=" as meaning NOT_EQUALS */
2157 					SET_YYLLOC();
2158 					return NOT_EQUALS;
2159 				}
2160 	YY_BREAK
2161 case 68:
2162 YY_RULE_SETUP
2163 #line 860 "scan.l"
2164 {
2165 					SET_YYLLOC();
2166 					return yytext[0];
2167 				}
2168 	YY_BREAK
2169 case 69:
2170 YY_RULE_SETUP
2171 #line 865 "scan.l"
2172 {
2173 					/*
2174 					 * Check for embedded slash-star or dash-dash; those
2175 					 * are comment starts, so operator must stop there.
2176 					 * Note that slash-star or dash-dash at the first
2177 					 * character will match a prior rule, not this one.
2178 					 */
2179 					int			nchars = yyleng;
2180 					char	   *slashstar = strstr(yytext, "/*");
2181 					char	   *dashdash = strstr(yytext, "--");
2182 
2183 					if (slashstar && dashdash)
2184 					{
2185 						/* if both appear, take the first one */
2186 						if (slashstar > dashdash)
2187 							slashstar = dashdash;
2188 					}
2189 					else if (!slashstar)
2190 						slashstar = dashdash;
2191 					if (slashstar)
2192 						nchars = slashstar - yytext;
2193 
2194 					/*
2195 					 * For SQL compatibility, '+' and '-' cannot be the
2196 					 * last char of a multi-char operator unless the operator
2197 					 * contains chars that are not in SQL operators.
2198 					 * The idea is to lex '=-' as two operators, but not
2199 					 * to forbid operator names like '?-' that could not be
2200 					 * sequences of SQL operators.
2201 					 */
2202 					while (nchars > 1 &&
2203 						   (yytext[nchars - 1] == '+' ||
2204 							yytext[nchars - 1] == '-'))
2205 					{
2206 						int			ic;
2207 
2208 						for (ic = nchars - 2; ic >= 0; ic--)
2209 						{
2210 							if (strchr("~!@#^&|`?%", yytext[ic]))
2211 								break;
2212 						}
2213 						if (ic >= 0)
2214 							break; /* found a char that makes it OK */
2215 						nchars--; /* else remove the +/-, and check again */
2216 					}
2217 
2218 					SET_YYLLOC();
2219 
2220 					if (nchars < yyleng)
2221 					{
2222 						/* Strip the unwanted chars from the token */
2223 						yyless(nchars);
2224 						/*
2225 						 * If what we have left is only one char, and it's
2226 						 * one of the characters matching "self", then
2227 						 * return it as a character token the same way
2228 						 * that the "self" rule would have.
2229 						 */
2230 						if (nchars == 1 &&
2231 							strchr(",()[].;:+-*/%^<>=", yytext[0]))
2232 							return yytext[0];
2233 					}
2234 
2235 					/*
2236 					 * Complain if operator is too long.  Unlike the case
2237 					 * for identifiers, we make this an error not a notice-
2238 					 * and-truncate, because the odds are we are looking at
2239 					 * a syntactic mistake anyway.
2240 					 */
2241 					if (nchars >= NAMEDATALEN)
2242 						yyerror("operator too long");
2243 
2244 					yylval->str = pstrdup(yytext);
2245 					return Op;
2246 				}
2247 	YY_BREAK
2248 case 70:
2249 YY_RULE_SETUP
2250 #line 941 "scan.l"
2251 {
2252 					SET_YYLLOC();
2253 					yylval->ival = atol(yytext + 1);
2254 					return PARAM;
2255 				}
2256 	YY_BREAK
2257 case 71:
2258 YY_RULE_SETUP
2259 #line 947 "scan.l"
2260 {
2261 					SET_YYLLOC();
2262 					return process_integer_literal(yytext, yylval);
2263 				}
2264 	YY_BREAK
2265 case 72:
2266 YY_RULE_SETUP
2267 #line 951 "scan.l"
2268 {
2269 					SET_YYLLOC();
2270 					yylval->str = pstrdup(yytext);
2271 					return FCONST;
2272 				}
2273 	YY_BREAK
2274 case 73:
2275 YY_RULE_SETUP
2276 #line 956 "scan.l"
2277 {
2278 					/* throw back the .., and treat as integer */
2279 					yyless(yyleng - 2);
2280 					SET_YYLLOC();
2281 					return process_integer_literal(yytext, yylval);
2282 				}
2283 	YY_BREAK
2284 case 74:
2285 YY_RULE_SETUP
2286 #line 962 "scan.l"
2287 {
2288 					SET_YYLLOC();
2289 					yylval->str = pstrdup(yytext);
2290 					return FCONST;
2291 				}
2292 	YY_BREAK
2293 case 75:
2294 YY_RULE_SETUP
2295 #line 967 "scan.l"
2296 {
2297 					/*
2298 					 * throw back the [Ee], and treat as {decimal}.  Note
2299 					 * that it is possible the input is actually {integer},
2300 					 * but since this case will almost certainly lead to a
2301 					 * syntax error anyway, we don't bother to distinguish.
2302 					 */
2303 					yyless(yyleng - 1);
2304 					SET_YYLLOC();
2305 					yylval->str = pstrdup(yytext);
2306 					return FCONST;
2307 				}
2308 	YY_BREAK
2309 case 76:
2310 YY_RULE_SETUP
2311 #line 979 "scan.l"
2312 {
2313 					/* throw back the [Ee][+-], and proceed as above */
2314 					yyless(yyleng - 2);
2315 					SET_YYLLOC();
2316 					yylval->str = pstrdup(yytext);
2317 					return FCONST;
2318 				}
2319 	YY_BREAK
2320 case 77:
2321 YY_RULE_SETUP
2322 #line 988 "scan.l"
2323 {
2324 					const ScanKeyword *keyword;
2325 					char	   *ident;
2326 
2327 					SET_YYLLOC();
2328 
2329 					/* Is it a keyword? */
2330 					keyword = ScanKeywordLookup(yytext,
2331 												yyextra->keywords,
2332 												yyextra->num_keywords);
2333 					if (keyword != NULL)
2334 					{
2335 						yylval->keyword = keyword->name;
2336 						return keyword->value;
2337 					}
2338 
2339 					/*
2340 					 * No.  Convert the identifier to lower case, and truncate
2341 					 * if necessary.
2342 					 */
2343 					ident = downcase_truncate_identifier(yytext, yyleng, true);
2344 					yylval->str = ident;
2345 					return IDENT;
2346 				}
2347 	YY_BREAK
2348 case 78:
2349 YY_RULE_SETUP
2350 #line 1013 "scan.l"
2351 {
2352 					SET_YYLLOC();
2353 					return yytext[0];
2354 				}
2355 	YY_BREAK
2356 case YY_STATE_EOF(INITIAL):
2357 #line 1018 "scan.l"
2358 {
2359 					SET_YYLLOC();
2360 					yyterminate();
2361 				}
2362 	YY_BREAK
2363 case 79:
2364 YY_RULE_SETUP
2365 #line 1023 "scan.l"
2366 YY_FATAL_ERROR( "flex scanner jammed" );
2367 	YY_BREAK
2368 #line 2369 "scan.c"
2369 
2370 	case YY_END_OF_BUFFER:
2371 		{
2372 		/* Amount of text matched not including the EOB char. */
2373 		int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
2374 
2375 		/* Undo the effects of YY_DO_BEFORE_ACTION. */
2376 		*yy_cp = yyg->yy_hold_char;
2377 		YY_RESTORE_YY_MORE_OFFSET
2378 
2379 		if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
2380 			{
2381 			/* We're scanning a new file or input source.  It's
2382 			 * possible that this happened because the user
2383 			 * just pointed yyin at a new source and called
2384 			 * core_yylex().  If so, then we have to assure
2385 			 * consistency between YY_CURRENT_BUFFER and our
2386 			 * globals.  Here is the right place to do so, because
2387 			 * this is the first action (other than possibly a
2388 			 * back-up) that will match for the new input source.
2389 			 */
2390 			yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2391 			YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
2392 			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
2393 			}
2394 
2395 		/* Note that here we test for yy_c_buf_p "<=" to the position
2396 		 * of the first EOB in the buffer, since yy_c_buf_p will
2397 		 * already have been incremented past the NUL character
2398 		 * (since all states make transitions on EOB to the
2399 		 * end-of-buffer state).  Contrast this with the test
2400 		 * in input().
2401 		 */
2402 		if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
2403 			{ /* This was really a NUL. */
2404 			yy_state_type yy_next_state;
2405 
2406 			yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
2407 
2408 			yy_current_state = yy_get_previous_state( yyscanner );
2409 
2410 			/* Okay, we're now positioned to make the NUL
2411 			 * transition.  We couldn't have
2412 			 * yy_get_previous_state() go ahead and do it
2413 			 * for us because it doesn't know how to deal
2414 			 * with the possibility of jamming (and we don't
2415 			 * want to build jamming into it because then it
2416 			 * will run more slowly).
2417 			 */
2418 
2419 			yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
2420 
2421 			yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
2422 
2423 			if ( yy_next_state )
2424 				{
2425 				/* Consume the NUL. */
2426 				yy_cp = ++yyg->yy_c_buf_p;
2427 				yy_current_state = yy_next_state;
2428 				goto yy_match;
2429 				}
2430 
2431 			else
2432 				{
2433 				yy_cp = yyg->yy_last_accepting_cpos;
2434 				yy_current_state = yyg->yy_last_accepting_state;
2435 				goto yy_find_action;
2436 				}
2437 			}
2438 
2439 		else switch ( yy_get_next_buffer( yyscanner ) )
2440 			{
2441 			case EOB_ACT_END_OF_FILE:
2442 				{
2443 				yyg->yy_did_buffer_switch_on_eof = 0;
2444 
2445 				if ( core_yywrap(yyscanner ) )
2446 					{
2447 					/* Note: because we've taken care in
2448 					 * yy_get_next_buffer() to have set up
2449 					 * yytext, we can now set up
2450 					 * yy_c_buf_p so that if some total
2451 					 * hoser (like flex itself) wants to
2452 					 * call the scanner after we return the
2453 					 * YY_NULL, it'll still work - another
2454 					 * YY_NULL will get returned.
2455 					 */
2456 					yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
2457 
2458 					yy_act = YY_STATE_EOF(YY_START);
2459 					goto do_action;
2460 					}
2461 
2462 				else
2463 					{
2464 					if ( ! yyg->yy_did_buffer_switch_on_eof )
2465 						YY_NEW_FILE;
2466 					}
2467 				break;
2468 				}
2469 
2470 			case EOB_ACT_CONTINUE_SCAN:
2471 				yyg->yy_c_buf_p =
2472 					yyg->yytext_ptr + yy_amount_of_matched_text;
2473 
2474 				yy_current_state = yy_get_previous_state( yyscanner );
2475 
2476 				yy_cp = yyg->yy_c_buf_p;
2477 				yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
2478 				goto yy_match;
2479 
2480 			case EOB_ACT_LAST_MATCH:
2481 				yyg->yy_c_buf_p =
2482 				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
2483 
2484 				yy_current_state = yy_get_previous_state( yyscanner );
2485 
2486 				yy_cp = yyg->yy_c_buf_p;
2487 				yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
2488 				goto yy_find_action;
2489 			}
2490 		break;
2491 		}
2492 
2493 	default:
2494 		YY_FATAL_ERROR(
2495 			"fatal flex scanner internal error--no action found" );
2496 	} /* end of action switch */
2497 		} /* end of scanning one token */
2498 } /* end of core_yylex */
2499 
2500 /* yy_get_next_buffer - try to read in a new buffer
2501  *
2502  * Returns a code representing an action:
2503  *	EOB_ACT_LAST_MATCH -
2504  *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
2505  *	EOB_ACT_END_OF_FILE - end of file
2506  */
yy_get_next_buffer(yyscan_t yyscanner)2507 static int yy_get_next_buffer (yyscan_t yyscanner)
2508 {
2509     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2510 	register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
2511 	register char *source = yyg->yytext_ptr;
2512 	register int number_to_move, i;
2513 	int ret_val;
2514 
2515 	if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
2516 		YY_FATAL_ERROR(
2517 		"fatal flex scanner internal error--end of buffer missed" );
2518 
2519 	if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
2520 		{ /* Don't try to fill the buffer, so this is an EOF. */
2521 		if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
2522 			{
2523 			/* We matched a single character, the EOB, so
2524 			 * treat this as a final EOF.
2525 			 */
2526 			return EOB_ACT_END_OF_FILE;
2527 			}
2528 
2529 		else
2530 			{
2531 			/* We matched some text prior to the EOB, first
2532 			 * process it.
2533 			 */
2534 			return EOB_ACT_LAST_MATCH;
2535 			}
2536 		}
2537 
2538 	/* Try to read more data. */
2539 
2540 	/* First move last chars to start of buffer. */
2541 	number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
2542 
2543 	for ( i = 0; i < number_to_move; ++i )
2544 		*(dest++) = *(source++);
2545 
2546 	if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
2547 		/* don't do the read, it's not guaranteed to return an EOF,
2548 		 * just force an EOF
2549 		 */
2550 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
2551 
2552 	else
2553 		{
2554 			yy_size_t num_to_read =
2555 			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
2556 
2557 		while ( num_to_read <= 0 )
2558 			{ /* Not enough room in the buffer - grow it. */
2559 
2560 			/* just a shorter name for the current buffer */
2561 			YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
2562 
2563 			int yy_c_buf_p_offset =
2564 				(int) (yyg->yy_c_buf_p - b->yy_ch_buf);
2565 
2566 			if ( b->yy_is_our_buffer )
2567 				{
2568 				yy_size_t new_size = b->yy_buf_size * 2;
2569 
2570 				if ( new_size <= 0 )
2571 					b->yy_buf_size += b->yy_buf_size / 8;
2572 				else
2573 					b->yy_buf_size *= 2;
2574 
2575 				b->yy_ch_buf = (char *)
2576 					/* Include room in for 2 EOB chars. */
2577 					core_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
2578 				}
2579 			else
2580 				/* Can't grow it, we don't own it. */
2581 				b->yy_ch_buf = 0;
2582 
2583 			if ( ! b->yy_ch_buf )
2584 				YY_FATAL_ERROR(
2585 				"fatal error - scanner input buffer overflow" );
2586 
2587 			yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
2588 
2589 			num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
2590 						number_to_move - 1;
2591 
2592 			}
2593 
2594 		if ( num_to_read > YY_READ_BUF_SIZE )
2595 			num_to_read = YY_READ_BUF_SIZE;
2596 
2597 		/* Read in more data. */
2598 		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
2599 			yyg->yy_n_chars, num_to_read );
2600 
2601 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2602 		}
2603 
2604 	if ( yyg->yy_n_chars == 0 )
2605 		{
2606 		if ( number_to_move == YY_MORE_ADJ )
2607 			{
2608 			ret_val = EOB_ACT_END_OF_FILE;
2609 			core_yyrestart(yyin  ,yyscanner);
2610 			}
2611 
2612 		else
2613 			{
2614 			ret_val = EOB_ACT_LAST_MATCH;
2615 			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
2616 				YY_BUFFER_EOF_PENDING;
2617 			}
2618 		}
2619 
2620 	else
2621 		ret_val = EOB_ACT_CONTINUE_SCAN;
2622 
2623 	if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
2624 		/* Extend the array by 50%, plus the number we really need. */
2625 		yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
2626 		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) core_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
2627 		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
2628 			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
2629 	}
2630 
2631 	yyg->yy_n_chars += number_to_move;
2632 	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
2633 	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
2634 
2635 	yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
2636 
2637 	return ret_val;
2638 }
2639 
2640 /* yy_get_previous_state - get the state just before the EOB char was reached */
2641 
yy_get_previous_state(yyscan_t yyscanner)2642     static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
2643 {
2644 	register yy_state_type yy_current_state;
2645 	register char *yy_cp;
2646     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2647 
2648 	yy_current_state = yyg->yy_start;
2649 
2650 	for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
2651 		{
2652 		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
2653 		if ( yy_accept[yy_current_state] )
2654 			{
2655 			yyg->yy_last_accepting_state = yy_current_state;
2656 			yyg->yy_last_accepting_cpos = yy_cp;
2657 			}
2658 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
2659 			{
2660 			yy_current_state = (int) yy_def[yy_current_state];
2661 			if ( yy_current_state >= 290 )
2662 				yy_c = yy_meta[(unsigned int) yy_c];
2663 			}
2664 		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
2665 		}
2666 
2667 	return yy_current_state;
2668 }
2669 
2670 /* yy_try_NUL_trans - try to make a transition on the NUL character
2671  *
2672  * synopsis
2673  *	next_state = yy_try_NUL_trans( current_state );
2674  */
yy_try_NUL_trans(yy_state_type yy_current_state,yyscan_t yyscanner)2675     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
2676 {
2677 	register int yy_is_jam;
2678     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
2679 	register char *yy_cp = yyg->yy_c_buf_p;
2680 
2681 	register YY_CHAR yy_c = 1;
2682 	if ( yy_accept[yy_current_state] )
2683 		{
2684 		yyg->yy_last_accepting_state = yy_current_state;
2685 		yyg->yy_last_accepting_cpos = yy_cp;
2686 		}
2687 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
2688 		{
2689 		yy_current_state = (int) yy_def[yy_current_state];
2690 		if ( yy_current_state >= 290 )
2691 			yy_c = yy_meta[(unsigned int) yy_c];
2692 		}
2693 	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
2694 	yy_is_jam = (yy_current_state == 289);
2695 
2696 	(void)yyg;
2697 	return yy_is_jam ? 0 : yy_current_state;
2698 }
2699 
2700 #ifndef YY_NO_INPUT
2701 #ifdef __cplusplus
yyinput(yyscan_t yyscanner)2702     static int yyinput (yyscan_t yyscanner)
2703 #else
2704     static int input  (yyscan_t yyscanner)
2705 #endif
2706 
2707 {
2708 	int c;
2709     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2710 
2711 	*yyg->yy_c_buf_p = yyg->yy_hold_char;
2712 
2713 	if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
2714 		{
2715 		/* yy_c_buf_p now points to the character we want to return.
2716 		 * If this occurs *before* the EOB characters, then it's a
2717 		 * valid NUL; if not, then we've hit the end of the buffer.
2718 		 */
2719 		if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
2720 			/* This was really a NUL. */
2721 			*yyg->yy_c_buf_p = '\0';
2722 
2723 		else
2724 			{ /* need more input */
2725 			yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
2726 			++yyg->yy_c_buf_p;
2727 
2728 			switch ( yy_get_next_buffer( yyscanner ) )
2729 				{
2730 				case EOB_ACT_LAST_MATCH:
2731 					/* This happens because yy_g_n_b()
2732 					 * sees that we've accumulated a
2733 					 * token and flags that we need to
2734 					 * try matching the token before
2735 					 * proceeding.  But for input(),
2736 					 * there's no matching to consider.
2737 					 * So convert the EOB_ACT_LAST_MATCH
2738 					 * to EOB_ACT_END_OF_FILE.
2739 					 */
2740 
2741 					/* Reset buffer status. */
2742 					core_yyrestart(yyin ,yyscanner);
2743 
2744 					/*FALLTHROUGH*/
2745 
2746 				case EOB_ACT_END_OF_FILE:
2747 					{
2748 					if ( core_yywrap(yyscanner ) )
2749 						return EOF;
2750 
2751 					if ( ! yyg->yy_did_buffer_switch_on_eof )
2752 						YY_NEW_FILE;
2753 #ifdef __cplusplus
2754 					return yyinput(yyscanner);
2755 #else
2756 					return input(yyscanner);
2757 #endif
2758 					}
2759 
2760 				case EOB_ACT_CONTINUE_SCAN:
2761 					yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
2762 					break;
2763 				}
2764 			}
2765 		}
2766 
2767 	c = *(unsigned char *) yyg->yy_c_buf_p;	/* cast for 8-bit char's */
2768 	*yyg->yy_c_buf_p = '\0';	/* preserve yytext */
2769 	yyg->yy_hold_char = *++yyg->yy_c_buf_p;
2770 
2771 	return c;
2772 }
2773 #endif	/* ifndef YY_NO_INPUT */
2774 
2775 /** Immediately switch to a different input stream.
2776  * @param input_file A readable stream.
2777  * @param yyscanner The scanner object.
2778  * @note This function does not reset the start condition to @c INITIAL .
2779  */
core_yyrestart(FILE * input_file,yyscan_t yyscanner)2780     void core_yyrestart  (FILE * input_file , yyscan_t yyscanner)
2781 {
2782     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2783 
2784 	if ( ! YY_CURRENT_BUFFER ){
2785         core_yyensure_buffer_stack (yyscanner);
2786 		YY_CURRENT_BUFFER_LVALUE =
2787             core_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
2788 	}
2789 
2790 	core_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
2791 	core_yy_load_buffer_state(yyscanner );
2792 }
2793 
2794 /** Switch to a different input buffer.
2795  * @param new_buffer The new input buffer.
2796  * @param yyscanner The scanner object.
2797  */
core_yy_switch_to_buffer(YY_BUFFER_STATE new_buffer,yyscan_t yyscanner)2798     void core_yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
2799 {
2800     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2801 
2802 	/* TODO. We should be able to replace this entire function body
2803 	 * with
2804 	 *		core_yypop_buffer_state();
2805 	 *		core_yypush_buffer_state(new_buffer);
2806      */
2807 	core_yyensure_buffer_stack (yyscanner);
2808 	if ( YY_CURRENT_BUFFER == new_buffer )
2809 		return;
2810 
2811 	if ( YY_CURRENT_BUFFER )
2812 		{
2813 		/* Flush out information for old buffer. */
2814 		*yyg->yy_c_buf_p = yyg->yy_hold_char;
2815 		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2816 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2817 		}
2818 
2819 	YY_CURRENT_BUFFER_LVALUE = new_buffer;
2820 	core_yy_load_buffer_state(yyscanner );
2821 
2822 	/* We don't actually know whether we did this switch during
2823 	 * EOF (core_yywrap()) processing, but the only time this flag
2824 	 * is looked at is after core_yywrap() is called, so it's safe
2825 	 * to go ahead and always set it.
2826 	 */
2827 	yyg->yy_did_buffer_switch_on_eof = 1;
2828 }
2829 
core_yy_load_buffer_state(yyscan_t yyscanner)2830 static void core_yy_load_buffer_state  (yyscan_t yyscanner)
2831 {
2832     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2833 	yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2834 	yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
2835 	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
2836 	yyg->yy_hold_char = *yyg->yy_c_buf_p;
2837 }
2838 
2839 /** Allocate and initialize an input buffer state.
2840  * @param file A readable stream.
2841  * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
2842  * @param yyscanner The scanner object.
2843  * @return the allocated buffer state.
2844  */
core_yy_create_buffer(FILE * file,int size,yyscan_t yyscanner)2845     YY_BUFFER_STATE core_yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
2846 {
2847 	YY_BUFFER_STATE b;
2848 
2849 	b = (YY_BUFFER_STATE) core_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
2850 	if ( ! b )
2851 		YY_FATAL_ERROR( "out of dynamic memory in core_yy_create_buffer()" );
2852 
2853 	b->yy_buf_size = size;
2854 
2855 	/* yy_ch_buf has to be 2 characters longer than the size given because
2856 	 * we need to put in 2 end-of-buffer characters.
2857 	 */
2858 	b->yy_ch_buf = (char *) core_yyalloc(b->yy_buf_size + 2 ,yyscanner );
2859 	if ( ! b->yy_ch_buf )
2860 		YY_FATAL_ERROR( "out of dynamic memory in core_yy_create_buffer()" );
2861 
2862 	b->yy_is_our_buffer = 1;
2863 
2864 	core_yy_init_buffer(b,file ,yyscanner);
2865 
2866 	return b;
2867 }
2868 
2869 /** Destroy the buffer.
2870  * @param b a buffer created with core_yy_create_buffer()
2871  * @param yyscanner The scanner object.
2872  */
core_yy_delete_buffer(YY_BUFFER_STATE b,yyscan_t yyscanner)2873     void core_yy_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
2874 {
2875     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2876 
2877 	if ( ! b )
2878 		return;
2879 
2880 	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
2881 		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
2882 
2883 	if ( b->yy_is_our_buffer )
2884 		core_yyfree((void *) b->yy_ch_buf ,yyscanner );
2885 
2886 	core_yyfree((void *) b ,yyscanner );
2887 }
2888 
2889 /* Initializes or reinitializes a buffer.
2890  * This function is sometimes called more than once on the same buffer,
2891  * such as during a core_yyrestart() or at EOF.
2892  */
core_yy_init_buffer(YY_BUFFER_STATE b,FILE * file,yyscan_t yyscanner)2893     static void core_yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
2894 
2895 {
2896 	int oerrno = errno;
2897     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2898 
2899 	core_yy_flush_buffer(b ,yyscanner);
2900 
2901 	b->yy_input_file = file;
2902 	b->yy_fill_buffer = 1;
2903 
2904     /* If b is the current buffer, then core_yy_init_buffer was _probably_
2905      * called from core_yyrestart() or through yy_get_next_buffer.
2906      * In that case, we don't want to reset the lineno or column.
2907      */
2908     if (b != YY_CURRENT_BUFFER){
2909         b->yy_bs_lineno = 1;
2910         b->yy_bs_column = 0;
2911     }
2912 
2913         b->yy_is_interactive = 0;
2914 
2915 	errno = oerrno;
2916 }
2917 
2918 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2919  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2920  * @param yyscanner The scanner object.
2921  */
core_yy_flush_buffer(YY_BUFFER_STATE b,yyscan_t yyscanner)2922     void core_yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
2923 {
2924     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2925 	if ( ! b )
2926 		return;
2927 
2928 	b->yy_n_chars = 0;
2929 
2930 	/* We always need two end-of-buffer characters.  The first causes
2931 	 * a transition to the end-of-buffer state.  The second causes
2932 	 * a jam in that state.
2933 	 */
2934 	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2935 	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2936 
2937 	b->yy_buf_pos = &b->yy_ch_buf[0];
2938 
2939 	b->yy_at_bol = 1;
2940 	b->yy_buffer_status = YY_BUFFER_NEW;
2941 
2942 	if ( b == YY_CURRENT_BUFFER )
2943 		core_yy_load_buffer_state(yyscanner );
2944 }
2945 
2946 /** Pushes the new state onto the stack. The new state becomes
2947  *  the current state. This function will allocate the stack
2948  *  if necessary.
2949  *  @param new_buffer The new state.
2950  *  @param yyscanner The scanner object.
2951  */
core_yypush_buffer_state(YY_BUFFER_STATE new_buffer,yyscan_t yyscanner)2952 void core_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
2953 {
2954     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2955 	if (new_buffer == NULL)
2956 		return;
2957 
2958 	core_yyensure_buffer_stack(yyscanner);
2959 
2960 	/* This block is copied from core_yy_switch_to_buffer. */
2961 	if ( YY_CURRENT_BUFFER )
2962 		{
2963 		/* Flush out information for old buffer. */
2964 		*yyg->yy_c_buf_p = yyg->yy_hold_char;
2965 		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2966 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2967 		}
2968 
2969 	/* Only push if top exists. Otherwise, replace top. */
2970 	if (YY_CURRENT_BUFFER)
2971 		yyg->yy_buffer_stack_top++;
2972 	YY_CURRENT_BUFFER_LVALUE = new_buffer;
2973 
2974 	/* copied from core_yy_switch_to_buffer. */
2975 	core_yy_load_buffer_state(yyscanner );
2976 	yyg->yy_did_buffer_switch_on_eof = 1;
2977 }
2978 
2979 /** Removes and deletes the top of the stack, if present.
2980  *  The next element becomes the new top.
2981  *  @param yyscanner The scanner object.
2982  */
core_yypop_buffer_state(yyscan_t yyscanner)2983 void core_yypop_buffer_state (yyscan_t yyscanner)
2984 {
2985     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2986 	if (!YY_CURRENT_BUFFER)
2987 		return;
2988 
2989 	core_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
2990 	YY_CURRENT_BUFFER_LVALUE = NULL;
2991 	if (yyg->yy_buffer_stack_top > 0)
2992 		--yyg->yy_buffer_stack_top;
2993 
2994 	if (YY_CURRENT_BUFFER) {
2995 		core_yy_load_buffer_state(yyscanner );
2996 		yyg->yy_did_buffer_switch_on_eof = 1;
2997 	}
2998 }
2999 
3000 /* Allocates the stack if it does not exist.
3001  *  Guarantees space for at least one push.
3002  */
core_yyensure_buffer_stack(yyscan_t yyscanner)3003 static void core_yyensure_buffer_stack (yyscan_t yyscanner)
3004 {
3005 	yy_size_t num_to_alloc;
3006     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3007 
3008 	if (!yyg->yy_buffer_stack) {
3009 
3010 		/* First allocation is just for 2 elements, since we don't know if this
3011 		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
3012 		 * immediate realloc on the next call.
3013          */
3014 		num_to_alloc = 1;
3015 		yyg->yy_buffer_stack = (struct yy_buffer_state**)core_yyalloc
3016 								(num_to_alloc * sizeof(struct yy_buffer_state*)
3017 								, yyscanner);
3018 		if ( ! yyg->yy_buffer_stack )
3019 			YY_FATAL_ERROR( "out of dynamic memory in core_yyensure_buffer_stack()" );
3020 
3021 		memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
3022 
3023 		yyg->yy_buffer_stack_max = num_to_alloc;
3024 		yyg->yy_buffer_stack_top = 0;
3025 		return;
3026 	}
3027 
3028 	if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
3029 
3030 		/* Increase the buffer to prepare for a possible push. */
3031 		int grow_size = 8 /* arbitrary grow size */;
3032 
3033 		num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
3034 		yyg->yy_buffer_stack = (struct yy_buffer_state**)core_yyrealloc
3035 								(yyg->yy_buffer_stack,
3036 								num_to_alloc * sizeof(struct yy_buffer_state*)
3037 								, yyscanner);
3038 		if ( ! yyg->yy_buffer_stack )
3039 			YY_FATAL_ERROR( "out of dynamic memory in core_yyensure_buffer_stack()" );
3040 
3041 		/* zero only the new slots.*/
3042 		memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
3043 		yyg->yy_buffer_stack_max = num_to_alloc;
3044 	}
3045 }
3046 
3047 /** Setup the input buffer state to scan directly from a user-specified character buffer.
3048  * @param base the character buffer
3049  * @param size the size in bytes of the character buffer
3050  * @param yyscanner The scanner object.
3051  * @return the newly allocated buffer state object.
3052  */
core_yy_scan_buffer(char * base,yy_size_t size,yyscan_t yyscanner)3053 YY_BUFFER_STATE core_yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
3054 {
3055 	YY_BUFFER_STATE b;
3056 
3057 	if ( size < 2 ||
3058 	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
3059 	     base[size-1] != YY_END_OF_BUFFER_CHAR )
3060 		/* They forgot to leave room for the EOB's. */
3061 		return 0;
3062 
3063 	b = (YY_BUFFER_STATE) core_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
3064 	if ( ! b )
3065 		YY_FATAL_ERROR( "out of dynamic memory in core_yy_scan_buffer()" );
3066 
3067 	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
3068 	b->yy_buf_pos = b->yy_ch_buf = base;
3069 	b->yy_is_our_buffer = 0;
3070 	b->yy_input_file = 0;
3071 	b->yy_n_chars = b->yy_buf_size;
3072 	b->yy_is_interactive = 0;
3073 	b->yy_at_bol = 1;
3074 	b->yy_fill_buffer = 0;
3075 	b->yy_buffer_status = YY_BUFFER_NEW;
3076 
3077 	core_yy_switch_to_buffer(b ,yyscanner );
3078 
3079 	return b;
3080 }
3081 
3082 /** Setup the input buffer state to scan a string. The next call to core_yylex() will
3083  * scan from a @e copy of @a str.
3084  * @param yystr a NUL-terminated string to scan
3085  * @param yyscanner The scanner object.
3086  * @return the newly allocated buffer state object.
3087  * @note If you want to scan bytes that may contain NUL values, then use
3088  *       core_yy_scan_bytes() instead.
3089  */
core_yy_scan_string(yyconst char * yystr,yyscan_t yyscanner)3090 YY_BUFFER_STATE core_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
3091 {
3092 
3093 	return core_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner);
3094 }
3095 
3096 /** Setup the input buffer state to scan the given bytes. The next call to core_yylex() will
3097  * scan from a @e copy of @a bytes.
3098  * @param yybytes the byte buffer to scan
3099  * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
3100  * @param yyscanner The scanner object.
3101  * @return the newly allocated buffer state object.
3102  */
core_yy_scan_bytes(yyconst char * yybytes,yy_size_t _yybytes_len,yyscan_t yyscanner)3103 YY_BUFFER_STATE core_yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len , yyscan_t yyscanner)
3104 {
3105 	YY_BUFFER_STATE b;
3106 	char *buf;
3107 	yy_size_t n;
3108 	yy_size_t i;
3109 
3110 	/* Get memory for full buffer, including space for trailing EOB's. */
3111 	n = _yybytes_len + 2;
3112 	buf = (char *) core_yyalloc(n ,yyscanner );
3113 	if ( ! buf )
3114 		YY_FATAL_ERROR( "out of dynamic memory in core_yy_scan_bytes()" );
3115 
3116 	for ( i = 0; i < _yybytes_len; ++i )
3117 		buf[i] = yybytes[i];
3118 
3119 	buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
3120 
3121 	b = core_yy_scan_buffer(buf,n ,yyscanner);
3122 	if ( ! b )
3123 		YY_FATAL_ERROR( "bad buffer in core_yy_scan_bytes()" );
3124 
3125 	/* It's okay to grow etc. this buffer, and we should throw it
3126 	 * away when we're done.
3127 	 */
3128 	b->yy_is_our_buffer = 1;
3129 
3130 	return b;
3131 }
3132 
3133 #ifndef YY_EXIT_FAILURE
3134 #define YY_EXIT_FAILURE 2
3135 #endif
3136 
yy_fatal_error(yyconst char * msg,yyscan_t yyscanner)3137 static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
3138 {
3139     	(void) fprintf( stderr, "%s\n", msg );
3140 	exit( YY_EXIT_FAILURE );
3141 }
3142 
3143 /* Redefine yyless() so it works in section 3 code. */
3144 
3145 #undef yyless
3146 #define yyless(n) \
3147 	do \
3148 		{ \
3149 		/* Undo effects of setting up yytext. */ \
3150         int yyless_macro_arg = (n); \
3151         YY_LESS_LINENO(yyless_macro_arg);\
3152 		yytext[yyleng] = yyg->yy_hold_char; \
3153 		yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
3154 		yyg->yy_hold_char = *yyg->yy_c_buf_p; \
3155 		*yyg->yy_c_buf_p = '\0'; \
3156 		yyleng = yyless_macro_arg; \
3157 		} \
3158 	while ( 0 )
3159 
3160 /* Accessor  methods (get/set functions) to struct members. */
3161 
3162 /** Get the user-defined data for this scanner.
3163  * @param yyscanner The scanner object.
3164  */
core_yyget_extra(yyscan_t yyscanner)3165 YY_EXTRA_TYPE core_yyget_extra  (yyscan_t yyscanner)
3166 {
3167     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3168     return yyextra;
3169 }
3170 
3171 /** Get the current line number.
3172  * @param yyscanner The scanner object.
3173  */
core_yyget_lineno(yyscan_t yyscanner)3174 int core_yyget_lineno  (yyscan_t yyscanner)
3175 {
3176     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3177 
3178         if (! YY_CURRENT_BUFFER)
3179             return 0;
3180 
3181     return yylineno;
3182 }
3183 
3184 /** Get the current column number.
3185  * @param yyscanner The scanner object.
3186  */
core_yyget_column(yyscan_t yyscanner)3187 int core_yyget_column  (yyscan_t yyscanner)
3188 {
3189     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3190 
3191         if (! YY_CURRENT_BUFFER)
3192             return 0;
3193 
3194     return yycolumn;
3195 }
3196 
3197 /** Get the input stream.
3198  * @param yyscanner The scanner object.
3199  */
core_yyget_in(yyscan_t yyscanner)3200 FILE *core_yyget_in  (yyscan_t yyscanner)
3201 {
3202     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3203     return yyin;
3204 }
3205 
3206 /** Get the output stream.
3207  * @param yyscanner The scanner object.
3208  */
core_yyget_out(yyscan_t yyscanner)3209 FILE *core_yyget_out  (yyscan_t yyscanner)
3210 {
3211     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3212     return yyout;
3213 }
3214 
3215 /** Get the length of the current token.
3216  * @param yyscanner The scanner object.
3217  */
core_yyget_leng(yyscan_t yyscanner)3218 yy_size_t core_yyget_leng  (yyscan_t yyscanner)
3219 {
3220     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3221     return yyleng;
3222 }
3223 
3224 /** Get the current token.
3225  * @param yyscanner The scanner object.
3226  */
3227 
core_yyget_text(yyscan_t yyscanner)3228 char *core_yyget_text  (yyscan_t yyscanner)
3229 {
3230     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3231     return yytext;
3232 }
3233 
3234 /** Set the user-defined data. This data is never touched by the scanner.
3235  * @param user_defined The data to be associated with this scanner.
3236  * @param yyscanner The scanner object.
3237  */
core_yyset_extra(YY_EXTRA_TYPE user_defined,yyscan_t yyscanner)3238 void core_yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
3239 {
3240     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3241     yyextra = user_defined ;
3242 }
3243 
3244 /** Set the current line number.
3245  * @param line_number
3246  * @param yyscanner The scanner object.
3247  */
core_yyset_lineno(int line_number,yyscan_t yyscanner)3248 void core_yyset_lineno (int  line_number , yyscan_t yyscanner)
3249 {
3250     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3251 
3252         /* lineno is only valid if an input buffer exists. */
3253         if (! YY_CURRENT_BUFFER )
3254            YY_FATAL_ERROR( "core_yyset_lineno called with no buffer" );
3255 
3256     yylineno = line_number;
3257 }
3258 
3259 /** Set the current column.
3260  * @param line_number
3261  * @param yyscanner The scanner object.
3262  */
core_yyset_column(int column_no,yyscan_t yyscanner)3263 void core_yyset_column (int  column_no , yyscan_t yyscanner)
3264 {
3265     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3266 
3267         /* column is only valid if an input buffer exists. */
3268         if (! YY_CURRENT_BUFFER )
3269            YY_FATAL_ERROR( "core_yyset_column called with no buffer" );
3270 
3271     yycolumn = column_no;
3272 }
3273 
3274 /** Set the input stream. This does not discard the current
3275  * input buffer.
3276  * @param in_str A readable stream.
3277  * @param yyscanner The scanner object.
3278  * @see core_yy_switch_to_buffer
3279  */
core_yyset_in(FILE * in_str,yyscan_t yyscanner)3280 void core_yyset_in (FILE *  in_str , yyscan_t yyscanner)
3281 {
3282     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3283     yyin = in_str ;
3284 }
3285 
core_yyset_out(FILE * out_str,yyscan_t yyscanner)3286 void core_yyset_out (FILE *  out_str , yyscan_t yyscanner)
3287 {
3288     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3289     yyout = out_str ;
3290 }
3291 
core_yyget_debug(yyscan_t yyscanner)3292 int core_yyget_debug  (yyscan_t yyscanner)
3293 {
3294     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3295     return yy_flex_debug;
3296 }
3297 
core_yyset_debug(int bdebug,yyscan_t yyscanner)3298 void core_yyset_debug (int  bdebug , yyscan_t yyscanner)
3299 {
3300     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3301     yy_flex_debug = bdebug ;
3302 }
3303 
3304 /* Accessor methods for yylval and yylloc */
3305 
core_yyget_lval(yyscan_t yyscanner)3306 YYSTYPE * core_yyget_lval  (yyscan_t yyscanner)
3307 {
3308     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3309     return yylval;
3310 }
3311 
core_yyset_lval(YYSTYPE * yylval_param,yyscan_t yyscanner)3312 void core_yyset_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)
3313 {
3314     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3315     yylval = yylval_param;
3316 }
3317 
core_yyget_lloc(yyscan_t yyscanner)3318 YYLTYPE *core_yyget_lloc  (yyscan_t yyscanner)
3319 {
3320     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3321     return yylloc;
3322 }
3323 
core_yyset_lloc(YYLTYPE * yylloc_param,yyscan_t yyscanner)3324 void core_yyset_lloc (YYLTYPE *  yylloc_param , yyscan_t yyscanner)
3325 {
3326     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3327     yylloc = yylloc_param;
3328 }
3329 
3330 /* User-visible API */
3331 
3332 /* core_yylex_init is special because it creates the scanner itself, so it is
3333  * the ONLY reentrant function that doesn't take the scanner as the last argument.
3334  * That's why we explicitly handle the declaration, instead of using our macros.
3335  */
3336 
core_yylex_init(yyscan_t * ptr_yy_globals)3337 int core_yylex_init(yyscan_t* ptr_yy_globals)
3338 
3339 {
3340     if (ptr_yy_globals == NULL){
3341         errno = EINVAL;
3342         return 1;
3343     }
3344 
3345     *ptr_yy_globals = (yyscan_t) core_yyalloc ( sizeof( struct yyguts_t ), NULL );
3346 
3347     if (*ptr_yy_globals == NULL){
3348         errno = ENOMEM;
3349         return 1;
3350     }
3351 
3352     /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
3353     memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
3354 
3355     return yy_init_globals ( *ptr_yy_globals );
3356 }
3357 
3358 /* core_yylex_init_extra has the same functionality as core_yylex_init, but follows the
3359  * convention of taking the scanner as the last argument. Note however, that
3360  * this is a *pointer* to a scanner, as it will be allocated by this call (and
3361  * is the reason, too, why this function also must handle its own declaration).
3362  * The user defined value in the first argument will be available to core_yyalloc in
3363  * the yyextra field.
3364  */
3365 
core_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t * ptr_yy_globals)3366 int core_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
3367 
3368 {
3369     struct yyguts_t dummy_yyguts;
3370 
3371     core_yyset_extra (yy_user_defined, &dummy_yyguts);
3372 
3373     if (ptr_yy_globals == NULL){
3374         errno = EINVAL;
3375         return 1;
3376     }
3377 
3378     *ptr_yy_globals = (yyscan_t) core_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
3379 
3380     if (*ptr_yy_globals == NULL){
3381         errno = ENOMEM;
3382         return 1;
3383     }
3384 
3385     /* By setting to 0xAA, we expose bugs in
3386     yy_init_globals. Leave at 0x00 for releases. */
3387     memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
3388 
3389     core_yyset_extra (yy_user_defined, *ptr_yy_globals);
3390 
3391     return yy_init_globals ( *ptr_yy_globals );
3392 }
3393 
yy_init_globals(yyscan_t yyscanner)3394 static int yy_init_globals (yyscan_t yyscanner)
3395 {
3396     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3397     /* Initialization is the same as for the non-reentrant scanner.
3398      * This function is called from core_yylex_destroy(), so don't allocate here.
3399      */
3400 
3401     yyg->yy_buffer_stack = 0;
3402     yyg->yy_buffer_stack_top = 0;
3403     yyg->yy_buffer_stack_max = 0;
3404     yyg->yy_c_buf_p = (char *) 0;
3405     yyg->yy_init = 0;
3406     yyg->yy_start = 0;
3407 
3408     yyg->yy_start_stack_ptr = 0;
3409     yyg->yy_start_stack_depth = 0;
3410     yyg->yy_start_stack =  NULL;
3411 
3412 /* Defined in main.c */
3413 #ifdef YY_STDINIT
3414     yyin = stdin;
3415     yyout = stdout;
3416 #else
3417     yyin = (FILE *) 0;
3418     yyout = (FILE *) 0;
3419 #endif
3420 
3421     /* For future reference: Set errno on error, since we are called by
3422      * core_yylex_init()
3423      */
3424     return 0;
3425 }
3426 
3427 /* core_yylex_destroy is for both reentrant and non-reentrant scanners. */
core_yylex_destroy(yyscan_t yyscanner)3428 int core_yylex_destroy  (yyscan_t yyscanner)
3429 {
3430     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3431 
3432     /* Pop the buffer stack, destroying each element. */
3433 	while(YY_CURRENT_BUFFER){
3434 		core_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
3435 		YY_CURRENT_BUFFER_LVALUE = NULL;
3436 		core_yypop_buffer_state(yyscanner);
3437 	}
3438 
3439 	/* Destroy the stack itself. */
3440 	core_yyfree(yyg->yy_buffer_stack ,yyscanner);
3441 	yyg->yy_buffer_stack = NULL;
3442 
3443     /* Destroy the start condition stack. */
3444         core_yyfree(yyg->yy_start_stack ,yyscanner );
3445         yyg->yy_start_stack = NULL;
3446 
3447     /* Reset the globals. This is important in a non-reentrant scanner so the next time
3448      * core_yylex() is called, initialization will occur. */
3449     yy_init_globals( yyscanner);
3450 
3451     /* Destroy the main struct (reentrant only). */
3452     core_yyfree ( yyscanner , yyscanner );
3453     yyscanner = NULL;
3454     return 0;
3455 }
3456 
3457 /*
3458  * Internal utility routines.
3459  */
3460 
3461 #ifndef yytext_ptr
yy_flex_strncpy(char * s1,yyconst char * s2,int n,yyscan_t yyscanner)3462 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
3463 {
3464 	register int i;
3465 	for ( i = 0; i < n; ++i )
3466 		s1[i] = s2[i];
3467 }
3468 #endif
3469 
3470 #ifdef YY_NEED_STRLEN
yy_flex_strlen(yyconst char * s,yyscan_t yyscanner)3471 static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
3472 {
3473 	register int n;
3474 	for ( n = 0; s[n]; ++n )
3475 		;
3476 
3477 	return n;
3478 }
3479 #endif
3480 
3481 #define YYTABLES_NAME "yytables"
3482 
3483 #line 1023 "scan.l"
3484 
3485 
3486 
3487 /* LCOV_EXCL_STOP */
3488 
3489 /*
3490  * Arrange access to yyextra for subroutines of the main core_yylex() function.
3491  * We expect each subroutine to have a yyscanner parameter.  Rather than
3492  * use the yyget_xxx functions, which might or might not get inlined by the
3493  * compiler, we cheat just a bit and cast yyscanner to the right type.
3494  */
3495 #undef yyextra
3496 #define yyextra  (((struct yyguts_t *) yyscanner)->yyextra_r)
3497 
3498 /* Likewise for a couple of other things we need. */
3499 #undef yylloc
3500 #define yylloc	(((struct yyguts_t *) yyscanner)->yylloc_r)
3501 #undef yyleng
3502 #define yyleng	(((struct yyguts_t *) yyscanner)->yyleng_r)
3503 
3504 
3505 /*
3506  * scanner_errposition
3507  *		Report a lexer or grammar error cursor position, if possible.
3508  *
3509  * This is expected to be used within an ereport() call.  The return value
3510  * is a dummy (always 0, in fact).
3511  *
3512  * Note that this can only be used for messages emitted during raw parsing
3513  * (essentially, scan.l and gram.y), since it requires the yyscanner struct
3514  * to still be available.
3515  */
3516 int
scanner_errposition(int location,core_yyscan_t yyscanner)3517 scanner_errposition(int location, core_yyscan_t yyscanner)
3518 {
3519 #ifdef PGPOOL_NOT_USED
3520 	int		pos;
3521 
3522 	if (location < 0)
3523 		return 0;				/* no-op if location is unknown */
3524 
3525 	/* Convert byte offset to character number */
3526 	pos = pg_mbstrlen_with_len(yyextra->scanbuf, location) + 1;
3527 	/* And pass it to the ereport mechanism */
3528 	return errposition(pos);
3529 #endif
3530 	return 0;
3531 }
3532 
3533 /*
3534  * scanner_yyerror
3535  *		Report a lexer or grammar error.
3536  *
3537  * The message's cursor position is whatever YYLLOC was last set to,
3538  * ie, the start of the current token if called within core_yylex(), or the
3539  * most recently lexed token if called from the grammar.
3540  * This is OK for syntax error messages from the Bison parser, because Bison
3541  * parsers report error as soon as the first unparsable token is reached.
3542  * Beware of using yyerror for other purposes, as the cursor position might
3543  * be misleading!
3544  */
3545 void
scanner_yyerror(const char * message,core_yyscan_t yyscanner)3546 scanner_yyerror(const char *message, core_yyscan_t yyscanner)
3547 {
3548 	const char *loc = yyextra->scanbuf + *yylloc;
3549 
3550 	if (*loc == YY_END_OF_BUFFER_CHAR)
3551 	{
3552 		ereport(ERROR,
3553 				(errcode(ERRCODE_SYNTAX_ERROR),
3554 		/* translator: %s is typically the translation of "syntax error" */
3555 				 errmsg("%s at end of input", _(message)),
3556 				 lexer_errposition()));
3557 	}
3558 	else
3559 	{
3560 		ereport(ERROR,
3561 				(errcode(ERRCODE_SYNTAX_ERROR),
3562 		/* translator: first %s is typically the translation of "syntax error" */
3563 				 errmsg("%s at or near \"%s\"", _(message), loc),
3564 				 lexer_errposition()));
3565 	}
3566 }
3567 
3568 
3569 /*
3570  * Called before any actual parsing is done
3571  */
3572 core_yyscan_t
scanner_init(const char * str,core_yy_extra_type * yyext,const ScanKeyword * keywords,int num_keywords)3573 scanner_init(const char *str,
3574 			 core_yy_extra_type *yyext,
3575 			 const ScanKeyword *keywords,
3576 			 int num_keywords)
3577 {
3578 	Size		slen = strlen(str);
3579 	yyscan_t	scanner;
3580 
3581 	if (core_yylex_init(&scanner) != 0)
3582 		elog(ERROR, "core_yylex_init() failed: %m");
3583 
3584 	core_yyset_extra(yyext, scanner);
3585 
3586 	yyext->keywords = keywords;
3587 	yyext->num_keywords = num_keywords;
3588 
3589 	yyext->backslash_quote = backslash_quote;
3590 	yyext->escape_string_warning = escape_string_warning;
3591 	yyext->standard_conforming_strings = standard_conforming_strings;
3592 
3593 	/*
3594 	 * Make a scan buffer with special termination needed by flex.
3595 	 */
3596 	yyext->scanbuf = (char *) palloc(slen + 2);
3597 	yyext->scanbuflen = slen;
3598 	memcpy(yyext->scanbuf, str, slen);
3599 	yyext->scanbuf[slen] = yyext->scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR;
3600 	core_yy_scan_buffer(yyext->scanbuf,slen + 2,scanner);
3601 
3602 	/* initialize literal buffer to a reasonable but expansible size */
3603 	yyext->literalalloc = 1024;
3604 	yyext->literalbuf = (char *) palloc(yyext->literalalloc);
3605 	yyext->literallen = 0;
3606 
3607 	return scanner;
3608 }
3609 
3610 
3611 /*
3612  * Called after parsing is done to clean up after scanner_init()
3613  */
3614 void
scanner_finish(core_yyscan_t yyscanner)3615 scanner_finish(core_yyscan_t yyscanner)
3616 {
3617 	/*
3618 	 * We don't bother to call core_yylex_destroy(), because all it would do is
3619 	 * pfree a small amount of control storage.  It's cheaper to leak the
3620 	 * storage until the parsing context is destroyed.  The amount of space
3621 	 * involved is usually negligible compared to the output parse tree
3622 	 * anyway.
3623 	 *
3624 	 * We do bother to pfree the scanbuf and literal buffer, but only if they
3625 	 * represent a nontrivial amount of space.  The 8K cutoff is arbitrary.
3626 	 */
3627 	if (yyextra->scanbuflen >= 8192)
3628 		pfree(yyextra->scanbuf);
3629 	if (yyextra->literalalloc >= 8192)
3630 		pfree(yyextra->literalbuf);
3631 }
3632 
3633 
3634 static void
addlit(char * ytext,int yleng,core_yyscan_t yyscanner)3635 addlit(char *ytext, int yleng, core_yyscan_t yyscanner)
3636 {
3637 	/* enlarge buffer if needed */
3638 	if ((yyextra->literallen + yleng) >= yyextra->literalalloc)
3639 	{
3640 		do
3641 		{
3642 			yyextra->literalalloc *= 2;
3643 		} while ((yyextra->literallen + yleng) >= yyextra->literalalloc);
3644 		yyextra->literalbuf = (char *) repalloc(yyextra->literalbuf,
3645 												yyextra->literalalloc);
3646 	}
3647 	/* append new data */
3648 	memcpy(yyextra->literalbuf + yyextra->literallen, ytext, yleng);
3649 	yyextra->literallen += yleng;
3650 }
3651 
3652 
3653 static void
addlitchar(unsigned char ychar,core_yyscan_t yyscanner)3654 addlitchar(unsigned char ychar, core_yyscan_t yyscanner)
3655 {
3656 	/* enlarge buffer if needed */
3657 	if ((yyextra->literallen + 1) >= yyextra->literalalloc)
3658 	{
3659 		yyextra->literalalloc *= 2;
3660 		yyextra->literalbuf = (char *) repalloc(yyextra->literalbuf,
3661 												yyextra->literalalloc);
3662 	}
3663 	/* append new data */
3664 	yyextra->literalbuf[yyextra->literallen] = ychar;
3665 	yyextra->literallen += 1;
3666 }
3667 
3668 
3669 /*
3670  * Create a palloc'd copy of literalbuf, adding a trailing null.
3671  */
3672 static char *
litbufdup(core_yyscan_t yyscanner)3673 litbufdup(core_yyscan_t yyscanner)
3674 {
3675 	int			llen = yyextra->literallen;
3676 	char	   *new;
3677 
3678 	new = palloc(llen + 1);
3679 	memcpy(new, yyextra->literalbuf, llen);
3680 	new[llen] = '\0';
3681 	return new;
3682 }
3683 
3684 static int
process_integer_literal(const char * token,YYSTYPE * lval)3685 process_integer_literal(const char *token, YYSTYPE *lval)
3686 {
3687 	int 		val;
3688 	long		val_long;
3689 	char	   *endptr;
3690 
3691 	errno = 0;
3692 	val_long = strtol(token, &endptr, 10);
3693 	val = (int) val_long;
3694 
3695 	if (*endptr != '\0' || errno == ERANGE
3696 #ifdef HAVE_LONG_INT_64
3697 	/* if long > 32 bits, check for overflow of int4 */
3698 		|| val != (int) val_long
3699 #endif
3700 		)
3701 	{
3702 		/* integer too large, treat it as a float */
3703 		lval->str = pstrdup(token);
3704 		return FCONST;
3705 	}
3706 	lval->ival = val;
3707 	return ICONST;
3708 }
3709 
3710 static unsigned int
hexval(unsigned char c)3711 hexval(unsigned char c)
3712 {
3713 	if (c >= '0' && c <= '9')
3714 		return c - '0';
3715 	if (c >= 'a' && c <= 'f')
3716 		return c - 'a' + 0xA;
3717 	if (c >= 'A' && c <= 'F')
3718 		return c - 'A' + 0xA;
3719 	elog(ERROR, "invalid hexadecimal digit");
3720 	return 0;					/* not reached */
3721 }
3722 
3723 static void
check_unicode_value(pg_wchar c,char * loc,core_yyscan_t yyscanner)3724 check_unicode_value(pg_wchar c, char *loc, core_yyscan_t yyscanner)
3725 {
3726 	if (GetDatabaseEncoding() == PG_UTF8)
3727 		return;
3728 
3729 	if (c > 0x7F)
3730 	{
3731 		ADVANCE_YYLLOC(loc - yyextra->literalbuf + 3);	/* 3 for U&" */
3732 		yyerror("Unicode escape values cannot be used for code point values above 007F when the server encoding is not UTF8");
3733 	}
3734 }
3735 
3736 static bool
is_utf16_surrogate_first(pg_wchar c)3737 is_utf16_surrogate_first(pg_wchar c)
3738 {
3739 	return (c >= 0xD800 && c <= 0xDBFF);
3740 }
3741 
3742 static bool
is_utf16_surrogate_second(pg_wchar c)3743 is_utf16_surrogate_second(pg_wchar c)
3744 {
3745 	return (c >= 0xDC00 && c <= 0xDFFF);
3746 }
3747 
3748 static pg_wchar
surrogate_pair_to_codepoint(pg_wchar first,pg_wchar second)3749 surrogate_pair_to_codepoint(pg_wchar first, pg_wchar second)
3750 {
3751 	return ((first & 0x3FF) << 10) + 0x10000 + (second & 0x3FF);
3752 }
3753 
3754 static void
addunicode(pg_wchar c,core_yyscan_t yyscanner)3755 addunicode(pg_wchar c, core_yyscan_t yyscanner)
3756 {
3757 	char		buf[8];
3758 
3759 	if (c == 0 || c > 0x10FFFF)
3760 		yyerror("invalid Unicode escape value");
3761 	if (c > 0x7F)
3762 	{
3763 		if (GetDatabaseEncoding() != PG_UTF8)
3764 			yyerror("Unicode escape values cannot be used for code point values above 007F when the server encoding is not UTF8");
3765 		yyextra->saw_non_ascii = true;
3766 	}
3767 	unicode_to_utf8(c, (unsigned char *) buf);
3768 	addlit(buf, pg_mblen(buf), yyscanner);
3769 }
3770 
3771 /* is 'escape' acceptable as Unicode escape character (UESCAPE syntax) ? */
3772 static bool
check_uescapechar(unsigned char escape)3773 check_uescapechar(unsigned char escape)
3774 {
3775 	if (isxdigit(escape)
3776 		|| escape == '+'
3777 		|| escape == '\''
3778 		|| escape == '"'
3779 		|| scanner_isspace(escape))
3780 	{
3781 		return false;
3782 	}
3783 	else
3784 		return true;
3785 }
3786 
3787 /* like litbufdup, but handle unicode escapes */
3788 static char *
litbuf_udeescape(unsigned char escape,core_yyscan_t yyscanner)3789 litbuf_udeescape(unsigned char escape, core_yyscan_t yyscanner)
3790 {
3791 	char	   *new;
3792 	char	   *litbuf,
3793 			   *in,
3794 			   *out;
3795 	pg_wchar	pair_first = 0;
3796 
3797 	/* Make literalbuf null-terminated to simplify the scanning loop */
3798 	litbuf = yyextra->literalbuf;
3799 	litbuf[yyextra->literallen] = '\0';
3800 
3801 	/*
3802 	 * This relies on the subtle assumption that a UTF-8 expansion cannot be
3803 	 * longer than its escaped representation.
3804 	 */
3805 	new = palloc(yyextra->literallen + 1);
3806 
3807 	in = litbuf;
3808 	out = new;
3809 	while (*in)
3810 	{
3811 		if (in[0] == escape)
3812 		{
3813 			if (in[1] == escape)
3814 			{
3815 				if (pair_first)
3816 				{
3817 					ADVANCE_YYLLOC(in - litbuf + 3);	/* 3 for U&" */
3818 					yyerror("invalid Unicode surrogate pair");
3819 				}
3820 				*out++ = escape;
3821 				in += 2;
3822 			}
3823 			else if (isxdigit((unsigned char) in[1]) &&
3824 					 isxdigit((unsigned char) in[2]) &&
3825 					 isxdigit((unsigned char) in[3]) &&
3826 					 isxdigit((unsigned char) in[4]))
3827 			{
3828 				pg_wchar	unicode;
3829 
3830 				unicode = (hexval(in[1]) << 12) +
3831 					(hexval(in[2]) << 8) +
3832 					(hexval(in[3]) << 4) +
3833 					hexval(in[4]);
3834 				check_unicode_value(unicode, in, yyscanner);
3835 				if (pair_first)
3836 				{
3837 					if (is_utf16_surrogate_second(unicode))
3838 					{
3839 						unicode = surrogate_pair_to_codepoint(pair_first, unicode);
3840 						pair_first = 0;
3841 					}
3842 					else
3843 					{
3844 						ADVANCE_YYLLOC(in - litbuf + 3);		/* 3 for U&" */
3845 						yyerror("invalid Unicode surrogate pair");
3846 					}
3847 				}
3848 				else if (is_utf16_surrogate_second(unicode))
3849 					yyerror("invalid Unicode surrogate pair");
3850 
3851 				if (is_utf16_surrogate_first(unicode))
3852 					pair_first = unicode;
3853 				else
3854 				{
3855 					unicode_to_utf8(unicode, (unsigned char *) out);
3856 					out += pg_mblen(out);
3857 				}
3858 				in += 5;
3859 			}
3860 			else if (in[1] == '+' &&
3861 					 isxdigit((unsigned char) in[2]) &&
3862 					 isxdigit((unsigned char) in[3]) &&
3863 					 isxdigit((unsigned char) in[4]) &&
3864 					 isxdigit((unsigned char) in[5]) &&
3865 					 isxdigit((unsigned char) in[6]) &&
3866 					 isxdigit((unsigned char) in[7]))
3867 			{
3868 				pg_wchar	unicode;
3869 
3870 				unicode = (hexval(in[2]) << 20) +
3871 					(hexval(in[3]) << 16) +
3872 					(hexval(in[4]) << 12) +
3873 					(hexval(in[5]) << 8) +
3874 					(hexval(in[6]) << 4) +
3875 					hexval(in[7]);
3876 				check_unicode_value(unicode, in, yyscanner);
3877 				if (pair_first)
3878 				{
3879 					if (is_utf16_surrogate_second(unicode))
3880 					{
3881 						unicode = surrogate_pair_to_codepoint(pair_first, unicode);
3882 						pair_first = 0;
3883 					}
3884 					else
3885 					{
3886 						ADVANCE_YYLLOC(in - litbuf + 3);		/* 3 for U&" */
3887 						yyerror("invalid Unicode surrogate pair");
3888 					}
3889 				}
3890 				else if (is_utf16_surrogate_second(unicode))
3891 					yyerror("invalid Unicode surrogate pair");
3892 
3893 				if (is_utf16_surrogate_first(unicode))
3894 					pair_first = unicode;
3895 				else
3896 				{
3897 					unicode_to_utf8(unicode, (unsigned char *) out);
3898 					out += pg_mblen(out);
3899 				}
3900 				in += 8;
3901 			}
3902 			else
3903 			{
3904 				ADVANCE_YYLLOC(in - litbuf + 3);		/* 3 for U&" */
3905 				yyerror("invalid Unicode escape value");
3906 			}
3907 		}
3908 		else
3909 		{
3910 			if (pair_first)
3911 			{
3912 				ADVANCE_YYLLOC(in - litbuf + 3);		/* 3 for U&" */
3913 				yyerror("invalid Unicode surrogate pair");
3914 			}
3915 			*out++ = *in++;
3916 		}
3917 	}
3918 
3919 	/* unfinished surrogate pair? */
3920 	if (pair_first)
3921 	{
3922 		ADVANCE_YYLLOC(in - litbuf + 3);				/* 3 for U&" */
3923 		yyerror("invalid Unicode surrogate pair");
3924 	}
3925 
3926 	*out = '\0';
3927 
3928 	/*
3929 	 * We could skip pg_verifymbstr if we didn't process any non-7-bit-ASCII
3930 	 * codes; but it's probably not worth the trouble, since this isn't likely
3931 	 * to be a performance-critical path.
3932 	 */
3933 	pg_verifymbstr(new, out - new, false);
3934 	return new;
3935 }
3936 
3937 static unsigned char
unescape_single_char(unsigned char c,core_yyscan_t yyscanner)3938 unescape_single_char(unsigned char c, core_yyscan_t yyscanner)
3939 {
3940 	switch (c)
3941 	{
3942 		case 'b':
3943 			return '\b';
3944 		case 'f':
3945 			return '\f';
3946 		case 'n':
3947 			return '\n';
3948 		case 'r':
3949 			return '\r';
3950 		case 't':
3951 			return '\t';
3952 		default:
3953 			/* check for backslash followed by non-7-bit-ASCII */
3954 			if (c == '\0' || IS_HIGHBIT_SET(c))
3955 				yyextra->saw_non_ascii = true;
3956 
3957 			return c;
3958 	}
3959 }
3960 
3961 static void
check_string_escape_warning(unsigned char ychar,core_yyscan_t yyscanner)3962 check_string_escape_warning(unsigned char ychar, core_yyscan_t yyscanner)
3963 {
3964 	if (ychar == '\'')
3965 	{
3966 		if (yyextra->warn_on_first_escape && yyextra->escape_string_warning)
3967 			ereport(WARNING,
3968 					(errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
3969 					 errmsg("nonstandard use of \\' in a string literal"),
3970 					 errhint("Use '' to write quotes in strings, or use the escape string syntax (E'...')."),
3971 					 lexer_errposition()));
3972 		yyextra->warn_on_first_escape = false;	/* warn only once per string */
3973 	}
3974 	else if (ychar == '\\')
3975 	{
3976 		if (yyextra->warn_on_first_escape && yyextra->escape_string_warning)
3977 			ereport(WARNING,
3978 					(errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
3979 					 errmsg("nonstandard use of \\\\ in a string literal"),
3980 					 errhint("Use the escape string syntax for backslashes, e.g., E'\\\\'."),
3981 					 lexer_errposition()));
3982 		yyextra->warn_on_first_escape = false;	/* warn only once per string */
3983 	}
3984 	else
3985 		check_escape_warning(yyscanner);
3986 }
3987 
3988 static void
check_escape_warning(core_yyscan_t yyscanner)3989 check_escape_warning(core_yyscan_t yyscanner)
3990 {
3991 	if (yyextra->warn_on_first_escape && yyextra->escape_string_warning)
3992 		ereport(WARNING,
3993 				(errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
3994 				 errmsg("nonstandard use of escape in a string literal"),
3995 		errhint("Use the escape string syntax for escapes, e.g., E'\\r\\n'."),
3996 				 lexer_errposition()));
3997 	yyextra->warn_on_first_escape = false;		/* warn only once per string */
3998 }
3999 
4000 /*
4001  * Interface functions to make flex use palloc() instead of malloc().
4002  * It'd be better to make these static, but flex insists otherwise.
4003  */
4004 
4005 void *
core_yyalloc(yy_size_t bytes,core_yyscan_t yyscanner)4006 core_yyalloc(yy_size_t bytes, core_yyscan_t yyscanner)
4007 {
4008 	return palloc(bytes);
4009 }
4010 
4011 void *
core_yyrealloc(void * ptr,yy_size_t bytes,core_yyscan_t yyscanner)4012 core_yyrealloc(void *ptr, yy_size_t bytes, core_yyscan_t yyscanner)
4013 {
4014 	if (ptr)
4015 		return repalloc(ptr, bytes);
4016 	else
4017 		return palloc(bytes);
4018 }
4019 
4020 void
core_yyfree(void * ptr,core_yyscan_t yyscanner)4021 core_yyfree(void *ptr, core_yyscan_t yyscanner)
4022 {
4023 	if (ptr)
4024 		pfree(ptr);
4025 }
4026 
4027