1 #line 2 "exprscan.c"
2
3 #line 4 "exprscan.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 6
12 #define YY_FLEX_SUBMINOR_VERSION 4
13 #if YY_FLEX_SUBMINOR_VERSION > 0
14 #define FLEX_BETA
15 #endif
16
17 #ifdef yy_create_buffer
18 #define expr_yy_create_buffer_ALREADY_DEFINED
19 #else
20 #define yy_create_buffer expr_yy_create_buffer
21 #endif
22
23 #ifdef yy_delete_buffer
24 #define expr_yy_delete_buffer_ALREADY_DEFINED
25 #else
26 #define yy_delete_buffer expr_yy_delete_buffer
27 #endif
28
29 #ifdef yy_scan_buffer
30 #define expr_yy_scan_buffer_ALREADY_DEFINED
31 #else
32 #define yy_scan_buffer expr_yy_scan_buffer
33 #endif
34
35 #ifdef yy_scan_string
36 #define expr_yy_scan_string_ALREADY_DEFINED
37 #else
38 #define yy_scan_string expr_yy_scan_string
39 #endif
40
41 #ifdef yy_scan_bytes
42 #define expr_yy_scan_bytes_ALREADY_DEFINED
43 #else
44 #define yy_scan_bytes expr_yy_scan_bytes
45 #endif
46
47 #ifdef yy_init_buffer
48 #define expr_yy_init_buffer_ALREADY_DEFINED
49 #else
50 #define yy_init_buffer expr_yy_init_buffer
51 #endif
52
53 #ifdef yy_flush_buffer
54 #define expr_yy_flush_buffer_ALREADY_DEFINED
55 #else
56 #define yy_flush_buffer expr_yy_flush_buffer
57 #endif
58
59 #ifdef yy_load_buffer_state
60 #define expr_yy_load_buffer_state_ALREADY_DEFINED
61 #else
62 #define yy_load_buffer_state expr_yy_load_buffer_state
63 #endif
64
65 #ifdef yy_switch_to_buffer
66 #define expr_yy_switch_to_buffer_ALREADY_DEFINED
67 #else
68 #define yy_switch_to_buffer expr_yy_switch_to_buffer
69 #endif
70
71 #ifdef yypush_buffer_state
72 #define expr_yypush_buffer_state_ALREADY_DEFINED
73 #else
74 #define yypush_buffer_state expr_yypush_buffer_state
75 #endif
76
77 #ifdef yypop_buffer_state
78 #define expr_yypop_buffer_state_ALREADY_DEFINED
79 #else
80 #define yypop_buffer_state expr_yypop_buffer_state
81 #endif
82
83 #ifdef yyensure_buffer_stack
84 #define expr_yyensure_buffer_stack_ALREADY_DEFINED
85 #else
86 #define yyensure_buffer_stack expr_yyensure_buffer_stack
87 #endif
88
89 #ifdef yylex
90 #define expr_yylex_ALREADY_DEFINED
91 #else
92 #define yylex expr_yylex
93 #endif
94
95 #ifdef yyrestart
96 #define expr_yyrestart_ALREADY_DEFINED
97 #else
98 #define yyrestart expr_yyrestart
99 #endif
100
101 #ifdef yylex_init
102 #define expr_yylex_init_ALREADY_DEFINED
103 #else
104 #define yylex_init expr_yylex_init
105 #endif
106
107 #ifdef yylex_init_extra
108 #define expr_yylex_init_extra_ALREADY_DEFINED
109 #else
110 #define yylex_init_extra expr_yylex_init_extra
111 #endif
112
113 #ifdef yylex_destroy
114 #define expr_yylex_destroy_ALREADY_DEFINED
115 #else
116 #define yylex_destroy expr_yylex_destroy
117 #endif
118
119 #ifdef yyget_debug
120 #define expr_yyget_debug_ALREADY_DEFINED
121 #else
122 #define yyget_debug expr_yyget_debug
123 #endif
124
125 #ifdef yyset_debug
126 #define expr_yyset_debug_ALREADY_DEFINED
127 #else
128 #define yyset_debug expr_yyset_debug
129 #endif
130
131 #ifdef yyget_extra
132 #define expr_yyget_extra_ALREADY_DEFINED
133 #else
134 #define yyget_extra expr_yyget_extra
135 #endif
136
137 #ifdef yyset_extra
138 #define expr_yyset_extra_ALREADY_DEFINED
139 #else
140 #define yyset_extra expr_yyset_extra
141 #endif
142
143 #ifdef yyget_in
144 #define expr_yyget_in_ALREADY_DEFINED
145 #else
146 #define yyget_in expr_yyget_in
147 #endif
148
149 #ifdef yyset_in
150 #define expr_yyset_in_ALREADY_DEFINED
151 #else
152 #define yyset_in expr_yyset_in
153 #endif
154
155 #ifdef yyget_out
156 #define expr_yyget_out_ALREADY_DEFINED
157 #else
158 #define yyget_out expr_yyget_out
159 #endif
160
161 #ifdef yyset_out
162 #define expr_yyset_out_ALREADY_DEFINED
163 #else
164 #define yyset_out expr_yyset_out
165 #endif
166
167 #ifdef yyget_leng
168 #define expr_yyget_leng_ALREADY_DEFINED
169 #else
170 #define yyget_leng expr_yyget_leng
171 #endif
172
173 #ifdef yyget_text
174 #define expr_yyget_text_ALREADY_DEFINED
175 #else
176 #define yyget_text expr_yyget_text
177 #endif
178
179 #ifdef yyget_lineno
180 #define expr_yyget_lineno_ALREADY_DEFINED
181 #else
182 #define yyget_lineno expr_yyget_lineno
183 #endif
184
185 #ifdef yyset_lineno
186 #define expr_yyset_lineno_ALREADY_DEFINED
187 #else
188 #define yyset_lineno expr_yyset_lineno
189 #endif
190
191 #ifdef yyget_column
192 #define expr_yyget_column_ALREADY_DEFINED
193 #else
194 #define yyget_column expr_yyget_column
195 #endif
196
197 #ifdef yyset_column
198 #define expr_yyset_column_ALREADY_DEFINED
199 #else
200 #define yyset_column expr_yyset_column
201 #endif
202
203 #ifdef yywrap
204 #define expr_yywrap_ALREADY_DEFINED
205 #else
206 #define yywrap expr_yywrap
207 #endif
208
209 #ifdef yyget_lval
210 #define expr_yyget_lval_ALREADY_DEFINED
211 #else
212 #define yyget_lval expr_yyget_lval
213 #endif
214
215 #ifdef yyset_lval
216 #define expr_yyset_lval_ALREADY_DEFINED
217 #else
218 #define yyset_lval expr_yyset_lval
219 #endif
220
221 #ifdef yyalloc
222 #define expr_yyalloc_ALREADY_DEFINED
223 #else
224 #define yyalloc expr_yyalloc
225 #endif
226
227 #ifdef yyrealloc
228 #define expr_yyrealloc_ALREADY_DEFINED
229 #else
230 #define yyrealloc expr_yyrealloc
231 #endif
232
233 #ifdef yyfree
234 #define expr_yyfree_ALREADY_DEFINED
235 #else
236 #define yyfree expr_yyfree
237 #endif
238
239 /* First, we deal with platform-specific or compiler-specific issues. */
240
241 /* begin standard C headers. */
242 #include <stdio.h>
243 #include <string.h>
244 #include <errno.h>
245 #include <stdlib.h>
246
247 /* end standard C headers. */
248
249 /* flex integer type definitions */
250
251 #ifndef FLEXINT_H
252 #define FLEXINT_H
253
254 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
255
256 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
257
258 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
259 * if you want the limit (max/min) macros for int types.
260 */
261 #ifndef __STDC_LIMIT_MACROS
262 #define __STDC_LIMIT_MACROS 1
263 #endif
264
265 #include <inttypes.h>
266 typedef int8_t flex_int8_t;
267 typedef uint8_t flex_uint8_t;
268 typedef int16_t flex_int16_t;
269 typedef uint16_t flex_uint16_t;
270 typedef int32_t flex_int32_t;
271 typedef uint32_t flex_uint32_t;
272 #else
273 typedef signed char flex_int8_t;
274 typedef short int flex_int16_t;
275 typedef int flex_int32_t;
276 typedef unsigned char flex_uint8_t;
277 typedef unsigned short int flex_uint16_t;
278 typedef unsigned int flex_uint32_t;
279
280 /* Limits of integral types. */
281 #ifndef INT8_MIN
282 #define INT8_MIN (-128)
283 #endif
284 #ifndef INT16_MIN
285 #define INT16_MIN (-32767-1)
286 #endif
287 #ifndef INT32_MIN
288 #define INT32_MIN (-2147483647-1)
289 #endif
290 #ifndef INT8_MAX
291 #define INT8_MAX (127)
292 #endif
293 #ifndef INT16_MAX
294 #define INT16_MAX (32767)
295 #endif
296 #ifndef INT32_MAX
297 #define INT32_MAX (2147483647)
298 #endif
299 #ifndef UINT8_MAX
300 #define UINT8_MAX (255U)
301 #endif
302 #ifndef UINT16_MAX
303 #define UINT16_MAX (65535U)
304 #endif
305 #ifndef UINT32_MAX
306 #define UINT32_MAX (4294967295U)
307 #endif
308
309 #ifndef SIZE_MAX
310 #define SIZE_MAX (~(size_t)0)
311 #endif
312
313 #endif /* ! C99 */
314
315 #endif /* ! FLEXINT_H */
316
317 /* begin standard C++ headers. */
318
319 /* TODO: this is always defined, so inline it */
320 #define yyconst const
321
322 #if defined(__GNUC__) && __GNUC__ >= 3
323 #define yynoreturn __attribute__((__noreturn__))
324 #else
325 #define yynoreturn
326 #endif
327
328 /* Returned upon end-of-file. */
329 #define YY_NULL 0
330
331 /* Promotes a possibly negative, possibly signed char to an
332 * integer in range [0..255] for use as an array index.
333 */
334 #define YY_SC_TO_UI(c) ((YY_CHAR) (c))
335
336 /* An opaque pointer. */
337 #ifndef YY_TYPEDEF_YY_SCANNER_T
338 #define YY_TYPEDEF_YY_SCANNER_T
339 typedef void* yyscan_t;
340 #endif
341
342 /* For convenience, these vars (plus the bison vars far below)
343 are macros in the reentrant scanner. */
344 #define yyin yyg->yyin_r
345 #define yyout yyg->yyout_r
346 #define yyextra yyg->yyextra_r
347 #define yyleng yyg->yyleng_r
348 #define yytext yyg->yytext_r
349 #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
350 #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
351 #define yy_flex_debug yyg->yy_flex_debug_r
352
353 /* Enter a start condition. This macro really ought to take a parameter,
354 * but we do it the disgusting crufty way forced on us by the ()-less
355 * definition of BEGIN.
356 */
357 #define BEGIN yyg->yy_start = 1 + 2 *
358 /* Translate the current start state into a value that can be later handed
359 * to BEGIN to return to the state. The YYSTATE alias is for lex
360 * compatibility.
361 */
362 #define YY_START ((yyg->yy_start - 1) / 2)
363 #define YYSTATE YY_START
364 /* Action number for EOF rule of a given start state. */
365 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
366 /* Special action meaning "start processing a new file". */
367 #define YY_NEW_FILE yyrestart( yyin , yyscanner )
368 #define YY_END_OF_BUFFER_CHAR 0
369
370 /* Size of default input buffer. */
371 #ifndef YY_BUF_SIZE
372 #ifdef __ia64__
373 /* On IA-64, the buffer size is 16k, not 8k.
374 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
375 * Ditto for the __ia64__ case accordingly.
376 */
377 #define YY_BUF_SIZE 32768
378 #else
379 #define YY_BUF_SIZE 16384
380 #endif /* __ia64__ */
381 #endif
382
383 /* The state buf must be large enough to hold one state per character in the main buffer.
384 */
385 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
386
387 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
388 #define YY_TYPEDEF_YY_BUFFER_STATE
389 typedef struct yy_buffer_state *YY_BUFFER_STATE;
390 #endif
391
392 #ifndef YY_TYPEDEF_YY_SIZE_T
393 #define YY_TYPEDEF_YY_SIZE_T
394 typedef size_t yy_size_t;
395 #endif
396
397 #define EOB_ACT_CONTINUE_SCAN 0
398 #define EOB_ACT_END_OF_FILE 1
399 #define EOB_ACT_LAST_MATCH 2
400
401 #define YY_LESS_LINENO(n)
402 #define YY_LINENO_REWIND_TO(ptr)
403
404 /* Return all but the first "n" matched characters back to the input stream. */
405 #define yyless(n) \
406 do \
407 { \
408 /* Undo effects of setting up yytext. */ \
409 int yyless_macro_arg = (n); \
410 YY_LESS_LINENO(yyless_macro_arg);\
411 *yy_cp = yyg->yy_hold_char; \
412 YY_RESTORE_YY_MORE_OFFSET \
413 yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
414 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
415 } \
416 while ( 0 )
417 #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
418
419 #ifndef YY_STRUCT_YY_BUFFER_STATE
420 #define YY_STRUCT_YY_BUFFER_STATE
421 struct yy_buffer_state
422 {
423 FILE *yy_input_file;
424
425 char *yy_ch_buf; /* input buffer */
426 char *yy_buf_pos; /* current position in input buffer */
427
428 /* Size of input buffer in bytes, not including room for EOB
429 * characters.
430 */
431 int yy_buf_size;
432
433 /* Number of characters read into yy_ch_buf, not including EOB
434 * characters.
435 */
436 int yy_n_chars;
437
438 /* Whether we "own" the buffer - i.e., we know we created it,
439 * and can realloc() it to grow it, and should free() it to
440 * delete it.
441 */
442 int yy_is_our_buffer;
443
444 /* Whether this is an "interactive" input source; if so, and
445 * if we're using stdio for input, then we want to use getc()
446 * instead of fread(), to make sure we stop fetching input after
447 * each newline.
448 */
449 int yy_is_interactive;
450
451 /* Whether we're considered to be at the beginning of a line.
452 * If so, '^' rules will be active on the next match, otherwise
453 * not.
454 */
455 int yy_at_bol;
456
457 int yy_bs_lineno; /**< The line count. */
458 int yy_bs_column; /**< The column count. */
459
460 /* Whether to try to fill the input buffer when we reach the
461 * end of it.
462 */
463 int yy_fill_buffer;
464
465 int yy_buffer_status;
466
467 #define YY_BUFFER_NEW 0
468 #define YY_BUFFER_NORMAL 1
469 /* When an EOF's been seen but there's still some text to process
470 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
471 * shouldn't try reading from the input source any more. We might
472 * still have a bunch of tokens to match, though, because of
473 * possible backing-up.
474 *
475 * When we actually see the EOF, we change the status to "new"
476 * (via yyrestart()), so that the user can continue scanning by
477 * just pointing yyin at a new input file.
478 */
479 #define YY_BUFFER_EOF_PENDING 2
480
481 };
482 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
483
484 /* We provide macros for accessing buffer states in case in the
485 * future we want to put the buffer states in a more general
486 * "scanner state".
487 *
488 * Returns the top of the stack, or NULL.
489 */
490 #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
491 ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
492 : NULL)
493 /* Same as previous macro, but useful when we know that the buffer stack is not
494 * NULL or when we need an lvalue. For internal use only.
495 */
496 #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
497
498 void yyrestart ( FILE *input_file , yyscan_t yyscanner );
499 void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
500 YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
501 void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
502 void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
503 void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
504 void yypop_buffer_state ( yyscan_t yyscanner );
505
506 static void yyensure_buffer_stack ( yyscan_t yyscanner );
507 static void yy_load_buffer_state ( yyscan_t yyscanner );
508 static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
509 #define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)
510
511 YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
512 YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
513 YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
514
515 void *yyalloc ( yy_size_t , yyscan_t yyscanner );
516 void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
517 void yyfree ( void * , yyscan_t yyscanner );
518
519 #define yy_new_buffer yy_create_buffer
520 #define yy_set_interactive(is_interactive) \
521 { \
522 if ( ! YY_CURRENT_BUFFER ){ \
523 yyensure_buffer_stack (yyscanner); \
524 YY_CURRENT_BUFFER_LVALUE = \
525 yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
526 } \
527 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
528 }
529 #define yy_set_bol(at_bol) \
530 { \
531 if ( ! YY_CURRENT_BUFFER ){\
532 yyensure_buffer_stack (yyscanner); \
533 YY_CURRENT_BUFFER_LVALUE = \
534 yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
535 } \
536 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
537 }
538 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
539
540 /* Begin user sect3 */
541
542 #define expr_yywrap(yyscanner) (/*CONSTCOND*/1)
543 #define YY_SKIP_YYWRAP
544 typedef flex_uint8_t YY_CHAR;
545
546 typedef int yy_state_type;
547
548 #define yytext_ptr yytext_r
549
550 static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
551 static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner);
552 static int yy_get_next_buffer ( yyscan_t yyscanner );
553 static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
554
555 /* Done after the current pattern has been matched and before the
556 * corresponding action - sets up yytext.
557 */
558 #define YY_DO_BEFORE_ACTION \
559 yyg->yytext_ptr = yy_bp; \
560 yyleng = (int) (yy_cp - yy_bp); \
561 yyg->yy_hold_char = *yy_cp; \
562 *yy_cp = '\0'; \
563 yyg->yy_c_buf_p = yy_cp;
564 #define YY_NUM_RULES 51
565 #define YY_END_OF_BUFFER 52
566 /* This struct is not used in this scanner,
567 but its presence is necessary. */
568 struct yy_trans_info
569 {
570 flex_int32_t yy_verify;
571 flex_int32_t yy_nxt;
572 };
573 static const flex_int16_t yy_accept[129] =
574 { 0,
575 0, 0, 0, 0, 52, 1, 3, 5, 1, 50,
576 47, 49, 50, 22, 10, 21, 24, 25, 8, 6,
577 26, 7, 50, 9, 43, 43, 50, 18, 11, 19,
578 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
579 50, 20, 23, 1, 1, 3, 4, 0, 47, 13,
580 45, 44, 43, 0, 43, 38, 16, 14, 12, 15,
581 17, 46, 46, 46, 46, 46, 46, 30, 46, 46,
582 28, 46, 46, 46, 48, 0, 2, 0, 0, 44,
583 0, 44, 43, 27, 46, 46, 37, 46, 46, 29,
584 46, 46, 46, 46, 0, 45, 43, 33, 36, 46,
585
586 46, 46, 39, 35, 40, 34, 43, 41, 46, 46,
587 43, 31, 46, 43, 32, 43, 43, 43, 43, 43,
588 43, 43, 43, 43, 43, 43, 42, 0
589 } ;
590
591 static const YY_CHAR yy_ec[256] =
592 { 0,
593 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
594 2, 2, 4, 1, 1, 1, 1, 1, 1, 1,
595 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
596 1, 2, 5, 1, 6, 1, 7, 8, 1, 9,
597 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
598 20, 21, 22, 23, 24, 25, 26, 27, 1, 28,
599 29, 30, 1, 1, 31, 32, 33, 34, 35, 36,
600 32, 37, 38, 32, 32, 39, 32, 40, 41, 32,
601 32, 42, 43, 44, 45, 32, 46, 32, 32, 32,
602 1, 47, 1, 1, 32, 1, 31, 32, 33, 34,
603
604 35, 36, 32, 37, 38, 32, 32, 39, 32, 40,
605 41, 32, 32, 42, 43, 44, 45, 32, 46, 32,
606 32, 32, 1, 48, 1, 49, 1, 32, 32, 32,
607 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
608 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
609 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
610 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
611 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
612 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
613 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
614
615 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
616 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
617 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
618 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
619 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
620 32, 32, 32, 32, 32
621 } ;
622
623 static const YY_CHAR yy_meta[50] =
624 { 0,
625 1, 2, 2, 2, 1, 1, 1, 1, 1, 1,
626 1, 3, 1, 3, 4, 1, 5, 5, 5, 5,
627 5, 5, 5, 5, 5, 5, 1, 1, 1, 1,
628 6, 6, 6, 6, 7, 6, 6, 6, 6, 6,
629 6, 6, 6, 6, 6, 6, 1, 1, 1
630 } ;
631
632 static const flex_int16_t yy_base[138] =
633 { 0,
634 0, 3, 50, 0, 204, 156, 6, 205, 97, 205,
635 7, 205, 173, 205, 205, 205, 205, 205, 205, 205,
636 205, 205, 0, 205, 0, 1, 0, 0, 205, 2,
637 161, 0, 169, 0, 168, 155, 0, 155, 0, 159,
638 9, 205, 205, 148, 99, 15, 205, 191, 19, 205,
639 158, 157, 172, 10, 171, 0, 205, 205, 205, 205,
640 205, 0, 155, 145, 144, 152, 146, 144, 139, 143,
641 0, 146, 135, 143, 205, 172, 205, 169, 13, 128,
642 32, 0, 14, 0, 120, 110, 0, 100, 97, 101,
643 101, 99, 103, 97, 92, 0, 29, 0, 0, 101,
644
645 95, 88, 0, 0, 0, 0, 19, 0, 93, 92,
646 103, 0, 74, 88, 0, 89, 91, 92, 93, 97,
647 100, 101, 104, 102, 111, 110, 7, 205, 146, 153,
648 9, 157, 160, 163, 166, 171, 174
649 } ;
650
651 static const flex_int16_t yy_def[138] =
652 { 0,
653 129, 129, 128, 3, 128, 130, 128, 128, 130, 128,
654 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
655 128, 128, 131, 128, 132, 132, 133, 128, 128, 128,
656 134, 134, 134, 134, 134, 134, 134, 134, 134, 134,
657 128, 128, 128, 130, 130, 128, 128, 128, 128, 128,
658 131, 135, 26, 136, 26, 133, 128, 128, 128, 128,
659 128, 134, 134, 134, 134, 134, 134, 134, 134, 134,
660 134, 134, 134, 134, 128, 128, 128, 128, 137, 135,
661 136, 81, 26, 134, 134, 134, 134, 134, 134, 134,
662 134, 134, 134, 134, 137, 95, 26, 134, 134, 134,
663
664 134, 134, 134, 134, 134, 134, 26, 134, 134, 134,
665 26, 134, 134, 26, 134, 26, 26, 26, 26, 26,
666 26, 26, 26, 26, 26, 26, 26, 0, 128, 128,
667 128, 128, 128, 128, 128, 128, 128
668 } ;
669
670 static const flex_int16_t yy_nxt[255] =
671 { 0,
672 128, 7, 8, 7, 7, 8, 7, 46, 49, 46,
673 49, 75, 76, 51, 52, 52, 46, 128, 46, 55,
674 49, 81, 49, 81, 95, 53, 95, 57, 58, 59,
675 60, 61, 53, 97, 54, 54, 72, 53, 65, 66,
676 69, 73, 111, 128, 70, 128, 9, 53, 107, 9,
677 10, 11, 12, 11, 13, 14, 15, 16, 17, 18,
678 19, 20, 21, 22, 23, 24, 25, 25, 25, 25,
679 25, 25, 25, 25, 25, 26, 27, 28, 29, 30,
680 31, 32, 33, 32, 34, 35, 32, 36, 32, 37,
681 38, 32, 32, 39, 32, 40, 41, 42, 43, 47,
682
683 48, 77, 78, 128, 116, 128, 53, 53, 117, 53,
684 53, 53, 115, 118, 120, 53, 119, 121, 53, 53,
685 53, 114, 53, 122, 123, 124, 125, 126, 53, 53,
686 113, 112, 110, 109, 127, 108, 106, 105, 104, 103,
687 102, 101, 100, 45, 99, 45, 6, 6, 6, 6,
688 6, 6, 6, 44, 98, 44, 44, 44, 44, 44,
689 53, 53, 54, 53, 56, 56, 56, 62, 62, 62,
690 80, 77, 80, 82, 75, 82, 96, 94, 96, 93,
691 92, 91, 90, 89, 88, 87, 86, 85, 84, 83,
692 53, 54, 79, 47, 45, 74, 71, 68, 67, 64,
693
694 63, 50, 45, 128, 5, 128, 128, 128, 128, 128,
695 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
696 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
697 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
698 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
699 128, 128, 128, 128
700 } ;
701
702 static const flex_int16_t yy_chk[255] =
703 { 0,
704 0, 1, 1, 1, 2, 2, 2, 7, 11, 7,
705 11, 41, 41, 131, 25, 26, 46, 0, 46, 26,
706 49, 54, 49, 54, 79, 127, 79, 28, 28, 28,
707 30, 30, 83, 83, 25, 26, 39, 107, 34, 34,
708 37, 39, 107, 81, 37, 81, 1, 97, 97, 2,
709 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
710 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
711 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
712 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
713 3, 3, 3, 3, 3, 3, 3, 3, 3, 9,
714
715 9, 45, 45, 95, 114, 95, 114, 116, 116, 117,
716 118, 119, 113, 117, 119, 120, 118, 120, 121, 122,
717 124, 111, 123, 121, 122, 123, 124, 125, 126, 125,
718 110, 109, 102, 101, 126, 100, 94, 93, 92, 91,
719 90, 89, 88, 9, 86, 45, 129, 129, 129, 129,
720 129, 129, 129, 130, 85, 130, 130, 130, 130, 130,
721 132, 132, 80, 132, 133, 133, 133, 134, 134, 134,
722 135, 78, 135, 136, 76, 136, 137, 74, 137, 73,
723 72, 70, 69, 68, 67, 66, 65, 64, 63, 55,
724 53, 52, 51, 48, 44, 40, 38, 36, 35, 33,
725
726 31, 13, 6, 5, 128, 128, 128, 128, 128, 128,
727 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
728 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
729 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
730 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
731 128, 128, 128, 128
732 } ;
733
734 /* The intent behind this definition is that it'll catch
735 * any uses of REJECT which flex missed.
736 */
737 #define REJECT reject_used_but_not_detected
738 #define yymore() yymore_used_but_not_detected
739 #define YY_MORE_ADJ 0
740 #define YY_RESTORE_YY_MORE_OFFSET
741 #line 1 "exprscan.l"
742 #line 2 "exprscan.l"
743 /*-------------------------------------------------------------------------
744 *
745 * exprscan.l
746 * lexical scanner for pgbench backslash commands
747 *
748 * This lexer supports two operating modes:
749 *
750 * In INITIAL state, just parse off whitespace-separated words (this mode
751 * is basically equivalent to strtok(), which is what we used to use).
752 *
753 * In EXPR state, lex for the simple expression syntax of exprparse.y.
754 *
755 * In either mode, stop upon hitting newline or end of string.
756 *
757 * Note that this lexer operates within the framework created by psqlscan.l,
758 *
759 * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
760 * Portions Copyright (c) 1994, Regents of the University of California
761 *
762 * src/bin/pgbench/exprscan.l
763 *
764 *-------------------------------------------------------------------------
765 */
766
767 #include "fe_utils/psqlscan_int.h"
768
769 /* context information for reporting errors in expressions */
770 static const char *expr_source = NULL;
771 static int expr_lineno = 0;
772 static int expr_start_offset = 0;
773 static const char *expr_command = NULL;
774
775 /* indicates whether last yylex() call read a newline */
776 static bool last_was_newline = false;
777
778 /*
779 * Work around a bug in flex 2.5.35: it emits a couple of functions that
780 * it forgets to emit declarations for. Since we use -Wmissing-prototypes,
781 * this would cause warnings. Providing our own declarations should be
782 * harmless even when the bug gets fixed.
783 */
784 extern int expr_yyget_column(yyscan_t yyscanner);
785 extern void expr_yyset_column(int column_no, yyscan_t yyscanner);
786
787 /* LCOV_EXCL_START */
788
789 #line 790 "exprscan.c"
790 /* Except for the prefix, these options should match psqlscan.l */
791 #define YY_NO_INPUT 1
792 /* Character classes */
793 /* {space} + {nonspace} + {newline} should cover all characters */
794 /* Line continuation marker */
795 /* case insensitive keywords */
796 /* Exclusive states */
797
798 #line 799 "exprscan.c"
799
800 #define INITIAL 0
801 #define EXPR 1
802
803 #ifndef YY_NO_UNISTD_H
804 /* Special case for "unistd.h", since it is non-ANSI. We include it way
805 * down here because we want the user's section 1 to have been scanned first.
806 * The user has a chance to override it with an option.
807 */
808 #include <unistd.h>
809 #endif
810
811 #ifndef YY_EXTRA_TYPE
812 #define YY_EXTRA_TYPE void *
813 #endif
814
815 /* Holds the entire state of the reentrant scanner. */
816 struct yyguts_t
817 {
818
819 /* User-defined. Not touched by flex. */
820 YY_EXTRA_TYPE yyextra_r;
821
822 /* The rest are the same as the globals declared in the non-reentrant scanner. */
823 FILE *yyin_r, *yyout_r;
824 size_t yy_buffer_stack_top; /**< index of top of stack. */
825 size_t yy_buffer_stack_max; /**< capacity of stack. */
826 YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
827 char yy_hold_char;
828 int yy_n_chars;
829 int yyleng_r;
830 char *yy_c_buf_p;
831 int yy_init;
832 int yy_start;
833 int yy_did_buffer_switch_on_eof;
834 int yy_start_stack_ptr;
835 int yy_start_stack_depth;
836 int *yy_start_stack;
837 yy_state_type yy_last_accepting_state;
838 char* yy_last_accepting_cpos;
839
840 int yylineno_r;
841 int yy_flex_debug_r;
842
843 char *yytext_r;
844 int yy_more_flag;
845 int yy_more_len;
846
847 YYSTYPE * yylval_r;
848
849 }; /* end struct yyguts_t */
850
851 static int yy_init_globals ( yyscan_t yyscanner );
852
853 /* This must go here because YYSTYPE and YYLTYPE are included
854 * from bison output in section 1.*/
855 # define yylval yyg->yylval_r
856
857 int yylex_init (yyscan_t* scanner);
858
859 int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
860
861 /* Accessor methods to globals.
862 These are made visible to non-reentrant scanners for convenience. */
863
864 int yylex_destroy ( yyscan_t yyscanner );
865
866 int yyget_debug ( yyscan_t yyscanner );
867
868 void yyset_debug ( int debug_flag , yyscan_t yyscanner );
869
870 YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
871
872 void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
873
874 FILE *yyget_in ( yyscan_t yyscanner );
875
876 void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
877
878 FILE *yyget_out ( yyscan_t yyscanner );
879
880 void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
881
882 int yyget_leng ( yyscan_t yyscanner );
883
884 char *yyget_text ( yyscan_t yyscanner );
885
886 int yyget_lineno ( yyscan_t yyscanner );
887
888 void yyset_lineno ( int _line_number , yyscan_t yyscanner );
889
890 int yyget_column ( yyscan_t yyscanner );
891
892 void yyset_column ( int _column_no , yyscan_t yyscanner );
893
894 YYSTYPE * yyget_lval ( yyscan_t yyscanner );
895
896 void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );
897
898 /* Macros after this point can all be overridden by user definitions in
899 * section 1.
900 */
901
902 #ifndef YY_SKIP_YYWRAP
903 #ifdef __cplusplus
904 extern "C" int yywrap ( yyscan_t yyscanner );
905 #else
906 extern int yywrap ( yyscan_t yyscanner );
907 #endif
908 #endif
909
910 #ifndef YY_NO_UNPUT
911
912 #endif
913
914 #ifndef yytext_ptr
915 static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
916 #endif
917
918 #ifdef YY_NEED_STRLEN
919 static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
920 #endif
921
922 #ifndef YY_NO_INPUT
923 #ifdef __cplusplus
924 static int yyinput ( yyscan_t yyscanner );
925 #else
926 static int input ( yyscan_t yyscanner );
927 #endif
928
929 #endif
930
931 /* Amount of stuff to slurp up with each read. */
932 #ifndef YY_READ_BUF_SIZE
933 #ifdef __ia64__
934 /* On IA-64, the buffer size is 16k, not 8k */
935 #define YY_READ_BUF_SIZE 16384
936 #else
937 #define YY_READ_BUF_SIZE 8192
938 #endif /* __ia64__ */
939 #endif
940
941 /* Copy whatever the last rule matched to the standard output. */
942 #ifndef ECHO
943 /* This used to be an fputs(), but since the string might contain NUL's,
944 * we now use fwrite().
945 */
946 #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
947 #endif
948
949 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
950 * is returned in "result".
951 */
952 #ifndef YY_INPUT
953 #define YY_INPUT(buf,result,max_size) \
954 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
955 { \
956 int c = '*'; \
957 int n; \
958 for ( n = 0; n < max_size && \
959 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
960 buf[n] = (char) c; \
961 if ( c == '\n' ) \
962 buf[n++] = (char) c; \
963 if ( c == EOF && ferror( yyin ) ) \
964 YY_FATAL_ERROR( "input in flex scanner failed" ); \
965 result = n; \
966 } \
967 else \
968 { \
969 errno=0; \
970 while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
971 { \
972 if( errno != EINTR) \
973 { \
974 YY_FATAL_ERROR( "input in flex scanner failed" ); \
975 break; \
976 } \
977 errno=0; \
978 clearerr(yyin); \
979 } \
980 }\
981 \
982
983 #endif
984
985 /* No semi-colon after return; correct usage is to write "yyterminate();" -
986 * we don't want an extra ';' after the "return" because that will cause
987 * some compilers to complain about unreachable statements.
988 */
989 #ifndef yyterminate
990 #define yyterminate() return YY_NULL
991 #endif
992
993 /* Number of entries by which start-condition stack grows. */
994 #ifndef YY_START_STACK_INCR
995 #define YY_START_STACK_INCR 25
996 #endif
997
998 /* Report a fatal error. */
999 #ifndef YY_FATAL_ERROR
1000 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
1001 #endif
1002
1003 /* end tables serialization structures and prototypes */
1004
1005 /* Default declaration of generated scanner - a define so the user can
1006 * easily add parameters.
1007 */
1008 #ifndef YY_DECL
1009 #define YY_DECL_IS_OURS 1
1010
1011 extern int yylex \
1012 (YYSTYPE * yylval_param , yyscan_t yyscanner);
1013
1014 #define YY_DECL int yylex \
1015 (YYSTYPE * yylval_param , yyscan_t yyscanner)
1016 #endif /* !YY_DECL */
1017
1018 /* Code executed at the beginning of each rule, after yytext and yyleng
1019 * have been set up.
1020 */
1021 #ifndef YY_USER_ACTION
1022 #define YY_USER_ACTION
1023 #endif
1024
1025 /* Code executed at the end of each rule. */
1026 #ifndef YY_BREAK
1027 #define YY_BREAK /*LINTED*/break;
1028 #endif
1029
1030 #define YY_RULE_SETUP \
1031 YY_USER_ACTION
1032
1033 /** The main scanner function which does all the work.
1034 */
1035 YY_DECL
1036 {
1037 yy_state_type yy_current_state;
1038 char *yy_cp, *yy_bp;
1039 int yy_act;
1040 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1041
1042 yylval = yylval_param;
1043
1044 if ( !yyg->yy_init )
1045 {
1046 yyg->yy_init = 1;
1047
1048 #ifdef YY_USER_INIT
1049 YY_USER_INIT;
1050 #endif
1051
1052 if ( ! yyg->yy_start )
1053 yyg->yy_start = 1; /* first start state */
1054
1055 if ( ! yyin )
1056 yyin = stdin;
1057
1058 if ( ! yyout )
1059 yyout = stdout;
1060
1061 if ( ! YY_CURRENT_BUFFER ) {
1062 yyensure_buffer_stack (yyscanner);
1063 YY_CURRENT_BUFFER_LVALUE =
1064 yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
1065 }
1066
1067 yy_load_buffer_state( yyscanner );
1068 }
1069
1070 {
1071 #line 93 "exprscan.l"
1072
1073
1074
1075 #line 97 "exprscan.l"
1076 /* Declare some local variables inside yylex(), for convenience */
1077 PsqlScanState cur_state = yyextra;
1078
1079 /*
1080 * Force flex into the state indicated by start_state. This has a
1081 * couple of purposes: it lets some of the functions below set a new
1082 * starting state without ugly direct access to flex variables, and it
1083 * allows us to transition from one flex lexer to another so that we
1084 * can lex different parts of the source string using separate lexers.
1085 */
1086 BEGIN(cur_state->start_state);
1087
1088 /* Reset was-newline flag */
1089 last_was_newline = false;
1090
1091
1092 /* INITIAL state */
1093
1094 #line 1095 "exprscan.c"
1095
1096 while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
1097 {
1098 yy_cp = yyg->yy_c_buf_p;
1099
1100 /* Support of yytext. */
1101 *yy_cp = yyg->yy_hold_char;
1102
1103 /* yy_bp points to the position in yy_ch_buf of the start of
1104 * the current run.
1105 */
1106 yy_bp = yy_cp;
1107
1108 yy_current_state = yyg->yy_start;
1109 yy_match:
1110 do
1111 {
1112 YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
1113 if ( yy_accept[yy_current_state] )
1114 {
1115 yyg->yy_last_accepting_state = yy_current_state;
1116 yyg->yy_last_accepting_cpos = yy_cp;
1117 }
1118 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1119 {
1120 yy_current_state = (int) yy_def[yy_current_state];
1121 if ( yy_current_state >= 129 )
1122 yy_c = yy_meta[yy_c];
1123 }
1124 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1125 ++yy_cp;
1126 }
1127 while ( yy_current_state != 128 );
1128 yy_cp = yyg->yy_last_accepting_cpos;
1129 yy_current_state = yyg->yy_last_accepting_state;
1130
1131 yy_find_action:
1132 yy_act = yy_accept[yy_current_state];
1133
1134 YY_DO_BEFORE_ACTION;
1135
1136 do_action: /* This label is used only to access EOF actions. */
1137
1138 switch ( yy_act )
1139 { /* beginning of action switch */
1140 case 0: /* must back up */
1141 /* undo the effects of YY_DO_BEFORE_ACTION */
1142 *yy_cp = yyg->yy_hold_char;
1143 yy_cp = yyg->yy_last_accepting_cpos;
1144 yy_current_state = yyg->yy_last_accepting_state;
1145 goto yy_find_action;
1146
1147 case 1:
1148 YY_RULE_SETUP
1149 #line 115 "exprscan.l"
1150 {
1151 /* Found a word, emit and return it */
1152 psqlscan_emit(cur_state, yytext, yyleng);
1153 return 1;
1154 }
1155 YY_BREAK
1156 /*
1157 * We need this rule to avoid returning "word\" instead of recognizing
1158 * a continuation marker just after a word:
1159 */
1160 case 2:
1161 /* rule 2 can match eol */
1162 YY_RULE_SETUP
1163 #line 125 "exprscan.l"
1164 {
1165 /* Found "word\\\r?\n", emit and return just "word" */
1166 int wordlen = yyleng - 2;
1167 if (yytext[wordlen] == '\r')
1168 wordlen--;
1169 Assert(yytext[wordlen] == '\\');
1170 psqlscan_emit(cur_state, yytext, wordlen);
1171 return 1;
1172 }
1173 YY_BREAK
1174 case 3:
1175 YY_RULE_SETUP
1176 #line 135 "exprscan.l"
1177 { /* ignore */ }
1178 YY_BREAK
1179 case 4:
1180 /* rule 4 can match eol */
1181 YY_RULE_SETUP
1182 #line 137 "exprscan.l"
1183 { /* ignore */ }
1184 YY_BREAK
1185 case 5:
1186 /* rule 5 can match eol */
1187 YY_RULE_SETUP
1188 #line 139 "exprscan.l"
1189 {
1190 /* report end of command */
1191 last_was_newline = true;
1192 return 0;
1193 }
1194 YY_BREAK
1195 /* EXPR state */
1196
1197 case 6:
1198 YY_RULE_SETUP
1199 #line 149 "exprscan.l"
1200 { return '+'; }
1201 YY_BREAK
1202 case 7:
1203 YY_RULE_SETUP
1204 #line 150 "exprscan.l"
1205 { return '-'; }
1206 YY_BREAK
1207 case 8:
1208 YY_RULE_SETUP
1209 #line 151 "exprscan.l"
1210 { return '*'; }
1211 YY_BREAK
1212 case 9:
1213 YY_RULE_SETUP
1214 #line 152 "exprscan.l"
1215 { return '/'; }
1216 YY_BREAK
1217 case 10:
1218 YY_RULE_SETUP
1219 #line 153 "exprscan.l"
1220 { return '%'; } /* C version, also in Pg SQL */
1221 YY_BREAK
1222 case 11:
1223 YY_RULE_SETUP
1224 #line 154 "exprscan.l"
1225 { return '='; }
1226 YY_BREAK
1227 case 12:
1228 YY_RULE_SETUP
1229 #line 155 "exprscan.l"
1230 { return NE_OP; }
1231 YY_BREAK
1232 case 13:
1233 YY_RULE_SETUP
1234 #line 156 "exprscan.l"
1235 { return NE_OP; } /* C version, also in Pg SQL */
1236 YY_BREAK
1237 case 14:
1238 YY_RULE_SETUP
1239 #line 157 "exprscan.l"
1240 { return LE_OP; }
1241 YY_BREAK
1242 case 15:
1243 YY_RULE_SETUP
1244 #line 158 "exprscan.l"
1245 { return GE_OP; }
1246 YY_BREAK
1247 case 16:
1248 YY_RULE_SETUP
1249 #line 159 "exprscan.l"
1250 { return LS_OP; }
1251 YY_BREAK
1252 case 17:
1253 YY_RULE_SETUP
1254 #line 160 "exprscan.l"
1255 { return RS_OP; }
1256 YY_BREAK
1257 case 18:
1258 YY_RULE_SETUP
1259 #line 161 "exprscan.l"
1260 { return '<'; }
1261 YY_BREAK
1262 case 19:
1263 YY_RULE_SETUP
1264 #line 162 "exprscan.l"
1265 { return '>'; }
1266 YY_BREAK
1267 case 20:
1268 YY_RULE_SETUP
1269 #line 163 "exprscan.l"
1270 { return '|'; }
1271 YY_BREAK
1272 case 21:
1273 YY_RULE_SETUP
1274 #line 164 "exprscan.l"
1275 { return '&'; }
1276 YY_BREAK
1277 case 22:
1278 YY_RULE_SETUP
1279 #line 165 "exprscan.l"
1280 { return '#'; }
1281 YY_BREAK
1282 case 23:
1283 YY_RULE_SETUP
1284 #line 166 "exprscan.l"
1285 { return '~'; }
1286 YY_BREAK
1287 case 24:
1288 YY_RULE_SETUP
1289 #line 168 "exprscan.l"
1290 { return '('; }
1291 YY_BREAK
1292 case 25:
1293 YY_RULE_SETUP
1294 #line 169 "exprscan.l"
1295 { return ')'; }
1296 YY_BREAK
1297 case 26:
1298 YY_RULE_SETUP
1299 #line 170 "exprscan.l"
1300 { return ','; }
1301 YY_BREAK
1302 case 27:
1303 YY_RULE_SETUP
1304 #line 172 "exprscan.l"
1305 { return AND_OP; }
1306 YY_BREAK
1307 case 28:
1308 YY_RULE_SETUP
1309 #line 173 "exprscan.l"
1310 { return OR_OP; }
1311 YY_BREAK
1312 case 29:
1313 YY_RULE_SETUP
1314 #line 174 "exprscan.l"
1315 { return NOT_OP; }
1316 YY_BREAK
1317 case 30:
1318 YY_RULE_SETUP
1319 #line 175 "exprscan.l"
1320 { return IS_OP; }
1321 YY_BREAK
1322 case 31:
1323 YY_RULE_SETUP
1324 #line 176 "exprscan.l"
1325 { return ISNULL_OP; }
1326 YY_BREAK
1327 case 32:
1328 YY_RULE_SETUP
1329 #line 177 "exprscan.l"
1330 { return NOTNULL_OP; }
1331 YY_BREAK
1332 case 33:
1333 YY_RULE_SETUP
1334 #line 179 "exprscan.l"
1335 { return CASE_KW; }
1336 YY_BREAK
1337 case 34:
1338 YY_RULE_SETUP
1339 #line 180 "exprscan.l"
1340 { return WHEN_KW; }
1341 YY_BREAK
1342 case 35:
1343 YY_RULE_SETUP
1344 #line 181 "exprscan.l"
1345 { return THEN_KW; }
1346 YY_BREAK
1347 case 36:
1348 YY_RULE_SETUP
1349 #line 182 "exprscan.l"
1350 { return ELSE_KW; }
1351 YY_BREAK
1352 case 37:
1353 YY_RULE_SETUP
1354 #line 183 "exprscan.l"
1355 { return END_KW; }
1356 YY_BREAK
1357 case 38:
1358 YY_RULE_SETUP
1359 #line 185 "exprscan.l"
1360 {
1361 yylval->str = pg_strdup(yytext + 1);
1362 return VARIABLE;
1363 }
1364 YY_BREAK
1365 case 39:
1366 YY_RULE_SETUP
1367 #line 190 "exprscan.l"
1368 { return NULL_CONST; }
1369 YY_BREAK
1370 case 40:
1371 YY_RULE_SETUP
1372 #line 191 "exprscan.l"
1373 {
1374 yylval->bval = true;
1375 return BOOLEAN_CONST;
1376 }
1377 YY_BREAK
1378 case 41:
1379 YY_RULE_SETUP
1380 #line 195 "exprscan.l"
1381 {
1382 yylval->bval = false;
1383 return BOOLEAN_CONST;
1384 }
1385 YY_BREAK
1386 case 42:
1387 YY_RULE_SETUP
1388 #line 199 "exprscan.l"
1389 {
1390 /*
1391 * Special handling for PG_INT64_MIN, which can't
1392 * accurately be represented here, as the minus sign is
1393 * lexed separately and INT64_MIN can't be represented as
1394 * a positive integer.
1395 */
1396 return MAXINT_PLUS_ONE_CONST;
1397 }
1398 YY_BREAK
1399 case 43:
1400 YY_RULE_SETUP
1401 #line 208 "exprscan.l"
1402 {
1403 if (!strtoint64(yytext, true, &yylval->ival))
1404 expr_yyerror_more(yyscanner, "bigint constant overflow",
1405 strdup(yytext));
1406 return INTEGER_CONST;
1407 }
1408 YY_BREAK
1409 case 44:
1410 YY_RULE_SETUP
1411 #line 214 "exprscan.l"
1412 {
1413 if (!strtodouble(yytext, true, &yylval->dval))
1414 expr_yyerror_more(yyscanner, "double constant overflow",
1415 strdup(yytext));
1416 return DOUBLE_CONST;
1417 }
1418 YY_BREAK
1419 case 45:
1420 YY_RULE_SETUP
1421 #line 220 "exprscan.l"
1422 {
1423 if (!strtodouble(yytext, true, &yylval->dval))
1424 expr_yyerror_more(yyscanner, "double constant overflow",
1425 strdup(yytext));
1426 return DOUBLE_CONST;
1427 }
1428 YY_BREAK
1429 case 46:
1430 YY_RULE_SETUP
1431 #line 226 "exprscan.l"
1432 {
1433 yylval->str = pg_strdup(yytext);
1434 return FUNCTION;
1435 }
1436 YY_BREAK
1437 case 47:
1438 YY_RULE_SETUP
1439 #line 231 "exprscan.l"
1440 { /* ignore */ }
1441 YY_BREAK
1442 case 48:
1443 /* rule 48 can match eol */
1444 YY_RULE_SETUP
1445 #line 233 "exprscan.l"
1446 { /* ignore */ }
1447 YY_BREAK
1448 case 49:
1449 /* rule 49 can match eol */
1450 YY_RULE_SETUP
1451 #line 235 "exprscan.l"
1452 {
1453 /* report end of command */
1454 last_was_newline = true;
1455 return 0;
1456 }
1457 YY_BREAK
1458 case 50:
1459 YY_RULE_SETUP
1460 #line 241 "exprscan.l"
1461 {
1462 /*
1463 * must strdup yytext so that expr_yyerror_more doesn't
1464 * change it while finding end of line
1465 */
1466 expr_yyerror_more(yyscanner, "unexpected character",
1467 pg_strdup(yytext));
1468 /* NOTREACHED, syntax_error calls exit() */
1469 return 0;
1470 }
1471 YY_BREAK
1472
1473 case YY_STATE_EOF(INITIAL):
1474 case YY_STATE_EOF(EXPR):
1475 #line 254 "exprscan.l"
1476 {
1477 if (cur_state->buffer_stack == NULL)
1478 return 0; /* end of input reached */
1479
1480 /*
1481 * We were expanding a variable, so pop the inclusion
1482 * stack and keep lexing
1483 */
1484 psqlscan_pop_buffer_stack(cur_state);
1485 psqlscan_select_top_buffer(cur_state);
1486 }
1487 YY_BREAK
1488 case 51:
1489 YY_RULE_SETUP
1490 #line 266 "exprscan.l"
1491 YY_FATAL_ERROR( "flex scanner jammed" );
1492 YY_BREAK
1493 #line 1494 "exprscan.c"
1494
1495 case YY_END_OF_BUFFER:
1496 {
1497 /* Amount of text matched not including the EOB char. */
1498 int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1499
1500 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1501 *yy_cp = yyg->yy_hold_char;
1502 YY_RESTORE_YY_MORE_OFFSET
1503
1504 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1505 {
1506 /* We're scanning a new file or input source. It's
1507 * possible that this happened because the user
1508 * just pointed yyin at a new source and called
1509 * yylex(). If so, then we have to assure
1510 * consistency between YY_CURRENT_BUFFER and our
1511 * globals. Here is the right place to do so, because
1512 * this is the first action (other than possibly a
1513 * back-up) that will match for the new input source.
1514 */
1515 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1516 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1517 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1518 }
1519
1520 /* Note that here we test for yy_c_buf_p "<=" to the position
1521 * of the first EOB in the buffer, since yy_c_buf_p will
1522 * already have been incremented past the NUL character
1523 * (since all states make transitions on EOB to the
1524 * end-of-buffer state). Contrast this with the test
1525 * in input().
1526 */
1527 if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1528 { /* This was really a NUL. */
1529 yy_state_type yy_next_state;
1530
1531 yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1532
1533 yy_current_state = yy_get_previous_state( yyscanner );
1534
1535 /* Okay, we're now positioned to make the NUL
1536 * transition. We couldn't have
1537 * yy_get_previous_state() go ahead and do it
1538 * for us because it doesn't know how to deal
1539 * with the possibility of jamming (and we don't
1540 * want to build jamming into it because then it
1541 * will run more slowly).
1542 */
1543
1544 yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1545
1546 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1547
1548 if ( yy_next_state )
1549 {
1550 /* Consume the NUL. */
1551 yy_cp = ++yyg->yy_c_buf_p;
1552 yy_current_state = yy_next_state;
1553 goto yy_match;
1554 }
1555
1556 else
1557 {
1558 yy_cp = yyg->yy_last_accepting_cpos;
1559 yy_current_state = yyg->yy_last_accepting_state;
1560 goto yy_find_action;
1561 }
1562 }
1563
1564 else switch ( yy_get_next_buffer( yyscanner ) )
1565 {
1566 case EOB_ACT_END_OF_FILE:
1567 {
1568 yyg->yy_did_buffer_switch_on_eof = 0;
1569
1570 if ( yywrap( yyscanner ) )
1571 {
1572 /* Note: because we've taken care in
1573 * yy_get_next_buffer() to have set up
1574 * yytext, we can now set up
1575 * yy_c_buf_p so that if some total
1576 * hoser (like flex itself) wants to
1577 * call the scanner after we return the
1578 * YY_NULL, it'll still work - another
1579 * YY_NULL will get returned.
1580 */
1581 yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1582
1583 yy_act = YY_STATE_EOF(YY_START);
1584 goto do_action;
1585 }
1586
1587 else
1588 {
1589 if ( ! yyg->yy_did_buffer_switch_on_eof )
1590 YY_NEW_FILE;
1591 }
1592 break;
1593 }
1594
1595 case EOB_ACT_CONTINUE_SCAN:
1596 yyg->yy_c_buf_p =
1597 yyg->yytext_ptr + yy_amount_of_matched_text;
1598
1599 yy_current_state = yy_get_previous_state( yyscanner );
1600
1601 yy_cp = yyg->yy_c_buf_p;
1602 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1603 goto yy_match;
1604
1605 case EOB_ACT_LAST_MATCH:
1606 yyg->yy_c_buf_p =
1607 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1608
1609 yy_current_state = yy_get_previous_state( yyscanner );
1610
1611 yy_cp = yyg->yy_c_buf_p;
1612 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1613 goto yy_find_action;
1614 }
1615 break;
1616 }
1617
1618 default:
1619 YY_FATAL_ERROR(
1620 "fatal flex scanner internal error--no action found" );
1621 } /* end of action switch */
1622 } /* end of scanning one token */
1623 } /* end of user's declarations */
1624 } /* end of yylex */
1625
1626 /* yy_get_next_buffer - try to read in a new buffer
1627 *
1628 * Returns a code representing an action:
1629 * EOB_ACT_LAST_MATCH -
1630 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1631 * EOB_ACT_END_OF_FILE - end of file
1632 */
yy_get_next_buffer(yyscan_t yyscanner)1633 static int yy_get_next_buffer (yyscan_t yyscanner)
1634 {
1635 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1636 char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1637 char *source = yyg->yytext_ptr;
1638 int number_to_move, i;
1639 int ret_val;
1640
1641 if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1642 YY_FATAL_ERROR(
1643 "fatal flex scanner internal error--end of buffer missed" );
1644
1645 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1646 { /* Don't try to fill the buffer, so this is an EOF. */
1647 if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1648 {
1649 /* We matched a single character, the EOB, so
1650 * treat this as a final EOF.
1651 */
1652 return EOB_ACT_END_OF_FILE;
1653 }
1654
1655 else
1656 {
1657 /* We matched some text prior to the EOB, first
1658 * process it.
1659 */
1660 return EOB_ACT_LAST_MATCH;
1661 }
1662 }
1663
1664 /* Try to read more data. */
1665
1666 /* First move last chars to start of buffer. */
1667 number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
1668
1669 for ( i = 0; i < number_to_move; ++i )
1670 *(dest++) = *(source++);
1671
1672 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1673 /* don't do the read, it's not guaranteed to return an EOF,
1674 * just force an EOF
1675 */
1676 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1677
1678 else
1679 {
1680 int num_to_read =
1681 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1682
1683 while ( num_to_read <= 0 )
1684 { /* Not enough room in the buffer - grow it. */
1685
1686 /* just a shorter name for the current buffer */
1687 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1688
1689 int yy_c_buf_p_offset =
1690 (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1691
1692 if ( b->yy_is_our_buffer )
1693 {
1694 int new_size = b->yy_buf_size * 2;
1695
1696 if ( new_size <= 0 )
1697 b->yy_buf_size += b->yy_buf_size / 8;
1698 else
1699 b->yy_buf_size *= 2;
1700
1701 b->yy_ch_buf = (char *)
1702 /* Include room in for 2 EOB chars. */
1703 yyrealloc( (void *) b->yy_ch_buf,
1704 (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
1705 }
1706 else
1707 /* Can't grow it, we don't own it. */
1708 b->yy_ch_buf = NULL;
1709
1710 if ( ! b->yy_ch_buf )
1711 YY_FATAL_ERROR(
1712 "fatal error - scanner input buffer overflow" );
1713
1714 yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1715
1716 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1717 number_to_move - 1;
1718
1719 }
1720
1721 if ( num_to_read > YY_READ_BUF_SIZE )
1722 num_to_read = YY_READ_BUF_SIZE;
1723
1724 /* Read in more data. */
1725 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1726 yyg->yy_n_chars, num_to_read );
1727
1728 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1729 }
1730
1731 if ( yyg->yy_n_chars == 0 )
1732 {
1733 if ( number_to_move == YY_MORE_ADJ )
1734 {
1735 ret_val = EOB_ACT_END_OF_FILE;
1736 yyrestart( yyin , yyscanner);
1737 }
1738
1739 else
1740 {
1741 ret_val = EOB_ACT_LAST_MATCH;
1742 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1743 YY_BUFFER_EOF_PENDING;
1744 }
1745 }
1746
1747 else
1748 ret_val = EOB_ACT_CONTINUE_SCAN;
1749
1750 if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1751 /* Extend the array by 50%, plus the number we really need. */
1752 int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1753 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
1754 (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
1755 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1756 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1757 /* "- 2" to take care of EOB's */
1758 YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
1759 }
1760
1761 yyg->yy_n_chars += number_to_move;
1762 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1763 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1764
1765 yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1766
1767 return ret_val;
1768 }
1769
1770 /* yy_get_previous_state - get the state just before the EOB char was reached */
1771
yy_get_previous_state(yyscan_t yyscanner)1772 static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1773 {
1774 yy_state_type yy_current_state;
1775 char *yy_cp;
1776 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1777
1778 yy_current_state = yyg->yy_start;
1779
1780 for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1781 {
1782 YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1783 if ( yy_accept[yy_current_state] )
1784 {
1785 yyg->yy_last_accepting_state = yy_current_state;
1786 yyg->yy_last_accepting_cpos = yy_cp;
1787 }
1788 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1789 {
1790 yy_current_state = (int) yy_def[yy_current_state];
1791 if ( yy_current_state >= 129 )
1792 yy_c = yy_meta[yy_c];
1793 }
1794 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1795 }
1796
1797 return yy_current_state;
1798 }
1799
1800 /* yy_try_NUL_trans - try to make a transition on the NUL character
1801 *
1802 * synopsis
1803 * next_state = yy_try_NUL_trans( current_state );
1804 */
yy_try_NUL_trans(yy_state_type yy_current_state,yyscan_t yyscanner)1805 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
1806 {
1807 int yy_is_jam;
1808 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1809 char *yy_cp = yyg->yy_c_buf_p;
1810
1811 YY_CHAR yy_c = 1;
1812 if ( yy_accept[yy_current_state] )
1813 {
1814 yyg->yy_last_accepting_state = yy_current_state;
1815 yyg->yy_last_accepting_cpos = yy_cp;
1816 }
1817 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1818 {
1819 yy_current_state = (int) yy_def[yy_current_state];
1820 if ( yy_current_state >= 129 )
1821 yy_c = yy_meta[yy_c];
1822 }
1823 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1824 yy_is_jam = (yy_current_state == 128);
1825
1826 (void)yyg;
1827 return yy_is_jam ? 0 : yy_current_state;
1828 }
1829
1830 #ifndef YY_NO_UNPUT
1831
1832 #endif
1833
1834 #ifndef YY_NO_INPUT
1835 #ifdef __cplusplus
yyinput(yyscan_t yyscanner)1836 static int yyinput (yyscan_t yyscanner)
1837 #else
1838 static int input (yyscan_t yyscanner)
1839 #endif
1840
1841 {
1842 int c;
1843 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1844
1845 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1846
1847 if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1848 {
1849 /* yy_c_buf_p now points to the character we want to return.
1850 * If this occurs *before* the EOB characters, then it's a
1851 * valid NUL; if not, then we've hit the end of the buffer.
1852 */
1853 if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1854 /* This was really a NUL. */
1855 *yyg->yy_c_buf_p = '\0';
1856
1857 else
1858 { /* need more input */
1859 int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
1860 ++yyg->yy_c_buf_p;
1861
1862 switch ( yy_get_next_buffer( yyscanner ) )
1863 {
1864 case EOB_ACT_LAST_MATCH:
1865 /* This happens because yy_g_n_b()
1866 * sees that we've accumulated a
1867 * token and flags that we need to
1868 * try matching the token before
1869 * proceeding. But for input(),
1870 * there's no matching to consider.
1871 * So convert the EOB_ACT_LAST_MATCH
1872 * to EOB_ACT_END_OF_FILE.
1873 */
1874
1875 /* Reset buffer status. */
1876 yyrestart( yyin , yyscanner);
1877
1878 /*FALLTHROUGH*/
1879
1880 case EOB_ACT_END_OF_FILE:
1881 {
1882 if ( yywrap( yyscanner ) )
1883 return 0;
1884
1885 if ( ! yyg->yy_did_buffer_switch_on_eof )
1886 YY_NEW_FILE;
1887 #ifdef __cplusplus
1888 return yyinput(yyscanner);
1889 #else
1890 return input(yyscanner);
1891 #endif
1892 }
1893
1894 case EOB_ACT_CONTINUE_SCAN:
1895 yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1896 break;
1897 }
1898 }
1899 }
1900
1901 c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1902 *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1903 yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1904
1905 return c;
1906 }
1907 #endif /* ifndef YY_NO_INPUT */
1908
1909 /** Immediately switch to a different input stream.
1910 * @param input_file A readable stream.
1911 * @param yyscanner The scanner object.
1912 * @note This function does not reset the start condition to @c INITIAL .
1913 */
yyrestart(FILE * input_file,yyscan_t yyscanner)1914 void yyrestart (FILE * input_file , yyscan_t yyscanner)
1915 {
1916 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1917
1918 if ( ! YY_CURRENT_BUFFER ){
1919 yyensure_buffer_stack (yyscanner);
1920 YY_CURRENT_BUFFER_LVALUE =
1921 yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
1922 }
1923
1924 yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
1925 yy_load_buffer_state( yyscanner );
1926 }
1927
1928 /** Switch to a different input buffer.
1929 * @param new_buffer The new input buffer.
1930 * @param yyscanner The scanner object.
1931 */
yy_switch_to_buffer(YY_BUFFER_STATE new_buffer,yyscan_t yyscanner)1932 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1933 {
1934 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1935
1936 /* TODO. We should be able to replace this entire function body
1937 * with
1938 * yypop_buffer_state();
1939 * yypush_buffer_state(new_buffer);
1940 */
1941 yyensure_buffer_stack (yyscanner);
1942 if ( YY_CURRENT_BUFFER == new_buffer )
1943 return;
1944
1945 if ( YY_CURRENT_BUFFER )
1946 {
1947 /* Flush out information for old buffer. */
1948 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1949 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1950 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1951 }
1952
1953 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1954 yy_load_buffer_state( yyscanner );
1955
1956 /* We don't actually know whether we did this switch during
1957 * EOF (yywrap()) processing, but the only time this flag
1958 * is looked at is after yywrap() is called, so it's safe
1959 * to go ahead and always set it.
1960 */
1961 yyg->yy_did_buffer_switch_on_eof = 1;
1962 }
1963
yy_load_buffer_state(yyscan_t yyscanner)1964 static void yy_load_buffer_state (yyscan_t yyscanner)
1965 {
1966 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1967 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1968 yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1969 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1970 yyg->yy_hold_char = *yyg->yy_c_buf_p;
1971 }
1972
1973 /** Allocate and initialize an input buffer state.
1974 * @param file A readable stream.
1975 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1976 * @param yyscanner The scanner object.
1977 * @return the allocated buffer state.
1978 */
yy_create_buffer(FILE * file,int size,yyscan_t yyscanner)1979 YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
1980 {
1981 YY_BUFFER_STATE b;
1982
1983 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
1984 if ( ! b )
1985 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1986
1987 b->yy_buf_size = size;
1988
1989 /* yy_ch_buf has to be 2 characters longer than the size given because
1990 * we need to put in 2 end-of-buffer characters.
1991 */
1992 b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
1993 if ( ! b->yy_ch_buf )
1994 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1995
1996 b->yy_is_our_buffer = 1;
1997
1998 yy_init_buffer( b, file , yyscanner);
1999
2000 return b;
2001 }
2002
2003 /** Destroy the buffer.
2004 * @param b a buffer created with yy_create_buffer()
2005 * @param yyscanner The scanner object.
2006 */
yy_delete_buffer(YY_BUFFER_STATE b,yyscan_t yyscanner)2007 void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
2008 {
2009 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2010
2011 if ( ! b )
2012 return;
2013
2014 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
2015 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
2016
2017 if ( b->yy_is_our_buffer )
2018 yyfree( (void *) b->yy_ch_buf , yyscanner );
2019
2020 yyfree( (void *) b , yyscanner );
2021 }
2022
2023 /* Initializes or reinitializes a buffer.
2024 * This function is sometimes called more than once on the same buffer,
2025 * such as during a yyrestart() or at EOF.
2026 */
yy_init_buffer(YY_BUFFER_STATE b,FILE * file,yyscan_t yyscanner)2027 static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
2028
2029 {
2030 int oerrno = errno;
2031 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2032
2033 yy_flush_buffer( b , yyscanner);
2034
2035 b->yy_input_file = file;
2036 b->yy_fill_buffer = 1;
2037
2038 /* If b is the current buffer, then yy_init_buffer was _probably_
2039 * called from yyrestart() or through yy_get_next_buffer.
2040 * In that case, we don't want to reset the lineno or column.
2041 */
2042 if (b != YY_CURRENT_BUFFER){
2043 b->yy_bs_lineno = 1;
2044 b->yy_bs_column = 0;
2045 }
2046
2047 b->yy_is_interactive = 0;
2048
2049 errno = oerrno;
2050 }
2051
2052 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2053 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2054 * @param yyscanner The scanner object.
2055 */
yy_flush_buffer(YY_BUFFER_STATE b,yyscan_t yyscanner)2056 void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
2057 {
2058 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2059 if ( ! b )
2060 return;
2061
2062 b->yy_n_chars = 0;
2063
2064 /* We always need two end-of-buffer characters. The first causes
2065 * a transition to the end-of-buffer state. The second causes
2066 * a jam in that state.
2067 */
2068 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2069 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2070
2071 b->yy_buf_pos = &b->yy_ch_buf[0];
2072
2073 b->yy_at_bol = 1;
2074 b->yy_buffer_status = YY_BUFFER_NEW;
2075
2076 if ( b == YY_CURRENT_BUFFER )
2077 yy_load_buffer_state( yyscanner );
2078 }
2079
2080 /** Pushes the new state onto the stack. The new state becomes
2081 * the current state. This function will allocate the stack
2082 * if necessary.
2083 * @param new_buffer The new state.
2084 * @param yyscanner The scanner object.
2085 */
yypush_buffer_state(YY_BUFFER_STATE new_buffer,yyscan_t yyscanner)2086 void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
2087 {
2088 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2089 if (new_buffer == NULL)
2090 return;
2091
2092 yyensure_buffer_stack(yyscanner);
2093
2094 /* This block is copied from yy_switch_to_buffer. */
2095 if ( YY_CURRENT_BUFFER )
2096 {
2097 /* Flush out information for old buffer. */
2098 *yyg->yy_c_buf_p = yyg->yy_hold_char;
2099 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2100 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2101 }
2102
2103 /* Only push if top exists. Otherwise, replace top. */
2104 if (YY_CURRENT_BUFFER)
2105 yyg->yy_buffer_stack_top++;
2106 YY_CURRENT_BUFFER_LVALUE = new_buffer;
2107
2108 /* copied from yy_switch_to_buffer. */
2109 yy_load_buffer_state( yyscanner );
2110 yyg->yy_did_buffer_switch_on_eof = 1;
2111 }
2112
2113 /** Removes and deletes the top of the stack, if present.
2114 * The next element becomes the new top.
2115 * @param yyscanner The scanner object.
2116 */
yypop_buffer_state(yyscan_t yyscanner)2117 void yypop_buffer_state (yyscan_t yyscanner)
2118 {
2119 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2120 if (!YY_CURRENT_BUFFER)
2121 return;
2122
2123 yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
2124 YY_CURRENT_BUFFER_LVALUE = NULL;
2125 if (yyg->yy_buffer_stack_top > 0)
2126 --yyg->yy_buffer_stack_top;
2127
2128 if (YY_CURRENT_BUFFER) {
2129 yy_load_buffer_state( yyscanner );
2130 yyg->yy_did_buffer_switch_on_eof = 1;
2131 }
2132 }
2133
2134 /* Allocates the stack if it does not exist.
2135 * Guarantees space for at least one push.
2136 */
yyensure_buffer_stack(yyscan_t yyscanner)2137 static void yyensure_buffer_stack (yyscan_t yyscanner)
2138 {
2139 yy_size_t num_to_alloc;
2140 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2141
2142 if (!yyg->yy_buffer_stack) {
2143
2144 /* First allocation is just for 2 elements, since we don't know if this
2145 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2146 * immediate realloc on the next call.
2147 */
2148 num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
2149 yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
2150 (num_to_alloc * sizeof(struct yy_buffer_state*)
2151 , yyscanner);
2152 if ( ! yyg->yy_buffer_stack )
2153 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2154
2155 memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2156
2157 yyg->yy_buffer_stack_max = num_to_alloc;
2158 yyg->yy_buffer_stack_top = 0;
2159 return;
2160 }
2161
2162 if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
2163
2164 /* Increase the buffer to prepare for a possible push. */
2165 yy_size_t grow_size = 8 /* arbitrary grow size */;
2166
2167 num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
2168 yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
2169 (yyg->yy_buffer_stack,
2170 num_to_alloc * sizeof(struct yy_buffer_state*)
2171 , yyscanner);
2172 if ( ! yyg->yy_buffer_stack )
2173 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2174
2175 /* zero only the new slots.*/
2176 memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
2177 yyg->yy_buffer_stack_max = num_to_alloc;
2178 }
2179 }
2180
2181 /** Setup the input buffer state to scan directly from a user-specified character buffer.
2182 * @param base the character buffer
2183 * @param size the size in bytes of the character buffer
2184 * @param yyscanner The scanner object.
2185 * @return the newly allocated buffer state object.
2186 */
yy_scan_buffer(char * base,yy_size_t size,yyscan_t yyscanner)2187 YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
2188 {
2189 YY_BUFFER_STATE b;
2190
2191 if ( size < 2 ||
2192 base[size-2] != YY_END_OF_BUFFER_CHAR ||
2193 base[size-1] != YY_END_OF_BUFFER_CHAR )
2194 /* They forgot to leave room for the EOB's. */
2195 return NULL;
2196
2197 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
2198 if ( ! b )
2199 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
2200
2201 b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
2202 b->yy_buf_pos = b->yy_ch_buf = base;
2203 b->yy_is_our_buffer = 0;
2204 b->yy_input_file = NULL;
2205 b->yy_n_chars = b->yy_buf_size;
2206 b->yy_is_interactive = 0;
2207 b->yy_at_bol = 1;
2208 b->yy_fill_buffer = 0;
2209 b->yy_buffer_status = YY_BUFFER_NEW;
2210
2211 yy_switch_to_buffer( b , yyscanner );
2212
2213 return b;
2214 }
2215
2216 /** Setup the input buffer state to scan a string. The next call to yylex() will
2217 * scan from a @e copy of @a str.
2218 * @param yystr a NUL-terminated string to scan
2219 * @param yyscanner The scanner object.
2220 * @return the newly allocated buffer state object.
2221 * @note If you want to scan bytes that may contain NUL values, then use
2222 * yy_scan_bytes() instead.
2223 */
yy_scan_string(const char * yystr,yyscan_t yyscanner)2224 YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
2225 {
2226
2227 return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
2228 }
2229
2230 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
2231 * scan from a @e copy of @a bytes.
2232 * @param yybytes the byte buffer to scan
2233 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2234 * @param yyscanner The scanner object.
2235 * @return the newly allocated buffer state object.
2236 */
yy_scan_bytes(const char * yybytes,int _yybytes_len,yyscan_t yyscanner)2237 YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner)
2238 {
2239 YY_BUFFER_STATE b;
2240 char *buf;
2241 yy_size_t n;
2242 int i;
2243
2244 /* Get memory for full buffer, including space for trailing EOB's. */
2245 n = (yy_size_t) (_yybytes_len + 2);
2246 buf = (char *) yyalloc( n , yyscanner );
2247 if ( ! buf )
2248 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
2249
2250 for ( i = 0; i < _yybytes_len; ++i )
2251 buf[i] = yybytes[i];
2252
2253 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2254
2255 b = yy_scan_buffer( buf, n , yyscanner);
2256 if ( ! b )
2257 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
2258
2259 /* It's okay to grow etc. this buffer, and we should throw it
2260 * away when we're done.
2261 */
2262 b->yy_is_our_buffer = 1;
2263
2264 return b;
2265 }
2266
2267 #ifndef YY_EXIT_FAILURE
2268 #define YY_EXIT_FAILURE 2
2269 #endif
2270
yy_fatal_error(const char * msg,yyscan_t yyscanner)2271 static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
2272 {
2273 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2274 (void)yyg;
2275 fprintf( stderr, "%s\n", msg );
2276 exit( YY_EXIT_FAILURE );
2277 }
2278
2279 /* Redefine yyless() so it works in section 3 code. */
2280
2281 #undef yyless
2282 #define yyless(n) \
2283 do \
2284 { \
2285 /* Undo effects of setting up yytext. */ \
2286 int yyless_macro_arg = (n); \
2287 YY_LESS_LINENO(yyless_macro_arg);\
2288 yytext[yyleng] = yyg->yy_hold_char; \
2289 yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
2290 yyg->yy_hold_char = *yyg->yy_c_buf_p; \
2291 *yyg->yy_c_buf_p = '\0'; \
2292 yyleng = yyless_macro_arg; \
2293 } \
2294 while ( 0 )
2295
2296 /* Accessor methods (get/set functions) to struct members. */
2297
2298 /** Get the user-defined data for this scanner.
2299 * @param yyscanner The scanner object.
2300 */
yyget_extra(yyscan_t yyscanner)2301 YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner)
2302 {
2303 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2304 return yyextra;
2305 }
2306
2307 /** Get the current line number.
2308 * @param yyscanner The scanner object.
2309 */
yyget_lineno(yyscan_t yyscanner)2310 int yyget_lineno (yyscan_t yyscanner)
2311 {
2312 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2313
2314 if (! YY_CURRENT_BUFFER)
2315 return 0;
2316
2317 return yylineno;
2318 }
2319
2320 /** Get the current column number.
2321 * @param yyscanner The scanner object.
2322 */
yyget_column(yyscan_t yyscanner)2323 int yyget_column (yyscan_t yyscanner)
2324 {
2325 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2326
2327 if (! YY_CURRENT_BUFFER)
2328 return 0;
2329
2330 return yycolumn;
2331 }
2332
2333 /** Get the input stream.
2334 * @param yyscanner The scanner object.
2335 */
yyget_in(yyscan_t yyscanner)2336 FILE *yyget_in (yyscan_t yyscanner)
2337 {
2338 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2339 return yyin;
2340 }
2341
2342 /** Get the output stream.
2343 * @param yyscanner The scanner object.
2344 */
yyget_out(yyscan_t yyscanner)2345 FILE *yyget_out (yyscan_t yyscanner)
2346 {
2347 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2348 return yyout;
2349 }
2350
2351 /** Get the length of the current token.
2352 * @param yyscanner The scanner object.
2353 */
yyget_leng(yyscan_t yyscanner)2354 int yyget_leng (yyscan_t yyscanner)
2355 {
2356 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2357 return yyleng;
2358 }
2359
2360 /** Get the current token.
2361 * @param yyscanner The scanner object.
2362 */
2363
yyget_text(yyscan_t yyscanner)2364 char *yyget_text (yyscan_t yyscanner)
2365 {
2366 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2367 return yytext;
2368 }
2369
2370 /** Set the user-defined data. This data is never touched by the scanner.
2371 * @param user_defined The data to be associated with this scanner.
2372 * @param yyscanner The scanner object.
2373 */
yyset_extra(YY_EXTRA_TYPE user_defined,yyscan_t yyscanner)2374 void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
2375 {
2376 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2377 yyextra = user_defined ;
2378 }
2379
2380 /** Set the current line number.
2381 * @param _line_number line number
2382 * @param yyscanner The scanner object.
2383 */
yyset_lineno(int _line_number,yyscan_t yyscanner)2384 void yyset_lineno (int _line_number , yyscan_t yyscanner)
2385 {
2386 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2387
2388 /* lineno is only valid if an input buffer exists. */
2389 if (! YY_CURRENT_BUFFER )
2390 YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
2391
2392 yylineno = _line_number;
2393 }
2394
2395 /** Set the current column.
2396 * @param _column_no column number
2397 * @param yyscanner The scanner object.
2398 */
yyset_column(int _column_no,yyscan_t yyscanner)2399 void yyset_column (int _column_no , yyscan_t yyscanner)
2400 {
2401 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2402
2403 /* column is only valid if an input buffer exists. */
2404 if (! YY_CURRENT_BUFFER )
2405 YY_FATAL_ERROR( "yyset_column called with no buffer" );
2406
2407 yycolumn = _column_no;
2408 }
2409
2410 /** Set the input stream. This does not discard the current
2411 * input buffer.
2412 * @param _in_str A readable stream.
2413 * @param yyscanner The scanner object.
2414 * @see yy_switch_to_buffer
2415 */
yyset_in(FILE * _in_str,yyscan_t yyscanner)2416 void yyset_in (FILE * _in_str , yyscan_t yyscanner)
2417 {
2418 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2419 yyin = _in_str ;
2420 }
2421
yyset_out(FILE * _out_str,yyscan_t yyscanner)2422 void yyset_out (FILE * _out_str , yyscan_t yyscanner)
2423 {
2424 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2425 yyout = _out_str ;
2426 }
2427
yyget_debug(yyscan_t yyscanner)2428 int yyget_debug (yyscan_t yyscanner)
2429 {
2430 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2431 return yy_flex_debug;
2432 }
2433
yyset_debug(int _bdebug,yyscan_t yyscanner)2434 void yyset_debug (int _bdebug , yyscan_t yyscanner)
2435 {
2436 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2437 yy_flex_debug = _bdebug ;
2438 }
2439
2440 /* Accessor methods for yylval and yylloc */
2441
yyget_lval(yyscan_t yyscanner)2442 YYSTYPE * yyget_lval (yyscan_t yyscanner)
2443 {
2444 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2445 return yylval;
2446 }
2447
yyset_lval(YYSTYPE * yylval_param,yyscan_t yyscanner)2448 void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
2449 {
2450 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2451 yylval = yylval_param;
2452 }
2453
2454 /* User-visible API */
2455
2456 /* yylex_init is special because it creates the scanner itself, so it is
2457 * the ONLY reentrant function that doesn't take the scanner as the last argument.
2458 * That's why we explicitly handle the declaration, instead of using our macros.
2459 */
yylex_init(yyscan_t * ptr_yy_globals)2460 int yylex_init(yyscan_t* ptr_yy_globals)
2461 {
2462 if (ptr_yy_globals == NULL){
2463 errno = EINVAL;
2464 return 1;
2465 }
2466
2467 *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
2468
2469 if (*ptr_yy_globals == NULL){
2470 errno = ENOMEM;
2471 return 1;
2472 }
2473
2474 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2475 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2476
2477 return yy_init_globals ( *ptr_yy_globals );
2478 }
2479
2480 /* yylex_init_extra has the same functionality as yylex_init, but follows the
2481 * convention of taking the scanner as the last argument. Note however, that
2482 * this is a *pointer* to a scanner, as it will be allocated by this call (and
2483 * is the reason, too, why this function also must handle its own declaration).
2484 * The user defined value in the first argument will be available to yyalloc in
2485 * the yyextra field.
2486 */
yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t * ptr_yy_globals)2487 int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
2488 {
2489 struct yyguts_t dummy_yyguts;
2490
2491 yyset_extra (yy_user_defined, &dummy_yyguts);
2492
2493 if (ptr_yy_globals == NULL){
2494 errno = EINVAL;
2495 return 1;
2496 }
2497
2498 *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2499
2500 if (*ptr_yy_globals == NULL){
2501 errno = ENOMEM;
2502 return 1;
2503 }
2504
2505 /* By setting to 0xAA, we expose bugs in
2506 yy_init_globals. Leave at 0x00 for releases. */
2507 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2508
2509 yyset_extra (yy_user_defined, *ptr_yy_globals);
2510
2511 return yy_init_globals ( *ptr_yy_globals );
2512 }
2513
yy_init_globals(yyscan_t yyscanner)2514 static int yy_init_globals (yyscan_t yyscanner)
2515 {
2516 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2517 /* Initialization is the same as for the non-reentrant scanner.
2518 * This function is called from yylex_destroy(), so don't allocate here.
2519 */
2520
2521 yyg->yy_buffer_stack = NULL;
2522 yyg->yy_buffer_stack_top = 0;
2523 yyg->yy_buffer_stack_max = 0;
2524 yyg->yy_c_buf_p = NULL;
2525 yyg->yy_init = 0;
2526 yyg->yy_start = 0;
2527
2528 yyg->yy_start_stack_ptr = 0;
2529 yyg->yy_start_stack_depth = 0;
2530 yyg->yy_start_stack = NULL;
2531
2532 /* Defined in main.c */
2533 #ifdef YY_STDINIT
2534 yyin = stdin;
2535 yyout = stdout;
2536 #else
2537 yyin = NULL;
2538 yyout = NULL;
2539 #endif
2540
2541 /* For future reference: Set errno on error, since we are called by
2542 * yylex_init()
2543 */
2544 return 0;
2545 }
2546
2547 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
yylex_destroy(yyscan_t yyscanner)2548 int yylex_destroy (yyscan_t yyscanner)
2549 {
2550 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2551
2552 /* Pop the buffer stack, destroying each element. */
2553 while(YY_CURRENT_BUFFER){
2554 yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
2555 YY_CURRENT_BUFFER_LVALUE = NULL;
2556 yypop_buffer_state(yyscanner);
2557 }
2558
2559 /* Destroy the stack itself. */
2560 yyfree(yyg->yy_buffer_stack , yyscanner);
2561 yyg->yy_buffer_stack = NULL;
2562
2563 /* Destroy the start condition stack. */
2564 yyfree( yyg->yy_start_stack , yyscanner );
2565 yyg->yy_start_stack = NULL;
2566
2567 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2568 * yylex() is called, initialization will occur. */
2569 yy_init_globals( yyscanner);
2570
2571 /* Destroy the main struct (reentrant only). */
2572 yyfree ( yyscanner , yyscanner );
2573 yyscanner = NULL;
2574 return 0;
2575 }
2576
2577 /*
2578 * Internal utility routines.
2579 */
2580
2581 #ifndef yytext_ptr
yy_flex_strncpy(char * s1,const char * s2,int n,yyscan_t yyscanner)2582 static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
2583 {
2584 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2585 (void)yyg;
2586
2587 int i;
2588 for ( i = 0; i < n; ++i )
2589 s1[i] = s2[i];
2590 }
2591 #endif
2592
2593 #ifdef YY_NEED_STRLEN
yy_flex_strlen(const char * s,yyscan_t yyscanner)2594 static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
2595 {
2596 int n;
2597 for ( n = 0; s[n]; ++n )
2598 ;
2599
2600 return n;
2601 }
2602 #endif
2603
yyalloc(yy_size_t size,yyscan_t yyscanner)2604 void *yyalloc (yy_size_t size , yyscan_t yyscanner)
2605 {
2606 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2607 (void)yyg;
2608 return malloc(size);
2609 }
2610
yyrealloc(void * ptr,yy_size_t size,yyscan_t yyscanner)2611 void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
2612 {
2613 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2614 (void)yyg;
2615
2616 /* The cast to (char *) in the following accommodates both
2617 * implementations that use char* generic pointers, and those
2618 * that use void* generic pointers. It works with the latter
2619 * because both ANSI C and C++ allow castless assignment from
2620 * any pointer type to void*, and deal with argument conversions
2621 * as though doing an assignment.
2622 */
2623 return realloc(ptr, size);
2624 }
2625
yyfree(void * ptr,yyscan_t yyscanner)2626 void yyfree (void * ptr , yyscan_t yyscanner)
2627 {
2628 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2629 (void)yyg;
2630 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
2631 }
2632
2633 #define YYTABLES_NAME "yytables"
2634
2635 #line 266 "exprscan.l"
2636
2637
2638 /* LCOV_EXCL_STOP */
2639
2640 void
expr_yyerror_more(yyscan_t yyscanner,const char * message,const char * more)2641 expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more)
2642 {
2643 PsqlScanState state = yyget_extra(yyscanner);
2644 int error_detection_offset = expr_scanner_offset(state) - 1;
2645 YYSTYPE lval;
2646 char *full_line;
2647
2648 /*
2649 * While parsing an expression, we may not have collected the whole line
2650 * yet from the input source. Lex till EOL so we can report whole line.
2651 * (If we're at EOF, it's okay to call yylex() an extra time.)
2652 */
2653 if (!last_was_newline)
2654 {
2655 while (yylex(&lval, yyscanner))
2656 /* skip */ ;
2657 }
2658
2659 /* Extract the line, trimming trailing newline if any */
2660 full_line = expr_scanner_get_substring(state,
2661 expr_start_offset,
2662 expr_scanner_offset(state),
2663 true);
2664
2665 syntax_error(expr_source, expr_lineno, full_line, expr_command,
2666 message, more, error_detection_offset - expr_start_offset);
2667 }
2668
2669 void
expr_yyerror(yyscan_t yyscanner,const char * message)2670 expr_yyerror(yyscan_t yyscanner, const char *message)
2671 {
2672 expr_yyerror_more(yyscanner, message, NULL);
2673 }
2674
2675 /*
2676 * Collect a space-separated word from a backslash command and return it
2677 * in word_buf, along with its starting string offset in *offset.
2678 * Returns true if successful, false if at end of command.
2679 */
2680 bool
expr_lex_one_word(PsqlScanState state,PQExpBuffer word_buf,int * offset)2681 expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset)
2682 {
2683 int lexresult;
2684 YYSTYPE lval;
2685
2686 /* Must be scanning already */
2687 Assert(state->scanbufhandle != NULL);
2688
2689 /* Set current output target */
2690 state->output_buf = word_buf;
2691 resetPQExpBuffer(word_buf);
2692
2693 /* Set input source */
2694 if (state->buffer_stack != NULL)
2695 yy_switch_to_buffer(state->buffer_stack->buf, state->scanner);
2696 else
2697 yy_switch_to_buffer(state->scanbufhandle, state->scanner);
2698
2699 /* Set start state */
2700 state->start_state = INITIAL;
2701
2702 /* And lex. */
2703 lexresult = yylex(&lval, state->scanner);
2704
2705 /*
2706 * Save start offset of word, if any. We could do this more efficiently,
2707 * but for now this seems fine.
2708 */
2709 if (lexresult)
2710 *offset = expr_scanner_offset(state) - word_buf->len;
2711 else
2712 *offset = -1;
2713
2714 /*
2715 * In case the caller returns to using the regular SQL lexer, reselect the
2716 * appropriate initial state.
2717 */
2718 psql_scan_reselect_sql_lexer(state);
2719
2720 return (bool) lexresult;
2721 }
2722
2723 /*
2724 * Prepare to lex an expression via expr_yyparse().
2725 *
2726 * Returns the yyscan_t that is to be passed to expr_yyparse().
2727 * (This is just state->scanner, but callers don't need to know that.)
2728 */
2729 yyscan_t
expr_scanner_init(PsqlScanState state,const char * source,int lineno,int start_offset,const char * command)2730 expr_scanner_init(PsqlScanState state,
2731 const char *source, int lineno, int start_offset,
2732 const char *command)
2733 {
2734 /* Save error context info */
2735 expr_source = source;
2736 expr_lineno = lineno;
2737 expr_start_offset = start_offset;
2738 expr_command = command;
2739
2740 /* Must be scanning already */
2741 Assert(state->scanbufhandle != NULL);
2742
2743 /* Set current output target */
2744 state->output_buf = NULL;
2745
2746 /* Set input source */
2747 if (state->buffer_stack != NULL)
2748 yy_switch_to_buffer(state->buffer_stack->buf, state->scanner);
2749 else
2750 yy_switch_to_buffer(state->scanbufhandle, state->scanner);
2751
2752 /* Set start state */
2753 state->start_state = EXPR;
2754
2755 return state->scanner;
2756 }
2757
2758 /*
2759 * Finish lexing an expression.
2760 */
2761 void
expr_scanner_finish(yyscan_t yyscanner)2762 expr_scanner_finish(yyscan_t yyscanner)
2763 {
2764 PsqlScanState state = yyget_extra(yyscanner);
2765
2766 /*
2767 * Reselect appropriate initial state for SQL lexer.
2768 */
2769 psql_scan_reselect_sql_lexer(state);
2770 }
2771
2772 /*
2773 * Get offset from start of string to end of current lexer token.
2774 *
2775 * We rely on the knowledge that flex modifies the scan buffer by storing
2776 * a NUL at the end of the current token (yytext). Note that this might
2777 * not work quite right if we were parsing a sub-buffer, but since pgbench
2778 * never invokes that functionality, it doesn't matter.
2779 */
2780 int
expr_scanner_offset(PsqlScanState state)2781 expr_scanner_offset(PsqlScanState state)
2782 {
2783 return strlen(state->scanbuf);
2784 }
2785
2786 /*
2787 * Get a malloc'd copy of the lexer input string from start_offset
2788 * to just before end_offset. If chomp is true, drop any trailing
2789 * newline(s).
2790 */
2791 char *
expr_scanner_get_substring(PsqlScanState state,int start_offset,int end_offset,bool chomp)2792 expr_scanner_get_substring(PsqlScanState state,
2793 int start_offset, int end_offset,
2794 bool chomp)
2795 {
2796 char *result;
2797 const char *scanptr = state->scanbuf + start_offset;
2798 int slen = end_offset - start_offset;
2799
2800 Assert(slen >= 0);
2801 Assert(end_offset <= strlen(state->scanbuf));
2802
2803 if (chomp)
2804 {
2805 while (slen > 0 &&
2806 (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r'))
2807 slen--;
2808 }
2809
2810 result = (char *) pg_malloc(slen + 1);
2811 memcpy(result, scanptr, slen);
2812 result[slen] = '\0';
2813
2814 return result;
2815 }
2816
2817 /*
2818 * Get the line number associated with the given string offset
2819 * (which must not be past the end of where we've lexed to).
2820 */
2821 int
expr_scanner_get_lineno(PsqlScanState state,int offset)2822 expr_scanner_get_lineno(PsqlScanState state, int offset)
2823 {
2824 int lineno = 1;
2825 const char *p = state->scanbuf;
2826
2827 while (*p && offset > 0)
2828 {
2829 if (*p == '\n')
2830 lineno++;
2831 p++, offset--;
2832 }
2833 return lineno;
2834 }
2835
2836