]> git.8kb.co.uk Git - pgpool-ii/pgpool-ii_2.2.5/blob - parser/scan.c
Attempt to send a proper failure message to frontend when authentication
[pgpool-ii/pgpool-ii_2.2.5] / parser / scan.c
1 #line 2 "scan.c"
2
3 #line 4 "scan.c"
4
5 #define  YY_INT_ALIGNED short int
6
7 /* A lexical scanner generated by flex */
8
9 #define FLEX_SCANNER
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
14 #define FLEX_BETA
15 #endif
16
17 /* First, we deal with  platform-specific or compiler-specific issues. */
18
19 /* begin standard C headers. */
20 #include <stdio.h>
21 #include <string.h>
22 #include <errno.h>
23 #include <stdlib.h>
24
25 /* end standard C headers. */
26
27 /* flex integer type definitions */
28
29 #ifndef FLEXINT_H
30 #define FLEXINT_H
31
32 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
33
34 #if __STDC_VERSION__ >= 199901L
35
36 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
37  * if you want the limit (max/min) macros for int types. 
38  */
39 #ifndef __STDC_LIMIT_MACROS
40 #define __STDC_LIMIT_MACROS 1
41 #endif
42
43 #include <inttypes.h>
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;
50 #else
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;
57 #endif /* ! C99 */
58
59 /* Limits of integral types. */
60 #ifndef INT8_MIN
61 #define INT8_MIN               (-128)
62 #endif
63 #ifndef INT16_MIN
64 #define INT16_MIN              (-32767-1)
65 #endif
66 #ifndef INT32_MIN
67 #define INT32_MIN              (-2147483647-1)
68 #endif
69 #ifndef INT8_MAX
70 #define INT8_MAX               (127)
71 #endif
72 #ifndef INT16_MAX
73 #define INT16_MAX              (32767)
74 #endif
75 #ifndef INT32_MAX
76 #define INT32_MAX              (2147483647)
77 #endif
78 #ifndef UINT8_MAX
79 #define UINT8_MAX              (255U)
80 #endif
81 #ifndef UINT16_MAX
82 #define UINT16_MAX             (65535U)
83 #endif
84 #ifndef UINT32_MAX
85 #define UINT32_MAX             (4294967295U)
86 #endif
87
88 #endif /* ! FLEXINT_H */
89
90 #ifdef __cplusplus
91
92 /* The "const" storage-class-modifier is valid. */
93 #define YY_USE_CONST
94
95 #else   /* ! __cplusplus */
96
97 #if __STDC__
98
99 #define YY_USE_CONST
100
101 #endif  /* __STDC__ */
102 #endif  /* ! __cplusplus */
103
104 #ifdef YY_USE_CONST
105 #define yyconst const
106 #else
107 #define yyconst
108 #endif
109
110 /* Returned upon end-of-file. */
111 #define YY_NULL 0
112
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
116  * double cast.
117  */
118 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
119
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.
123  */
124 #define BEGIN (yy_start) = 1 + 2 *
125
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
128  * compatibility.
129  */
130 #define YY_START (((yy_start) - 1) / 2)
131 #define YYSTATE YY_START
132
133 /* Action number for EOF rule of a given start state. */
134 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
135
136 /* Special action meaning "start processing a new file". */
137 #define YY_NEW_FILE base_yyrestart(base_yyin  )
138
139 #define YY_END_OF_BUFFER_CHAR 0
140
141 /* Size of default input buffer. */
142 #ifndef YY_BUF_SIZE
143 #define YY_BUF_SIZE 16384
144 #endif
145
146 /* The state buf must be large enough to hold one state per character in the main buffer.
147  */
148 #define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
149
150 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
151 #define YY_TYPEDEF_YY_BUFFER_STATE
152 typedef struct yy_buffer_state *YY_BUFFER_STATE;
153 #endif
154
155 extern int base_yyleng;
156
157 extern FILE *base_yyin, *base_yyout;
158
159 #define EOB_ACT_CONTINUE_SCAN 0
160 #define EOB_ACT_END_OF_FILE 1
161 #define EOB_ACT_LAST_MATCH 2
162
163     #define YY_LESS_LINENO(n)
164     
165 /* Return all but the first "n" matched characters back to the input stream. */
166 #define yyless(n) \
167         do \
168                 { \
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 */ \
176                 } \
177         while ( 0 )
178
179 #define unput(c) yyunput( c, (yytext_ptr)  )
180
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).
184  */
185
186 #ifndef YY_TYPEDEF_YY_SIZE_T
187 #define YY_TYPEDEF_YY_SIZE_T
188 typedef unsigned int yy_size_t;
189 #endif
190
191 #ifndef YY_STRUCT_YY_BUFFER_STATE
192 #define YY_STRUCT_YY_BUFFER_STATE
193 struct yy_buffer_state
194         {
195         FILE *yy_input_file;
196
197         char *yy_ch_buf;                /* input buffer */
198         char *yy_buf_pos;               /* current position in input buffer */
199
200         /* Size of input buffer in bytes, not including room for EOB
201          * characters.
202          */
203         yy_size_t yy_buf_size;
204
205         /* Number of characters read into yy_ch_buf, not including EOB
206          * characters.
207          */
208         int yy_n_chars;
209
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
212          * delete it.
213          */
214         int yy_is_our_buffer;
215
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
219          * each newline.
220          */
221         int yy_is_interactive;
222
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
225          * not.
226          */
227         int yy_at_bol;
228
229     int yy_bs_lineno; /**< The line count. */
230     int yy_bs_column; /**< The column count. */
231     
232         /* Whether to try to fill the input buffer when we reach the
233          * end of it.
234          */
235         int yy_fill_buffer;
236
237         int yy_buffer_status;
238
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.
246          *
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.
250          */
251 #define YY_BUFFER_EOF_PENDING 2
252
253         };
254 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
255
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. */
260
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
263  * "scanner state".
264  *
265  * Returns the top of the stack, or NULL.
266  */
267 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
268                           ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
269                           : NULL)
270
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.
273  */
274 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
275
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 */
279 int base_yyleng;
280
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 */
285
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 ...
288  */
289 static int yy_did_buffer_switch_on_eof;
290
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 );
298
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  );
302
303 #define YY_FLUSH_BUFFER base_yy_flush_buffer(YY_CURRENT_BUFFER )
304
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  );
308
309 void *base_yyalloc (yy_size_t  );
310 void *base_yyrealloc (void *,yy_size_t  );
311 void base_yyfree (void *  );
312
313 #define yy_new_buffer base_yy_create_buffer
314
315 #define yy_set_interactive(is_interactive) \
316         { \
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 ); \
321         } \
322         YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
323         }
324
325 #define yy_set_bol(at_bol) \
326         { \
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 ); \
331         } \
332         YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
333         }
334
335 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
336
337 /* Begin user sect3 */
338
339 #define base_yywrap(n) 1
340 #define YY_SKIP_YYWRAP
341
342 typedef unsigned char YY_CHAR;
343
344 FILE *base_yyin = (FILE *) 0, *base_yyout = (FILE *) 0;
345
346 typedef int yy_state_type;
347
348 extern int base_yylineno;
349
350 int base_yylineno = 1;
351
352 extern char *base_yytext;
353 #define yytext_ptr base_yytext
354
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[]  );
359
360 /* Done after the current pattern has been matched and before the
361  * corresponding action - sets up base_yytext.
362  */
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; \
367         *yy_cp = '\0'; \
368         (yy_c_buf_p) = yy_cp;
369
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. */
374 struct yy_trans_info
375         {
376         flex_int32_t yy_verify;
377         flex_int32_t yy_nxt;
378         };
379 static yyconst flex_int16_t yy_accept[155] =
380     {   0,
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,
391
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,
397         9,   16,   21,    0
398     } ;
399
400 static yyconst flex_int32_t yy_ec[256] =
401     {   0,
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,
412
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,
423
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,
429        22,   22,   22,   22,   22
430     } ;
431
432 static yyconst flex_int32_t yy_meta[27] =
433     {   0,
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
437     } ;
438
439 static yyconst flex_int16_t yy_base[190] =
440     {   0,
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,
451
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
461     } ;
462
463 static yyconst flex_int16_t yy_def[190] =
464     {   0,
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,
475
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
485     } ;
486
487 static yyconst flex_int16_t yy_nxt[894] =
488     {   0,
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,
499
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,
510
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,
521
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,
532
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,
543
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,
554
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,
565
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,
576
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,
586       154,  154,  154
587
588     } ;
589
590 static yyconst flex_int16_t yy_chk[894] =
591     {   0,
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,
602
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,
613
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,
624
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,
635
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,
646
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,
657
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,
668
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,
679
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,
689       154,  154,  154
690
691     } ;
692
693 static yy_state_type yy_last_accepting_state;
694 static char *yy_last_accepting_cpos;
695
696 extern int base_yy_flex_debug;
697 int base_yy_flex_debug = 0;
698
699 /* The intent behind this definition is that it'll catch
700  * any uses of REJECT which flex missed.
701  */
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
706 char *base_yytext;
707 #line 1 "scan.l"
708 #line 2 "scan.l"
709 /*-------------------------------------------------------------------------
710  *
711  * scan.l
712  *        lexical scanner for PostgreSQL
713  *
714  * NOTE NOTE NOTE:
715  *
716  * The rules in this file must be kept in sync with psql's lexer!!!
717  *
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.
728  *
729  *
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
733  *
734  * IDENTIFICATION
735  *        $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.141 2007/09/12 20:49:27 adunstan Exp $
736  *
737  *-------------------------------------------------------------------------
738  */
739 #include "pool_parser.h"
740
741 #include <ctype.h>
742 #include <unistd.h>
743 #include <errno.h>
744 #include <string.h>
745 #include <setjmp.h>
746
747 #ifndef ereport
748 #define ereport(a,b) yyerror("")
749 #endif
750 #define IS_HIGHBIT_SET(c) 0
751
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" */
756 #include "gram.h"
757 #include "scansup.h"
758
759 #include "pool_memory.h"
760
761
762 /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
763 /*
764 #undef fprintf
765 #define fprintf(file, fmt, msg)  ereport(ERROR, (errmsg_internal("%s", msg)))
766 */
767
768 static int              xcdepth = 0;    /* depth of nesting in slash-star comments */
769 static char    *dolqstart;      /* current $foo$ quote start string */
770
771 /*
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.
777  */
778 typedef enum
779 {
780         BACKSLASH_QUOTE_OFF,
781         BACKSLASH_QUOTE_ON,
782         BACKSLASH_QUOTE_SAFE_ENCODING
783 } BackslashQuoteType;
784
785 BackslashQuoteType backslash_quote = BACKSLASH_QUOTE_SAFE_ENCODING;
786 int                     escape_string_warning = true;
787 int                     standard_conforming_strings = false;
788
789 static bool             warn_on_first_escape;
790 static bool     saw_high_bit = false;
791
792 /*
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.
797  */
798 static char        *literalbuf;         /* expandable buffer */
799 static int              literallen;             /* actual current length */
800 static int              literalalloc;   /* current allocated buffer size */
801
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);
806
807 #if 0
808 static int      lexer_errposition(void);
809 #endif
810 static void check_escape_warning(void);
811 static void check_string_escape_warning(unsigned char ychar);
812
813 extern char *base_yytext;
814
815 /*
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.
821  */
822 #define SET_YYLLOC()  (yylloc = base_yytext - scanbuf)
823
824 /* Handles to the buffer that the lexer uses internally */
825 static YY_BUFFER_STATE scanbufhandle;
826 static char *scanbuf;
827
828 static unsigned char unescape_single_char(unsigned char c);
829 void yyerror(const char *s);
830
831 /*
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.
838  *
839  * We use exclusive states for quoted strings, extended comments,
840  * and to eliminate parsing troubles for numeric strings.
841  * Exclusive states:
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
849  */
850
851
852
853
854
855
856
857 /*
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.
863  *
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.
868  *
869  * XXX perhaps \f (formfeed) should be treated as a newline as well?
870  *
871  * XXX if you change the set of whitespace characters, fix scanner_isspace()
872  * to agree, and see also the plpgsql lexer.
873  */
874 /*
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...
879  */
880 /*
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.
888  */
889 /* Bit string
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.
897  */
898 /* Hexadecimal number */
899 /* National character */
900 /* Quoted string that allows backslash escapes */
901 /* Extended quote
902  * xqdouble implements embedded quote, ''''
903  */
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.
909  *
910  * {dolqfailed} is an error rule to avoid scanner backup when {dolqdelim}
911  * fails to match its trailing "$".
912  */
913 /* Double quote
914  * Allows embedded spaces and other special characters into identifiers.
915  */
916 /* C-style comments
917  *
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
931  *    problem.
932  * Dash-dash comments have similar interactions with the operator rule.
933  */
934 /*
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.
940  *
941  * If you change either set, adjust the character lists appearing in the
942  * rule for "operator"!
943  */
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
947  *
948  * {realfail1} and {realfail2} are added to prevent the need for scanner
949  * backup when the {real} rule fails to match completely.
950  */
951 /*
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
954  *  and newline.
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.
962  */
963 #line 964 "scan.c"
964
965 #define INITIAL 0
966 #define xb 1
967 #define xc 2
968 #define xd 3
969 #define xh 4
970 #define xe 5
971 #define xq 6
972 #define xdolq 7
973
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.
978  */
979 #include <unistd.h>
980 #endif
981
982 #ifndef YY_EXTRA_TYPE
983 #define YY_EXTRA_TYPE void *
984 #endif
985
986 static int yy_init_globals (void );
987
988 /* Macros after this point can all be overridden by user definitions in
989  * section 1.
990  */
991
992 #ifndef YY_SKIP_YYWRAP
993 #ifdef __cplusplus
994 extern "C" int base_yywrap (void );
995 #else
996 extern int base_yywrap (void );
997 #endif
998 #endif
999
1000 #ifndef yytext_ptr
1001 static void yy_flex_strncpy (char *,yyconst char *,int );
1002 #endif
1003
1004 #ifdef YY_NEED_STRLEN
1005 static int yy_flex_strlen (yyconst char * );
1006 #endif
1007
1008 #ifndef YY_NO_INPUT
1009
1010 #ifdef __cplusplus
1011 static int yyinput (void );
1012 #else
1013 static int input (void );
1014 #endif
1015
1016 #endif
1017
1018 /* Amount of stuff to slurp up with each read. */
1019 #ifndef YY_READ_BUF_SIZE
1020 #define YY_READ_BUF_SIZE 8192
1021 #endif
1022
1023 /* Copy whatever the last rule matched to the standard output. */
1024 #ifndef ECHO
1025 /* This used to be an fputs(), but since the string might contain NUL's,
1026  * we now use fwrite().
1027  */
1028 #define ECHO (void) fwrite( base_yytext, base_yyleng, 1, base_yyout )
1029 #endif
1030
1031 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
1032  * is returned in "result".
1033  */
1034 #ifndef YY_INPUT
1035 #define YY_INPUT(buf,result,max_size) \
1036         if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
1037                 { \
1038                 int c = '*'; \
1039                 size_t n; \
1040                 for ( n = 0; n < max_size && \
1041                              (c = getc( base_yyin )) != EOF && c != '\n'; ++n ) \
1042                         buf[n] = (char) c; \
1043                 if ( c == '\n' ) \
1044                         buf[n++] = (char) c; \
1045                 if ( c == EOF && ferror( base_yyin ) ) \
1046                         YY_FATAL_ERROR( "input in flex scanner failed" ); \
1047                 result = n; \
1048                 } \
1049         else \
1050                 { \
1051                 errno=0; \
1052                 while ( (result = fread(buf, 1, max_size, base_yyin))==0 && ferror(base_yyin)) \
1053                         { \
1054                         if( errno != EINTR) \
1055                                 { \
1056                                 YY_FATAL_ERROR( "input in flex scanner failed" ); \
1057                                 break; \
1058                                 } \
1059                         errno=0; \
1060                         clearerr(base_yyin); \
1061                         } \
1062                 }\
1063 \
1064
1065 #endif
1066
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.
1070  */
1071 #ifndef yyterminate
1072 #define yyterminate() return YY_NULL
1073 #endif
1074
1075 /* Number of entries by which start-condition stack grows. */
1076 #ifndef YY_START_STACK_INCR
1077 #define YY_START_STACK_INCR 25
1078 #endif
1079
1080 /* Report a fatal error. */
1081 #ifndef YY_FATAL_ERROR
1082 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
1083 #endif
1084
1085 /* end tables serialization structures and prototypes */
1086
1087 /* Default declaration of generated scanner - a define so the user can
1088  * easily add parameters.
1089  */
1090 #ifndef YY_DECL
1091 #define YY_DECL_IS_OURS 1
1092
1093 extern int base_yylex (void);
1094
1095 #define YY_DECL int base_yylex (void)
1096 #endif /* !YY_DECL */
1097
1098 /* Code executed at the beginning of each rule, after base_yytext and base_yyleng
1099  * have been set up.
1100  */
1101 #ifndef YY_USER_ACTION
1102 #define YY_USER_ACTION
1103 #endif
1104
1105 /* Code executed at the end of each rule. */
1106 #ifndef YY_BREAK
1107 #define YY_BREAK break;
1108 #endif
1109
1110 #define YY_RULE_SETUP \
1111         YY_USER_ACTION
1112
1113 /** The main scanner function which does all the work.
1114  */
1115 YY_DECL
1116 {
1117         register yy_state_type yy_current_state;
1118         register char *yy_cp, *yy_bp;
1119         register int yy_act;
1120     
1121 #line 345 "scan.l"
1122
1123
1124 #line 1125 "scan.c"
1125
1126         if ( !(yy_init) )
1127                 {
1128                 (yy_init) = 1;
1129
1130 #ifdef YY_USER_INIT
1131                 YY_USER_INIT;
1132 #endif
1133
1134                 if ( ! (yy_start) )
1135                         (yy_start) = 1; /* first start state */
1136
1137                 if ( ! base_yyin )
1138                         base_yyin = stdin;
1139
1140                 if ( ! base_yyout )
1141                         base_yyout = stdout;
1142
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 );
1147                 }
1148
1149                 base_yy_load_buffer_state( );
1150                 }
1151
1152         while ( 1 )             /* loops until end-of-file is reached */
1153                 {
1154                 yy_cp = (yy_c_buf_p);
1155
1156                 /* Support of base_yytext. */
1157                 *yy_cp = (yy_hold_char);
1158
1159                 /* yy_bp points to the position in yy_ch_buf of the start of
1160                  * the current run.
1161                  */
1162                 yy_bp = yy_cp;
1163
1164                 yy_current_state = (yy_start);
1165 yy_match:
1166                 do
1167                         {
1168                         register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
1169                         if ( yy_accept[yy_current_state] )
1170                                 {
1171                                 (yy_last_accepting_state) = yy_current_state;
1172                                 (yy_last_accepting_cpos) = yy_cp;
1173                                 }
1174                         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1175                                 {
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];
1179                                 }
1180                         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1181                         ++yy_cp;
1182                         }
1183                 while ( yy_current_state != 154 );
1184                 yy_cp = (yy_last_accepting_cpos);
1185                 yy_current_state = (yy_last_accepting_state);
1186
1187 yy_find_action:
1188                 yy_act = yy_accept[yy_current_state];
1189
1190                 YY_DO_BEFORE_ACTION;
1191
1192 do_action:      /* This label is used only to access EOF actions. */
1193
1194                 switch ( yy_act )
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;
1202
1203 case 1:
1204 /* rule 1 can match eol */
1205 YY_RULE_SETUP
1206 #line 347 "scan.l"
1207 {
1208                                         /* ignore */
1209                                 }
1210         YY_BREAK
1211 case 2:
1212 YY_RULE_SETUP
1213 #line 351 "scan.l"
1214 {
1215                                         /* Set location in case of syntax error in comment */
1216                                         SET_YYLLOC();
1217                                         xcdepth = 0;
1218                                         BEGIN(xc);
1219                                         /* Put back any characters past slash-star; see above */
1220                                         yyless(2);
1221                                 }
1222         YY_BREAK
1223 case 3:
1224 YY_RULE_SETUP
1225 #line 360 "scan.l"
1226 {
1227                                         xcdepth++;
1228                                         /* Put back any characters past slash-star; see above */
1229                                         yyless(2);
1230                                 }
1231         YY_BREAK
1232 case 4:
1233 YY_RULE_SETUP
1234 #line 366 "scan.l"
1235 {
1236                                         if (xcdepth <= 0)
1237                                                 BEGIN(INITIAL);
1238                                         else
1239                                                 xcdepth--;
1240                                 }
1241         YY_BREAK
1242 case 5:
1243 /* rule 5 can match eol */
1244 YY_RULE_SETUP
1245 #line 373 "scan.l"
1246 {
1247                                         /* ignore */
1248                                 }
1249         YY_BREAK
1250 case 6:
1251 YY_RULE_SETUP
1252 #line 377 "scan.l"
1253 {
1254                                         /* ignore */
1255                                 }
1256         YY_BREAK
1257 case 7:
1258 YY_RULE_SETUP
1259 #line 381 "scan.l"
1260 {
1261                                         /* ignore */
1262                                 }
1263         YY_BREAK
1264 case YY_STATE_EOF(xc):
1265 #line 385 "scan.l"
1266 { yyerror("unterminated /* comment"); }
1267         YY_BREAK
1268 case 8:
1269 YY_RULE_SETUP
1270 #line 387 "scan.l"
1271 {
1272                                         /* Binary bit type.
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.
1277                                          */
1278                                         SET_YYLLOC();
1279                                         BEGIN(xb);
1280                                         startlit();
1281                                         addlitchar('b');
1282                                 }
1283         YY_BREAK
1284 case 9:
1285 /* rule 9 can match eol */
1286 #line 400 "scan.l"
1287 case 10:
1288 /* rule 10 can match eol */
1289 YY_RULE_SETUP
1290 #line 400 "scan.l"
1291 {
1292                                         yyless(1);
1293                                         BEGIN(INITIAL);
1294                                         yylval.str = litbufdup();
1295                                         return BCONST;
1296                                 }
1297         YY_BREAK
1298 case 11:
1299 /* rule 11 can match eol */
1300 #line 407 "scan.l"
1301 case 12:
1302 /* rule 12 can match eol */
1303 YY_RULE_SETUP
1304 #line 407 "scan.l"
1305 {
1306                                         addlit(base_yytext, base_yyleng);
1307                                 }
1308         YY_BREAK
1309 case 13:
1310 /* rule 13 can match eol */
1311 #line 411 "scan.l"
1312 case 14:
1313 /* rule 14 can match eol */
1314 YY_RULE_SETUP
1315 #line 411 "scan.l"
1316 {
1317                                         /* ignore */
1318                                 }
1319         YY_BREAK
1320 case YY_STATE_EOF(xb):
1321 #line 414 "scan.l"
1322 { yyerror("unterminated bit string literal"); }
1323         YY_BREAK
1324 case 15:
1325 YY_RULE_SETUP
1326 #line 416 "scan.l"
1327 {
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.
1333                                          */
1334                                         SET_YYLLOC();
1335                                         BEGIN(xh);
1336                                         startlit();
1337                                         addlitchar('x');
1338                                 }
1339         YY_BREAK
1340 case 16:
1341 /* rule 16 can match eol */
1342 #line 429 "scan.l"
1343 case 17:
1344 /* rule 17 can match eol */
1345 YY_RULE_SETUP
1346 #line 429 "scan.l"
1347 {
1348                                         yyless(1);
1349                                         BEGIN(INITIAL);
1350                                         yylval.str = litbufdup();
1351                                         return XCONST;
1352                                 }
1353         YY_BREAK
1354 case YY_STATE_EOF(xh):
1355 #line 435 "scan.l"
1356 { yyerror("unterminated hexadecimal string literal"); }
1357         YY_BREAK
1358 case 18:
1359 YY_RULE_SETUP
1360 #line 437 "scan.l"
1361 {
1362                                         /* National character.
1363                                          * We will pass this along as a normal character string,
1364                                          * but preceded with an internally-generated "NCHAR".
1365                                          */
1366                                         const ScanKeyword *keyword;
1367
1368                                         SET_YYLLOC();
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;
1374                                 }
1375         YY_BREAK
1376 case 19:
1377 YY_RULE_SETUP
1378 #line 452 "scan.l"
1379 {
1380                                         warn_on_first_escape = true;
1381                                         saw_high_bit = false;
1382                                         SET_YYLLOC();
1383                                         if (standard_conforming_strings)
1384                                                 BEGIN(xq);
1385                                         else
1386                                                 BEGIN(xe);
1387                                         startlit();
1388                                 }
1389         YY_BREAK
1390 case 20:
1391 YY_RULE_SETUP
1392 #line 462 "scan.l"
1393 {
1394                                         warn_on_first_escape = false;
1395                                         saw_high_bit = false;
1396                                         SET_YYLLOC();
1397                                         BEGIN(xe);
1398                                         startlit();
1399                                 }
1400         YY_BREAK
1401 case 21:
1402 /* rule 21 can match eol */
1403 #line 470 "scan.l"
1404 case 22:
1405 /* rule 22 can match eol */
1406 YY_RULE_SETUP
1407 #line 470 "scan.l"
1408 {
1409                                         yyless(1);
1410                                         BEGIN(INITIAL);
1411                                         /* check that the data remains valid if it might have been
1412                                          * made invalid by unescaping any chars.
1413                                          */
1414                                         if (saw_high_bit);
1415 /*                                              pg_verifymbstr(literalbuf, literallen, false);*/
1416                                         yylval.str = litbufdup();
1417                                         return SCONST;
1418                                 }
1419         YY_BREAK
1420 case 23:
1421 YY_RULE_SETUP
1422 #line 481 "scan.l"
1423 {
1424                                         addlitchar('\'');
1425                                 }
1426         YY_BREAK
1427 case 24:
1428 /* rule 24 can match eol */
1429 YY_RULE_SETUP
1430 #line 484 "scan.l"
1431 {
1432                                         addlit(base_yytext, base_yyleng);
1433                                 }
1434         YY_BREAK
1435 case 25:
1436 /* rule 25 can match eol */
1437 YY_RULE_SETUP
1438 #line 487 "scan.l"
1439 {
1440                                         addlit(base_yytext, base_yyleng);
1441                                 }
1442         YY_BREAK
1443 case 26:
1444 /* rule 26 can match eol */
1445 YY_RULE_SETUP
1446 #line 490 "scan.l"
1447 {
1448                                         if (base_yytext[1] == '\'')
1449                                         {
1450 #if 0
1451                                                 if (backslash_quote == BACKSLASH_QUOTE_OFF ||
1452                                                         (backslash_quote == BACKSLASH_QUOTE_SAFE_ENCODING &&
1453                                                          PG_ENCODING_IS_CLIENT_ONLY(pg_get_client_encoding())))
1454                                                         ereport(ERROR,
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()));
1459 #endif
1460                                         }
1461                                         check_string_escape_warning(base_yytext[1]);
1462                                         addlitchar(unescape_single_char(base_yytext[1]));
1463                                 }
1464         YY_BREAK
1465 case 27:
1466 YY_RULE_SETUP
1467 #line 507 "scan.l"
1468 {
1469                                         unsigned char c = strtoul(base_yytext+1, NULL, 8);
1470
1471                                         check_escape_warning();
1472                                         addlitchar(c);
1473                                         if (IS_HIGHBIT_SET(c))
1474                                                 saw_high_bit = true;
1475                                 }
1476         YY_BREAK
1477 case 28:
1478 YY_RULE_SETUP
1479 #line 515 "scan.l"
1480 {
1481                                         unsigned char c = strtoul(base_yytext+2, NULL, 16);
1482
1483                                         check_escape_warning();
1484                                         addlitchar(c);
1485                                         if (IS_HIGHBIT_SET(c))
1486                                                 saw_high_bit = true;
1487                                 }
1488         YY_BREAK
1489 case 29:
1490 /* rule 29 can match eol */
1491 YY_RULE_SETUP
1492 #line 523 "scan.l"
1493 {
1494                                         /* ignore */
1495                                 }
1496         YY_BREAK
1497 case 30:
1498 YY_RULE_SETUP
1499 #line 526 "scan.l"
1500 {
1501                                         /* This is only needed for \ just before EOF */
1502                                         addlitchar(base_yytext[0]);
1503                                 }
1504         YY_BREAK
1505 case YY_STATE_EOF(xq):
1506 case YY_STATE_EOF(xe):
1507 #line 530 "scan.l"
1508 { yyerror("unterminated quoted string"); }
1509         YY_BREAK
1510 case 31:
1511 YY_RULE_SETUP
1512 #line 532 "scan.l"
1513 {
1514                                         SET_YYLLOC();
1515                                         dolqstart = pstrdup(base_yytext);
1516                                         BEGIN(xdolq);
1517                                         startlit();
1518                                 }
1519         YY_BREAK
1520 case 32:
1521 YY_RULE_SETUP
1522 #line 538 "scan.l"
1523 {
1524                                         /* throw back all but the initial "$" */
1525                                         yyless(1);
1526                                         /* and treat it as {other} */
1527                                         return base_yytext[0];
1528                                 }
1529         YY_BREAK
1530 case 33:
1531 YY_RULE_SETUP
1532 #line 544 "scan.l"
1533 {
1534                                         if (strcmp(base_yytext, dolqstart) == 0)
1535                                         {
1536                                                 pfree(dolqstart);
1537                                                 BEGIN(INITIAL);
1538                                                 yylval.str = litbufdup();
1539                                                 return SCONST;
1540                                         }
1541                                         else
1542                                         {
1543                                                 /*
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$
1547                                                  */
1548                                                 addlit(base_yytext, base_yyleng-1);
1549                                                 yyless(base_yyleng-1);
1550                                         }
1551                                 }
1552         YY_BREAK
1553 case 34:
1554 /* rule 34 can match eol */
1555 YY_RULE_SETUP
1556 #line 563 "scan.l"
1557 {
1558                                         addlit(base_yytext, base_yyleng);
1559                                 }
1560         YY_BREAK
1561 case 35:
1562 YY_RULE_SETUP
1563 #line 566 "scan.l"
1564 {
1565                                         addlit(base_yytext, base_yyleng);
1566                                 }
1567         YY_BREAK
1568 case 36:
1569 YY_RULE_SETUP
1570 #line 569 "scan.l"
1571 {
1572                                         /* This is only needed for $ inside the quoted text */
1573                                         addlitchar(base_yytext[0]);
1574                                 }
1575         YY_BREAK
1576 case YY_STATE_EOF(xdolq):
1577 #line 573 "scan.l"
1578 { yyerror("unterminated dollar-quoted string"); }
1579         YY_BREAK
1580 case 37:
1581 YY_RULE_SETUP
1582 #line 575 "scan.l"
1583 {
1584                                         SET_YYLLOC();
1585                                         BEGIN(xd);
1586                                         startlit();
1587                                 }
1588         YY_BREAK
1589 case 38:
1590 YY_RULE_SETUP
1591 #line 580 "scan.l"
1592 {
1593                                         char               *ident;
1594
1595                                         BEGIN(INITIAL);
1596                                         if (literallen == 0)
1597                                                 yyerror("zero-length delimited identifier");
1598                                         ident = litbufdup();
1599                                         if (literallen >= NAMEDATALEN)
1600                                                 truncate_identifier(ident, literallen, true);
1601                                         yylval.str = ident;
1602                                         return IDENT;
1603                                 }
1604         YY_BREAK
1605 case 39:
1606 YY_RULE_SETUP
1607 #line 592 "scan.l"
1608 {
1609                                         addlitchar('"');
1610                                 }
1611         YY_BREAK
1612 case 40:
1613 /* rule 40 can match eol */
1614 YY_RULE_SETUP
1615 #line 595 "scan.l"
1616 {
1617                                         addlit(base_yytext, base_yyleng);
1618                                 }
1619         YY_BREAK
1620 case YY_STATE_EOF(xd):
1621 #line 598 "scan.l"
1622 { yyerror("unterminated quoted identifier"); }
1623         YY_BREAK
1624 case 41:
1625 YY_RULE_SETUP
1626 #line 600 "scan.l"
1627 {
1628                                         SET_YYLLOC();
1629                                         return TYPECAST;
1630                                 }
1631         YY_BREAK
1632 case 42:
1633 YY_RULE_SETUP
1634 #line 605 "scan.l"
1635 {
1636                                         SET_YYLLOC();
1637                                         return base_yytext[0];
1638                                 }
1639         YY_BREAK
1640 case 43:
1641 YY_RULE_SETUP
1642 #line 610 "scan.l"
1643 {
1644                                         /*
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.
1649                                          */
1650                                         int             nchars = base_yyleng;
1651                                         char   *slashstar = strstr(base_yytext, "/*");
1652                                         char   *dashdash = strstr(base_yytext, "--");
1653
1654                                         if (slashstar && dashdash)
1655                                         {
1656                                                 /* if both appear, take the first one */
1657                                                 if (slashstar > dashdash)
1658                                                         slashstar = dashdash;
1659                                         }
1660                                         else if (!slashstar)
1661                                                 slashstar = dashdash;
1662                                         if (slashstar)
1663                                                 nchars = slashstar - base_yytext;
1664
1665                                         /*
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.
1672                                          */
1673                                         while (nchars > 1 &&
1674                                                    (base_yytext[nchars-1] == '+' ||
1675                                                         base_yytext[nchars-1] == '-'))
1676                                         {
1677                                                 int             ic;
1678
1679                                                 for (ic = nchars-2; ic >= 0; ic--)
1680                                                 {
1681                                                         if (strchr("~!@#^&|`?%", base_yytext[ic]))
1682                                                                 break;
1683                                                 }
1684                                                 if (ic >= 0)
1685                                                         break; /* found a char that makes it OK */
1686                                                 nchars--; /* else remove the +/-, and check again */
1687                                         }
1688
1689                                         SET_YYLLOC();
1690
1691                                         if (nchars < base_yyleng)
1692                                         {
1693                                                 /* Strip the unwanted chars from the token */
1694                                                 yyless(nchars);
1695                                                 /*
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.
1700                                                  */
1701                                                 if (nchars == 1 &&
1702                                                         strchr(",()[].;:+-*/%^<>=", base_yytext[0]))
1703                                                         return base_yytext[0];
1704                                         }
1705
1706                                         /*
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.
1711                                          */
1712                                         if (nchars >= NAMEDATALEN)
1713                                                 yyerror("operator too long");
1714
1715                                         /* Convert "!=" operator to "<>" for compatibility */
1716                                         if (strcmp(base_yytext, "!=") == 0)
1717                                                 yylval.str = pstrdup("<>");
1718                                         else
1719                                                 yylval.str = pstrdup(base_yytext);
1720                                         return Op;
1721                                 }
1722         YY_BREAK
1723 case 44:
1724 YY_RULE_SETUP
1725 #line 690 "scan.l"
1726 {
1727                                         SET_YYLLOC();
1728                                         yylval.ival = atol(base_yytext + 1);
1729                                         return PARAM;
1730                                 }
1731         YY_BREAK
1732 case 45:
1733 YY_RULE_SETUP
1734 #line 696 "scan.l"
1735 {
1736                                         long val;
1737                                         char* endptr;
1738
1739                                         SET_YYLLOC();
1740                                         errno = 0;
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)
1746 #endif
1747                                                 )
1748                                         {
1749                                                 /* integer too large, treat it as a float */
1750                                                 yylval.str = pstrdup(base_yytext);
1751                                                 return FCONST;
1752                                         }
1753                                         yylval.ival = val;
1754                                         return ICONST;
1755                                 }
1756         YY_BREAK
1757 case 46:
1758 YY_RULE_SETUP
1759 #line 717 "scan.l"
1760 {
1761                                         SET_YYLLOC();
1762                                         yylval.str = pstrdup(base_yytext);
1763                                         return FCONST;
1764                                 }
1765         YY_BREAK
1766 case 47:
1767 YY_RULE_SETUP
1768 #line 722 "scan.l"
1769 {
1770                                         SET_YYLLOC();
1771                                         yylval.str = pstrdup(base_yytext);
1772                                         return FCONST;
1773                                 }
1774         YY_BREAK
1775 case 48:
1776 YY_RULE_SETUP
1777 #line 727 "scan.l"
1778 {
1779                                         /*
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.
1784                                          */
1785                                         yyless(base_yyleng-1);
1786                                         SET_YYLLOC();
1787                                         yylval.str = pstrdup(base_yytext);
1788                                         return FCONST;
1789                                 }
1790         YY_BREAK
1791 case 49:
1792 YY_RULE_SETUP
1793 #line 739 "scan.l"
1794 {
1795                                         /* throw back the [Ee][+-], and proceed as above */
1796                                         yyless(base_yyleng-2);
1797                                         SET_YYLLOC();
1798                                         yylval.str = pstrdup(base_yytext);
1799                                         return FCONST;
1800                                 }
1801         YY_BREAK
1802 case 50:
1803 YY_RULE_SETUP
1804 #line 748 "scan.l"
1805 {
1806                                         const ScanKeyword *keyword;
1807                                         char               *ident;
1808
1809                                         SET_YYLLOC();
1810
1811                                         /* Is it a keyword? */
1812                                         keyword = ScanKeywordLookup(base_yytext);
1813                                         if (keyword != NULL)
1814                                         {
1815                                                 yylval.keyword = keyword->name;
1816                                                 return keyword->value;
1817                                         }
1818
1819                                         /*
1820                                          * No.  Convert the identifier to lower case, and truncate
1821                                          * if necessary.
1822                                          */
1823                                         ident = downcase_truncate_identifier(base_yytext, base_yyleng, true);
1824                                         yylval.str = ident;
1825                                         return IDENT;
1826                                 }
1827         YY_BREAK
1828 case 51:
1829 YY_RULE_SETUP
1830 #line 771 "scan.l"
1831 {
1832                                         SET_YYLLOC();
1833                                         return base_yytext[0];
1834                                 }
1835         YY_BREAK
1836 case YY_STATE_EOF(INITIAL):
1837 #line 776 "scan.l"
1838 {
1839                                         SET_YYLLOC();
1840                                         yyterminate();
1841                                 }
1842         YY_BREAK
1843 case 52:
1844 YY_RULE_SETUP
1845 #line 781 "scan.l"
1846 YY_FATAL_ERROR( "flex scanner jammed" );
1847         YY_BREAK
1848 #line 1849 "scan.c"
1849
1850         case YY_END_OF_BUFFER:
1851                 {
1852                 /* Amount of text matched not including the EOB char. */
1853                 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1854
1855                 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1856                 *yy_cp = (yy_hold_char);
1857                 YY_RESTORE_YY_MORE_OFFSET
1858
1859                 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1860                         {
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.
1869                          */
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;
1873                         }
1874
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
1880                  * in input().
1881                  */
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;
1885
1886                         (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1887
1888                         yy_current_state = yy_get_previous_state(  );
1889
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).
1897                          */
1898
1899                         yy_next_state = yy_try_NUL_trans( yy_current_state );
1900
1901                         yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1902
1903                         if ( yy_next_state )
1904                                 {
1905                                 /* Consume the NUL. */
1906                                 yy_cp = ++(yy_c_buf_p);
1907                                 yy_current_state = yy_next_state;
1908                                 goto yy_match;
1909                                 }
1910
1911                         else
1912                                 {
1913                                 yy_cp = (yy_last_accepting_cpos);
1914                                 yy_current_state = (yy_last_accepting_state);
1915                                 goto yy_find_action;
1916                                 }
1917                         }
1918
1919                 else switch ( yy_get_next_buffer(  ) )
1920                         {
1921                         case EOB_ACT_END_OF_FILE:
1922                                 {
1923                                 (yy_did_buffer_switch_on_eof) = 0;
1924
1925                                 if ( base_yywrap( ) )
1926                                         {
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.
1935                                          */
1936                                         (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1937
1938                                         yy_act = YY_STATE_EOF(YY_START);
1939                                         goto do_action;
1940                                         }
1941
1942                                 else
1943                                         {
1944                                         if ( ! (yy_did_buffer_switch_on_eof) )
1945                                                 YY_NEW_FILE;
1946                                         }
1947                                 break;
1948                                 }
1949
1950                         case EOB_ACT_CONTINUE_SCAN:
1951                                 (yy_c_buf_p) =
1952                                         (yytext_ptr) + yy_amount_of_matched_text;
1953
1954                                 yy_current_state = yy_get_previous_state(  );
1955
1956                                 yy_cp = (yy_c_buf_p);
1957                                 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1958                                 goto yy_match;
1959
1960                         case EOB_ACT_LAST_MATCH:
1961                                 (yy_c_buf_p) =
1962                                 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1963
1964                                 yy_current_state = yy_get_previous_state(  );
1965
1966                                 yy_cp = (yy_c_buf_p);
1967                                 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1968                                 goto yy_find_action;
1969                         }
1970                 break;
1971                 }
1972
1973         default:
1974                 YY_FATAL_ERROR(
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 */
1979
1980 /* yy_get_next_buffer - try to read in a new buffer
1981  *
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
1986  */
1987 static int yy_get_next_buffer (void)
1988 {
1989         register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1990         register char *source = (yytext_ptr);
1991         register int number_to_move, i;
1992         int ret_val;
1993
1994         if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1995                 YY_FATAL_ERROR(
1996                 "fatal flex scanner internal error--end of buffer missed" );
1997
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 )
2001                         {
2002                         /* We matched a single character, the EOB, so
2003                          * treat this as a final EOF.
2004                          */
2005                         return EOB_ACT_END_OF_FILE;
2006                         }
2007
2008                 else
2009                         {
2010                         /* We matched some text prior to the EOB, first
2011                          * process it.
2012                          */
2013                         return EOB_ACT_LAST_MATCH;
2014                         }
2015                 }
2016
2017         /* Try to read more data. */
2018
2019         /* First move last chars to start of buffer. */
2020         number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
2021
2022         for ( i = 0; i < number_to_move; ++i )
2023                 *(dest++) = *(source++);
2024
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,
2027                  * just force an EOF
2028                  */
2029                 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
2030
2031         else
2032                 {
2033                         int num_to_read =
2034                         YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
2035
2036                 while ( num_to_read <= 0 )
2037                         { /* Not enough room in the buffer - grow it. */
2038
2039                         /* just a shorter name for the current buffer */
2040                         YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
2041
2042                         int yy_c_buf_p_offset =
2043                                 (int) ((yy_c_buf_p) - b->yy_ch_buf);
2044
2045                         if ( b->yy_is_our_buffer )
2046                                 {
2047                                 int new_size = b->yy_buf_size * 2;
2048
2049                                 if ( new_size <= 0 )
2050                                         b->yy_buf_size += b->yy_buf_size / 8;
2051                                 else
2052                                         b->yy_buf_size *= 2;
2053
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  );
2057                                 }
2058                         else
2059                                 /* Can't grow it, we don't own it. */
2060                                 b->yy_ch_buf = 0;
2061
2062                         if ( ! b->yy_ch_buf )
2063                                 YY_FATAL_ERROR(
2064                                 "fatal error - scanner input buffer overflow" );
2065
2066                         (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
2067
2068                         num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
2069                                                 number_to_move - 1;
2070
2071                         }
2072
2073                 if ( num_to_read > YY_READ_BUF_SIZE )
2074                         num_to_read = YY_READ_BUF_SIZE;
2075
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 );
2079
2080                 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
2081                 }
2082
2083         if ( (yy_n_chars) == 0 )
2084                 {
2085                 if ( number_to_move == YY_MORE_ADJ )
2086                         {
2087                         ret_val = EOB_ACT_END_OF_FILE;
2088                         base_yyrestart(base_yyin  );
2089                         }
2090
2091                 else
2092                         {
2093                         ret_val = EOB_ACT_LAST_MATCH;
2094                         YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
2095                                 YY_BUFFER_EOF_PENDING;
2096                         }
2097                 }
2098
2099         else
2100                 ret_val = EOB_ACT_CONTINUE_SCAN;
2101
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;
2105
2106         (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
2107
2108         return ret_val;
2109 }
2110
2111 /* yy_get_previous_state - get the state just before the EOB char was reached */
2112
2113     static yy_state_type yy_get_previous_state (void)
2114 {
2115         register yy_state_type yy_current_state;
2116         register char *yy_cp;
2117     
2118         yy_current_state = (yy_start);
2119
2120         for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
2121                 {
2122                 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
2123                 if ( yy_accept[yy_current_state] )
2124                         {
2125                         (yy_last_accepting_state) = yy_current_state;
2126                         (yy_last_accepting_cpos) = yy_cp;
2127                         }
2128                 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
2129                         {
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];
2133                         }
2134                 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
2135                 }
2136
2137         return yy_current_state;
2138 }
2139
2140 /* yy_try_NUL_trans - try to make a transition on the NUL character
2141  *
2142  * synopsis
2143  *      next_state = yy_try_NUL_trans( current_state );
2144  */
2145     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
2146 {
2147         register int yy_is_jam;
2148         register char *yy_cp = (yy_c_buf_p);
2149
2150         register YY_CHAR yy_c = 1;
2151         if ( yy_accept[yy_current_state] )
2152                 {
2153                 (yy_last_accepting_state) = yy_current_state;
2154                 (yy_last_accepting_cpos) = yy_cp;
2155                 }
2156         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
2157                 {
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];
2161                 }
2162         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
2163         yy_is_jam = (yy_current_state == 154);
2164
2165         return yy_is_jam ? 0 : yy_current_state;
2166 }
2167
2168 #ifndef YY_NO_INPUT
2169 #ifdef __cplusplus
2170     static int yyinput (void)
2171 #else
2172     static int input  (void)
2173 #endif
2174
2175 {
2176         int c;
2177     
2178         *(yy_c_buf_p) = (yy_hold_char);
2179
2180         if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
2181                 {
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.
2185                  */
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';
2189
2190                 else
2191                         { /* need more input */
2192                         int offset = (yy_c_buf_p) - (yytext_ptr);
2193                         ++(yy_c_buf_p);
2194
2195                         switch ( yy_get_next_buffer(  ) )
2196                                 {
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.
2206                                          */
2207
2208                                         /* Reset buffer status. */
2209                                         base_yyrestart(base_yyin );
2210
2211                                         /*FALLTHROUGH*/
2212
2213                                 case EOB_ACT_END_OF_FILE:
2214                                         {
2215                                         if ( base_yywrap( ) )
2216                                                 return EOF;
2217
2218                                         if ( ! (yy_did_buffer_switch_on_eof) )
2219                                                 YY_NEW_FILE;
2220 #ifdef __cplusplus
2221                                         return yyinput();
2222 #else
2223                                         return input();
2224 #endif
2225                                         }
2226
2227                                 case EOB_ACT_CONTINUE_SCAN:
2228                                         (yy_c_buf_p) = (yytext_ptr) + offset;
2229                                         break;
2230                                 }
2231                         }
2232                 }
2233
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);
2237
2238         return c;
2239 }
2240 #endif  /* ifndef YY_NO_INPUT */
2241
2242 /** Immediately switch to a different input stream.
2243  * @param input_file A readable stream.
2244  * 
2245  * @note This function does not reset the start condition to @c INITIAL .
2246  */
2247     void base_yyrestart  (FILE * input_file )
2248 {
2249     
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 );
2254         }
2255
2256         base_yy_init_buffer(YY_CURRENT_BUFFER,input_file );
2257         base_yy_load_buffer_state( );
2258 }
2259
2260 /** Switch to a different input buffer.
2261  * @param new_buffer The new input buffer.
2262  * 
2263  */
2264     void base_yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
2265 {
2266     
2267         /* TODO. We should be able to replace this entire function body
2268          * with
2269          *              base_yypop_buffer_state();
2270          *              base_yypush_buffer_state(new_buffer);
2271      */
2272         base_yyensure_buffer_stack ();
2273         if ( YY_CURRENT_BUFFER == new_buffer )
2274                 return;
2275
2276         if ( YY_CURRENT_BUFFER )
2277                 {
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);
2282                 }
2283
2284         YY_CURRENT_BUFFER_LVALUE = new_buffer;
2285         base_yy_load_buffer_state( );
2286
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.
2291          */
2292         (yy_did_buffer_switch_on_eof) = 1;
2293 }
2294
2295 static void base_yy_load_buffer_state  (void)
2296 {
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);
2301 }
2302
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.
2306  * 
2307  * @return the allocated buffer state.
2308  */
2309     YY_BUFFER_STATE base_yy_create_buffer  (FILE * file, int  size )
2310 {
2311         YY_BUFFER_STATE b;
2312     
2313         b = (YY_BUFFER_STATE) base_yyalloc(sizeof( struct yy_buffer_state )  );
2314         if ( ! b )
2315                 YY_FATAL_ERROR( "out of dynamic memory in base_yy_create_buffer()" );
2316
2317         b->yy_buf_size = size;
2318
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.
2321          */
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()" );
2325
2326         b->yy_is_our_buffer = 1;
2327
2328         base_yy_init_buffer(b,file );
2329
2330         return b;
2331 }
2332
2333 /** Destroy the buffer.
2334  * @param b a buffer created with base_yy_create_buffer()
2335  * 
2336  */
2337     void base_yy_delete_buffer (YY_BUFFER_STATE  b )
2338 {
2339     
2340         if ( ! b )
2341                 return;
2342
2343         if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
2344                 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
2345
2346         if ( b->yy_is_our_buffer )
2347                 base_yyfree((void *) b->yy_ch_buf  );
2348
2349         base_yyfree((void *) b  );
2350 }
2351
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.
2355  */
2356     static void base_yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file )
2357
2358 {
2359         int oerrno = errno;
2360     
2361         base_yy_flush_buffer(b );
2362
2363         b->yy_input_file = file;
2364         b->yy_fill_buffer = 1;
2365
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.
2369      */
2370     if (b != YY_CURRENT_BUFFER){
2371         b->yy_bs_lineno = 1;
2372         b->yy_bs_column = 0;
2373     }
2374
2375         b->yy_is_interactive = 0;
2376     
2377         errno = oerrno;
2378 }
2379
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.
2382  * 
2383  */
2384     void base_yy_flush_buffer (YY_BUFFER_STATE  b )
2385 {
2386         if ( ! b )
2387                 return;
2388
2389         b->yy_n_chars = 0;
2390
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.
2394          */
2395         b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2396         b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2397
2398         b->yy_buf_pos = &b->yy_ch_buf[0];
2399
2400         b->yy_at_bol = 1;
2401         b->yy_buffer_status = YY_BUFFER_NEW;
2402
2403         if ( b == YY_CURRENT_BUFFER )
2404                 base_yy_load_buffer_state( );
2405 }
2406
2407 /** Pushes the new state onto the stack. The new state becomes
2408  *  the current state. This function will allocate the stack
2409  *  if necessary.
2410  *  @param new_buffer The new state.
2411  *  
2412  */
2413 void base_yypush_buffer_state (YY_BUFFER_STATE new_buffer )
2414 {
2415         if (new_buffer == NULL)
2416                 return;
2417
2418         base_yyensure_buffer_stack();
2419
2420         /* This block is copied from base_yy_switch_to_buffer. */
2421         if ( YY_CURRENT_BUFFER )
2422                 {
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);
2427                 }
2428
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;
2433
2434         /* copied from base_yy_switch_to_buffer. */
2435         base_yy_load_buffer_state( );
2436         (yy_did_buffer_switch_on_eof) = 1;
2437 }
2438
2439 /** Removes and deletes the top of the stack, if present.
2440  *  The next element becomes the new top.
2441  *  
2442  */
2443 void base_yypop_buffer_state (void)
2444 {
2445         if (!YY_CURRENT_BUFFER)
2446                 return;
2447
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);
2452
2453         if (YY_CURRENT_BUFFER) {
2454                 base_yy_load_buffer_state( );
2455                 (yy_did_buffer_switch_on_eof) = 1;
2456         }
2457 }
2458
2459 /* Allocates the stack if it does not exist.
2460  *  Guarantees space for at least one push.
2461  */
2462 static void base_yyensure_buffer_stack (void)
2463 {
2464         int num_to_alloc;
2465     
2466         if (!(yy_buffer_stack)) {
2467
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.
2471          */
2472                 num_to_alloc = 1;
2473                 (yy_buffer_stack) = (struct yy_buffer_state**)base_yyalloc
2474                                                                 (num_to_alloc * sizeof(struct yy_buffer_state*)
2475                                                                 );
2476                 
2477                 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2478                                 
2479                 (yy_buffer_stack_max) = num_to_alloc;
2480                 (yy_buffer_stack_top) = 0;
2481                 return;
2482         }
2483
2484         if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
2485
2486                 /* Increase the buffer to prepare for a possible push. */
2487                 int grow_size = 8 /* arbitrary grow size */;
2488
2489                 num_to_alloc = (yy_buffer_stack_max) + grow_size;
2490                 (yy_buffer_stack) = (struct yy_buffer_state**)base_yyrealloc
2491                                                                 ((yy_buffer_stack),
2492                                                                 num_to_alloc * sizeof(struct yy_buffer_state*)
2493                                                                 );
2494
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;
2498         }
2499 }
2500
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
2504  * 
2505  * @return the newly allocated buffer state object. 
2506  */
2507 YY_BUFFER_STATE base_yy_scan_buffer  (char * base, yy_size_t  size )
2508 {
2509         YY_BUFFER_STATE b;
2510     
2511         if ( size < 2 ||
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. */
2515                 return 0;
2516
2517         b = (YY_BUFFER_STATE) base_yyalloc(sizeof( struct yy_buffer_state )  );
2518         if ( ! b )
2519                 YY_FATAL_ERROR( "out of dynamic memory in base_yy_scan_buffer()" );
2520
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;
2527         b->yy_at_bol = 1;
2528         b->yy_fill_buffer = 0;
2529         b->yy_buffer_status = YY_BUFFER_NEW;
2530
2531         base_yy_switch_to_buffer(b  );
2532
2533         return b;
2534 }
2535
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
2539  * 
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.
2543  */
2544 YY_BUFFER_STATE base_yy_scan_string (yyconst char * yystr )
2545 {
2546     
2547         return base_yy_scan_bytes(yystr,strlen(yystr) );
2548 }
2549
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.
2554  * 
2555  * @return the newly allocated buffer state object.
2556  */
2557 YY_BUFFER_STATE base_yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len )
2558 {
2559         YY_BUFFER_STATE b;
2560         char *buf;
2561         yy_size_t n;
2562         int i;
2563     
2564         /* Get memory for full buffer, including space for trailing EOB's. */
2565         n = _yybytes_len + 2;
2566         buf = (char *) base_yyalloc(n  );
2567         if ( ! buf )
2568                 YY_FATAL_ERROR( "out of dynamic memory in base_yy_scan_bytes()" );
2569
2570         for ( i = 0; i < _yybytes_len; ++i )
2571                 buf[i] = yybytes[i];
2572
2573         buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2574
2575         b = base_yy_scan_buffer(buf,n );
2576         if ( ! b )
2577                 YY_FATAL_ERROR( "bad buffer in base_yy_scan_bytes()" );
2578
2579         /* It's okay to grow etc. this buffer, and we should throw it
2580          * away when we're done.
2581          */
2582         b->yy_is_our_buffer = 1;
2583
2584         return b;
2585 }
2586
2587 #ifndef YY_EXIT_FAILURE
2588 #define YY_EXIT_FAILURE 2
2589 #endif
2590
2591 static void yy_fatal_error (yyconst char* msg )
2592 {
2593         (void) fprintf( stderr, "%s\n", msg );
2594         exit( YY_EXIT_FAILURE );
2595 }
2596
2597 /* Redefine yyless() so it works in section 3 code. */
2598
2599 #undef yyless
2600 #define yyless(n) \
2601         do \
2602                 { \
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; \
2611                 } \
2612         while ( 0 )
2613
2614 /* Accessor  methods (get/set functions) to struct members. */
2615
2616 /** Get the current line number.
2617  * 
2618  */
2619 int base_yyget_lineno  (void)
2620 {
2621         
2622     return base_yylineno;
2623 }
2624
2625 /** Get the input stream.
2626  * 
2627  */
2628 FILE *base_yyget_in  (void)
2629 {
2630         return base_yyin;
2631 }
2632
2633 /** Get the output stream.
2634  * 
2635  */
2636 FILE *base_yyget_out  (void)
2637 {
2638         return base_yyout;
2639 }
2640
2641 /** Get the length of the current token.
2642  * 
2643  */
2644 int base_yyget_leng  (void)
2645 {
2646         return base_yyleng;
2647 }
2648
2649 /** Get the current token.
2650  * 
2651  */
2652
2653 char *base_yyget_text  (void)
2654 {
2655         return base_yytext;
2656 }
2657
2658 /** Set the current line number.
2659  * @param line_number
2660  * 
2661  */
2662 void base_yyset_lineno (int  line_number )
2663 {
2664     
2665     base_yylineno = line_number;
2666 }
2667
2668 /** Set the input stream. This does not discard the current
2669  * input buffer.
2670  * @param in_str A readable stream.
2671  * 
2672  * @see base_yy_switch_to_buffer
2673  */
2674 void base_yyset_in (FILE *  in_str )
2675 {
2676         base_yyin = in_str ;
2677 }
2678
2679 void base_yyset_out (FILE *  out_str )
2680 {
2681         base_yyout = out_str ;
2682 }
2683
2684 int base_yyget_debug  (void)
2685 {
2686         return base_yy_flex_debug;
2687 }
2688
2689 void base_yyset_debug (int  bdebug )
2690 {
2691         base_yy_flex_debug = bdebug ;
2692 }
2693
2694 static int yy_init_globals (void)
2695 {
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.
2698      */
2699
2700     (yy_buffer_stack) = 0;
2701     (yy_buffer_stack_top) = 0;
2702     (yy_buffer_stack_max) = 0;
2703     (yy_c_buf_p) = (char *) 0;
2704     (yy_init) = 0;
2705     (yy_start) = 0;
2706
2707 /* Defined in main.c */
2708 #ifdef YY_STDINIT
2709     base_yyin = stdin;
2710     base_yyout = stdout;
2711 #else
2712     base_yyin = (FILE *) 0;
2713     base_yyout = (FILE *) 0;
2714 #endif
2715
2716     /* For future reference: Set errno on error, since we are called by
2717      * base_yylex_init()
2718      */
2719     return 0;
2720 }
2721
2722 /* base_yylex_destroy is for both reentrant and non-reentrant scanners. */
2723 int base_yylex_destroy  (void)
2724 {
2725     
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();
2731         }
2732
2733         /* Destroy the stack itself. */
2734         base_yyfree((yy_buffer_stack) );
2735         (yy_buffer_stack) = NULL;
2736
2737     /* Reset the globals. This is important in a non-reentrant scanner so the next time
2738      * base_yylex() is called, initialization will occur. */
2739     yy_init_globals( );
2740
2741     return 0;
2742 }
2743
2744 /*
2745  * Internal utility routines.
2746  */
2747
2748 #ifndef yytext_ptr
2749 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
2750 {
2751         register int i;
2752         for ( i = 0; i < n; ++i )
2753                 s1[i] = s2[i];
2754 }
2755 #endif
2756
2757 #ifdef YY_NEED_STRLEN
2758 static int yy_flex_strlen (yyconst char * s )
2759 {
2760         register int n;
2761         for ( n = 0; s[n]; ++n )
2762                 ;
2763
2764         return n;
2765 }
2766 #endif
2767
2768 void *base_yyalloc (yy_size_t  size )
2769 {
2770         return (void *) malloc( size );
2771 }
2772
2773 void *base_yyrealloc  (void * ptr, yy_size_t  size )
2774 {
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.
2781          */
2782         return (void *) realloc( (char *) ptr, size );
2783 }
2784
2785 void base_yyfree (void * ptr )
2786 {
2787         free( (char *) ptr );   /* see base_yyrealloc() for (char *) cast */
2788 }
2789
2790 #define YYTABLES_NAME "yytables"
2791
2792 #line 781 "scan.l"
2793
2794
2795
2796 /*
2797  * lexer_errposition
2798  *              Report a lexical-analysis-time cursor position, if possible.
2799  *
2800  * This is expected to be used within an ereport() call.  The return value
2801  * is a dummy (always 0, in fact).
2802  *
2803  * Note that this can only be used for messages from the lexer itself,
2804  * since it depends on scanbuf to still be valid.
2805  */
2806 #if 0
2807 static int
2808 lexer_errposition(void)
2809 {
2810         int             pos;
2811
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);
2816 }
2817 #endif
2818
2819 /*
2820  * yyerror
2821  *              Report a lexer or grammar error.
2822  *
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
2827  * be misleading!
2828  */
2829 void
2830 yyerror(const char *message)
2831 {
2832         longjmp(jmpbuffer, 1);
2833 }
2834
2835
2836 /*
2837  * Called before any actual parsing is done
2838  */
2839 void
2840 scanner_init(const char *str)
2841 {
2842         int     slen = strlen(str);
2843
2844         /*
2845          * Might be left over after ereport()
2846          */
2847         if (YY_CURRENT_BUFFER)
2848                 base_yy_delete_buffer(YY_CURRENT_BUFFER);
2849
2850         /*
2851          * Make a scan buffer with special termination needed by flex.
2852          */
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);
2857
2858         /* initialize literal buffer to a reasonable but expansible size */
2859         literalalloc = 1024;
2860         literalbuf = (char *) palloc(literalalloc);
2861         startlit();
2862
2863         BEGIN(INITIAL);
2864 }
2865
2866
2867 /*
2868  * Called after parsing is done to clean up after scanner_init()
2869  */
2870 void
2871 scanner_finish(void)
2872 {
2873         base_yy_delete_buffer(scanbufhandle);
2874         pfree(scanbuf);
2875 }
2876
2877
2878 static void
2879 addlit(char *ytext, int yleng)
2880 {
2881         /* enlarge buffer if needed */
2882         if ((literallen+yleng) >= literalalloc)
2883         {
2884                 do {
2885                         literalalloc *= 2;
2886                 } while ((literallen+yleng) >= literalalloc);
2887                 literalbuf = (char *) repalloc(literalbuf, literalalloc);
2888         }
2889         /* append new data, add trailing null */
2890         memcpy(literalbuf+literallen, ytext, yleng);
2891         literallen += yleng;
2892         literalbuf[literallen] = '\0';
2893 }
2894
2895
2896 static void
2897 addlitchar(unsigned char ychar)
2898 {
2899         /* enlarge buffer if needed */
2900         if ((literallen+1) >= literalalloc)
2901         {
2902                 literalalloc *= 2;
2903                 literalbuf = (char *) repalloc(literalbuf, literalalloc);
2904         }
2905         /* append new data, add trailing null */
2906         literalbuf[literallen] = ychar;
2907         literallen += 1;
2908         literalbuf[literallen] = '\0';
2909 }
2910
2911
2912 /*
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
2915  * already known.
2916  */
2917 static char *
2918 litbufdup(void)
2919 {
2920         char *new;
2921
2922         new = palloc(literallen + 1);
2923         memcpy(new, literalbuf, literallen+1);
2924         return new;
2925 }
2926
2927
2928 static unsigned char
2929 unescape_single_char(unsigned char c)
2930 {
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
2934          * checks.
2935          */
2936         if (IS_HIGHBIT_SET(c))
2937                 saw_high_bit = true;
2938
2939         switch (c)
2940         {
2941                 case 'b':
2942                         return '\b';
2943                 case 'f':
2944                         return '\f';
2945                 case 'n':
2946                         return '\n';
2947                 case 'r':
2948                         return '\r';
2949                 case 't':
2950                         return '\t';
2951                 default:
2952                         return c;
2953         }
2954 }
2955
2956 static void
2957 check_string_escape_warning(unsigned char ychar)
2958 {
2959 #if 0
2960         if (ychar == '\'')
2961         {
2962                 if (warn_on_first_escape && escape_string_warning)
2963                         ereport(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 */
2969         }
2970         else if (ychar == '\\')
2971         {
2972                 if (warn_on_first_escape && escape_string_warning)
2973                         ereport(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 */
2979         }
2980         else
2981                 check_escape_warning();
2982 #endif
2983 }
2984
2985 static void
2986 check_escape_warning(void)
2987 {
2988 #if 0
2989         if (warn_on_first_escape && escape_string_warning)
2990                 ereport(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 */
2996 #endif
2997 }
2998
2999 /*
3000  * downcase_truncate_identifier() --- do appropriate downcasing and
3001  * truncation of an unquoted identifier.  Optionally warn of truncation.
3002  *
3003  * Returns a palloc'd string containing the adjusted identifier.
3004  *
3005  * Note: in some usages the passed string is not null-terminated.
3006  *
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.
3011  */
3012 char *
3013 downcase_truncate_identifier(const char *ident, int len, int warn)
3014 {
3015         char       *result;
3016         int                     i;
3017
3018         result = palloc(len + 1);
3019
3020         /*
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
3027          * characters.
3028          */
3029         for (i = 0; i < len; i++)
3030         {
3031                 unsigned char ch = (unsigned char) ident[i];
3032
3033                 if (ch >= 'A' && ch <= 'Z')
3034                         ch += 'a' - 'A';
3035                 else if (ch >= 0x80 && isupper(ch))
3036                         ch = tolower(ch);
3037                 result[i] = (char) ch;
3038         }
3039         result[i] = '\0';
3040
3041         if (i >= NAMEDATALEN)
3042                 truncate_identifier(result, i, warn);
3043
3044         return result;
3045 }
3046
3047 /*
3048  * truncate_identifier() --- truncate an identifier to NAMEDATALEN-1 bytes.
3049  *
3050  * The given string is modified in-place, if necessary.  A warning is
3051  * issued if requested.
3052  *
3053  * We require the caller to pass in the string length since this saves a
3054  * strlen() call in some common usages.
3055  */
3056 void
3057 truncate_identifier(char *ident, int len, int warn)
3058 {
3059         if (len >= NAMEDATALEN)
3060         {
3061                 len = strlen(ident); /*pg_mbcliplen(ident, len, NAMEDATALEN - 1);*/
3062 #if 0
3063                 if (warn)
3064                         ereport(NOTICE,
3065                                         (errcode(ERRCODE_NAME_TOO_LONG),
3066                                          errmsg("identifier \"%s\" will be truncated to \"%.*s\"",
3067                                                         ident, len, ident)));
3068 #endif
3069                 ident[len] = '\0';
3070         }
3071 }
3072