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