5 #define YY_INT_ALIGNED short int
7 /* A lexical scanner generated by flex */
10 #define YY_FLEX_MAJOR_VERSION 2
11 #define YY_FLEX_MINOR_VERSION 5
12 #define YY_FLEX_SUBMINOR_VERSION 33
13 #if YY_FLEX_SUBMINOR_VERSION > 0
17 /* First, we deal with platform-specific or compiler-specific issues. */
19 /* begin standard C headers. */
25 /* end standard C headers. */
27 /* flex integer type definitions */
32 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
34 #if __STDC_VERSION__ >= 199901L
36 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
37 * if you want the limit (max/min) macros for int types.
39 #ifndef __STDC_LIMIT_MACROS
40 #define __STDC_LIMIT_MACROS 1
44 typedef int8_t flex_int8_t;
45 typedef uint8_t flex_uint8_t;
46 typedef int16_t flex_int16_t;
47 typedef uint16_t flex_uint16_t;
48 typedef int32_t flex_int32_t;
49 typedef uint32_t flex_uint32_t;
51 typedef signed char flex_int8_t;
52 typedef short int flex_int16_t;
53 typedef int flex_int32_t;
54 typedef unsigned char flex_uint8_t;
55 typedef unsigned short int flex_uint16_t;
56 typedef unsigned int flex_uint32_t;
59 /* Limits of integral types. */
61 #define INT8_MIN (-128)
64 #define INT16_MIN (-32767-1)
67 #define INT32_MIN (-2147483647-1)
70 #define INT8_MAX (127)
73 #define INT16_MAX (32767)
76 #define INT32_MAX (2147483647)
79 #define UINT8_MAX (255U)
82 #define UINT16_MAX (65535U)
85 #define UINT32_MAX (4294967295U)
88 #endif /* ! FLEXINT_H */
92 /* The "const" storage-class-modifier is valid. */
95 #else /* ! __cplusplus */
101 #endif /* __STDC__ */
102 #endif /* ! __cplusplus */
105 #define yyconst const
110 /* Returned upon end-of-file. */
113 /* Promotes a possibly negative, possibly signed char to an unsigned
114 * integer for use as an array index. If the signed char is negative,
115 * we want to instead treat it as an 8-bit unsigned char, hence the
118 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
120 /* Enter a start condition. This macro really ought to take a parameter,
121 * but we do it the disgusting crufty way forced on us by the ()-less
122 * definition of BEGIN.
124 #define BEGIN (yy_start) = 1 + 2 *
126 /* Translate the current start state into a value that can be later handed
127 * to BEGIN to return to the state. The YYSTATE alias is for lex
130 #define YY_START (((yy_start) - 1) / 2)
131 #define YYSTATE YY_START
133 /* Action number for EOF rule of a given start state. */
134 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
136 /* Special action meaning "start processing a new file". */
137 #define YY_NEW_FILE base_yyrestart(base_yyin )
139 #define YY_END_OF_BUFFER_CHAR 0
141 /* Size of default input buffer. */
143 #define YY_BUF_SIZE 16384
146 /* The state buf must be large enough to hold one state per character in the main buffer.
148 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
150 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
151 #define YY_TYPEDEF_YY_BUFFER_STATE
152 typedef struct yy_buffer_state *YY_BUFFER_STATE;
155 extern int base_yyleng;
157 extern FILE *base_yyin, *base_yyout;
159 #define EOB_ACT_CONTINUE_SCAN 0
160 #define EOB_ACT_END_OF_FILE 1
161 #define EOB_ACT_LAST_MATCH 2
163 #define YY_LESS_LINENO(n)
165 /* Return all but the first "n" matched characters back to the input stream. */
169 /* Undo effects of setting up base_yytext. */ \
170 int yyless_macro_arg = (n); \
171 YY_LESS_LINENO(yyless_macro_arg);\
172 *yy_cp = (yy_hold_char); \
173 YY_RESTORE_YY_MORE_OFFSET \
174 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
175 YY_DO_BEFORE_ACTION; /* set up base_yytext again */ \
179 #define unput(c) yyunput( c, (yytext_ptr) )
181 /* The following is because we cannot portably get our hands on size_t
182 * (without autoconf's help, which isn't available because we want
183 * flex-generated scanners to compile on their own).
186 #ifndef YY_TYPEDEF_YY_SIZE_T
187 #define YY_TYPEDEF_YY_SIZE_T
188 typedef unsigned int yy_size_t;
191 #ifndef YY_STRUCT_YY_BUFFER_STATE
192 #define YY_STRUCT_YY_BUFFER_STATE
193 struct yy_buffer_state
197 char *yy_ch_buf; /* input buffer */
198 char *yy_buf_pos; /* current position in input buffer */
200 /* Size of input buffer in bytes, not including room for EOB
203 yy_size_t yy_buf_size;
205 /* Number of characters read into yy_ch_buf, not including EOB
210 /* Whether we "own" the buffer - i.e., we know we created it,
211 * and can realloc() it to grow it, and should free() it to
214 int yy_is_our_buffer;
216 /* Whether this is an "interactive" input source; if so, and
217 * if we're using stdio for input, then we want to use getc()
218 * instead of fread(), to make sure we stop fetching input after
221 int yy_is_interactive;
223 /* Whether we're considered to be at the beginning of a line.
224 * If so, '^' rules will be active on the next match, otherwise
229 int yy_bs_lineno; /**< The line count. */
230 int yy_bs_column; /**< The column count. */
232 /* Whether to try to fill the input buffer when we reach the
237 int yy_buffer_status;
239 #define YY_BUFFER_NEW 0
240 #define YY_BUFFER_NORMAL 1
241 /* When an EOF's been seen but there's still some text to process
242 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
243 * shouldn't try reading from the input source any more. We might
244 * still have a bunch of tokens to match, though, because of
245 * possible backing-up.
247 * When we actually see the EOF, we change the status to "new"
248 * (via base_yyrestart()), so that the user can continue scanning by
249 * just pointing base_yyin at a new input file.
251 #define YY_BUFFER_EOF_PENDING 2
254 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
256 /* Stack of input buffers. */
257 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
258 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
259 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
261 /* We provide macros for accessing buffer states in case in the
262 * future we want to put the buffer states in a more general
265 * Returns the top of the stack, or NULL.
267 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
268 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
271 /* Same as previous macro, but useful when we know that the buffer stack is not
272 * NULL or when we need an lvalue. For internal use only.
274 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
276 /* yy_hold_char holds the character lost when base_yytext is formed. */
277 static char yy_hold_char;
278 static int yy_n_chars; /* number of characters read into yy_ch_buf */
281 /* Points to current character in buffer. */
282 static char *yy_c_buf_p = (char *) 0;
283 static int yy_init = 0; /* whether we need to initialize */
284 static int yy_start = 0; /* start state number */
286 /* Flag which is used to allow base_yywrap()'s to do buffer switches
287 * instead of setting up a fresh base_yyin. A bit of a hack ...
289 static int yy_did_buffer_switch_on_eof;
291 void base_yyrestart (FILE *input_file );
292 void base_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
293 YY_BUFFER_STATE base_yy_create_buffer (FILE *file,int size );
294 void base_yy_delete_buffer (YY_BUFFER_STATE b );
295 void base_yy_flush_buffer (YY_BUFFER_STATE b );
296 void base_yypush_buffer_state (YY_BUFFER_STATE new_buffer );
297 void base_yypop_buffer_state (void );
299 static void base_yyensure_buffer_stack (void );
300 static void base_yy_load_buffer_state (void );
301 static void base_yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
303 #define YY_FLUSH_BUFFER base_yy_flush_buffer(YY_CURRENT_BUFFER )
305 YY_BUFFER_STATE base_yy_scan_buffer (char *base,yy_size_t size );
306 YY_BUFFER_STATE base_yy_scan_string (yyconst char *yy_str );
307 YY_BUFFER_STATE base_yy_scan_bytes (yyconst char *bytes,int len );
309 void *base_yyalloc (yy_size_t );
310 void *base_yyrealloc (void *,yy_size_t );
311 void base_yyfree (void * );
313 #define yy_new_buffer base_yy_create_buffer
315 #define yy_set_interactive(is_interactive) \
317 if ( ! YY_CURRENT_BUFFER ){ \
318 base_yyensure_buffer_stack (); \
319 YY_CURRENT_BUFFER_LVALUE = \
320 base_yy_create_buffer(base_yyin,YY_BUF_SIZE ); \
322 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
325 #define yy_set_bol(at_bol) \
327 if ( ! YY_CURRENT_BUFFER ){\
328 base_yyensure_buffer_stack (); \
329 YY_CURRENT_BUFFER_LVALUE = \
330 base_yy_create_buffer(base_yyin,YY_BUF_SIZE ); \
332 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
335 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
337 /* Begin user sect3 */
339 #define base_yywrap(n) 1
340 #define YY_SKIP_YYWRAP
342 typedef unsigned char YY_CHAR;
344 FILE *base_yyin = (FILE *) 0, *base_yyout = (FILE *) 0;
346 typedef int yy_state_type;
348 extern int base_yylineno;
350 int base_yylineno = 1;
352 extern char *base_yytext;
353 #define yytext_ptr base_yytext
355 static yy_state_type yy_get_previous_state (void );
356 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
357 static int yy_get_next_buffer (void );
358 static void yy_fatal_error (yyconst char msg[] );
360 /* Done after the current pattern has been matched and before the
361 * corresponding action - sets up base_yytext.
363 #define YY_DO_BEFORE_ACTION \
364 (yytext_ptr) = yy_bp; \
365 base_yyleng = (size_t) (yy_cp - yy_bp); \
366 (yy_hold_char) = *yy_cp; \
368 (yy_c_buf_p) = yy_cp;
370 #define YY_NUM_RULES 52
371 #define YY_END_OF_BUFFER 53
372 /* This struct is not used in this scanner,
373 but its presence is necessary. */
376 flex_int32_t yy_verify;
379 static yyconst flex_int16_t yy_accept[155] =
381 0, 0, 12, 12, 0, 0, 0, 0, 11, 11,
382 0, 0, 0, 0, 0, 0, 53, 51, 1, 1,
383 43, 37, 51, 42, 19, 42, 42, 42, 42, 45,
384 42, 50, 50, 50, 50, 50, 12, 9, 5, 5,
385 6, 6, 40, 38, 11, 16, 25, 25, 21, 30,
386 24, 21, 34, 34, 36, 1, 43, 31, 44, 32,
387 1, 46, 2, 46, 45, 48, 41, 50, 8, 20,
388 18, 15, 12, 9, 9, 10, 5, 7, 4, 3,
389 40, 39, 11, 16, 16, 17, 25, 21, 21, 23,
390 22, 26, 27, 26, 24, 34, 33, 35, 32, 1,
392 1, 2, 46, 49, 47, 9, 14, 10, 9, 3,
393 16, 13, 17, 16, 21, 29, 22, 21, 27, 28,
394 35, 9, 9, 9, 9, 16, 16, 16, 16, 21,
395 21, 21, 21, 27, 28, 9, 9, 9, 9, 9,
396 16, 16, 16, 16, 16, 21, 21, 21, 21, 21,
400 static yyconst flex_int32_t yy_ec[256] =
402 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
403 1, 2, 4, 1, 1, 1, 1, 1, 1, 1,
404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
405 1, 2, 5, 6, 5, 7, 8, 5, 9, 10,
406 10, 11, 12, 10, 13, 14, 15, 16, 16, 16,
407 16, 16, 16, 16, 16, 17, 17, 18, 10, 8,
408 8, 8, 5, 5, 19, 20, 19, 19, 21, 19,
409 22, 22, 22, 22, 22, 22, 22, 23, 22, 22,
410 22, 22, 22, 22, 22, 22, 22, 24, 22, 22,
411 10, 25, 10, 8, 22, 5, 19, 20, 19, 19,
413 21, 19, 22, 22, 22, 22, 22, 22, 22, 23,
414 22, 22, 22, 22, 22, 22, 22, 22, 22, 26,
415 22, 22, 1, 5, 1, 5, 1, 22, 22, 22,
416 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
417 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
418 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
419 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
420 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
421 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
422 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
424 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
425 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
426 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
427 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
428 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
432 static yyconst flex_int32_t yy_meta[27] =
434 1, 2, 3, 3, 4, 5, 6, 4, 7, 1,
435 8, 4, 9, 1, 8, 10, 10, 1, 11, 11,
436 11, 12, 12, 12, 13, 12
439 static yyconst flex_int16_t yy_base[190] =
441 0, 0, 162, 161, 22, 33, 163, 162, 154, 153,
442 33, 40, 152, 151, 25, 44, 159, 867, 50, 53,
443 0, 867, 43, 0, 867, 867, 145, 23, 146, 52,
444 138, 0, 142, 141, 138, 137, 0, 72, 0, 0,
445 52, 128, 0, 132, 0, 84, 0, 0, 96, 45,
446 0, 0, 0, 0, 122, 75, 0, 867, 64, 112,
447 105, 73, 0, 75, 0, 109, 867, 0, 867, 867,
448 867, 867, 0, 0, 93, 101, 0, 92, 867, 0,
449 0, 867, 0, 0, 95, 99, 0, 92, 102, 867,
450 82, 867, 77, 0, 0, 0, 867, 77, 65, 0,
452 122, 0, 107, 66, 115, 127, 867, 57, 139, 0,
453 135, 867, 51, 151, 136, 867, 49, 163, 15, 0,
454 22, 175, 187, 199, 211, 223, 235, 247, 259, 271,
455 283, 295, 307, 867, 867, 319, 331, 0, 343, 355,
456 367, 379, 0, 391, 403, 415, 427, 0, 439, 451,
457 463, 475, 487, 867, 500, 513, 526, 539, 552, 565,
458 578, 588, 592, 599, 611, 624, 637, 650, 663, 675,
459 688, 701, 709, 716, 728, 738, 746, 752, 760, 768,
460 768, 774, 786, 799, 812, 816, 827, 840, 853
463 static yyconst flex_int16_t yy_def[190] =
465 154, 1, 155, 155, 156, 156, 157, 157, 158, 158,
466 159, 159, 160, 160, 161, 161, 154, 154, 154, 154,
467 162, 154, 163, 162, 154, 154, 162, 154, 162, 154,
468 154, 164, 164, 164, 164, 164, 165, 154, 166, 166,
469 154, 154, 167, 154, 168, 154, 169, 169, 154, 170,
470 171, 49, 172, 172, 173, 154, 162, 154, 154, 174,
471 175, 154, 176, 154, 30, 154, 154, 164, 154, 154,
472 154, 154, 165, 38, 177, 154, 166, 154, 154, 178,
473 167, 154, 168, 46, 179, 154, 169, 49, 180, 154,
474 154, 154, 154, 181, 171, 172, 154, 182, 174, 175,
476 175, 176, 154, 154, 154, 177, 154, 154, 183, 178,
477 179, 154, 154, 184, 180, 154, 154, 185, 154, 186,
478 182, 187, 183, 183, 183, 188, 184, 184, 184, 189,
479 185, 185, 185, 154, 154, 187, 187, 106, 187, 183,
480 188, 188, 111, 188, 184, 189, 189, 115, 189, 185,
481 187, 188, 189, 0, 154, 154, 154, 154, 154, 154,
482 154, 154, 154, 154, 154, 154, 154, 154, 154, 154,
483 154, 154, 154, 154, 154, 154, 154, 154, 154, 154,
484 154, 154, 154, 154, 154, 154, 154, 154, 154
487 static yyconst flex_int16_t yy_nxt[894] =
489 18, 19, 20, 19, 21, 22, 23, 24, 25, 26,
490 24, 24, 27, 28, 29, 30, 30, 31, 32, 33,
491 34, 32, 35, 36, 18, 36, 40, 54, 97, 40,
492 134, 55, 41, 40, 40, 48, 42, 40, 62, 62,
493 40, 49, 48, 41, 40, 40, 54, 42, 49, 58,
494 55, 56, 56, 56, 56, 56, 56, 50, 59, 59,
495 93, 130, 78, 126, 50, 64, 79, 65, 65, 122,
496 94, 58, 66, 74, 75, 75, 56, 56, 56, 59,
497 59, 105, 105, 97, 76, 84, 85, 85, 62, 62,
498 103, 103, 119, 66, 118, 66, 86, 88, 89, 89,
500 154, 107, 78, 112, 90, 108, 79, 113, 91, 101,
501 116, 114, 101, 109, 117, 101, 101, 101, 58, 101,
502 104, 104, 103, 103, 105, 105, 101, 66, 97, 101,
503 105, 105, 101, 101, 101, 107, 101, 82, 80, 108,
504 124, 75, 75, 112, 116, 72, 71, 113, 117, 70,
505 69, 125, 128, 85, 85, 67, 63, 61, 154, 52,
506 52, 46, 46, 129, 132, 89, 89, 44, 44, 38,
507 38, 154, 154, 154, 154, 133, 137, 138, 138, 154,
508 154, 154, 154, 154, 154, 154, 154, 139, 124, 75,
509 75, 154, 154, 154, 154, 154, 154, 154, 154, 125,
511 124, 75, 75, 154, 154, 154, 154, 154, 154, 154,
512 154, 125, 124, 75, 75, 154, 154, 154, 154, 154,
513 154, 154, 154, 140, 142, 143, 143, 154, 154, 154,
514 154, 154, 154, 154, 154, 144, 128, 85, 85, 154,
515 154, 154, 154, 154, 154, 154, 154, 129, 128, 85,
516 85, 154, 154, 154, 154, 154, 154, 154, 154, 129,
517 128, 85, 85, 154, 154, 154, 154, 154, 154, 154,
518 154, 145, 147, 148, 148, 154, 154, 154, 154, 154,
519 154, 154, 154, 149, 132, 89, 89, 154, 154, 154,
520 154, 154, 154, 154, 154, 133, 132, 89, 89, 154,
522 154, 154, 154, 154, 154, 154, 154, 133, 132, 89,
523 89, 154, 154, 154, 154, 154, 154, 154, 154, 150,
524 137, 138, 138, 154, 154, 154, 154, 154, 154, 154,
525 154, 139, 137, 138, 138, 154, 154, 154, 154, 154,
526 154, 154, 154, 139, 137, 138, 138, 154, 154, 154,
527 154, 154, 154, 154, 154, 151, 124, 75, 75, 154,
528 154, 154, 154, 154, 154, 154, 154, 140, 142, 143,
529 143, 154, 154, 154, 154, 154, 154, 154, 154, 144,
530 142, 143, 143, 154, 154, 154, 154, 154, 154, 154,
531 154, 144, 142, 143, 143, 154, 154, 154, 154, 154,
533 154, 154, 154, 152, 128, 85, 85, 154, 154, 154,
534 154, 154, 154, 154, 154, 145, 147, 148, 148, 154,
535 154, 154, 154, 154, 154, 154, 154, 149, 147, 148,
536 148, 154, 154, 154, 154, 154, 154, 154, 154, 149,
537 147, 148, 148, 154, 154, 154, 154, 154, 154, 154,
538 154, 153, 132, 89, 89, 154, 154, 154, 154, 154,
539 154, 154, 154, 150, 137, 138, 138, 154, 154, 154,
540 154, 154, 154, 154, 154, 151, 142, 143, 143, 154,
541 154, 154, 154, 154, 154, 154, 154, 152, 147, 148,
542 148, 154, 154, 154, 154, 154, 154, 154, 154, 153,
544 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
545 37, 37, 37, 39, 39, 39, 39, 39, 39, 39,
546 39, 39, 39, 39, 39, 39, 43, 43, 43, 43,
547 43, 43, 43, 43, 43, 43, 43, 43, 43, 45,
548 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
549 45, 45, 47, 47, 47, 47, 47, 47, 47, 47,
550 47, 47, 47, 47, 47, 51, 51, 51, 51, 51,
551 51, 51, 51, 51, 51, 51, 51, 51, 53, 53,
552 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
553 53, 57, 154, 154, 154, 57, 57, 60, 154, 154,
555 154, 60, 60, 60, 68, 154, 154, 154, 68, 68,
556 68, 73, 73, 73, 73, 73, 73, 154, 73, 73,
557 73, 73, 73, 73, 77, 77, 77, 77, 77, 77,
558 77, 154, 77, 77, 77, 77, 77, 81, 81, 81,
559 81, 154, 81, 81, 81, 81, 81, 81, 81, 81,
560 83, 83, 83, 83, 83, 83, 154, 83, 83, 83,
561 83, 83, 83, 87, 87, 87, 87, 87, 87, 154,
562 87, 87, 87, 87, 87, 92, 92, 92, 92, 92,
563 92, 92, 92, 92, 92, 92, 92, 92, 95, 95,
564 95, 95, 95, 95, 154, 95, 95, 95, 95, 95,
566 95, 96, 96, 96, 96, 96, 154, 96, 96, 96,
567 96, 96, 96, 96, 98, 154, 154, 154, 154, 98,
568 98, 99, 154, 154, 154, 99, 99, 99, 100, 100,
569 154, 100, 100, 100, 100, 100, 100, 100, 100, 100,
570 100, 102, 154, 154, 154, 102, 102, 106, 106, 154,
571 154, 154, 106, 154, 106, 110, 154, 154, 154, 110,
572 110, 111, 111, 154, 154, 154, 111, 154, 111, 115,
573 115, 154, 154, 154, 115, 154, 115, 120, 120, 121,
574 154, 154, 154, 121, 121, 121, 123, 123, 123, 123,
575 123, 123, 123, 123, 123, 123, 123, 123, 123, 127,
577 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
578 127, 127, 131, 131, 131, 131, 131, 131, 131, 131,
579 131, 131, 131, 131, 131, 135, 135, 136, 136, 136,
580 136, 136, 136, 136, 136, 136, 136, 136, 136, 136,
581 141, 141, 141, 141, 141, 141, 141, 141, 141, 141,
582 141, 141, 141, 146, 146, 146, 146, 146, 146, 146,
583 146, 146, 146, 146, 146, 146, 17, 154, 154, 154,
584 154, 154, 154, 154, 154, 154, 154, 154, 154, 154,
585 154, 154, 154, 154, 154, 154, 154, 154, 154, 154,
590 static yyconst flex_int16_t yy_chk[894] =
592 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
593 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
594 1, 1, 1, 1, 1, 1, 5, 15, 121, 5,
595 119, 15, 5, 5, 5, 11, 5, 6, 28, 28,
596 6, 11, 12, 6, 6, 6, 16, 6, 12, 23,
597 16, 19, 19, 19, 20, 20, 20, 11, 23, 23,
598 50, 117, 41, 113, 12, 30, 41, 30, 30, 108,
599 50, 99, 30, 38, 38, 38, 56, 56, 56, 59,
600 59, 104, 104, 98, 38, 46, 46, 46, 62, 62,
601 64, 64, 93, 62, 91, 64, 46, 49, 49, 49,
603 88, 75, 78, 85, 49, 75, 78, 85, 49, 61,
604 89, 86, 61, 76, 89, 61, 61, 61, 60, 61,
605 66, 66, 103, 103, 66, 66, 101, 103, 55, 101,
606 105, 105, 101, 101, 101, 106, 101, 44, 42, 106,
607 109, 109, 109, 111, 115, 36, 35, 111, 115, 34,
608 33, 109, 114, 114, 114, 31, 29, 27, 17, 14,
609 13, 10, 9, 114, 118, 118, 118, 8, 7, 4,
610 3, 0, 0, 0, 0, 118, 122, 122, 122, 0,
611 0, 0, 0, 0, 0, 0, 0, 122, 123, 123,
612 123, 0, 0, 0, 0, 0, 0, 0, 0, 123,
614 124, 124, 124, 0, 0, 0, 0, 0, 0, 0,
615 0, 124, 125, 125, 125, 0, 0, 0, 0, 0,
616 0, 0, 0, 125, 126, 126, 126, 0, 0, 0,
617 0, 0, 0, 0, 0, 126, 127, 127, 127, 0,
618 0, 0, 0, 0, 0, 0, 0, 127, 128, 128,
619 128, 0, 0, 0, 0, 0, 0, 0, 0, 128,
620 129, 129, 129, 0, 0, 0, 0, 0, 0, 0,
621 0, 129, 130, 130, 130, 0, 0, 0, 0, 0,
622 0, 0, 0, 130, 131, 131, 131, 0, 0, 0,
623 0, 0, 0, 0, 0, 131, 132, 132, 132, 0,
625 0, 0, 0, 0, 0, 0, 0, 132, 133, 133,
626 133, 0, 0, 0, 0, 0, 0, 0, 0, 133,
627 136, 136, 136, 0, 0, 0, 0, 0, 0, 0,
628 0, 136, 137, 137, 137, 0, 0, 0, 0, 0,
629 0, 0, 0, 137, 139, 139, 139, 0, 0, 0,
630 0, 0, 0, 0, 0, 139, 140, 140, 140, 0,
631 0, 0, 0, 0, 0, 0, 0, 140, 141, 141,
632 141, 0, 0, 0, 0, 0, 0, 0, 0, 141,
633 142, 142, 142, 0, 0, 0, 0, 0, 0, 0,
634 0, 142, 144, 144, 144, 0, 0, 0, 0, 0,
636 0, 0, 0, 144, 145, 145, 145, 0, 0, 0,
637 0, 0, 0, 0, 0, 145, 146, 146, 146, 0,
638 0, 0, 0, 0, 0, 0, 0, 146, 147, 147,
639 147, 0, 0, 0, 0, 0, 0, 0, 0, 147,
640 149, 149, 149, 0, 0, 0, 0, 0, 0, 0,
641 0, 149, 150, 150, 150, 0, 0, 0, 0, 0,
642 0, 0, 0, 150, 151, 151, 151, 0, 0, 0,
643 0, 0, 0, 0, 0, 151, 152, 152, 152, 0,
644 0, 0, 0, 0, 0, 0, 0, 152, 153, 153,
645 153, 0, 0, 0, 0, 0, 0, 0, 0, 153,
647 155, 155, 155, 155, 155, 155, 155, 155, 155, 155,
648 155, 155, 155, 156, 156, 156, 156, 156, 156, 156,
649 156, 156, 156, 156, 156, 156, 157, 157, 157, 157,
650 157, 157, 157, 157, 157, 157, 157, 157, 157, 158,
651 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
652 158, 158, 159, 159, 159, 159, 159, 159, 159, 159,
653 159, 159, 159, 159, 159, 160, 160, 160, 160, 160,
654 160, 160, 160, 160, 160, 160, 160, 160, 161, 161,
655 161, 161, 161, 161, 161, 161, 161, 161, 161, 161,
656 161, 162, 0, 0, 0, 162, 162, 163, 0, 0,
658 0, 163, 163, 163, 164, 0, 0, 0, 164, 164,
659 164, 165, 165, 165, 165, 165, 165, 0, 165, 165,
660 165, 165, 165, 165, 166, 166, 166, 166, 166, 166,
661 166, 0, 166, 166, 166, 166, 166, 167, 167, 167,
662 167, 0, 167, 167, 167, 167, 167, 167, 167, 167,
663 168, 168, 168, 168, 168, 168, 0, 168, 168, 168,
664 168, 168, 168, 169, 169, 169, 169, 169, 169, 0,
665 169, 169, 169, 169, 169, 170, 170, 170, 170, 170,
666 170, 170, 170, 170, 170, 170, 170, 170, 171, 171,
667 171, 171, 171, 171, 0, 171, 171, 171, 171, 171,
669 171, 172, 172, 172, 172, 172, 0, 172, 172, 172,
670 172, 172, 172, 172, 173, 0, 0, 0, 0, 173,
671 173, 174, 0, 0, 0, 174, 174, 174, 175, 175,
672 0, 175, 175, 175, 175, 175, 175, 175, 175, 175,
673 175, 176, 0, 0, 0, 176, 176, 177, 177, 0,
674 0, 0, 177, 0, 177, 178, 0, 0, 0, 178,
675 178, 179, 179, 0, 0, 0, 179, 0, 179, 180,
676 180, 0, 0, 0, 180, 0, 180, 181, 181, 182,
677 0, 0, 0, 182, 182, 182, 183, 183, 183, 183,
678 183, 183, 183, 183, 183, 183, 183, 183, 183, 184,
680 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
681 184, 184, 185, 185, 185, 185, 185, 185, 185, 185,
682 185, 185, 185, 185, 185, 186, 186, 187, 187, 187,
683 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
684 188, 188, 188, 188, 188, 188, 188, 188, 188, 188,
685 188, 188, 188, 189, 189, 189, 189, 189, 189, 189,
686 189, 189, 189, 189, 189, 189, 154, 154, 154, 154,
687 154, 154, 154, 154, 154, 154, 154, 154, 154, 154,
688 154, 154, 154, 154, 154, 154, 154, 154, 154, 154,
693 static yy_state_type yy_last_accepting_state;
694 static char *yy_last_accepting_cpos;
696 extern int base_yy_flex_debug;
697 int base_yy_flex_debug = 0;
699 /* The intent behind this definition is that it'll catch
700 * any uses of REJECT which flex missed.
702 #define REJECT reject_used_but_not_detected
703 #define yymore() yymore_used_but_not_detected
704 #define YY_MORE_ADJ 0
705 #define YY_RESTORE_YY_MORE_OFFSET
709 /*-------------------------------------------------------------------------
712 * lexical scanner for PostgreSQL
716 * The rules in this file must be kept in sync with psql's lexer!!!
718 * The rules are designed so that the scanner never has to backtrack,
719 * in the sense that there is always a rule that can match the input
720 * consumed so far (the rule action may internally throw back some input
721 * with yyless(), however). As explained in the flex manual, this makes
722 * for a useful speed increase --- about a third faster than a plain -CF
723 * lexer, in simple testing. The extra complexity is mostly in the rules
724 * for handling float numbers and continued string literals. If you change
725 * the lexical rules, verify that you haven't broken the no-backtrack
726 * property by running flex with the "-b" option and checking that the
727 * resulting "lex.backup" file says that no backing up is needed.
730 * Portions Copyright (c) 2003-2008, PgPool Global Development Group
731 * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
732 * Portions Copyright (c) 1994, Regents of the University of California
735 * $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.141 2007/09/12 20:49:27 adunstan Exp $
737 *-------------------------------------------------------------------------
739 #include "pool_parser.h"
748 #define ereport(a,b) yyerror("")
750 #define IS_HIGHBIT_SET(c) 0
752 #include "gramparse.h"
753 #include "keywords.h"
754 /* Not needed now that this file is compiled as part of gram.y */
755 /* #include "parser/parse.h" */
759 #include "pool_memory.h"
762 /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
765 #define fprintf(file, fmt, msg) ereport(ERROR, (errmsg_internal("%s", msg)))
768 static int xcdepth = 0; /* depth of nesting in slash-star comments */
769 static char *dolqstart; /* current $foo$ quote start string */
772 * GUC variables. This is a DIRECT violation of the warning given at the
773 * head of gram.y, ie flex/bison code must not depend on any GUC variables;
774 * as such, changing their values can induce very unintuitive behavior.
775 * But we shall have to live with it as a short-term thing until the switch
776 * to SQL-standard string syntax is complete.
782 BACKSLASH_QUOTE_SAFE_ENCODING
783 } BackslashQuoteType;
785 BackslashQuoteType backslash_quote = BACKSLASH_QUOTE_SAFE_ENCODING;
786 int escape_string_warning = true;
787 int standard_conforming_strings = false;
789 static bool warn_on_first_escape;
790 static bool saw_high_bit = false;
793 * literalbuf is used to accumulate literal values when multiple rules
794 * are needed to parse a single literal. Call startlit to reset buffer
795 * to empty, addlit to add text. Note that the buffer is palloc'd and
796 * starts life afresh on every parse cycle.
798 static char *literalbuf; /* expandable buffer */
799 static int literallen; /* actual current length */
800 static int literalalloc; /* current allocated buffer size */
802 #define startlit() (literalbuf[0] = '\0', literallen = 0)
803 static void addlit(char *ytext, int yleng);
804 static void addlitchar(unsigned char ychar);
805 static char *litbufdup(void);
808 static int lexer_errposition(void);
810 static void check_escape_warning(void);
811 static void check_string_escape_warning(unsigned char ychar);
813 extern char *base_yytext;
816 * Each call to base_yylex must set yylloc to the location of the found token
817 * (expressed as a byte offset from the start of the input text).
818 * When we parse a token that requires multiple lexer rules to process,
819 * this should be done in the first such rule, else yylloc will point
820 * into the middle of the token.
822 #define SET_YYLLOC() (yylloc = base_yytext - scanbuf)
824 /* Handles to the buffer that the lexer uses internally */
825 static YY_BUFFER_STATE scanbufhandle;
826 static char *scanbuf;
828 static unsigned char unescape_single_char(unsigned char c);
829 void yyerror(const char *s);
832 * OK, here is a short description of lex/flex rules behavior.
833 * The longest pattern which matches an input string is always chosen.
834 * For equal-length patterns, the first occurring in the rules list is chosen.
835 * INITIAL is the starting state, to which all non-conditional rules apply.
836 * Exclusive states change parsing rules while the state is active. When in
837 * an exclusive state, only those rules defined for that state apply.
839 * We use exclusive states for quoted strings, extended comments,
840 * and to eliminate parsing troubles for numeric strings.
842 * <xb> bit string literal
843 * <xc> extended C-style comments
844 * <xd> delimited identifiers (double-quoted identifiers)
845 * <xh> hexadecimal numeric string
846 * <xq> standard quoted strings
847 * <xe> extended quoted strings (support backslash escape sequences)
848 * <xdolq> $foo$ quoted strings
858 * In order to make the world safe for Windows and Mac clients as well as
859 * Unix ones, we accept either \n or \r as a newline. A DOS-style \r\n
860 * sequence will be seen as two successive newlines, but that doesn't cause
861 * any problems. Comments that start with -- and extend to the next
862 * newline are treated as equivalent to a single whitespace character.
864 * NOTE a fine point: if there is no newline following --, we will absorb
865 * everything to the end of the input as a comment. This is correct. Older
866 * versions of Postgres failed to recognize -- as a comment if the input
867 * did not end with a newline.
869 * XXX perhaps \f (formfeed) should be treated as a newline as well?
871 * XXX if you change the set of whitespace characters, fix scanner_isspace()
872 * to agree, and see also the plpgsql lexer.
875 * SQL requires at least one newline in the whitespace separating
876 * string literals that are to be concatenated. Silly, but who are we
877 * to argue? Note that {whitespace_with_newline} should not have * after
878 * it, whereas {whitespace} should generally have a * after it...
881 * To ensure that {quotecontinue} can be scanned without having to back up
882 * if the full pattern isn't matched, we include trailing whitespace in
883 * {quotestop}. This matches all cases where {quotecontinue} fails to match,
884 * except for {quote} followed by whitespace and just one "-" (not two,
885 * which would start a {comment}). To cover that we have {quotefail}.
886 * The actions for {quotestop} and {quotefail} must throw back characters
887 * beyond the quote proper.
890 * It is tempting to scan the string for only those characters
891 * which are allowed. However, this leads to silently swallowed
892 * characters if illegal characters are included in the string.
893 * For example, if xbinside is [01] then B'ABCD' is interpreted
894 * as a zero-length string, and the ABCD' is lost!
895 * Better to pass the string forward and let the input routines
896 * validate the contents.
898 /* Hexadecimal number */
899 /* National character */
900 /* Quoted string that allows backslash escapes */
902 * xqdouble implements embedded quote, ''''
904 /* $foo$ style quotes ("dollar quoting")
905 * The quoted string starts with $foo$ where "foo" is an optional string
906 * in the form of an identifier, except that it may not contain "$",
907 * and extends to the first occurrence of an identical string.
908 * There is *no* processing of the quoted text.
910 * {dolqfailed} is an error rule to avoid scanner backup when {dolqdelim}
911 * fails to match its trailing "$".
914 * Allows embedded spaces and other special characters into identifiers.
918 * The "extended comment" syntax closely resembles allowable operator syntax.
919 * The tricky part here is to get lex to recognize a string starting with
920 * slash-star as a comment, when interpreting it as an operator would produce
921 * a longer match --- remember lex will prefer a longer match! Also, if we
922 * have something like plus-slash-star, lex will think this is a 3-character
923 * operator whereas we want to see it as a + operator and a comment start.
924 * The solution is two-fold:
925 * 1. append {op_chars}* to xcstart so that it matches as much text as
926 * {operator} would. Then the tie-breaker (first matching rule of same
927 * length) ensures xcstart wins. We put back the extra stuff with yyless()
928 * in case it contains a star-slash that should terminate the comment.
929 * 2. In the operator rule, check for slash-star within the operator, and
930 * if found throw it back with yyless(). This handles the plus-slash-star
932 * Dash-dash comments have similar interactions with the operator rule.
935 * "self" is the set of chars that should be returned as single-character
936 * tokens. "op_chars" is the set of chars that can make up "Op" tokens,
937 * which can be one or more characters long (but if a single-char token
938 * appears in the "self" set, it is not to be returned as an Op). Note
939 * that the sets overlap, but each has some chars that are not in the other.
941 * If you change either set, adjust the character lists appearing in the
942 * rule for "operator"!
944 /* we no longer allow unary minus in numbers.
945 * instead we pass it separately to parser. there it gets
946 * coerced via doNegate() -- Leon aug 20 1999
948 * {realfail1} and {realfail2} are added to prevent the need for scanner
949 * backup when the {real} rule fails to match completely.
952 * Dollar quoted strings are totally opaque, and no escaping is done on them.
953 * Other quoted strings must allow some special characters such as single-quote
955 * Embedded single-quotes are implemented both in the SQL standard
956 * style of two adjacent single quotes "''" and in the Postgres/Java style
957 * of escaped-quote "\'".
958 * Other embedded escaped characters are matched explicitly and the leading
959 * backslash is dropped from the string.
960 * Note that xcstart must appear before operator, as explained above!
961 * Also whitespace (comment) must appear before operator.
974 #ifndef YY_NO_UNISTD_H
975 /* Special case for "unistd.h", since it is non-ANSI. We include it way
976 * down here because we want the user's section 1 to have been scanned first.
977 * The user has a chance to override it with an option.
982 #ifndef YY_EXTRA_TYPE
983 #define YY_EXTRA_TYPE void *
986 static int yy_init_globals (void );
988 /* Macros after this point can all be overridden by user definitions in
992 #ifndef YY_SKIP_YYWRAP
994 extern "C" int base_yywrap (void );
996 extern int base_yywrap (void );
1001 static void yy_flex_strncpy (char *,yyconst char *,int );
1004 #ifdef YY_NEED_STRLEN
1005 static int yy_flex_strlen (yyconst char * );
1011 static int yyinput (void );
1013 static int input (void );
1018 /* Amount of stuff to slurp up with each read. */
1019 #ifndef YY_READ_BUF_SIZE
1020 #define YY_READ_BUF_SIZE 8192
1023 /* Copy whatever the last rule matched to the standard output. */
1025 /* This used to be an fputs(), but since the string might contain NUL's,
1026 * we now use fwrite().
1028 #define ECHO (void) fwrite( base_yytext, base_yyleng, 1, base_yyout )
1031 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
1032 * is returned in "result".
1035 #define YY_INPUT(buf,result,max_size) \
1036 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
1040 for ( n = 0; n < max_size && \
1041 (c = getc( base_yyin )) != EOF && c != '\n'; ++n ) \
1042 buf[n] = (char) c; \
1044 buf[n++] = (char) c; \
1045 if ( c == EOF && ferror( base_yyin ) ) \
1046 YY_FATAL_ERROR( "input in flex scanner failed" ); \
1052 while ( (result = fread(buf, 1, max_size, base_yyin))==0 && ferror(base_yyin)) \
1054 if( errno != EINTR) \
1056 YY_FATAL_ERROR( "input in flex scanner failed" ); \
1060 clearerr(base_yyin); \
1067 /* No semi-colon after return; correct usage is to write "yyterminate();" -
1068 * we don't want an extra ';' after the "return" because that will cause
1069 * some compilers to complain about unreachable statements.
1072 #define yyterminate() return YY_NULL
1075 /* Number of entries by which start-condition stack grows. */
1076 #ifndef YY_START_STACK_INCR
1077 #define YY_START_STACK_INCR 25
1080 /* Report a fatal error. */
1081 #ifndef YY_FATAL_ERROR
1082 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
1085 /* end tables serialization structures and prototypes */
1087 /* Default declaration of generated scanner - a define so the user can
1088 * easily add parameters.
1091 #define YY_DECL_IS_OURS 1
1093 extern int base_yylex (void);
1095 #define YY_DECL int base_yylex (void)
1096 #endif /* !YY_DECL */
1098 /* Code executed at the beginning of each rule, after base_yytext and base_yyleng
1101 #ifndef YY_USER_ACTION
1102 #define YY_USER_ACTION
1105 /* Code executed at the end of each rule. */
1107 #define YY_BREAK break;
1110 #define YY_RULE_SETUP \
1113 /** The main scanner function which does all the work.
1117 register yy_state_type yy_current_state;
1118 register char *yy_cp, *yy_bp;
1119 register int yy_act;
1135 (yy_start) = 1; /* first start state */
1141 base_yyout = stdout;
1143 if ( ! YY_CURRENT_BUFFER ) {
1144 base_yyensure_buffer_stack ();
1145 YY_CURRENT_BUFFER_LVALUE =
1146 base_yy_create_buffer(base_yyin,YY_BUF_SIZE );
1149 base_yy_load_buffer_state( );
1152 while ( 1 ) /* loops until end-of-file is reached */
1154 yy_cp = (yy_c_buf_p);
1156 /* Support of base_yytext. */
1157 *yy_cp = (yy_hold_char);
1159 /* yy_bp points to the position in yy_ch_buf of the start of
1164 yy_current_state = (yy_start);
1168 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
1169 if ( yy_accept[yy_current_state] )
1171 (yy_last_accepting_state) = yy_current_state;
1172 (yy_last_accepting_cpos) = yy_cp;
1174 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1176 yy_current_state = (int) yy_def[yy_current_state];
1177 if ( yy_current_state >= 155 )
1178 yy_c = yy_meta[(unsigned int) yy_c];
1180 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1183 while ( yy_current_state != 154 );
1184 yy_cp = (yy_last_accepting_cpos);
1185 yy_current_state = (yy_last_accepting_state);
1188 yy_act = yy_accept[yy_current_state];
1190 YY_DO_BEFORE_ACTION;
1192 do_action: /* This label is used only to access EOF actions. */
1195 { /* beginning of action switch */
1196 case 0: /* must back up */
1197 /* undo the effects of YY_DO_BEFORE_ACTION */
1198 *yy_cp = (yy_hold_char);
1199 yy_cp = (yy_last_accepting_cpos);
1200 yy_current_state = (yy_last_accepting_state);
1201 goto yy_find_action;
1204 /* rule 1 can match eol */
1215 /* Set location in case of syntax error in comment */
1219 /* Put back any characters past slash-star; see above */
1228 /* Put back any characters past slash-star; see above */
1243 /* rule 5 can match eol */
1264 case YY_STATE_EOF(xc):
1266 { yyerror("unterminated /* comment"); }
1273 * At some point we should simply pass the string
1274 * forward to the parser and label it there.
1275 * In the meantime, place a leading "b" on the string
1276 * to mark it for the input routine as a binary string.
1285 /* rule 9 can match eol */
1288 /* rule 10 can match eol */
1294 yylval.str = litbufdup();
1299 /* rule 11 can match eol */
1302 /* rule 12 can match eol */
1306 addlit(base_yytext, base_yyleng);
1310 /* rule 13 can match eol */
1313 /* rule 14 can match eol */
1320 case YY_STATE_EOF(xb):
1322 { yyerror("unterminated bit string literal"); }
1328 /* Hexadecimal bit type.
1329 * At some point we should simply pass the string
1330 * forward to the parser and label it there.
1331 * In the meantime, place a leading "x" on the string
1332 * to mark it for the input routine as a hex string.
1341 /* rule 16 can match eol */
1344 /* rule 17 can match eol */
1350 yylval.str = litbufdup();
1354 case YY_STATE_EOF(xh):
1356 { yyerror("unterminated hexadecimal string literal"); }
1362 /* National character.
1363 * We will pass this along as a normal character string,
1364 * but preceded with an internally-generated "NCHAR".
1366 const ScanKeyword *keyword;
1369 yyless(1); /* eat only 'n' this time */
1370 /* nchar had better be a keyword! */
1371 keyword = ScanKeywordLookup("nchar");
1372 yylval.keyword = keyword->name;
1373 return keyword->value;
1380 warn_on_first_escape = true;
1381 saw_high_bit = false;
1383 if (standard_conforming_strings)
1394 warn_on_first_escape = false;
1395 saw_high_bit = false;
1402 /* rule 21 can match eol */
1405 /* rule 22 can match eol */
1411 /* check that the data remains valid if it might have been
1412 * made invalid by unescaping any chars.
1415 /* pg_verifymbstr(literalbuf, literallen, false);*/
1416 yylval.str = litbufdup();
1428 /* rule 24 can match eol */
1432 addlit(base_yytext, base_yyleng);
1436 /* rule 25 can match eol */
1440 addlit(base_yytext, base_yyleng);
1444 /* rule 26 can match eol */
1448 if (base_yytext[1] == '\'')
1451 if (backslash_quote == BACKSLASH_QUOTE_OFF ||
1452 (backslash_quote == BACKSLASH_QUOTE_SAFE_ENCODING &&
1453 PG_ENCODING_IS_CLIENT_ONLY(pg_get_client_encoding())))
1455 (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
1456 errmsg("unsafe use of \\' in a string literal"),
1457 errhint("Use '' to write quotes in strings. \\' is insecure in client-only encodings."),
1458 lexer_errposition()));
1461 check_string_escape_warning(base_yytext[1]);
1462 addlitchar(unescape_single_char(base_yytext[1]));
1469 unsigned char c = strtoul(base_yytext+1, NULL, 8);
1471 check_escape_warning();
1473 if (IS_HIGHBIT_SET(c))
1474 saw_high_bit = true;
1481 unsigned char c = strtoul(base_yytext+2, NULL, 16);
1483 check_escape_warning();
1485 if (IS_HIGHBIT_SET(c))
1486 saw_high_bit = true;
1490 /* rule 29 can match eol */
1501 /* This is only needed for \ just before EOF */
1502 addlitchar(base_yytext[0]);
1505 case YY_STATE_EOF(xq):
1506 case YY_STATE_EOF(xe):
1508 { yyerror("unterminated quoted string"); }
1515 dolqstart = pstrdup(base_yytext);
1524 /* throw back all but the initial "$" */
1526 /* and treat it as {other} */
1527 return base_yytext[0];
1534 if (strcmp(base_yytext, dolqstart) == 0)
1538 yylval.str = litbufdup();
1544 * When we fail to match $...$ to dolqstart, transfer
1545 * the $... part to the output, but put back the final
1546 * $ for rescanning. Consider $delim$...$junk$delim$
1548 addlit(base_yytext, base_yyleng-1);
1549 yyless(base_yyleng-1);
1554 /* rule 34 can match eol */
1558 addlit(base_yytext, base_yyleng);
1565 addlit(base_yytext, base_yyleng);
1572 /* This is only needed for $ inside the quoted text */
1573 addlitchar(base_yytext[0]);
1576 case YY_STATE_EOF(xdolq):
1578 { yyerror("unterminated dollar-quoted string"); }
1596 if (literallen == 0)
1597 yyerror("zero-length delimited identifier");
1598 ident = litbufdup();
1599 if (literallen >= NAMEDATALEN)
1600 truncate_identifier(ident, literallen, true);
1613 /* rule 40 can match eol */
1617 addlit(base_yytext, base_yyleng);
1620 case YY_STATE_EOF(xd):
1622 { yyerror("unterminated quoted identifier"); }
1637 return base_yytext[0];
1645 * Check for embedded slash-star or dash-dash; those
1646 * are comment starts, so operator must stop there.
1647 * Note that slash-star or dash-dash at the first
1648 * character will match a prior rule, not this one.
1650 int nchars = base_yyleng;
1651 char *slashstar = strstr(base_yytext, "/*");
1652 char *dashdash = strstr(base_yytext, "--");
1654 if (slashstar && dashdash)
1656 /* if both appear, take the first one */
1657 if (slashstar > dashdash)
1658 slashstar = dashdash;
1660 else if (!slashstar)
1661 slashstar = dashdash;
1663 nchars = slashstar - base_yytext;
1666 * For SQL compatibility, '+' and '-' cannot be the
1667 * last char of a multi-char operator unless the operator
1668 * contains chars that are not in SQL operators.
1669 * The idea is to lex '=-' as two operators, but not
1670 * to forbid operator names like '?-' that could not be
1671 * sequences of SQL operators.
1673 while (nchars > 1 &&
1674 (base_yytext[nchars-1] == '+' ||
1675 base_yytext[nchars-1] == '-'))
1679 for (ic = nchars-2; ic >= 0; ic--)
1681 if (strchr("~!@#^&|`?%", base_yytext[ic]))
1685 break; /* found a char that makes it OK */
1686 nchars--; /* else remove the +/-, and check again */
1691 if (nchars < base_yyleng)
1693 /* Strip the unwanted chars from the token */
1696 * If what we have left is only one char, and it's
1697 * one of the characters matching "self", then
1698 * return it as a character token the same way
1699 * that the "self" rule would have.
1702 strchr(",()[].;:+-*/%^<>=", base_yytext[0]))
1703 return base_yytext[0];
1707 * Complain if operator is too long. Unlike the case
1708 * for identifiers, we make this an error not a notice-
1709 * and-truncate, because the odds are we are looking at
1710 * a syntactic mistake anyway.
1712 if (nchars >= NAMEDATALEN)
1713 yyerror("operator too long");
1715 /* Convert "!=" operator to "<>" for compatibility */
1716 if (strcmp(base_yytext, "!=") == 0)
1717 yylval.str = pstrdup("<>");
1719 yylval.str = pstrdup(base_yytext);
1728 yylval.ival = atol(base_yytext + 1);
1741 val = strtol(base_yytext, &endptr, 10);
1742 if (*endptr != '\0' || errno == ERANGE
1743 #ifdef HAVE_LONG_INT_64
1744 /* if long > 32 bits, check for overflow of int4 */
1745 || val != (long) ((int32) val)
1749 /* integer too large, treat it as a float */
1750 yylval.str = pstrdup(base_yytext);
1762 yylval.str = pstrdup(base_yytext);
1771 yylval.str = pstrdup(base_yytext);
1780 * throw back the [Ee], and treat as {decimal}. Note
1781 * that it is possible the input is actually {integer},
1782 * but since this case will almost certainly lead to a
1783 * syntax error anyway, we don't bother to distinguish.
1785 yyless(base_yyleng-1);
1787 yylval.str = pstrdup(base_yytext);
1795 /* throw back the [Ee][+-], and proceed as above */
1796 yyless(base_yyleng-2);
1798 yylval.str = pstrdup(base_yytext);
1806 const ScanKeyword *keyword;
1811 /* Is it a keyword? */
1812 keyword = ScanKeywordLookup(base_yytext);
1813 if (keyword != NULL)
1815 yylval.keyword = keyword->name;
1816 return keyword->value;
1820 * No. Convert the identifier to lower case, and truncate
1823 ident = downcase_truncate_identifier(base_yytext, base_yyleng, true);
1833 return base_yytext[0];
1836 case YY_STATE_EOF(INITIAL):
1846 YY_FATAL_ERROR( "flex scanner jammed" );
1850 case YY_END_OF_BUFFER:
1852 /* Amount of text matched not including the EOB char. */
1853 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1855 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1856 *yy_cp = (yy_hold_char);
1857 YY_RESTORE_YY_MORE_OFFSET
1859 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1861 /* We're scanning a new file or input source. It's
1862 * possible that this happened because the user
1863 * just pointed base_yyin at a new source and called
1864 * base_yylex(). If so, then we have to assure
1865 * consistency between YY_CURRENT_BUFFER and our
1866 * globals. Here is the right place to do so, because
1867 * this is the first action (other than possibly a
1868 * back-up) that will match for the new input source.
1870 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1871 YY_CURRENT_BUFFER_LVALUE->yy_input_file = base_yyin;
1872 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1875 /* Note that here we test for yy_c_buf_p "<=" to the position
1876 * of the first EOB in the buffer, since yy_c_buf_p will
1877 * already have been incremented past the NUL character
1878 * (since all states make transitions on EOB to the
1879 * end-of-buffer state). Contrast this with the test
1882 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1883 { /* This was really a NUL. */
1884 yy_state_type yy_next_state;
1886 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1888 yy_current_state = yy_get_previous_state( );
1890 /* Okay, we're now positioned to make the NUL
1891 * transition. We couldn't have
1892 * yy_get_previous_state() go ahead and do it
1893 * for us because it doesn't know how to deal
1894 * with the possibility of jamming (and we don't
1895 * want to build jamming into it because then it
1896 * will run more slowly).
1899 yy_next_state = yy_try_NUL_trans( yy_current_state );
1901 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1903 if ( yy_next_state )
1905 /* Consume the NUL. */
1906 yy_cp = ++(yy_c_buf_p);
1907 yy_current_state = yy_next_state;
1913 yy_cp = (yy_last_accepting_cpos);
1914 yy_current_state = (yy_last_accepting_state);
1915 goto yy_find_action;
1919 else switch ( yy_get_next_buffer( ) )
1921 case EOB_ACT_END_OF_FILE:
1923 (yy_did_buffer_switch_on_eof) = 0;
1925 if ( base_yywrap( ) )
1927 /* Note: because we've taken care in
1928 * yy_get_next_buffer() to have set up
1929 * base_yytext, we can now set up
1930 * yy_c_buf_p so that if some total
1931 * hoser (like flex itself) wants to
1932 * call the scanner after we return the
1933 * YY_NULL, it'll still work - another
1934 * YY_NULL will get returned.
1936 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1938 yy_act = YY_STATE_EOF(YY_START);
1944 if ( ! (yy_did_buffer_switch_on_eof) )
1950 case EOB_ACT_CONTINUE_SCAN:
1952 (yytext_ptr) + yy_amount_of_matched_text;
1954 yy_current_state = yy_get_previous_state( );
1956 yy_cp = (yy_c_buf_p);
1957 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1960 case EOB_ACT_LAST_MATCH:
1962 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1964 yy_current_state = yy_get_previous_state( );
1966 yy_cp = (yy_c_buf_p);
1967 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1968 goto yy_find_action;
1975 "fatal flex scanner internal error--no action found" );
1976 } /* end of action switch */
1977 } /* end of scanning one token */
1978 } /* end of base_yylex */
1980 /* yy_get_next_buffer - try to read in a new buffer
1982 * Returns a code representing an action:
1983 * EOB_ACT_LAST_MATCH -
1984 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1985 * EOB_ACT_END_OF_FILE - end of file
1987 static int yy_get_next_buffer (void)
1989 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1990 register char *source = (yytext_ptr);
1991 register int number_to_move, i;
1994 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1996 "fatal flex scanner internal error--end of buffer missed" );
1998 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1999 { /* Don't try to fill the buffer, so this is an EOF. */
2000 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
2002 /* We matched a single character, the EOB, so
2003 * treat this as a final EOF.
2005 return EOB_ACT_END_OF_FILE;
2010 /* We matched some text prior to the EOB, first
2013 return EOB_ACT_LAST_MATCH;
2017 /* Try to read more data. */
2019 /* First move last chars to start of buffer. */
2020 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
2022 for ( i = 0; i < number_to_move; ++i )
2023 *(dest++) = *(source++);
2025 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
2026 /* don't do the read, it's not guaranteed to return an EOF,
2029 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
2034 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
2036 while ( num_to_read <= 0 )
2037 { /* Not enough room in the buffer - grow it. */
2039 /* just a shorter name for the current buffer */
2040 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
2042 int yy_c_buf_p_offset =
2043 (int) ((yy_c_buf_p) - b->yy_ch_buf);
2045 if ( b->yy_is_our_buffer )
2047 int new_size = b->yy_buf_size * 2;
2049 if ( new_size <= 0 )
2050 b->yy_buf_size += b->yy_buf_size / 8;
2052 b->yy_buf_size *= 2;
2054 b->yy_ch_buf = (char *)
2055 /* Include room in for 2 EOB chars. */
2056 base_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
2059 /* Can't grow it, we don't own it. */
2062 if ( ! b->yy_ch_buf )
2064 "fatal error - scanner input buffer overflow" );
2066 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
2068 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
2073 if ( num_to_read > YY_READ_BUF_SIZE )
2074 num_to_read = YY_READ_BUF_SIZE;
2076 /* Read in more data. */
2077 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
2078 (yy_n_chars), num_to_read );
2080 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
2083 if ( (yy_n_chars) == 0 )
2085 if ( number_to_move == YY_MORE_ADJ )
2087 ret_val = EOB_ACT_END_OF_FILE;
2088 base_yyrestart(base_yyin );
2093 ret_val = EOB_ACT_LAST_MATCH;
2094 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
2095 YY_BUFFER_EOF_PENDING;
2100 ret_val = EOB_ACT_CONTINUE_SCAN;
2102 (yy_n_chars) += number_to_move;
2103 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
2104 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
2106 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
2111 /* yy_get_previous_state - get the state just before the EOB char was reached */
2113 static yy_state_type yy_get_previous_state (void)
2115 register yy_state_type yy_current_state;
2116 register char *yy_cp;
2118 yy_current_state = (yy_start);
2120 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
2122 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
2123 if ( yy_accept[yy_current_state] )
2125 (yy_last_accepting_state) = yy_current_state;
2126 (yy_last_accepting_cpos) = yy_cp;
2128 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
2130 yy_current_state = (int) yy_def[yy_current_state];
2131 if ( yy_current_state >= 155 )
2132 yy_c = yy_meta[(unsigned int) yy_c];
2134 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
2137 return yy_current_state;
2140 /* yy_try_NUL_trans - try to make a transition on the NUL character
2143 * next_state = yy_try_NUL_trans( current_state );
2145 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
2147 register int yy_is_jam;
2148 register char *yy_cp = (yy_c_buf_p);
2150 register YY_CHAR yy_c = 1;
2151 if ( yy_accept[yy_current_state] )
2153 (yy_last_accepting_state) = yy_current_state;
2154 (yy_last_accepting_cpos) = yy_cp;
2156 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
2158 yy_current_state = (int) yy_def[yy_current_state];
2159 if ( yy_current_state >= 155 )
2160 yy_c = yy_meta[(unsigned int) yy_c];
2162 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
2163 yy_is_jam = (yy_current_state == 154);
2165 return yy_is_jam ? 0 : yy_current_state;
2170 static int yyinput (void)
2172 static int input (void)
2178 *(yy_c_buf_p) = (yy_hold_char);
2180 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
2182 /* yy_c_buf_p now points to the character we want to return.
2183 * If this occurs *before* the EOB characters, then it's a
2184 * valid NUL; if not, then we've hit the end of the buffer.
2186 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
2187 /* This was really a NUL. */
2188 *(yy_c_buf_p) = '\0';
2191 { /* need more input */
2192 int offset = (yy_c_buf_p) - (yytext_ptr);
2195 switch ( yy_get_next_buffer( ) )
2197 case EOB_ACT_LAST_MATCH:
2198 /* This happens because yy_g_n_b()
2199 * sees that we've accumulated a
2200 * token and flags that we need to
2201 * try matching the token before
2202 * proceeding. But for input(),
2203 * there's no matching to consider.
2204 * So convert the EOB_ACT_LAST_MATCH
2205 * to EOB_ACT_END_OF_FILE.
2208 /* Reset buffer status. */
2209 base_yyrestart(base_yyin );
2213 case EOB_ACT_END_OF_FILE:
2215 if ( base_yywrap( ) )
2218 if ( ! (yy_did_buffer_switch_on_eof) )
2227 case EOB_ACT_CONTINUE_SCAN:
2228 (yy_c_buf_p) = (yytext_ptr) + offset;
2234 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
2235 *(yy_c_buf_p) = '\0'; /* preserve base_yytext */
2236 (yy_hold_char) = *++(yy_c_buf_p);
2240 #endif /* ifndef YY_NO_INPUT */
2242 /** Immediately switch to a different input stream.
2243 * @param input_file A readable stream.
2245 * @note This function does not reset the start condition to @c INITIAL .
2247 void base_yyrestart (FILE * input_file )
2250 if ( ! YY_CURRENT_BUFFER ){
2251 base_yyensure_buffer_stack ();
2252 YY_CURRENT_BUFFER_LVALUE =
2253 base_yy_create_buffer(base_yyin,YY_BUF_SIZE );
2256 base_yy_init_buffer(YY_CURRENT_BUFFER,input_file );
2257 base_yy_load_buffer_state( );
2260 /** Switch to a different input buffer.
2261 * @param new_buffer The new input buffer.
2264 void base_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
2267 /* TODO. We should be able to replace this entire function body
2269 * base_yypop_buffer_state();
2270 * base_yypush_buffer_state(new_buffer);
2272 base_yyensure_buffer_stack ();
2273 if ( YY_CURRENT_BUFFER == new_buffer )
2276 if ( YY_CURRENT_BUFFER )
2278 /* Flush out information for old buffer. */
2279 *(yy_c_buf_p) = (yy_hold_char);
2280 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
2281 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
2284 YY_CURRENT_BUFFER_LVALUE = new_buffer;
2285 base_yy_load_buffer_state( );
2287 /* We don't actually know whether we did this switch during
2288 * EOF (base_yywrap()) processing, but the only time this flag
2289 * is looked at is after base_yywrap() is called, so it's safe
2290 * to go ahead and always set it.
2292 (yy_did_buffer_switch_on_eof) = 1;
2295 static void base_yy_load_buffer_state (void)
2297 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2298 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
2299 base_yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
2300 (yy_hold_char) = *(yy_c_buf_p);
2303 /** Allocate and initialize an input buffer state.
2304 * @param file A readable stream.
2305 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
2307 * @return the allocated buffer state.
2309 YY_BUFFER_STATE base_yy_create_buffer (FILE * file, int size )
2313 b = (YY_BUFFER_STATE) base_yyalloc(sizeof( struct yy_buffer_state ) );
2315 YY_FATAL_ERROR( "out of dynamic memory in base_yy_create_buffer()" );
2317 b->yy_buf_size = size;
2319 /* yy_ch_buf has to be 2 characters longer than the size given because
2320 * we need to put in 2 end-of-buffer characters.
2322 b->yy_ch_buf = (char *) base_yyalloc(b->yy_buf_size + 2 );
2323 if ( ! b->yy_ch_buf )
2324 YY_FATAL_ERROR( "out of dynamic memory in base_yy_create_buffer()" );
2326 b->yy_is_our_buffer = 1;
2328 base_yy_init_buffer(b,file );
2333 /** Destroy the buffer.
2334 * @param b a buffer created with base_yy_create_buffer()
2337 void base_yy_delete_buffer (YY_BUFFER_STATE b )
2343 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
2344 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
2346 if ( b->yy_is_our_buffer )
2347 base_yyfree((void *) b->yy_ch_buf );
2349 base_yyfree((void *) b );
2352 /* Initializes or reinitializes a buffer.
2353 * This function is sometimes called more than once on the same buffer,
2354 * such as during a base_yyrestart() or at EOF.
2356 static void base_yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
2361 base_yy_flush_buffer(b );
2363 b->yy_input_file = file;
2364 b->yy_fill_buffer = 1;
2366 /* If b is the current buffer, then base_yy_init_buffer was _probably_
2367 * called from base_yyrestart() or through yy_get_next_buffer.
2368 * In that case, we don't want to reset the lineno or column.
2370 if (b != YY_CURRENT_BUFFER){
2371 b->yy_bs_lineno = 1;
2372 b->yy_bs_column = 0;
2375 b->yy_is_interactive = 0;
2380 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2381 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2384 void base_yy_flush_buffer (YY_BUFFER_STATE b )
2391 /* We always need two end-of-buffer characters. The first causes
2392 * a transition to the end-of-buffer state. The second causes
2393 * a jam in that state.
2395 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2396 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2398 b->yy_buf_pos = &b->yy_ch_buf[0];
2401 b->yy_buffer_status = YY_BUFFER_NEW;
2403 if ( b == YY_CURRENT_BUFFER )
2404 base_yy_load_buffer_state( );
2407 /** Pushes the new state onto the stack. The new state becomes
2408 * the current state. This function will allocate the stack
2410 * @param new_buffer The new state.
2413 void base_yypush_buffer_state (YY_BUFFER_STATE new_buffer )
2415 if (new_buffer == NULL)
2418 base_yyensure_buffer_stack();
2420 /* This block is copied from base_yy_switch_to_buffer. */
2421 if ( YY_CURRENT_BUFFER )
2423 /* Flush out information for old buffer. */
2424 *(yy_c_buf_p) = (yy_hold_char);
2425 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
2426 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
2429 /* Only push if top exists. Otherwise, replace top. */
2430 if (YY_CURRENT_BUFFER)
2431 (yy_buffer_stack_top)++;
2432 YY_CURRENT_BUFFER_LVALUE = new_buffer;
2434 /* copied from base_yy_switch_to_buffer. */
2435 base_yy_load_buffer_state( );
2436 (yy_did_buffer_switch_on_eof) = 1;
2439 /** Removes and deletes the top of the stack, if present.
2440 * The next element becomes the new top.
2443 void base_yypop_buffer_state (void)
2445 if (!YY_CURRENT_BUFFER)
2448 base_yy_delete_buffer(YY_CURRENT_BUFFER );
2449 YY_CURRENT_BUFFER_LVALUE = NULL;
2450 if ((yy_buffer_stack_top) > 0)
2451 --(yy_buffer_stack_top);
2453 if (YY_CURRENT_BUFFER) {
2454 base_yy_load_buffer_state( );
2455 (yy_did_buffer_switch_on_eof) = 1;
2459 /* Allocates the stack if it does not exist.
2460 * Guarantees space for at least one push.
2462 static void base_yyensure_buffer_stack (void)
2466 if (!(yy_buffer_stack)) {
2468 /* First allocation is just for 2 elements, since we don't know if this
2469 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2470 * immediate realloc on the next call.
2473 (yy_buffer_stack) = (struct yy_buffer_state**)base_yyalloc
2474 (num_to_alloc * sizeof(struct yy_buffer_state*)
2477 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2479 (yy_buffer_stack_max) = num_to_alloc;
2480 (yy_buffer_stack_top) = 0;
2484 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
2486 /* Increase the buffer to prepare for a possible push. */
2487 int grow_size = 8 /* arbitrary grow size */;
2489 num_to_alloc = (yy_buffer_stack_max) + grow_size;
2490 (yy_buffer_stack) = (struct yy_buffer_state**)base_yyrealloc
2492 num_to_alloc * sizeof(struct yy_buffer_state*)
2495 /* zero only the new slots.*/
2496 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
2497 (yy_buffer_stack_max) = num_to_alloc;
2501 /** Setup the input buffer state to scan directly from a user-specified character buffer.
2502 * @param base the character buffer
2503 * @param size the size in bytes of the character buffer
2505 * @return the newly allocated buffer state object.
2507 YY_BUFFER_STATE base_yy_scan_buffer (char * base, yy_size_t size )
2512 base[size-2] != YY_END_OF_BUFFER_CHAR ||
2513 base[size-1] != YY_END_OF_BUFFER_CHAR )
2514 /* They forgot to leave room for the EOB's. */
2517 b = (YY_BUFFER_STATE) base_yyalloc(sizeof( struct yy_buffer_state ) );
2519 YY_FATAL_ERROR( "out of dynamic memory in base_yy_scan_buffer()" );
2521 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
2522 b->yy_buf_pos = b->yy_ch_buf = base;
2523 b->yy_is_our_buffer = 0;
2524 b->yy_input_file = 0;
2525 b->yy_n_chars = b->yy_buf_size;
2526 b->yy_is_interactive = 0;
2528 b->yy_fill_buffer = 0;
2529 b->yy_buffer_status = YY_BUFFER_NEW;
2531 base_yy_switch_to_buffer(b );
2536 /** Setup the input buffer state to scan a string. The next call to base_yylex() will
2537 * scan from a @e copy of @a str.
2538 * @param str a NUL-terminated string to scan
2540 * @return the newly allocated buffer state object.
2541 * @note If you want to scan bytes that may contain NUL values, then use
2542 * base_yy_scan_bytes() instead.
2544 YY_BUFFER_STATE base_yy_scan_string (yyconst char * yystr )
2547 return base_yy_scan_bytes(yystr,strlen(yystr) );
2550 /** Setup the input buffer state to scan the given bytes. The next call to base_yylex() will
2551 * scan from a @e copy of @a bytes.
2552 * @param bytes the byte buffer to scan
2553 * @param len the number of bytes in the buffer pointed to by @a bytes.
2555 * @return the newly allocated buffer state object.
2557 YY_BUFFER_STATE base_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
2564 /* Get memory for full buffer, including space for trailing EOB's. */
2565 n = _yybytes_len + 2;
2566 buf = (char *) base_yyalloc(n );
2568 YY_FATAL_ERROR( "out of dynamic memory in base_yy_scan_bytes()" );
2570 for ( i = 0; i < _yybytes_len; ++i )
2571 buf[i] = yybytes[i];
2573 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2575 b = base_yy_scan_buffer(buf,n );
2577 YY_FATAL_ERROR( "bad buffer in base_yy_scan_bytes()" );
2579 /* It's okay to grow etc. this buffer, and we should throw it
2580 * away when we're done.
2582 b->yy_is_our_buffer = 1;
2587 #ifndef YY_EXIT_FAILURE
2588 #define YY_EXIT_FAILURE 2
2591 static void yy_fatal_error (yyconst char* msg )
2593 (void) fprintf( stderr, "%s\n", msg );
2594 exit( YY_EXIT_FAILURE );
2597 /* Redefine yyless() so it works in section 3 code. */
2603 /* Undo effects of setting up base_yytext. */ \
2604 int yyless_macro_arg = (n); \
2605 YY_LESS_LINENO(yyless_macro_arg);\
2606 base_yytext[base_yyleng] = (yy_hold_char); \
2607 (yy_c_buf_p) = base_yytext + yyless_macro_arg; \
2608 (yy_hold_char) = *(yy_c_buf_p); \
2609 *(yy_c_buf_p) = '\0'; \
2610 base_yyleng = yyless_macro_arg; \
2614 /* Accessor methods (get/set functions) to struct members. */
2616 /** Get the current line number.
2619 int base_yyget_lineno (void)
2622 return base_yylineno;
2625 /** Get the input stream.
2628 FILE *base_yyget_in (void)
2633 /** Get the output stream.
2636 FILE *base_yyget_out (void)
2641 /** Get the length of the current token.
2644 int base_yyget_leng (void)
2649 /** Get the current token.
2653 char *base_yyget_text (void)
2658 /** Set the current line number.
2659 * @param line_number
2662 void base_yyset_lineno (int line_number )
2665 base_yylineno = line_number;
2668 /** Set the input stream. This does not discard the current
2670 * @param in_str A readable stream.
2672 * @see base_yy_switch_to_buffer
2674 void base_yyset_in (FILE * in_str )
2676 base_yyin = in_str ;
2679 void base_yyset_out (FILE * out_str )
2681 base_yyout = out_str ;
2684 int base_yyget_debug (void)
2686 return base_yy_flex_debug;
2689 void base_yyset_debug (int bdebug )
2691 base_yy_flex_debug = bdebug ;
2694 static int yy_init_globals (void)
2696 /* Initialization is the same as for the non-reentrant scanner.
2697 * This function is called from base_yylex_destroy(), so don't allocate here.
2700 (yy_buffer_stack) = 0;
2701 (yy_buffer_stack_top) = 0;
2702 (yy_buffer_stack_max) = 0;
2703 (yy_c_buf_p) = (char *) 0;
2707 /* Defined in main.c */
2710 base_yyout = stdout;
2712 base_yyin = (FILE *) 0;
2713 base_yyout = (FILE *) 0;
2716 /* For future reference: Set errno on error, since we are called by
2722 /* base_yylex_destroy is for both reentrant and non-reentrant scanners. */
2723 int base_yylex_destroy (void)
2726 /* Pop the buffer stack, destroying each element. */
2727 while(YY_CURRENT_BUFFER){
2728 base_yy_delete_buffer(YY_CURRENT_BUFFER );
2729 YY_CURRENT_BUFFER_LVALUE = NULL;
2730 base_yypop_buffer_state();
2733 /* Destroy the stack itself. */
2734 base_yyfree((yy_buffer_stack) );
2735 (yy_buffer_stack) = NULL;
2737 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2738 * base_yylex() is called, initialization will occur. */
2745 * Internal utility routines.
2749 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
2752 for ( i = 0; i < n; ++i )
2757 #ifdef YY_NEED_STRLEN
2758 static int yy_flex_strlen (yyconst char * s )
2761 for ( n = 0; s[n]; ++n )
2768 void *base_yyalloc (yy_size_t size )
2770 return (void *) malloc( size );
2773 void *base_yyrealloc (void * ptr, yy_size_t size )
2775 /* The cast to (char *) in the following accommodates both
2776 * implementations that use char* generic pointers, and those
2777 * that use void* generic pointers. It works with the latter
2778 * because both ANSI C and C++ allow castless assignment from
2779 * any pointer type to void*, and deal with argument conversions
2780 * as though doing an assignment.
2782 return (void *) realloc( (char *) ptr, size );
2785 void base_yyfree (void * ptr )
2787 free( (char *) ptr ); /* see base_yyrealloc() for (char *) cast */
2790 #define YYTABLES_NAME "yytables"
2798 * Report a lexical-analysis-time cursor position, if possible.
2800 * This is expected to be used within an ereport() call. The return value
2801 * is a dummy (always 0, in fact).
2803 * Note that this can only be used for messages from the lexer itself,
2804 * since it depends on scanbuf to still be valid.
2808 lexer_errposition(void)
2812 /* Convert byte offset to character number */
2813 pos = pg_mbstrlen_with_len(scanbuf, yylloc) + 1;
2814 /* And pass it to the ereport mechanism */
2815 return errposition(pos);
2821 * Report a lexer or grammar error.
2823 * The message's cursor position identifies the most recently lexed token.
2824 * This is OK for syntax error messages from the Bison parser, because Bison
2825 * parsers report error as soon as the first unparsable token is reached.
2826 * Beware of using yyerror for other purposes, as the cursor position might
2830 yyerror(const char *message)
2832 longjmp(jmpbuffer, 1);
2837 * Called before any actual parsing is done
2840 scanner_init(const char *str)
2842 int slen = strlen(str);
2845 * Might be left over after ereport()
2847 if (YY_CURRENT_BUFFER)
2848 base_yy_delete_buffer(YY_CURRENT_BUFFER);
2851 * Make a scan buffer with special termination needed by flex.
2853 scanbuf = palloc(slen + 2);
2854 memcpy(scanbuf, str, slen);
2855 scanbuf[slen] = scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR;
2856 scanbufhandle = base_yy_scan_buffer(scanbuf,slen + 2);
2858 /* initialize literal buffer to a reasonable but expansible size */
2859 literalalloc = 1024;
2860 literalbuf = (char *) palloc(literalalloc);
2868 * Called after parsing is done to clean up after scanner_init()
2871 scanner_finish(void)
2873 base_yy_delete_buffer(scanbufhandle);
2879 addlit(char *ytext, int yleng)
2881 /* enlarge buffer if needed */
2882 if ((literallen+yleng) >= literalalloc)
2886 } while ((literallen+yleng) >= literalalloc);
2887 literalbuf = (char *) repalloc(literalbuf, literalalloc);
2889 /* append new data, add trailing null */
2890 memcpy(literalbuf+literallen, ytext, yleng);
2891 literallen += yleng;
2892 literalbuf[literallen] = '\0';
2897 addlitchar(unsigned char ychar)
2899 /* enlarge buffer if needed */
2900 if ((literallen+1) >= literalalloc)
2903 literalbuf = (char *) repalloc(literalbuf, literalalloc);
2905 /* append new data, add trailing null */
2906 literalbuf[literallen] = ychar;
2908 literalbuf[literallen] = '\0';
2913 * One might be tempted to write pstrdup(literalbuf) instead of this,
2914 * but for long literals this is much faster because the length is
2922 new = palloc(literallen + 1);
2923 memcpy(new, literalbuf, literallen+1);
2928 static unsigned char
2929 unescape_single_char(unsigned char c)
2931 /* Normally we wouldn't expect to see \n where n has its high bit set
2932 * but we set the flag to check the string if we do get it, so
2933 * that this doesn't become a way of getting around the coding validity
2936 if (IS_HIGHBIT_SET(c))
2937 saw_high_bit = true;
2957 check_string_escape_warning(unsigned char ychar)
2962 if (warn_on_first_escape && escape_string_warning)
2964 (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
2965 errmsg("nonstandard use of \\' in a string literal"),
2966 errhint("Use '' to write quotes in strings, or use the escape string syntax (E'...')."),
2967 lexer_errposition()));
2968 warn_on_first_escape = false; /* warn only once per string */
2970 else if (ychar == '\\')
2972 if (warn_on_first_escape && escape_string_warning)
2974 (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
2975 errmsg("nonstandard use of \\\\ in a string literal"),
2976 errhint("Use the escape string syntax for backslashes, e.g., E'\\\\'."),
2977 lexer_errposition()));
2978 warn_on_first_escape = false; /* warn only once per string */
2981 check_escape_warning();
2986 check_escape_warning(void)
2989 if (warn_on_first_escape && escape_string_warning)
2991 (errcode(ERRCODE_NONSTANDARD_USE_OF_ESCAPE_CHARACTER),
2992 errmsg("nonstandard use of escape in a string literal"),
2993 errhint("Use the escape string syntax for escapes, e.g., E'\\r\\n'."),
2994 lexer_errposition()));
2995 warn_on_first_escape = false; /* warn only once per string */
3000 * downcase_truncate_identifier() --- do appropriate downcasing and
3001 * truncation of an unquoted identifier. Optionally warn of truncation.
3003 * Returns a palloc'd string containing the adjusted identifier.
3005 * Note: in some usages the passed string is not null-terminated.
3007 * Note: the API of this function is designed to allow for downcasing
3008 * transformations that increase the string length, but we don't yet
3009 * support that. If you want to implement it, you'll need to fix
3010 * SplitIdentifierString() in utils/adt/varlena.c.
3013 downcase_truncate_identifier(const char *ident, int len, int warn)
3018 result = palloc(len + 1);
3021 * SQL99 specifies Unicode-aware case normalization, which we don't yet
3022 * have the infrastructure for. Instead we use tolower() to provide a
3023 * locale-aware translation. However, there are some locales where this
3024 * is not right either (eg, Turkish may do strange things with 'i' and
3025 * 'I'). Our current compromise is to use tolower() for characters with
3026 * the high bit set, and use an ASCII-only downcasing for 7-bit
3029 for (i = 0; i < len; i++)
3031 unsigned char ch = (unsigned char) ident[i];
3033 if (ch >= 'A' && ch <= 'Z')
3035 else if (ch >= 0x80 && isupper(ch))
3037 result[i] = (char) ch;
3041 if (i >= NAMEDATALEN)
3042 truncate_identifier(result, i, warn);
3048 * truncate_identifier() --- truncate an identifier to NAMEDATALEN-1 bytes.
3050 * The given string is modified in-place, if necessary. A warning is
3051 * issued if requested.
3053 * We require the caller to pass in the string length since this saves a
3054 * strlen() call in some common usages.
3057 truncate_identifier(char *ident, int len, int warn)
3059 if (len >= NAMEDATALEN)
3061 len = strlen(ident); /*pg_mbcliplen(ident, len, NAMEDATALEN - 1);*/
3065 (errcode(ERRCODE_NAME_TOO_LONG),
3066 errmsg("identifier \"%s\" will be truncated to \"%.*s\"",
3067 ident, len, ident)));