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