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