Coverage Report

Created: 2023-03-26 07:38

/src/yara/libyara/re_lexer.c
Line
Count
Source (jump to first uncovered line)
1
#line 2 "re_lexer.c"
2
3
#line 4 "re_lexer.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 re_yy_create_buffer_ALREADY_DEFINED
19
#else
20
0
#define yy_create_buffer re_yy_create_buffer
21
#endif
22
23
#ifdef yy_delete_buffer
24
#define re_yy_delete_buffer_ALREADY_DEFINED
25
#else
26
22.4k
#define yy_delete_buffer re_yy_delete_buffer
27
#endif
28
29
#ifdef yy_scan_buffer
30
#define re_yy_scan_buffer_ALREADY_DEFINED
31
#else
32
22.4k
#define yy_scan_buffer re_yy_scan_buffer
33
#endif
34
35
#ifdef yy_scan_string
36
#define re_yy_scan_string_ALREADY_DEFINED
37
#else
38
22.4k
#define yy_scan_string re_yy_scan_string
39
#endif
40
41
#ifdef yy_scan_bytes
42
#define re_yy_scan_bytes_ALREADY_DEFINED
43
#else
44
22.4k
#define yy_scan_bytes re_yy_scan_bytes
45
#endif
46
47
#ifdef yy_init_buffer
48
#define re_yy_init_buffer_ALREADY_DEFINED
49
#else
50
8
#define yy_init_buffer re_yy_init_buffer
51
#endif
52
53
#ifdef yy_flush_buffer
54
#define re_yy_flush_buffer_ALREADY_DEFINED
55
#else
56
8
#define yy_flush_buffer re_yy_flush_buffer
57
#endif
58
59
#ifdef yy_load_buffer_state
60
#define re_yy_load_buffer_state_ALREADY_DEFINED
61
#else
62
44.8k
#define yy_load_buffer_state re_yy_load_buffer_state
63
#endif
64
65
#ifdef yy_switch_to_buffer
66
#define re_yy_switch_to_buffer_ALREADY_DEFINED
67
#else
68
22.4k
#define yy_switch_to_buffer re_yy_switch_to_buffer
69
#endif
70
71
#ifdef yypush_buffer_state
72
#define re_yypush_buffer_state_ALREADY_DEFINED
73
#else
74
#define yypush_buffer_state re_yypush_buffer_state
75
#endif
76
77
#ifdef yypop_buffer_state
78
#define re_yypop_buffer_state_ALREADY_DEFINED
79
#else
80
22.4k
#define yypop_buffer_state re_yypop_buffer_state
81
#endif
82
83
#ifdef yyensure_buffer_stack
84
#define re_yyensure_buffer_stack_ALREADY_DEFINED
85
#else
86
22.4k
#define yyensure_buffer_stack re_yyensure_buffer_stack
87
#endif
88
89
#ifdef yylex
90
#define re_yylex_ALREADY_DEFINED
91
#else
92
#define yylex re_yylex
93
#endif
94
95
#ifdef yyrestart
96
#define re_yyrestart_ALREADY_DEFINED
97
#else
98
8
#define yyrestart re_yyrestart
99
#endif
100
101
#ifdef yylex_init
102
#define re_yylex_init_ALREADY_DEFINED
103
#else
104
22.4k
#define yylex_init re_yylex_init
105
#endif
106
107
#ifdef yylex_init_extra
108
#define re_yylex_init_extra_ALREADY_DEFINED
109
#else
110
#define yylex_init_extra re_yylex_init_extra
111
#endif
112
113
#ifdef yylex_destroy
114
#define re_yylex_destroy_ALREADY_DEFINED
115
#else
116
22.4k
#define yylex_destroy re_yylex_destroy
117
#endif
118
119
#ifdef yyget_debug
120
#define re_yyget_debug_ALREADY_DEFINED
121
#else
122
#define yyget_debug re_yyget_debug
123
#endif
124
125
#ifdef yyset_debug
126
#define re_yyset_debug_ALREADY_DEFINED
127
#else
128
#define yyset_debug re_yyset_debug
129
#endif
130
131
#ifdef yyget_extra
132
#define re_yyget_extra_ALREADY_DEFINED
133
#else
134
#define yyget_extra re_yyget_extra
135
#endif
136
137
#ifdef yyset_extra
138
#define re_yyset_extra_ALREADY_DEFINED
139
#else
140
22.4k
#define yyset_extra re_yyset_extra
141
#endif
142
143
#ifdef yyget_in
144
#define re_yyget_in_ALREADY_DEFINED
145
#else
146
#define yyget_in re_yyget_in
147
#endif
148
149
#ifdef yyset_in
150
#define re_yyset_in_ALREADY_DEFINED
151
#else
152
#define yyset_in re_yyset_in
153
#endif
154
155
#ifdef yyget_out
156
#define re_yyget_out_ALREADY_DEFINED
157
#else
158
#define yyget_out re_yyget_out
159
#endif
160
161
#ifdef yyset_out
162
#define re_yyset_out_ALREADY_DEFINED
163
#else
164
#define yyset_out re_yyset_out
165
#endif
166
167
#ifdef yyget_leng
168
#define re_yyget_leng_ALREADY_DEFINED
169
#else
170
#define yyget_leng re_yyget_leng
171
#endif
172
173
#ifdef yyget_text
174
#define re_yyget_text_ALREADY_DEFINED
175
#else
176
#define yyget_text re_yyget_text
177
#endif
178
179
#ifdef yyget_lineno
180
#define re_yyget_lineno_ALREADY_DEFINED
181
#else
182
#define yyget_lineno re_yyget_lineno
183
#endif
184
185
#ifdef yyset_lineno
186
#define re_yyset_lineno_ALREADY_DEFINED
187
#else
188
#define yyset_lineno re_yyset_lineno
189
#endif
190
191
#ifdef yyget_column
192
#define re_yyget_column_ALREADY_DEFINED
193
#else
194
#define yyget_column re_yyget_column
195
#endif
196
197
#ifdef yyset_column
198
#define re_yyset_column_ALREADY_DEFINED
199
#else
200
#define yyset_column re_yyset_column
201
#endif
202
203
#ifdef yywrap
204
#define re_yywrap_ALREADY_DEFINED
205
#else
206
22.2k
#define yywrap re_yywrap
207
#endif
208
209
#ifdef yyget_lval
210
#define re_yyget_lval_ALREADY_DEFINED
211
#else
212
#define yyget_lval re_yyget_lval
213
#endif
214
215
#ifdef yyset_lval
216
#define re_yyset_lval_ALREADY_DEFINED
217
#else
218
#define yyset_lval re_yyset_lval
219
#endif
220
221
#ifdef yyalloc
222
#define re_yyalloc_ALREADY_DEFINED
223
#else
224
89.7k
#define yyalloc re_yyalloc
225
#endif
226
227
#ifdef yyrealloc
228
#define re_yyrealloc_ALREADY_DEFINED
229
#else
230
0
#define yyrealloc re_yyrealloc
231
#endif
232
233
#ifdef yyfree
234
#define re_yyfree_ALREADY_DEFINED
235
#else
236
112k
#define yyfree re_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
22.4k
#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
5.87M
#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
156k
#define yyin yyg->yyin_r
345
89.7k
#define yyout yyg->yyout_r
346
73.1k
#define yyextra yyg->yyextra_r
347
6.29M
#define yyleng yyg->yyleng_r
348
3.72M
#define yytext yyg->yytext_r
349
0
#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
350
0
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
351
0
#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
1.86k
#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
44.5k
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
366
/* Special action meaning "start processing a new file". */
367
0
#define YY_NEW_FILE yyrestart( yyin , yyscanner )
368
3.30M
#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
0
#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
0
#define EOB_ACT_CONTINUE_SCAN 0
398
44.5k
#define EOB_ACT_END_OF_FILE 1
399
45.4k
#define EOB_ACT_LAST_MATCH 2
400
    
401
    /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
402
     *       access to the local variable yy_act. Since yyless() is a macro, it would break
403
     *       existing scanners that call yyless() from OUTSIDE yylex.
404
     *       One obvious solution it to make yy_act a global. I tried that, and saw
405
     *       a 5% performance hit in a non-yylineno scanner, because yy_act is
406
     *       normally declared as a register variable-- so it is not worth it.
407
     */
408
    #define  YY_LESS_LINENO(n) \
409
            do { \
410
                int yyl;\
411
                for ( yyl = n; yyl < yyleng; ++yyl )\
412
                    if ( yytext[yyl] == '\n' )\
413
                        --yylineno;\
414
            }while(0)
415
    #define YY_LINENO_REWIND_TO(dst) \
416
            do {\
417
                const char *p;\
418
                for ( p = yy_cp-1; p >= (dst); --p)\
419
                    if ( *p == '\n' )\
420
                        --yylineno;\
421
            }while(0)
422
    
423
/* Return all but the first "n" matched characters back to the input stream. */
424
#define yyless(n) \
425
  do \
426
    { \
427
    /* Undo effects of setting up yytext. */ \
428
        int yyless_macro_arg = (n); \
429
        YY_LESS_LINENO(yyless_macro_arg);\
430
    *yy_cp = yyg->yy_hold_char; \
431
    YY_RESTORE_YY_MORE_OFFSET \
432
    yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
433
    YY_DO_BEFORE_ACTION; /* set up yytext again */ \
434
    } \
435
  while ( 0 )
436
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
437
438
#ifndef YY_STRUCT_YY_BUFFER_STATE
439
#define YY_STRUCT_YY_BUFFER_STATE
440
struct yy_buffer_state
441
  {
442
  FILE *yy_input_file;
443
444
  char *yy_ch_buf;    /* input buffer */
445
  char *yy_buf_pos;   /* current position in input buffer */
446
447
  /* Size of input buffer in bytes, not including room for EOB
448
   * characters.
449
   */
450
  int yy_buf_size;
451
452
  /* Number of characters read into yy_ch_buf, not including EOB
453
   * characters.
454
   */
455
  int yy_n_chars;
456
457
  /* Whether we "own" the buffer - i.e., we know we created it,
458
   * and can realloc() it to grow it, and should free() it to
459
   * delete it.
460
   */
461
  int yy_is_our_buffer;
462
463
  /* Whether this is an "interactive" input source; if so, and
464
   * if we're using stdio for input, then we want to use getc()
465
   * instead of fread(), to make sure we stop fetching input after
466
   * each newline.
467
   */
468
  int yy_is_interactive;
469
470
  /* Whether we're considered to be at the beginning of a line.
471
   * If so, '^' rules will be active on the next match, otherwise
472
   * not.
473
   */
474
  int yy_at_bol;
475
476
    int yy_bs_lineno; /**< The line count. */
477
    int yy_bs_column; /**< The column count. */
478
479
  /* Whether to try to fill the input buffer when we reach the
480
   * end of it.
481
   */
482
  int yy_fill_buffer;
483
484
  int yy_buffer_status;
485
486
67.4k
#define YY_BUFFER_NEW 0
487
22.3k
#define YY_BUFFER_NORMAL 1
488
  /* When an EOF's been seen but there's still some text to process
489
   * then we mark the buffer as YY_EOF_PENDING, to indicate that we
490
   * shouldn't try reading from the input source any more.  We might
491
   * still have a bunch of tokens to match, though, because of
492
   * possible backing-up.
493
   *
494
   * When we actually see the EOF, we change the status to "new"
495
   * (via yyrestart()), so that the user can continue scanning by
496
   * just pointing yyin at a new input file.
497
   */
498
0
#define YY_BUFFER_EOF_PENDING 2
499
500
  };
501
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
502
503
/* We provide macros for accessing buffer states in case in the
504
 * future we want to put the buffer states in a more general
505
 * "scanner state".
506
 *
507
 * Returns the top of the stack, or NULL.
508
 */
509
179k
#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
510
179k
                          ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
511
179k
                          : NULL)
512
/* Same as previous macro, but useful when we know that the buffer stack is not
513
 * NULL or when we need an lvalue. For internal use only.
514
 */
515
516k
#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
516
517
void yyrestart ( FILE *input_file , yyscan_t yyscanner );
518
void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
519
YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
520
void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
521
void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
522
void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
523
void yypop_buffer_state ( yyscan_t yyscanner );
524
525
static void yyensure_buffer_stack ( yyscan_t yyscanner );
526
static void yy_load_buffer_state ( yyscan_t yyscanner );
527
static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
528
#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)
529
530
YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
531
YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
532
YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
533
534
void *yyalloc ( yy_size_t , yyscan_t yyscanner );
535
void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
536
void yyfree ( void * , yyscan_t yyscanner );
537
538
#define yy_new_buffer yy_create_buffer
539
#define yy_set_interactive(is_interactive) \
540
  { \
541
  if ( ! YY_CURRENT_BUFFER ){ \
542
        yyensure_buffer_stack (yyscanner); \
543
    YY_CURRENT_BUFFER_LVALUE =    \
544
            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
545
  } \
546
  YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
547
  }
548
#define yy_set_bol(at_bol) \
549
  { \
550
  if ( ! YY_CURRENT_BUFFER ){\
551
        yyensure_buffer_stack (yyscanner); \
552
    YY_CURRENT_BUFFER_LVALUE =    \
553
            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
554
  } \
555
  YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
556
  }
557
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
558
559
/* Begin user sect3 */
560
561
22.2k
#define re_yywrap(yyscanner) (/*CONSTCOND*/1)
562
#define YY_SKIP_YYWRAP
563
typedef flex_uint8_t YY_CHAR;
564
565
typedef int yy_state_type;
566
567
3.17M
#define yytext_ptr yytext_r
568
569
static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
570
static yy_state_type yy_try_NUL_trans ( yy_state_type current_state  , yyscan_t yyscanner);
571
static int yy_get_next_buffer ( yyscan_t yyscanner );
572
static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
573
574
/* Done after the current pattern has been matched and before the
575
 * corresponding action - sets up yytext.
576
 */
577
#define YY_DO_BEFORE_ACTION \
578
2.92M
  yyg->yytext_ptr = yy_bp; \
579
2.92M
  yyleng = (int) (yy_cp - yy_bp); \
580
2.92M
  yyg->yy_hold_char = *yy_cp; \
581
2.92M
  *yy_cp = '\0'; \
582
2.92M
  yyg->yy_c_buf_p = yy_cp;
583
#define YY_NUM_RULES 29
584
5.94M
#define YY_END_OF_BUFFER 30
585
/* This struct is not used in this scanner,
586
   but its presence is necessary. */
587
struct yy_trans_info
588
  {
589
  flex_int32_t yy_verify;
590
  flex_int32_t yy_nxt;
591
  };
592
static const flex_int16_t yy_accept[45] =
593
    {   0,
594
        0,    0,    0,    0,   30,    7,    7,   28,    6,   17,
595
        7,   27,   29,   26,   18,    5,    3,   16,   15,   13,
596
       11,    9,   14,   12,   10,    8,    0,    0,    0,    0,
597
       25,   23,   21,   24,   22,   20,    0,    4,    0,    1,
598
        2,   19,    0,    0
599
    } ;
600
601
static const YY_CHAR yy_ec[256] =
602
    {   0,
603
        1,    1,    1,    1,    1,    1,    1,    1,    1,    2,
604
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
605
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
606
        1,    1,    1,    1,    1,    3,    1,    1,    1,    3,
607
        3,    3,    3,    4,    5,    3,    1,    6,    6,    6,
608
        6,    6,    6,    6,    6,    6,    6,    1,    1,    1,
609
        1,    1,    3,    1,    7,    8,    7,    9,    7,    7,
610
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
611
        1,    1,   10,    1,    1,    1,   11,    1,    1,    1,
612
       12,   13,   14,   15,    1,    1,    7,   16,    7,   17,
613
614
        7,    7,    1,    1,    1,    1,    1,    1,    1,    1,
615
        1,    1,    1,    1,   18,    1,    1,    1,   19,   20,
616
        1,    1,   21,    3,   22,    1,    1,    1,    1,    1,
617
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
618
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
619
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
620
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
621
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
622
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
623
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
624
625
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
626
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
627
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
628
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
629
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
630
        1,    1,    1,    1,    1
631
    } ;
632
633
static const YY_CHAR yy_meta[23] =
634
    {   0,
635
        1,    2,    1,    1,    3,    4,    4,    4,    4,    1,
636
        1,    1,    1,    5,    1,    4,    4,    1,    1,    1,
637
        1,    1
638
    } ;
639
640
static const flex_int16_t yy_base[51] =
641
    {   0,
642
        0,   20,    3,    5,   49,   89,   89,   89,   10,   36,
643
        0,   43,   38,   47,   89,   89,   26,   33,   89,   89,
644
       89,   89,   89,   89,   89,   89,    4,    5,    0,   33,
645
       32,   31,   29,   26,   24,   23,   15,   89,    8,   89,
646
       89,   89,    0,   89,   67,   72,   77,   82,   84,    4
647
    } ;
648
649
static const flex_int16_t yy_def[51] =
650
    {   0,
651
       45,   45,   46,   46,   44,   44,   44,   44,   44,   44,
652
       44,   44,   44,   47,   44,   44,   44,   44,   44,   44,
653
       44,   44,   44,   44,   44,   44,   44,   44,   48,   44,
654
       44,   44,   44,   44,   44,   44,   49,   44,   44,   44,
655
       44,   44,   50,    0,   44,   44,   44,   44,   44,   44
656
    } ;
657
658
static const flex_int16_t yy_nxt[112] =
659
    {   0,
660
       44,    7,    8,   27,   13,   28,   13,   30,   27,   39,
661
       28,    9,   10,   39,    8,   14,   15,   14,   15,   29,
662
       11,    7,    8,   16,   17,   40,   41,   29,   29,   40,
663
       29,    9,   10,   29,    8,   29,   29,   29,   18,   38,
664
       11,   18,   29,   19,   20,   21,   22,   29,   44,   44,
665
       44,   23,   24,   25,   26,   31,   32,   33,   44,   44,
666
       44,   44,   44,   34,   35,   36,   37,    6,    6,    6,
667
        6,    6,   12,   12,   12,   12,   12,   30,   44,   30,
668
       30,   30,   42,   42,   42,   42,   43,   43,    5,   44,
669
       44,   44,   44,   44,   44,   44,   44,   44,   44,   44,
670
671
       44,   44,   44,   44,   44,   44,   44,   44,   44,   44,
672
       44
673
    } ;
674
675
static const flex_int16_t yy_chk[112] =
676
    {   0,
677
        0,    1,    1,   11,    3,   11,    4,   50,   28,   27,
678
       28,    1,    1,   39,    1,    3,    3,    4,    4,   37,
679
        1,    2,    2,    9,    9,   27,   28,   36,   35,   39,
680
       34,    2,    2,   33,    2,   32,   31,   30,   18,   17,
681
        2,   10,   13,   10,   10,   10,   10,   12,    5,    0,
682
        0,   10,   10,   10,   10,   14,   14,   14,    0,    0,
683
        0,    0,    0,   14,   14,   14,   14,   45,   45,   45,
684
       45,   45,   46,   46,   46,   46,   46,   47,    0,   47,
685
       47,   47,   48,   48,   48,   48,   49,   49,   44,   44,
686
       44,   44,   44,   44,   44,   44,   44,   44,   44,   44,
687
688
       44,   44,   44,   44,   44,   44,   44,   44,   44,   44,
689
       44
690
    } ;
691
692
/* Table of booleans, true if rule could match eol. */
693
static const flex_int32_t yy_rule_can_match_eol[30] =
694
    {   0,
695
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
696
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,     };
697
698
/* The intent behind this definition is that it'll catch
699
 * any uses of REJECT which flex missed.
700
 */
701
#define REJECT reject_used_but_not_detected
702
#define yymore() yymore_used_but_not_detected
703
112k
#define YY_MORE_ADJ 0
704
#define YY_RESTORE_YY_MORE_OFFSET
705
#line 1 "re_lexer.l"
706
/*
707
Copyright (c) 2013. The YARA Authors. All Rights Reserved.
708
709
Redistribution and use in source and binary forms, with or without modification,
710
are permitted provided that the following conditions are met:
711
712
1. Redistributions of source code must retain the above copyright notice, this
713
list of conditions and the following disclaimer.
714
715
2. Redistributions in binary form must reproduce the above copyright notice,
716
this list of conditions and the following disclaimer in the documentation and/or
717
other materials provided with the distribution.
718
719
3. Neither the name of the copyright holder nor the names of its contributors
720
may be used to endorse or promote products derived from this software without
721
specific prior written permission.
722
723
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
724
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
725
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
726
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
727
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
728
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
729
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
730
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
731
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
732
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
733
*/
734
/* Lexical analyzer for regular expressions */
735
#line 33 "re_lexer.l"
736
737
/* Disable warnings for unused functions in this file.
738
739
As we redefine YY_FATAL_ERROR macro to use our own function re_yyfatal, the
740
yy_fatal_error function generated by Flex is not actually used, causing a
741
compiler warning. Flex doesn't offer any options to remove the yy_fatal_error
742
function. When they include something like %option noyy_fatal_error as they do
743
with noyywrap then we can remove this pragma.
744
*/
745
746
#ifdef __GNUC__
747
#pragma GCC diagnostic ignored "-Wunused-function"
748
#endif
749
750
#include <assert.h>
751
#include <setjmp.h>
752
753
#include <yara/globals.h>
754
#include <yara/utils.h>
755
#include <yara/error.h>
756
#include <yara/limits.h>
757
#include <yara/mem.h>
758
#include <yara/re.h>
759
#include <yara/re_lexer.h>
760
#include <yara/threading.h>
761
#include <yara/strutils.h>
762
763
764
#ifdef _WIN32
765
#define snprintf _snprintf
766
#endif
767
768
// Bitmap with 1 bit for each of the 256 characters in the ASCII table. The bit
769
// is set to 1 if the corresponding character is alphanumeric or 0 if otherwise.
770
static uint8_t word_chars[] = {
771
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03,
772
    0xFE, 0xFF, 0xFF, 0x87, 0xFE, 0xFF, 0xFF, 0x07,
773
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
774
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
775
776
// Bitmap with 1 bit for each of the 256 characters in the ASCII table. The bit
777
// is set to 1 if the corresponding character is considered a space. Space
778
// characters include horizontal and vertical tabs, carriage return, new line
779
// and form feed (\t, \v, \r, \n, \f).
780
static uint8_t space_chars[] = {
781
    0x00, 0x3E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
782
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
783
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
784
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
785
786
int escaped_char_value(
787
    char* text,
788
    uint8_t* value);
789
790
int read_escaped_char(
791
    yyscan_t yyscanner,
792
    uint8_t* escaped_char);
793
794
#line 795 "re_lexer.c"
795
#define YY_NO_UNISTD_H 1
796
797
#line 798 "re_lexer.c"
798
799
858
#define INITIAL 0
800
1.01k
#define char_class 1
801
802
#ifndef YY_NO_UNISTD_H
803
/* Special case for "unistd.h", since it is non-ANSI. We include it way
804
 * down here because we want the user's section 1 to have been scanned first.
805
 * The user has a chance to override it with an option.
806
 */
807
#include <unistd.h>
808
#endif
809
810
#ifndef YY_EXTRA_TYPE
811
#define YY_EXTRA_TYPE void *
812
#endif
813
814
/* Holds the entire state of the reentrant scanner. */
815
struct yyguts_t
816
    {
817
818
    /* User-defined. Not touched by flex. */
819
    YY_EXTRA_TYPE yyextra_r;
820
821
    /* The rest are the same as the globals declared in the non-reentrant scanner. */
822
    FILE *yyin_r, *yyout_r;
823
    size_t yy_buffer_stack_top; /**< index of top of stack. */
824
    size_t yy_buffer_stack_max; /**< capacity of stack. */
825
    YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
826
    char yy_hold_char;
827
    int yy_n_chars;
828
    int yyleng_r;
829
    char *yy_c_buf_p;
830
    int yy_init;
831
    int yy_start;
832
    int yy_did_buffer_switch_on_eof;
833
    int yy_start_stack_ptr;
834
    int yy_start_stack_depth;
835
    int *yy_start_stack;
836
    yy_state_type yy_last_accepting_state;
837
    char* yy_last_accepting_cpos;
838
839
    int yylineno_r;
840
    int yy_flex_debug_r;
841
842
    char *yytext_r;
843
    int yy_more_flag;
844
    int yy_more_len;
845
846
    YYSTYPE * yylval_r;
847
848
    }; /* end struct yyguts_t */
849
850
static int yy_init_globals ( yyscan_t yyscanner );
851
852
    /* This must go here because YYSTYPE and YYLTYPE are included
853
     * from bison output in section 1.*/
854
5.65M
    #    define yylval yyg->yylval_r
855
    
856
int yylex_init (yyscan_t* scanner);
857
858
int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
859
860
/* Accessor methods to globals.
861
   These are made visible to non-reentrant scanners for convenience. */
862
863
int yylex_destroy ( yyscan_t yyscanner );
864
865
int yyget_debug ( yyscan_t yyscanner );
866
867
void yyset_debug ( int debug_flag , yyscan_t yyscanner );
868
869
YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
870
871
void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
872
873
FILE *yyget_in ( yyscan_t yyscanner );
874
875
void yyset_in  ( FILE * _in_str , yyscan_t yyscanner );
876
877
FILE *yyget_out ( yyscan_t yyscanner );
878
879
void yyset_out  ( FILE * _out_str , yyscan_t yyscanner );
880
881
      int yyget_leng ( yyscan_t yyscanner );
882
883
char *yyget_text ( yyscan_t yyscanner );
884
885
int yyget_lineno ( yyscan_t yyscanner );
886
887
void yyset_lineno ( int _line_number , yyscan_t yyscanner );
888
889
int yyget_column  ( yyscan_t yyscanner );
890
891
void yyset_column ( int _column_no , yyscan_t yyscanner );
892
893
YYSTYPE * yyget_lval ( yyscan_t yyscanner );
894
895
void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );
896
897
/* Macros after this point can all be overridden by user definitions in
898
 * section 1.
899
 */
900
901
#ifndef YY_SKIP_YYWRAP
902
#ifdef __cplusplus
903
extern "C" int yywrap ( yyscan_t yyscanner );
904
#else
905
extern int yywrap ( yyscan_t yyscanner );
906
#endif
907
#endif
908
909
#ifndef YY_NO_UNPUT
910
    
911
#endif
912
913
#ifndef yytext_ptr
914
static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
915
#endif
916
917
#ifdef YY_NEED_STRLEN
918
static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
919
#endif
920
921
#ifndef YY_NO_INPUT
922
#ifdef __cplusplus
923
static int yyinput ( yyscan_t yyscanner );
924
#else
925
static int input ( yyscan_t yyscanner );
926
#endif
927
928
#endif
929
930
/* Amount of stuff to slurp up with each read. */
931
#ifndef YY_READ_BUF_SIZE
932
#ifdef __ia64__
933
/* On IA-64, the buffer size is 16k, not 8k */
934
#define YY_READ_BUF_SIZE 16384
935
#else
936
0
#define YY_READ_BUF_SIZE 8192
937
#endif /* __ia64__ */
938
#endif
939
940
/* Copy whatever the last rule matched to the standard output. */
941
#ifndef ECHO
942
/* This used to be an fputs(), but since the string might contain NUL's,
943
 * we now use fwrite().
944
 */
945
0
#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
946
#endif
947
948
/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
949
 * is returned in "result".
950
 */
951
#ifndef YY_INPUT
952
#define YY_INPUT(buf,result,max_size) \
953
0
  if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
954
0
    { \
955
0
    int c = '*'; \
956
0
    int n; \
957
0
    for ( n = 0; n < max_size && \
958
0
           (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
959
0
      buf[n] = (char) c; \
960
0
    if ( c == '\n' ) \
961
0
      buf[n++] = (char) c; \
962
0
    if ( c == EOF && ferror( yyin ) ) \
963
0
      YY_FATAL_ERROR( "input in flex scanner failed" ); \
964
0
    result = n; \
965
0
    } \
966
0
  else \
967
0
    { \
968
0
    errno=0; \
969
0
    while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
970
0
      { \
971
0
      if( errno != EINTR) \
972
0
        { \
973
0
        YY_FATAL_ERROR( "input in flex scanner failed" ); \
974
0
        break; \
975
0
        } \
976
0
      errno=0; \
977
0
      clearerr(yyin); \
978
0
      } \
979
0
    }\
980
\
981
982
#endif
983
984
/* No semi-colon after return; correct usage is to write "yyterminate();" -
985
 * we don't want an extra ';' after the "return" because that will cause
986
 * some compilers to complain about unreachable statements.
987
 */
988
#ifndef yyterminate
989
22.4k
#define yyterminate() return YY_NULL
990
#endif
991
992
/* Number of entries by which start-condition stack grows. */
993
#ifndef YY_START_STACK_INCR
994
#define YY_START_STACK_INCR 25
995
#endif
996
997
/* Report a fatal error. */
998
#ifndef YY_FATAL_ERROR
999
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
1000
#endif
1001
1002
/* end tables serialization structures and prototypes */
1003
1004
/* Default declaration of generated scanner - a define so the user can
1005
 * easily add parameters.
1006
 */
1007
#ifndef YY_DECL
1008
#define YY_DECL_IS_OURS 1
1009
1010
extern int yylex \
1011
               (YYSTYPE * yylval_param , yyscan_t yyscanner);
1012
1013
#define YY_DECL int yylex \
1014
               (YYSTYPE * yylval_param , yyscan_t yyscanner)
1015
#endif /* !YY_DECL */
1016
1017
/* Code executed at the beginning of each rule, after yytext and yyleng
1018
 * have been set up.
1019
 */
1020
#ifndef YY_USER_ACTION
1021
#define YY_USER_ACTION
1022
#endif
1023
1024
/* Code executed at the end of each rule. */
1025
#ifndef YY_BREAK
1026
12.4k
#define YY_BREAK /*LINTED*/break;
1027
#endif
1028
1029
#define YY_RULE_SETUP \
1030
  YY_USER_ACTION
1031
1032
/** The main scanner function which does all the work.
1033
 */
1034
YY_DECL
1035
2.89M
{
1036
2.89M
  yy_state_type yy_current_state;
1037
2.89M
  char *yy_cp, *yy_bp;
1038
2.89M
  int yy_act;
1039
2.89M
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1040
1041
2.89M
    yylval = yylval_param;
1042
1043
2.89M
  if ( !yyg->yy_init )
1044
22.4k
    {
1045
22.4k
    yyg->yy_init = 1;
1046
1047
#ifdef YY_USER_INIT
1048
    YY_USER_INIT;
1049
#endif
1050
1051
22.4k
    if ( ! yyg->yy_start )
1052
22.4k
      yyg->yy_start = 1; /* first start state */
1053
1054
22.4k
    if ( ! yyin )
1055
22.4k
      yyin = stdin;
1056
1057
22.4k
    if ( ! yyout )
1058
22.4k
      yyout = stdout;
1059
1060
22.4k
    if ( ! YY_CURRENT_BUFFER ) {
1061
0
      yyensure_buffer_stack (yyscanner);
1062
0
      YY_CURRENT_BUFFER_LVALUE =
1063
0
        yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
1064
0
    }
1065
1066
22.4k
    yy_load_buffer_state( yyscanner );
1067
22.4k
    }
1068
1069
2.89M
  {
1070
2.89M
#line 111 "re_lexer.l"
1071
1072
1073
2.89M
#line 1074 "re_lexer.c"
1074
1075
2.90M
  while ( /*CONSTCOND*/1 )    /* loops until end-of-file is reached */
1076
2.90M
    {
1077
2.90M
    yy_cp = yyg->yy_c_buf_p;
1078
1079
    /* Support of yytext. */
1080
2.90M
    *yy_cp = yyg->yy_hold_char;
1081
1082
    /* yy_bp points to the position in yy_ch_buf of the start of
1083
     * the current run.
1084
     */
1085
2.90M
    yy_bp = yy_cp;
1086
1087
2.90M
    yy_current_state = yyg->yy_start;
1088
2.90M
yy_match:
1089
2.90M
    do
1090
5.85M
      {
1091
5.85M
      YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
1092
5.85M
      if ( yy_accept[yy_current_state] )
1093
2.94M
        {
1094
2.94M
        yyg->yy_last_accepting_state = yy_current_state;
1095
2.94M
        yyg->yy_last_accepting_cpos = yy_cp;
1096
2.94M
        }
1097
10.4M
      while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1098
4.61M
        {
1099
4.61M
        yy_current_state = (int) yy_def[yy_current_state];
1100
4.61M
        if ( yy_current_state >= 45 )
1101
1.70M
          yy_c = yy_meta[yy_c];
1102
4.61M
        }
1103
5.85M
      yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1104
5.85M
      ++yy_cp;
1105
5.85M
      }
1106
5.85M
    while ( yy_current_state != 44 );
1107
2.90M
    yy_cp = yyg->yy_last_accepting_cpos;
1108
2.90M
    yy_current_state = yyg->yy_last_accepting_state;
1109
1110
2.92M
yy_find_action:
1111
2.92M
    yy_act = yy_accept[yy_current_state];
1112
1113
2.92M
    YY_DO_BEFORE_ACTION;
1114
1115
2.92M
    if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
1116
1.68M
      {
1117
1.68M
      int yyl;
1118
3.36M
      for ( yyl = 0; yyl < yyleng; ++yyl )
1119
1.68M
        if ( yytext[yyl] == '\n' )
1120
          
1121
0
    do{ yylineno++;
1122
0
        yycolumn=0;
1123
0
    }while(0)
1124
1.68M
;
1125
1.68M
      }
1126
1127
2.94M
do_action:  /* This label is used only to access EOF actions. */
1128
1129
2.94M
    switch ( yy_act )
1130
2.94M
  { /* beginning of action switch */
1131
400
      case 0: /* must back up */
1132
      /* undo the effects of YY_DO_BEFORE_ACTION */
1133
400
      *yy_cp = yyg->yy_hold_char;
1134
400
      yy_cp = yyg->yy_last_accepting_cpos;
1135
400
      yy_current_state = yyg->yy_last_accepting_state;
1136
400
      goto yy_find_action;
1137
1138
3.44k
case 1:
1139
3.44k
YY_RULE_SETUP
1140
3.44k
#line 113 "re_lexer.l"
1141
3.44k
{
1142
1143
  // Examples: {3,8} {0,5} {,5} {7,}
1144
1145
3.44k
  int hi_bound;
1146
3.44k
  int lo_bound = atoi(yytext + 1);
1147
1148
3.44k
  char* comma = strchr(yytext, ',');
1149
1150
3.44k
  if (comma - yytext == strlen(yytext) - 2)
1151
    // if comma is followed by the closing curly bracket
1152
    // (example: {2,}) set high bound value to maximum.
1153
3.18k
    hi_bound = RE_MAX_RANGE;
1154
255
  else
1155
255
    hi_bound = atoi(comma + 1);
1156
1157
3.44k
  if (hi_bound > RE_MAX_RANGE)
1158
0
  {
1159
0
    yyerror(yyscanner, lex_env, "repeat interval too large");
1160
0
    yyterminate();
1161
0
  }
1162
1163
3.44k
  if (hi_bound < lo_bound || hi_bound < 0 || lo_bound < 0)
1164
6
  {
1165
6
    yyerror(yyscanner, lex_env, "bad repeat interval");
1166
6
    yyterminate();
1167
6
  }
1168
1169
3.43k
  if (hi_bound == 0 && lo_bound == 0)
1170
0
  {
1171
0
    yyerror(yyscanner, lex_env, "bad repeat interval");
1172
0
    yyterminate();
1173
0
  }
1174
1175
3.43k
  yylval->range = (hi_bound << 16) | lo_bound;
1176
1177
3.43k
  return _RANGE_;
1178
3.43k
}
1179
0
  YY_BREAK
1180
1.40k
case 2:
1181
1.40k
YY_RULE_SETUP
1182
1.40k
#line 153 "re_lexer.l"
1183
1.40k
{
1184
1185
  // Example: {10}
1186
1187
1.40k
  int value = atoi(yytext + 1);
1188
1189
  // atoi can return a negative value if the input string represents a number
1190
  // too large to fit in an integer.
1191
1192
1.40k
  if (value > RE_MAX_RANGE || value < 0)
1193
5
  {
1194
5
    yyerror(yyscanner, lex_env, "repeat interval too large");
1195
5
    yyterminate();
1196
5
  }
1197
1198
1.39k
  if (value == 0)
1199
5
  {
1200
5
    yyerror(yyscanner, lex_env, "bad repeat interval");
1201
5
    yyterminate();
1202
5
  }
1203
1204
1.39k
  yylval->range = (value << 16) | value;
1205
1206
1.39k
  return _RANGE_;
1207
1.39k
}
1208
0
  YY_BREAK
1209
152
case 3:
1210
152
YY_RULE_SETUP
1211
152
#line 180 "re_lexer.l"
1212
152
{
1213
1214
  // Start of a negated character class. Example: [^abcd]
1215
1216
152
  BEGIN(char_class);
1217
152
  memset(LEX_ENV->re_class.bitmap, 0, 32);
1218
152
  LEX_ENV->re_class.negated = true;
1219
152
}
1220
152
  YY_BREAK
1221
149
case 4:
1222
149
YY_RULE_SETUP
1223
149
#line 189 "re_lexer.l"
1224
149
{
1225
1226
  // Start of character negated class containing a ].
1227
  // Example: [^]abc] this must be interpreted as a class
1228
  // not matching ], a, b, nor c
1229
1230
149
  BEGIN(char_class);
1231
149
  memset(LEX_ENV->re_class.bitmap, 0, 32);
1232
149
  LEX_ENV->re_class.negated = true;
1233
149
  LEX_ENV->re_class.bitmap[']' / 8] |= 1 << ']' % 8;
1234
149
}
1235
149
  YY_BREAK
1236
177
case 5:
1237
177
YY_RULE_SETUP
1238
177
#line 202 "re_lexer.l"
1239
177
{
1240
1241
  // Start of character class containing a ].
1242
  // Example: []abc] this must be interpreted as a class
1243
  // matching ], a, b, or c.
1244
1245
177
  BEGIN(char_class);
1246
177
  memset(LEX_ENV->re_class.bitmap, 0, 32);
1247
177
  LEX_ENV->re_class.negated = false;
1248
177
  LEX_ENV->re_class.bitmap[']' / 8] |= 1 << ']' % 8;
1249
177
}
1250
177
  YY_BREAK
1251
533
case 6:
1252
533
YY_RULE_SETUP
1253
533
#line 215 "re_lexer.l"
1254
533
{
1255
1256
  // Start of character class. Example: [abcd]
1257
1258
533
  BEGIN(char_class);
1259
533
  memset(LEX_ENV->re_class.bitmap, 0, 32);
1260
533
  LEX_ENV->re_class.negated = false;
1261
533
}
1262
533
  YY_BREAK
1263
1.67M
case 7:
1264
/* rule 7 can match eol */
1265
1.67M
YY_RULE_SETUP
1266
1.67M
#line 225 "re_lexer.l"
1267
1.67M
{
1268
1269
  // Any non-special character is passed as a CHAR token to the scanner.
1270
1271
1.67M
  yylval->integer = yytext[0];
1272
1.67M
  return _CHAR_;
1273
1.39k
}
1274
0
  YY_BREAK
1275
970
case 8:
1276
970
YY_RULE_SETUP
1277
970
#line 234 "re_lexer.l"
1278
970
{
1279
970
  return _WORD_CHAR_;
1280
1.39k
}
1281
0
  YY_BREAK
1282
198
case 9:
1283
198
YY_RULE_SETUP
1284
198
#line 239 "re_lexer.l"
1285
198
{
1286
198
  return _NON_WORD_CHAR_;
1287
1.39k
}
1288
0
  YY_BREAK
1289
306
case 10:
1290
306
YY_RULE_SETUP
1291
306
#line 244 "re_lexer.l"
1292
306
{
1293
306
  return _SPACE_;
1294
1.39k
}
1295
0
  YY_BREAK
1296
338
case 11:
1297
338
YY_RULE_SETUP
1298
338
#line 249 "re_lexer.l"
1299
338
{
1300
338
  return _NON_SPACE_;
1301
1.39k
}
1302
0
  YY_BREAK
1303
191
case 12:
1304
191
YY_RULE_SETUP
1305
191
#line 254 "re_lexer.l"
1306
191
{
1307
191
  return _DIGIT_;
1308
1.39k
}
1309
0
  YY_BREAK
1310
667
case 13:
1311
667
YY_RULE_SETUP
1312
667
#line 259 "re_lexer.l"
1313
667
{
1314
667
  return _NON_DIGIT_;
1315
1.39k
}
1316
0
  YY_BREAK
1317
133
case 14:
1318
133
YY_RULE_SETUP
1319
133
#line 264 "re_lexer.l"
1320
133
{
1321
133
  return _WORD_BOUNDARY_;
1322
1.39k
}
1323
0
  YY_BREAK
1324
144
case 15:
1325
144
YY_RULE_SETUP
1326
144
#line 268 "re_lexer.l"
1327
144
{
1328
144
  return _NON_WORD_BOUNDARY_;
1329
1.39k
}
1330
0
  YY_BREAK
1331
0
case 16:
1332
0
YY_RULE_SETUP
1333
0
#line 273 "re_lexer.l"
1334
0
{
1335
1336
0
  yyerror(yyscanner, lex_env, "backreferences are not allowed");
1337
0
  yyterminate();
1338
1.39k
}
1339
0
  YY_BREAK
1340
1.07M
case 17:
1341
1.07M
YY_RULE_SETUP
1342
1.07M
#line 280 "re_lexer.l"
1343
1.07M
{
1344
1345
1.07M
  uint8_t c;
1346
1347
1.07M
  if (read_escaped_char(yyscanner, &c))
1348
1.07M
  {
1349
1.07M
    yylval->integer = c;
1350
1.07M
    return _CHAR_;
1351
1.07M
  }
1352
5
  else
1353
5
  {
1354
5
    yyerror(yyscanner, lex_env, "illegal escape sequence");
1355
5
    yyterminate();
1356
5
  }
1357
1.07M
}
1358
0
  YY_BREAK
1359
858
case 18:
1360
858
YY_RULE_SETUP
1361
858
#line 297 "re_lexer.l"
1362
858
{
1363
1364
  // End of character class.
1365
858
  yylval->re_class = (RE_CLASS*) yr_malloc(sizeof(RE_CLASS));
1366
858
  memcpy(yylval->re_class->bitmap, LEX_ENV->re_class.bitmap, 32);
1367
1368
858
  yylval->re_class->negated = LEX_ENV->re_class.negated;
1369
1370
858
  BEGIN(INITIAL);
1371
858
  return _CLASS_;
1372
1.07M
}
1373
0
  YY_BREAK
1374
1.24k
case 19:
1375
/* rule 19 can match eol */
1376
1.24k
YY_RULE_SETUP
1377
1.24k
#line 311 "re_lexer.l"
1378
1.24k
{
1379
1380
  // A range inside a character class. The regexp is...
1381
  //
1382
  //   ( \x{hex_digit}{2}    Hex digit (i.e: \x01) ...
1383
  //   | \.                  ...or any escaped character (i.e. \\, \-) ...
1384
  //   | [^]\]               ...or any character except ] and \ ...
1385
  //   )
1386
  //   -                     ... followed by -
1387
  //   [^]]                  ... followed by any character except ]
1388
  //
1389
  // Some examples:
1390
  //
1391
  //  [abc0-9]
1392
  //      ^-^ matching range 0-9
1393
  //
1394
  //  [a-za-]
1395
  //   ^-^- matching range a-z
1396
  //
1397
  //  [\.-a]
1398
  //   ^--^- matching range \.-a
1399
  //
1400
1401
1.24k
  uint16_t c;
1402
1.24k
  uint8_t start = yytext[0];
1403
1.24k
  uint8_t end = yytext[2];
1404
1405
1.24k
  if (start == '\\')
1406
517
  {
1407
517
    if (!escaped_char_value(yytext, &start))
1408
0
    {
1409
0
      yyerror(yyscanner, lex_env, "illegal escape sequence");
1410
0
      yyterminate();
1411
0
    }
1412
1413
517
    if (yytext[1] == 'x')
1414
190
      end = yytext[5];
1415
327
    else
1416
327
      end = yytext[3];
1417
517
  }
1418
1419
1.24k
  if (end == '\\')
1420
513
  {
1421
513
    if (!read_escaped_char(yyscanner, &end))
1422
10
    {
1423
10
      yyerror(yyscanner, lex_env, "illegal escape sequence");
1424
10
      yyterminate();
1425
10
    }
1426
513
  }
1427
1428
1.23k
  if (end < start)
1429
63
  {
1430
63
    yyerror(yyscanner, lex_env, "bad character range");
1431
63
    yyterminate();
1432
63
  }
1433
1434
79.9k
  for (c = start; c <= end; c++)
1435
78.8k
  {
1436
78.8k
    LEX_ENV->re_class.bitmap[c / 8] |= 1 << c % 8;
1437
78.8k
  }
1438
1.17k
}
1439
1.17k
  YY_BREAK
1440
803
case 20:
1441
803
YY_RULE_SETUP
1442
803
#line 374 "re_lexer.l"
1443
803
{
1444
1445
26.4k
  for (int i = 0; i < 32; i++)
1446
25.6k
    LEX_ENV->re_class.bitmap[i] |= word_chars[i];
1447
803
}
1448
803
  YY_BREAK
1449
716
case 21:
1450
716
YY_RULE_SETUP
1451
716
#line 381 "re_lexer.l"
1452
716
{
1453
1454
23.6k
  for (int i = 0; i < 32; i++)
1455
22.9k
    LEX_ENV->re_class.bitmap[i] |= ~word_chars[i];
1456
716
}
1457
716
  YY_BREAK
1458
701
case 22:
1459
701
YY_RULE_SETUP
1460
701
#line 388 "re_lexer.l"
1461
701
{
1462
1463
23.1k
  for (int i = 0; i < 32; i++)
1464
22.4k
    LEX_ENV->re_class.bitmap[i] |= space_chars[i];
1465
701
}
1466
701
  YY_BREAK
1467
722
case 23:
1468
722
YY_RULE_SETUP
1469
722
#line 395 "re_lexer.l"
1470
722
{
1471
1472
23.8k
  for (int i = 0; i < 32; i++)
1473
23.1k
    LEX_ENV->re_class.bitmap[i] |= ~space_chars[i];
1474
722
}
1475
722
  YY_BREAK
1476
299
case 24:
1477
299
YY_RULE_SETUP
1478
299
#line 402 "re_lexer.l"
1479
299
{
1480
1481
3.28k
  for (char c = '0'; c <= '9'; c++)
1482
2.99k
    LEX_ENV->re_class.bitmap[c / 8] |= 1 << c % 8;
1483
299
}
1484
299
  YY_BREAK
1485
739
case 25:
1486
739
YY_RULE_SETUP
1487
739
#line 409 "re_lexer.l"
1488
739
{
1489
1490
24.3k
  for (int i = 0; i < 32; i++)
1491
23.6k
  {
1492
    // digits 0-7 are in the sixth byte of the vector, let that byte alone
1493
23.6k
    if (i == 6)
1494
739
      continue;
1495
1496
    // digits 8 and 9 are the lowest two bits in the seventh byte of the
1497
    // vector, let those bits alone.
1498
22.9k
    if (i == 7)
1499
739
      LEX_ENV->re_class.bitmap[i] |= 0xFC;
1500
22.1k
    else
1501
22.1k
      LEX_ENV->re_class.bitmap[i] = 0xFF;
1502
22.9k
  }
1503
739
}
1504
739
  YY_BREAK
1505
939
case 26:
1506
939
YY_RULE_SETUP
1507
939
#line 427 "re_lexer.l"
1508
939
{
1509
1510
939
  uint8_t c;
1511
1512
939
  if (read_escaped_char(yyscanner, &c))
1513
921
  {
1514
921
    LEX_ENV->re_class.bitmap[c / 8] |= 1 << c % 8;
1515
921
  }
1516
18
  else
1517
18
  {
1518
18
    yyerror(yyscanner, lex_env, "illegal escape sequence");
1519
18
    yyterminate();
1520
18
  }
1521
939
}
1522
921
  YY_BREAK
1523
5.42k
case 27:
1524
5.42k
YY_RULE_SETUP
1525
5.42k
#line 443 "re_lexer.l"
1526
5.42k
{
1527
1528
5.42k
  if (yytext[0] >= 32 && yytext[0] < 127)
1529
5.39k
  {
1530
    // A character class (i.e: [0-9a-f]) is represented by a 256-bits vector,
1531
    // here we set to 1 the vector's bit corresponding to the input character.
1532
1533
5.39k
    LEX_ENV->re_class.bitmap[yytext[0] / 8] |= 1 << yytext[0] % 8;
1534
5.39k
  }
1535
26
  else
1536
26
  {
1537
26
    yyerror(yyscanner, lex_env, "non-ascii character");
1538
26
    yyterminate();
1539
26
  }
1540
5.42k
}
1541
5.39k
  YY_BREAK
1542
5.39k
case YY_STATE_EOF(char_class):
1543
36
#line 460 "re_lexer.l"
1544
36
{
1545
1546
  // End of regexp reached while scanning a character class.
1547
1548
36
  yyerror(yyscanner, lex_env, "missing terminating ] for character class");
1549
36
  yyterminate();
1550
5.42k
}
1551
0
  YY_BREAK
1552
108k
case 28:
1553
108k
YY_RULE_SETUP
1554
108k
#line 469 "re_lexer.l"
1555
108k
{
1556
1557
108k
  if (yytext[0] >= 32 && yytext[0] < 127)
1558
108k
  {
1559
108k
    return yytext[0];
1560
108k
  }
1561
0
  else
1562
0
  {
1563
0
    yyerror(yyscanner, lex_env, "non-ascii character");
1564
0
    yyterminate();
1565
0
  }
1566
108k
}
1567
0
  YY_BREAK
1568
22.2k
case YY_STATE_EOF(INITIAL):
1569
22.2k
#line 483 "re_lexer.l"
1570
22.2k
{
1571
1572
22.2k
  yyterminate();
1573
108k
}
1574
0
  YY_BREAK
1575
0
case 29:
1576
0
YY_RULE_SETUP
1577
0
#line 488 "re_lexer.l"
1578
0
ECHO;
1579
0
  YY_BREAK
1580
0
#line 1581 "re_lexer.c"
1581
1582
44.9k
  case YY_END_OF_BUFFER:
1583
44.9k
    {
1584
    /* Amount of text matched not including the EOB char. */
1585
44.9k
    int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1586
1587
    /* Undo the effects of YY_DO_BEFORE_ACTION. */
1588
44.9k
    *yy_cp = yyg->yy_hold_char;
1589
44.9k
    YY_RESTORE_YY_MORE_OFFSET
1590
1591
44.9k
    if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1592
22.3k
      {
1593
      /* We're scanning a new file or input source.  It's
1594
       * possible that this happened because the user
1595
       * just pointed yyin at a new source and called
1596
       * yylex().  If so, then we have to assure
1597
       * consistency between YY_CURRENT_BUFFER and our
1598
       * globals.  Here is the right place to do so, because
1599
       * this is the first action (other than possibly a
1600
       * back-up) that will match for the new input source.
1601
       */
1602
22.3k
      yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1603
22.3k
      YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1604
22.3k
      YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1605
22.3k
      }
1606
1607
    /* Note that here we test for yy_c_buf_p "<=" to the position
1608
     * of the first EOB in the buffer, since yy_c_buf_p will
1609
     * already have been incremented past the NUL character
1610
     * (since all states make transitions on EOB to the
1611
     * end-of-buffer state).  Contrast this with the test
1612
     * in input().
1613
     */
1614
44.9k
    if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1615
0
      { /* This was really a NUL. */
1616
0
      yy_state_type yy_next_state;
1617
1618
0
      yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1619
1620
0
      yy_current_state = yy_get_previous_state( yyscanner );
1621
1622
      /* Okay, we're now positioned to make the NUL
1623
       * transition.  We couldn't have
1624
       * yy_get_previous_state() go ahead and do it
1625
       * for us because it doesn't know how to deal
1626
       * with the possibility of jamming (and we don't
1627
       * want to build jamming into it because then it
1628
       * will run more slowly).
1629
       */
1630
1631
0
      yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1632
1633
0
      yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1634
1635
0
      if ( yy_next_state )
1636
0
        {
1637
        /* Consume the NUL. */
1638
0
        yy_cp = ++yyg->yy_c_buf_p;
1639
0
        yy_current_state = yy_next_state;
1640
0
        goto yy_match;
1641
0
        }
1642
1643
0
      else
1644
0
        {
1645
0
        yy_cp = yyg->yy_last_accepting_cpos;
1646
0
        yy_current_state = yyg->yy_last_accepting_state;
1647
0
        goto yy_find_action;
1648
0
        }
1649
0
      }
1650
1651
44.9k
    else switch ( yy_get_next_buffer( yyscanner ) )
1652
44.9k
      {
1653
22.2k
      case EOB_ACT_END_OF_FILE:
1654
22.2k
        {
1655
22.2k
        yyg->yy_did_buffer_switch_on_eof = 0;
1656
1657
22.2k
        if ( yywrap( yyscanner ) )
1658
22.2k
          {
1659
          /* Note: because we've taken care in
1660
           * yy_get_next_buffer() to have set up
1661
           * yytext, we can now set up
1662
           * yy_c_buf_p so that if some total
1663
           * hoser (like flex itself) wants to
1664
           * call the scanner after we return the
1665
           * YY_NULL, it'll still work - another
1666
           * YY_NULL will get returned.
1667
           */
1668
22.2k
          yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1669
1670
22.2k
          yy_act = YY_STATE_EOF(YY_START);
1671
22.2k
          goto do_action;
1672
22.2k
          }
1673
1674
0
        else
1675
0
          {
1676
0
          if ( ! yyg->yy_did_buffer_switch_on_eof )
1677
0
            YY_NEW_FILE;
1678
0
          }
1679
0
        break;
1680
22.2k
        }
1681
1682
0
      case EOB_ACT_CONTINUE_SCAN:
1683
0
        yyg->yy_c_buf_p =
1684
0
          yyg->yytext_ptr + yy_amount_of_matched_text;
1685
1686
0
        yy_current_state = yy_get_previous_state( yyscanner );
1687
1688
0
        yy_cp = yyg->yy_c_buf_p;
1689
0
        yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1690
0
        goto yy_match;
1691
1692
22.6k
      case EOB_ACT_LAST_MATCH:
1693
22.6k
        yyg->yy_c_buf_p =
1694
22.6k
        &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1695
1696
22.6k
        yy_current_state = yy_get_previous_state( yyscanner );
1697
1698
22.6k
        yy_cp = yyg->yy_c_buf_p;
1699
22.6k
        yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1700
22.6k
        goto yy_find_action;
1701
44.9k
      }
1702
0
    break;
1703
44.9k
    }
1704
1705
0
  default:
1706
0
    YY_FATAL_ERROR(
1707
2.94M
      "fatal flex scanner internal error--no action found" );
1708
2.94M
  } /* end of action switch */
1709
2.94M
    } /* end of scanning one token */
1710
2.89M
  } /* end of user's declarations */
1711
2.89M
} /* end of yylex */
1712
1713
/* yy_get_next_buffer - try to read in a new buffer
1714
 *
1715
 * Returns a code representing an action:
1716
 *  EOB_ACT_LAST_MATCH -
1717
 *  EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1718
 *  EOB_ACT_END_OF_FILE - end of file
1719
 */
1720
static int yy_get_next_buffer (yyscan_t yyscanner)
1721
44.9k
{
1722
44.9k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1723
44.9k
  char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1724
44.9k
  char *source = yyg->yytext_ptr;
1725
44.9k
  int number_to_move, i;
1726
44.9k
  int ret_val;
1727
1728
44.9k
  if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1729
0
    YY_FATAL_ERROR(
1730
44.9k
    "fatal flex scanner internal error--end of buffer missed" );
1731
1732
44.9k
  if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1733
44.9k
    { /* Don't try to fill the buffer, so this is an EOF. */
1734
44.9k
    if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1735
22.2k
      {
1736
      /* We matched a single character, the EOB, so
1737
       * treat this as a final EOF.
1738
       */
1739
22.2k
      return EOB_ACT_END_OF_FILE;
1740
22.2k
      }
1741
1742
22.7k
    else
1743
22.7k
      {
1744
      /* We matched some text prior to the EOB, first
1745
       * process it.
1746
       */
1747
22.7k
      return EOB_ACT_LAST_MATCH;
1748
22.7k
      }
1749
44.9k
    }
1750
1751
  /* Try to read more data. */
1752
1753
  /* First move last chars to start of buffer. */
1754
0
  number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
1755
1756
0
  for ( i = 0; i < number_to_move; ++i )
1757
0
    *(dest++) = *(source++);
1758
1759
0
  if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1760
    /* don't do the read, it's not guaranteed to return an EOF,
1761
     * just force an EOF
1762
     */
1763
0
    YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1764
1765
0
  else
1766
0
    {
1767
0
      int num_to_read =
1768
0
      YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1769
1770
0
    while ( num_to_read <= 0 )
1771
0
      { /* Not enough room in the buffer - grow it. */
1772
1773
      /* just a shorter name for the current buffer */
1774
0
      YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1775
1776
0
      int yy_c_buf_p_offset =
1777
0
        (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1778
1779
0
      if ( b->yy_is_our_buffer )
1780
0
        {
1781
0
        int new_size = b->yy_buf_size * 2;
1782
1783
0
        if ( new_size <= 0 )
1784
0
          b->yy_buf_size += b->yy_buf_size / 8;
1785
0
        else
1786
0
          b->yy_buf_size *= 2;
1787
1788
0
        b->yy_ch_buf = (char *)
1789
          /* Include room in for 2 EOB chars. */
1790
0
          yyrealloc( (void *) b->yy_ch_buf,
1791
0
               (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
1792
0
        }
1793
0
      else
1794
        /* Can't grow it, we don't own it. */
1795
0
        b->yy_ch_buf = NULL;
1796
1797
0
      if ( ! b->yy_ch_buf )
1798
0
        YY_FATAL_ERROR(
1799
0
        "fatal error - scanner input buffer overflow" );
1800
1801
0
      yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1802
1803
0
      num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1804
0
            number_to_move - 1;
1805
1806
0
      }
1807
1808
0
    if ( num_to_read > YY_READ_BUF_SIZE )
1809
0
      num_to_read = YY_READ_BUF_SIZE;
1810
1811
    /* Read in more data. */
1812
0
    YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1813
0
      yyg->yy_n_chars, num_to_read );
1814
1815
0
    YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1816
0
    }
1817
1818
0
  if ( yyg->yy_n_chars == 0 )
1819
0
    {
1820
0
    if ( number_to_move == YY_MORE_ADJ )
1821
0
      {
1822
0
      ret_val = EOB_ACT_END_OF_FILE;
1823
0
      yyrestart( yyin  , yyscanner);
1824
0
      }
1825
1826
0
    else
1827
0
      {
1828
0
      ret_val = EOB_ACT_LAST_MATCH;
1829
0
      YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1830
0
        YY_BUFFER_EOF_PENDING;
1831
0
      }
1832
0
    }
1833
1834
0
  else
1835
0
    ret_val = EOB_ACT_CONTINUE_SCAN;
1836
1837
0
  if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1838
    /* Extend the array by 50%, plus the number we really need. */
1839
0
    int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1840
0
    YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
1841
0
      (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
1842
0
    if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1843
0
      YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1844
    /* "- 2" to take care of EOB's */
1845
0
    YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
1846
0
  }
1847
1848
0
  yyg->yy_n_chars += number_to_move;
1849
0
  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1850
0
  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1851
1852
0
  yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1853
1854
0
  return ret_val;
1855
44.9k
}
1856
1857
/* yy_get_previous_state - get the state just before the EOB char was reached */
1858
1859
    static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1860
22.6k
{
1861
22.6k
  yy_state_type yy_current_state;
1862
22.6k
  char *yy_cp;
1863
22.6k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1864
1865
22.6k
  yy_current_state = yyg->yy_start;
1866
1867
46.3k
  for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1868
23.6k
    {
1869
23.6k
    YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1870
23.6k
    if ( yy_accept[yy_current_state] )
1871
505
      {
1872
505
      yyg->yy_last_accepting_state = yy_current_state;
1873
505
      yyg->yy_last_accepting_cpos = yy_cp;
1874
505
      }
1875
43.4k
    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1876
19.7k
      {
1877
19.7k
      yy_current_state = (int) yy_def[yy_current_state];
1878
19.7k
      if ( yy_current_state >= 45 )
1879
19.7k
        yy_c = yy_meta[yy_c];
1880
19.7k
      }
1881
23.6k
    yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1882
23.6k
    }
1883
1884
22.6k
  return yy_current_state;
1885
22.6k
}
1886
1887
/* yy_try_NUL_trans - try to make a transition on the NUL character
1888
 *
1889
 * synopsis
1890
 *  next_state = yy_try_NUL_trans( current_state );
1891
 */
1892
    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
1893
0
{
1894
0
  int yy_is_jam;
1895
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1896
0
  char *yy_cp = yyg->yy_c_buf_p;
1897
1898
0
  YY_CHAR yy_c = 1;
1899
0
  if ( yy_accept[yy_current_state] )
1900
0
    {
1901
0
    yyg->yy_last_accepting_state = yy_current_state;
1902
0
    yyg->yy_last_accepting_cpos = yy_cp;
1903
0
    }
1904
0
  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1905
0
    {
1906
0
    yy_current_state = (int) yy_def[yy_current_state];
1907
0
    if ( yy_current_state >= 45 )
1908
0
      yy_c = yy_meta[yy_c];
1909
0
    }
1910
0
  yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1911
0
  yy_is_jam = (yy_current_state == 44);
1912
1913
0
  (void)yyg;
1914
0
  return yy_is_jam ? 0 : yy_current_state;
1915
0
}
1916
1917
#ifndef YY_NO_UNPUT
1918
1919
#endif
1920
1921
#ifndef YY_NO_INPUT
1922
#ifdef __cplusplus
1923
    static int yyinput (yyscan_t yyscanner)
1924
#else
1925
    static int input  (yyscan_t yyscanner)
1926
#endif
1927
1928
3.21M
{
1929
3.21M
  int c;
1930
3.21M
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1931
1932
3.21M
  *yyg->yy_c_buf_p = yyg->yy_hold_char;
1933
1934
3.21M
  if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1935
8
    {
1936
    /* yy_c_buf_p now points to the character we want to return.
1937
     * If this occurs *before* the EOB characters, then it's a
1938
     * valid NUL; if not, then we've hit the end of the buffer.
1939
     */
1940
8
    if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1941
      /* This was really a NUL. */
1942
0
      *yyg->yy_c_buf_p = '\0';
1943
1944
8
    else
1945
8
      { /* need more input */
1946
8
      int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
1947
8
      ++yyg->yy_c_buf_p;
1948
1949
8
      switch ( yy_get_next_buffer( yyscanner ) )
1950
8
        {
1951
8
        case EOB_ACT_LAST_MATCH:
1952
          /* This happens because yy_g_n_b()
1953
           * sees that we've accumulated a
1954
           * token and flags that we need to
1955
           * try matching the token before
1956
           * proceeding.  But for input(),
1957
           * there's no matching to consider.
1958
           * So convert the EOB_ACT_LAST_MATCH
1959
           * to EOB_ACT_END_OF_FILE.
1960
           */
1961
1962
          /* Reset buffer status. */
1963
8
          yyrestart( yyin , yyscanner);
1964
1965
          /*FALLTHROUGH*/
1966
1967
8
        case EOB_ACT_END_OF_FILE:
1968
8
          {
1969
8
          if ( yywrap( yyscanner ) )
1970
8
            return 0;
1971
1972
0
          if ( ! yyg->yy_did_buffer_switch_on_eof )
1973
0
            YY_NEW_FILE;
1974
#ifdef __cplusplus
1975
          return yyinput(yyscanner);
1976
#else
1977
0
          return input(yyscanner);
1978
8
#endif
1979
8
          }
1980
1981
0
        case EOB_ACT_CONTINUE_SCAN:
1982
0
          yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1983
0
          break;
1984
8
        }
1985
8
      }
1986
8
    }
1987
1988
3.21M
  c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1989
3.21M
  *yyg->yy_c_buf_p = '\0';  /* preserve yytext */
1990
3.21M
  yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1991
1992
3.21M
  if ( c == '\n' )
1993
    
1994
0
    do{ yylineno++;
1995
0
        yycolumn=0;
1996
0
    }while(0)
1997
3.21M
;
1998
1999
3.21M
  return c;
2000
3.21M
}
2001
#endif  /* ifndef YY_NO_INPUT */
2002
2003
/** Immediately switch to a different input stream.
2004
 * @param input_file A readable stream.
2005
 * @param yyscanner The scanner object.
2006
 * @note This function does not reset the start condition to @c INITIAL .
2007
 */
2008
    void yyrestart  (FILE * input_file , yyscan_t yyscanner)
2009
8
{
2010
8
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2011
2012
8
  if ( ! YY_CURRENT_BUFFER ){
2013
0
        yyensure_buffer_stack (yyscanner);
2014
0
    YY_CURRENT_BUFFER_LVALUE =
2015
0
            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
2016
0
  }
2017
2018
8
  yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
2019
8
  yy_load_buffer_state( yyscanner );
2020
8
}
2021
2022
/** Switch to a different input buffer.
2023
 * @param new_buffer The new input buffer.
2024
 * @param yyscanner The scanner object.
2025
 */
2026
    void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
2027
22.4k
{
2028
22.4k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2029
2030
  /* TODO. We should be able to replace this entire function body
2031
   * with
2032
   *    yypop_buffer_state();
2033
   *    yypush_buffer_state(new_buffer);
2034
     */
2035
22.4k
  yyensure_buffer_stack (yyscanner);
2036
22.4k
  if ( YY_CURRENT_BUFFER == new_buffer )
2037
0
    return;
2038
2039
22.4k
  if ( YY_CURRENT_BUFFER )
2040
0
    {
2041
    /* Flush out information for old buffer. */
2042
0
    *yyg->yy_c_buf_p = yyg->yy_hold_char;
2043
0
    YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2044
0
    YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2045
0
    }
2046
2047
22.4k
  YY_CURRENT_BUFFER_LVALUE = new_buffer;
2048
22.4k
  yy_load_buffer_state( yyscanner );
2049
2050
  /* We don't actually know whether we did this switch during
2051
   * EOF (yywrap()) processing, but the only time this flag
2052
   * is looked at is after yywrap() is called, so it's safe
2053
   * to go ahead and always set it.
2054
   */
2055
22.4k
  yyg->yy_did_buffer_switch_on_eof = 1;
2056
22.4k
}
2057
2058
static void yy_load_buffer_state  (yyscan_t yyscanner)
2059
44.8k
{
2060
44.8k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2061
44.8k
  yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2062
44.8k
  yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
2063
44.8k
  yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
2064
44.8k
  yyg->yy_hold_char = *yyg->yy_c_buf_p;
2065
44.8k
}
2066
2067
/** Allocate and initialize an input buffer state.
2068
 * @param file A readable stream.
2069
 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
2070
 * @param yyscanner The scanner object.
2071
 * @return the allocated buffer state.
2072
 */
2073
    YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
2074
0
{
2075
0
  YY_BUFFER_STATE b;
2076
    
2077
0
  b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
2078
0
  if ( ! b )
2079
0
    YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
2080
2081
0
  b->yy_buf_size = size;
2082
2083
  /* yy_ch_buf has to be 2 characters longer than the size given because
2084
   * we need to put in 2 end-of-buffer characters.
2085
   */
2086
0
  b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
2087
0
  if ( ! b->yy_ch_buf )
2088
0
    YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
2089
2090
0
  b->yy_is_our_buffer = 1;
2091
2092
0
  yy_init_buffer( b, file , yyscanner);
2093
2094
0
  return b;
2095
0
}
2096
2097
/** Destroy the buffer.
2098
 * @param b a buffer created with yy_create_buffer()
2099
 * @param yyscanner The scanner object.
2100
 */
2101
    void yy_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
2102
22.4k
{
2103
22.4k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2104
2105
22.4k
  if ( ! b )
2106
0
    return;
2107
2108
22.4k
  if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
2109
22.4k
    YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
2110
2111
22.4k
  if ( b->yy_is_our_buffer )
2112
22.4k
    yyfree( (void *) b->yy_ch_buf , yyscanner );
2113
2114
22.4k
  yyfree( (void *) b , yyscanner );
2115
22.4k
}
2116
2117
/* Initializes or reinitializes a buffer.
2118
 * This function is sometimes called more than once on the same buffer,
2119
 * such as during a yyrestart() or at EOF.
2120
 */
2121
    static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
2122
2123
8
{
2124
8
  int oerrno = errno;
2125
8
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2126
2127
8
  yy_flush_buffer( b , yyscanner);
2128
2129
8
  b->yy_input_file = file;
2130
8
  b->yy_fill_buffer = 1;
2131
2132
    /* If b is the current buffer, then yy_init_buffer was _probably_
2133
     * called from yyrestart() or through yy_get_next_buffer.
2134
     * In that case, we don't want to reset the lineno or column.
2135
     */
2136
8
    if (b != YY_CURRENT_BUFFER){
2137
0
        b->yy_bs_lineno = 1;
2138
0
        b->yy_bs_column = 0;
2139
0
    }
2140
2141
8
        b->yy_is_interactive = 0;
2142
    
2143
8
  errno = oerrno;
2144
8
}
2145
2146
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2147
 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2148
 * @param yyscanner The scanner object.
2149
 */
2150
    void yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
2151
8
{
2152
8
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2153
8
  if ( ! b )
2154
0
    return;
2155
2156
8
  b->yy_n_chars = 0;
2157
2158
  /* We always need two end-of-buffer characters.  The first causes
2159
   * a transition to the end-of-buffer state.  The second causes
2160
   * a jam in that state.
2161
   */
2162
8
  b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2163
8
  b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2164
2165
8
  b->yy_buf_pos = &b->yy_ch_buf[0];
2166
2167
8
  b->yy_at_bol = 1;
2168
8
  b->yy_buffer_status = YY_BUFFER_NEW;
2169
2170
8
  if ( b == YY_CURRENT_BUFFER )
2171
8
    yy_load_buffer_state( yyscanner );
2172
8
}
2173
2174
/** Pushes the new state onto the stack. The new state becomes
2175
 *  the current state. This function will allocate the stack
2176
 *  if necessary.
2177
 *  @param new_buffer The new state.
2178
 *  @param yyscanner The scanner object.
2179
 */
2180
void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
2181
0
{
2182
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2183
0
  if (new_buffer == NULL)
2184
0
    return;
2185
2186
0
  yyensure_buffer_stack(yyscanner);
2187
2188
  /* This block is copied from yy_switch_to_buffer. */
2189
0
  if ( YY_CURRENT_BUFFER )
2190
0
    {
2191
    /* Flush out information for old buffer. */
2192
0
    *yyg->yy_c_buf_p = yyg->yy_hold_char;
2193
0
    YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2194
0
    YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2195
0
    }
2196
2197
  /* Only push if top exists. Otherwise, replace top. */
2198
0
  if (YY_CURRENT_BUFFER)
2199
0
    yyg->yy_buffer_stack_top++;
2200
0
  YY_CURRENT_BUFFER_LVALUE = new_buffer;
2201
2202
  /* copied from yy_switch_to_buffer. */
2203
0
  yy_load_buffer_state( yyscanner );
2204
0
  yyg->yy_did_buffer_switch_on_eof = 1;
2205
0
}
2206
2207
/** Removes and deletes the top of the stack, if present.
2208
 *  The next element becomes the new top.
2209
 *  @param yyscanner The scanner object.
2210
 */
2211
void yypop_buffer_state (yyscan_t yyscanner)
2212
22.4k
{
2213
22.4k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2214
22.4k
  if (!YY_CURRENT_BUFFER)
2215
22.4k
    return;
2216
2217
0
  yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
2218
0
  YY_CURRENT_BUFFER_LVALUE = NULL;
2219
0
  if (yyg->yy_buffer_stack_top > 0)
2220
0
    --yyg->yy_buffer_stack_top;
2221
2222
0
  if (YY_CURRENT_BUFFER) {
2223
0
    yy_load_buffer_state( yyscanner );
2224
0
    yyg->yy_did_buffer_switch_on_eof = 1;
2225
0
  }
2226
0
}
2227
2228
/* Allocates the stack if it does not exist.
2229
 *  Guarantees space for at least one push.
2230
 */
2231
static void yyensure_buffer_stack (yyscan_t yyscanner)
2232
22.4k
{
2233
22.4k
  yy_size_t num_to_alloc;
2234
22.4k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2235
2236
22.4k
  if (!yyg->yy_buffer_stack) {
2237
2238
    /* First allocation is just for 2 elements, since we don't know if this
2239
     * scanner will even need a stack. We use 2 instead of 1 to avoid an
2240
     * immediate realloc on the next call.
2241
         */
2242
22.4k
      num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
2243
22.4k
    yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
2244
22.4k
                (num_to_alloc * sizeof(struct yy_buffer_state*)
2245
22.4k
                , yyscanner);
2246
22.4k
    if ( ! yyg->yy_buffer_stack )
2247
0
      YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2248
2249
22.4k
    memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2250
2251
22.4k
    yyg->yy_buffer_stack_max = num_to_alloc;
2252
22.4k
    yyg->yy_buffer_stack_top = 0;
2253
22.4k
    return;
2254
22.4k
  }
2255
2256
0
  if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
2257
2258
    /* Increase the buffer to prepare for a possible push. */
2259
0
    yy_size_t grow_size = 8 /* arbitrary grow size */;
2260
2261
0
    num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
2262
0
    yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
2263
0
                (yyg->yy_buffer_stack,
2264
0
                num_to_alloc * sizeof(struct yy_buffer_state*)
2265
0
                , yyscanner);
2266
0
    if ( ! yyg->yy_buffer_stack )
2267
0
      YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2268
2269
    /* zero only the new slots.*/
2270
0
    memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
2271
0
    yyg->yy_buffer_stack_max = num_to_alloc;
2272
0
  }
2273
0
}
2274
2275
/** Setup the input buffer state to scan directly from a user-specified character buffer.
2276
 * @param base the character buffer
2277
 * @param size the size in bytes of the character buffer
2278
 * @param yyscanner The scanner object.
2279
 * @return the newly allocated buffer state object.
2280
 */
2281
YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
2282
22.4k
{
2283
22.4k
  YY_BUFFER_STATE b;
2284
    
2285
22.4k
  if ( size < 2 ||
2286
22.4k
       base[size-2] != YY_END_OF_BUFFER_CHAR ||
2287
22.4k
       base[size-1] != YY_END_OF_BUFFER_CHAR )
2288
    /* They forgot to leave room for the EOB's. */
2289
0
    return NULL;
2290
2291
22.4k
  b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
2292
22.4k
  if ( ! b )
2293
0
    YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
2294
2295
22.4k
  b->yy_buf_size = (int) (size - 2);  /* "- 2" to take care of EOB's */
2296
22.4k
  b->yy_buf_pos = b->yy_ch_buf = base;
2297
22.4k
  b->yy_is_our_buffer = 0;
2298
22.4k
  b->yy_input_file = NULL;
2299
22.4k
  b->yy_n_chars = b->yy_buf_size;
2300
22.4k
  b->yy_is_interactive = 0;
2301
22.4k
  b->yy_at_bol = 1;
2302
22.4k
  b->yy_fill_buffer = 0;
2303
22.4k
  b->yy_buffer_status = YY_BUFFER_NEW;
2304
2305
22.4k
  yy_switch_to_buffer( b , yyscanner );
2306
2307
22.4k
  return b;
2308
22.4k
}
2309
2310
/** Setup the input buffer state to scan a string. The next call to yylex() will
2311
 * scan from a @e copy of @a str.
2312
 * @param yystr a NUL-terminated string to scan
2313
 * @param yyscanner The scanner object.
2314
 * @return the newly allocated buffer state object.
2315
 * @note If you want to scan bytes that may contain NUL values, then use
2316
 *       yy_scan_bytes() instead.
2317
 */
2318
YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
2319
22.4k
{
2320
    
2321
22.4k
  return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
2322
22.4k
}
2323
2324
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
2325
 * scan from a @e copy of @a bytes.
2326
 * @param yybytes the byte buffer to scan
2327
 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2328
 * @param yyscanner The scanner object.
2329
 * @return the newly allocated buffer state object.
2330
 */
2331
YY_BUFFER_STATE yy_scan_bytes  (const char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
2332
22.4k
{
2333
22.4k
  YY_BUFFER_STATE b;
2334
22.4k
  char *buf;
2335
22.4k
  yy_size_t n;
2336
22.4k
  int i;
2337
    
2338
  /* Get memory for full buffer, including space for trailing EOB's. */
2339
22.4k
  n = (yy_size_t) (_yybytes_len + 2);
2340
22.4k
  buf = (char *) yyalloc( n , yyscanner );
2341
22.4k
  if ( ! buf )
2342
0
    YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
2343
2344
6.15M
  for ( i = 0; i < _yybytes_len; ++i )
2345
6.13M
    buf[i] = yybytes[i];
2346
2347
22.4k
  buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2348
2349
22.4k
  b = yy_scan_buffer( buf, n , yyscanner);
2350
22.4k
  if ( ! b )
2351
0
    YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
2352
2353
  /* It's okay to grow etc. this buffer, and we should throw it
2354
   * away when we're done.
2355
   */
2356
22.4k
  b->yy_is_our_buffer = 1;
2357
2358
22.4k
  return b;
2359
22.4k
}
2360
2361
#ifndef YY_EXIT_FAILURE
2362
#define YY_EXIT_FAILURE 2
2363
#endif
2364
2365
static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
2366
0
{
2367
0
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2368
0
  (void)yyg;
2369
0
  fprintf( stderr, "%s\n", msg );
2370
0
  exit( YY_EXIT_FAILURE );
2371
0
}
2372
2373
/* Redefine yyless() so it works in section 3 code. */
2374
2375
#undef yyless
2376
#define yyless(n) \
2377
  do \
2378
    { \
2379
    /* Undo effects of setting up yytext. */ \
2380
        int yyless_macro_arg = (n); \
2381
        YY_LESS_LINENO(yyless_macro_arg);\
2382
    yytext[yyleng] = yyg->yy_hold_char; \
2383
    yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
2384
    yyg->yy_hold_char = *yyg->yy_c_buf_p; \
2385
    *yyg->yy_c_buf_p = '\0'; \
2386
    yyleng = yyless_macro_arg; \
2387
    } \
2388
  while ( 0 )
2389
2390
/* Accessor  methods (get/set functions) to struct members. */
2391
2392
/** Get the user-defined data for this scanner.
2393
 * @param yyscanner The scanner object.
2394
 */
2395
YY_EXTRA_TYPE yyget_extra  (yyscan_t yyscanner)
2396
50.7k
{
2397
50.7k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2398
50.7k
    return yyextra;
2399
50.7k
}
2400
2401
/** Get the current line number.
2402
 * @param yyscanner The scanner object.
2403
 */
2404
int yyget_lineno  (yyscan_t yyscanner)
2405
0
{
2406
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2407
2408
0
        if (! YY_CURRENT_BUFFER)
2409
0
            return 0;
2410
    
2411
0
    return yylineno;
2412
0
}
2413
2414
/** Get the current column number.
2415
 * @param yyscanner The scanner object.
2416
 */
2417
int yyget_column  (yyscan_t yyscanner)
2418
0
{
2419
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2420
2421
0
        if (! YY_CURRENT_BUFFER)
2422
0
            return 0;
2423
    
2424
0
    return yycolumn;
2425
0
}
2426
2427
/** Get the input stream.
2428
 * @param yyscanner The scanner object.
2429
 */
2430
FILE *yyget_in  (yyscan_t yyscanner)
2431
0
{
2432
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2433
0
    return yyin;
2434
0
}
2435
2436
/** Get the output stream.
2437
 * @param yyscanner The scanner object.
2438
 */
2439
FILE *yyget_out  (yyscan_t yyscanner)
2440
0
{
2441
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2442
0
    return yyout;
2443
0
}
2444
2445
/** Get the length of the current token.
2446
 * @param yyscanner The scanner object.
2447
 */
2448
int yyget_leng  (yyscan_t yyscanner)
2449
0
{
2450
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2451
0
    return yyleng;
2452
0
}
2453
2454
/** Get the current token.
2455
 * @param yyscanner The scanner object.
2456
 */
2457
2458
char *yyget_text  (yyscan_t yyscanner)
2459
0
{
2460
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2461
0
    return yytext;
2462
0
}
2463
2464
/** Set the user-defined data. This data is never touched by the scanner.
2465
 * @param user_defined The data to be associated with this scanner.
2466
 * @param yyscanner The scanner object.
2467
 */
2468
void yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
2469
22.4k
{
2470
22.4k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2471
22.4k
    yyextra = user_defined ;
2472
22.4k
}
2473
2474
/** Set the current line number.
2475
 * @param _line_number line number
2476
 * @param yyscanner The scanner object.
2477
 */
2478
void yyset_lineno (int  _line_number , yyscan_t yyscanner)
2479
0
{
2480
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2481
2482
        /* lineno is only valid if an input buffer exists. */
2483
0
        if (! YY_CURRENT_BUFFER )
2484
0
           YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
2485
    
2486
0
    yylineno = _line_number;
2487
0
}
2488
2489
/** Set the current column.
2490
 * @param _column_no column number
2491
 * @param yyscanner The scanner object.
2492
 */
2493
void yyset_column (int  _column_no , yyscan_t yyscanner)
2494
0
{
2495
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2496
2497
        /* column is only valid if an input buffer exists. */
2498
0
        if (! YY_CURRENT_BUFFER )
2499
0
           YY_FATAL_ERROR( "yyset_column called with no buffer" );
2500
    
2501
0
    yycolumn = _column_no;
2502
0
}
2503
2504
/** Set the input stream. This does not discard the current
2505
 * input buffer.
2506
 * @param _in_str A readable stream.
2507
 * @param yyscanner The scanner object.
2508
 * @see yy_switch_to_buffer
2509
 */
2510
void yyset_in (FILE *  _in_str , yyscan_t yyscanner)
2511
0
{
2512
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2513
0
    yyin = _in_str ;
2514
0
}
2515
2516
void yyset_out (FILE *  _out_str , yyscan_t yyscanner)
2517
0
{
2518
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2519
0
    yyout = _out_str ;
2520
0
}
2521
2522
int yyget_debug  (yyscan_t yyscanner)
2523
0
{
2524
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2525
0
    return yy_flex_debug;
2526
0
}
2527
2528
void yyset_debug (int  _bdebug , yyscan_t yyscanner)
2529
0
{
2530
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2531
0
    yy_flex_debug = _bdebug ;
2532
0
}
2533
2534
/* Accessor methods for yylval and yylloc */
2535
2536
YYSTYPE * yyget_lval  (yyscan_t yyscanner)
2537
0
{
2538
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2539
0
    return yylval;
2540
0
}
2541
2542
void yyset_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)
2543
0
{
2544
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2545
0
    yylval = yylval_param;
2546
0
}
2547
2548
/* User-visible API */
2549
2550
/* yylex_init is special because it creates the scanner itself, so it is
2551
 * the ONLY reentrant function that doesn't take the scanner as the last argument.
2552
 * That's why we explicitly handle the declaration, instead of using our macros.
2553
 */
2554
int yylex_init(yyscan_t* ptr_yy_globals)
2555
22.4k
{
2556
22.4k
    if (ptr_yy_globals == NULL){
2557
0
        errno = EINVAL;
2558
0
        return 1;
2559
0
    }
2560
2561
22.4k
    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
2562
2563
22.4k
    if (*ptr_yy_globals == NULL){
2564
0
        errno = ENOMEM;
2565
0
        return 1;
2566
0
    }
2567
2568
    /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2569
22.4k
    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2570
2571
22.4k
    return yy_init_globals ( *ptr_yy_globals );
2572
22.4k
}
2573
2574
/* yylex_init_extra has the same functionality as yylex_init, but follows the
2575
 * convention of taking the scanner as the last argument. Note however, that
2576
 * this is a *pointer* to a scanner, as it will be allocated by this call (and
2577
 * is the reason, too, why this function also must handle its own declaration).
2578
 * The user defined value in the first argument will be available to yyalloc in
2579
 * the yyextra field.
2580
 */
2581
int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
2582
0
{
2583
0
    struct yyguts_t dummy_yyguts;
2584
2585
0
    yyset_extra (yy_user_defined, &dummy_yyguts);
2586
2587
0
    if (ptr_yy_globals == NULL){
2588
0
        errno = EINVAL;
2589
0
        return 1;
2590
0
    }
2591
2592
0
    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2593
2594
0
    if (*ptr_yy_globals == NULL){
2595
0
        errno = ENOMEM;
2596
0
        return 1;
2597
0
    }
2598
2599
    /* By setting to 0xAA, we expose bugs in
2600
    yy_init_globals. Leave at 0x00 for releases. */
2601
0
    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2602
2603
0
    yyset_extra (yy_user_defined, *ptr_yy_globals);
2604
2605
0
    return yy_init_globals ( *ptr_yy_globals );
2606
0
}
2607
2608
static int yy_init_globals (yyscan_t yyscanner)
2609
44.8k
{
2610
44.8k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2611
    /* Initialization is the same as for the non-reentrant scanner.
2612
     * This function is called from yylex_destroy(), so don't allocate here.
2613
     */
2614
2615
44.8k
    yyg->yy_buffer_stack = NULL;
2616
44.8k
    yyg->yy_buffer_stack_top = 0;
2617
44.8k
    yyg->yy_buffer_stack_max = 0;
2618
44.8k
    yyg->yy_c_buf_p = NULL;
2619
44.8k
    yyg->yy_init = 0;
2620
44.8k
    yyg->yy_start = 0;
2621
2622
44.8k
    yyg->yy_start_stack_ptr = 0;
2623
44.8k
    yyg->yy_start_stack_depth = 0;
2624
44.8k
    yyg->yy_start_stack =  NULL;
2625
2626
/* Defined in main.c */
2627
#ifdef YY_STDINIT
2628
    yyin = stdin;
2629
    yyout = stdout;
2630
#else
2631
44.8k
    yyin = NULL;
2632
44.8k
    yyout = NULL;
2633
44.8k
#endif
2634
2635
    /* For future reference: Set errno on error, since we are called by
2636
     * yylex_init()
2637
     */
2638
44.8k
    return 0;
2639
44.8k
}
2640
2641
/* yylex_destroy is for both reentrant and non-reentrant scanners. */
2642
int yylex_destroy  (yyscan_t yyscanner)
2643
22.4k
{
2644
22.4k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2645
2646
    /* Pop the buffer stack, destroying each element. */
2647
44.8k
  while(YY_CURRENT_BUFFER){
2648
22.4k
    yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
2649
22.4k
    YY_CURRENT_BUFFER_LVALUE = NULL;
2650
22.4k
    yypop_buffer_state(yyscanner);
2651
22.4k
  }
2652
2653
  /* Destroy the stack itself. */
2654
22.4k
  yyfree(yyg->yy_buffer_stack , yyscanner);
2655
22.4k
  yyg->yy_buffer_stack = NULL;
2656
2657
    /* Destroy the start condition stack. */
2658
22.4k
        yyfree( yyg->yy_start_stack , yyscanner );
2659
22.4k
        yyg->yy_start_stack = NULL;
2660
2661
    /* Reset the globals. This is important in a non-reentrant scanner so the next time
2662
     * yylex() is called, initialization will occur. */
2663
22.4k
    yy_init_globals( yyscanner);
2664
2665
    /* Destroy the main struct (reentrant only). */
2666
22.4k
    yyfree ( yyscanner , yyscanner );
2667
22.4k
    yyscanner = NULL;
2668
22.4k
    return 0;
2669
22.4k
}
2670
2671
/*
2672
 * Internal utility routines.
2673
 */
2674
2675
#ifndef yytext_ptr
2676
static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
2677
{
2678
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2679
  (void)yyg;
2680
2681
  int i;
2682
  for ( i = 0; i < n; ++i )
2683
    s1[i] = s2[i];
2684
}
2685
#endif
2686
2687
#ifdef YY_NEED_STRLEN
2688
static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
2689
{
2690
  int n;
2691
  for ( n = 0; s[n]; ++n )
2692
    ;
2693
2694
  return n;
2695
}
2696
#endif
2697
2698
void *yyalloc (yy_size_t  size , yyscan_t yyscanner)
2699
89.7k
{
2700
89.7k
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2701
89.7k
  (void)yyg;
2702
89.7k
  return malloc(size);
2703
89.7k
}
2704
2705
void *yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
2706
0
{
2707
0
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2708
0
  (void)yyg;
2709
2710
  /* The cast to (char *) in the following accommodates both
2711
   * implementations that use char* generic pointers, and those
2712
   * that use void* generic pointers.  It works with the latter
2713
   * because both ANSI C and C++ allow castless assignment from
2714
   * any pointer type to void*, and deal with argument conversions
2715
   * as though doing an assignment.
2716
   */
2717
0
  return realloc(ptr, size);
2718
0
}
2719
2720
void yyfree (void * ptr , yyscan_t yyscanner)
2721
112k
{
2722
112k
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2723
112k
  (void)yyg;
2724
112k
  free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
2725
112k
}
2726
2727
#define YYTABLES_NAME "yytables"
2728
2729
#line 488 "re_lexer.l"
2730
2731
2732
int escaped_char_value(
2733
    char* text,
2734
    uint8_t* value)
2735
1.07M
{
2736
1.07M
  unsigned int hex_value;
2737
1.07M
  char hex[3];
2738
2739
1.07M
  assert(text[0] == '\\');
2740
2741
1.07M
  switch(text[1])
2742
1.07M
  {
2743
1.07M
  case 'x':
2744
1.07M
    if (!isxdigit(text[2]) || !isxdigit(text[3]))
2745
12
      return 0;
2746
1.07M
    hex[0] = text[2];
2747
1.07M
    hex[1] = text[3];
2748
1.07M
    hex[2] = '\0';
2749
1.07M
    sscanf(hex, "%x", &hex_value);
2750
1.07M
    *value = (uint8_t) hex_value;
2751
1.07M
    break;
2752
2753
134
  case 'n':
2754
134
    *value = '\n';
2755
134
    break;
2756
2757
146
  case 't':
2758
146
    *value = '\t';
2759
146
    break;
2760
2761
187
  case 'r':
2762
187
    *value = '\r';
2763
187
    break;
2764
2765
134
  case 'f':
2766
134
    *value = '\f';
2767
134
    break;
2768
2769
133
  case 'a':
2770
133
    *value = '\a';
2771
133
    break;
2772
2773
3.38k
  default:
2774
3.38k
    *value = text[1];
2775
1.07M
  }
2776
2777
1.07M
  return 1;
2778
1.07M
}
2779
2780
2781
#ifdef __cplusplus
2782
#define RE_YY_INPUT yyinput
2783
#else
2784
3.21M
#define RE_YY_INPUT input
2785
#endif
2786
2787
2788
int read_escaped_char(
2789
    yyscan_t yyscanner,
2790
    uint8_t* escaped_char)
2791
1.07M
{
2792
1.07M
  char text[4] = {0, 0, 0, 0};
2793
2794
1.07M
  text[0] = '\\';
2795
1.07M
  text[1] = RE_YY_INPUT(yyscanner);
2796
2797
1.07M
  if (text[1] == EOF || text[1] == 0)
2798
13
    return 0;
2799
2800
1.07M
  if (text[1] == 'x')
2801
1.07M
  {
2802
1.07M
    text[2] = RE_YY_INPUT(yyscanner);
2803
2804
1.07M
    if (text[2] == EOF || text[2] == 0)
2805
8
      return 0;
2806
2807
1.07M
    text[3] = RE_YY_INPUT(yyscanner);
2808
2809
1.07M
    if (text[3] == EOF || text[3] == 0)
2810
0
      return 0;
2811
1.07M
  }
2812
2813
1.07M
  return escaped_char_value(text, escaped_char);
2814
1.07M
}
2815
2816
2817
//
2818
// yyfatal (actually named re_yyfatal because of the '%option prefix="re_yy"'
2819
// directive) is called when a fatal error occurs in the parser. When this
2820
// happens we are deep inside the parsing logic generated by flex/bison and
2821
// the only way to exit gracefully from there is using setjmp/longjmp.
2822
//
2823
void yyfatal(
2824
    yyscan_t yyscanner,
2825
    const char *error_message)
2826
0
{
2827
0
  jmp_buf* recovery_trampoline = (jmp_buf*) yr_thread_storage_get_value(
2828
0
      &yr_yyfatal_trampoline_tls);
2829
2830
0
  longjmp(*recovery_trampoline, 1);
2831
0
}
2832
2833
2834
void yyerror(
2835
    yyscan_t yyscanner,
2836
    RE_LEX_ENVIRONMENT* lex_env,
2837
    const char *error_message)
2838
390
{
2839
  // if lex_env->last_error was set to some error code before
2840
  // don't overwrite it, we are interested in the first error, not in
2841
  // subsequent errors like "syntax error, unexpected $end" caused by
2842
  // early parser termination.
2843
2844
390
  if (lex_env->last_error == ERROR_SUCCESS)
2845
235
  {
2846
235
    lex_env->last_error = ERROR_INVALID_REGULAR_EXPRESSION;
2847
2848
235
    strlcpy(
2849
235
        lex_env->last_error_message,
2850
235
        error_message,
2851
235
        sizeof(lex_env->last_error_message));
2852
235
  }
2853
390
}
2854
2855
2856
int yr_parse_re_string(
2857
  const char* re_string,
2858
  RE_AST** re_ast,
2859
  RE_ERROR* error)
2860
22.4k
{
2861
22.4k
  yyscan_t yyscanner;
2862
22.4k
  jmp_buf recovery_trampoline;
2863
22.4k
  RE_LEX_ENVIRONMENT lex_env;
2864
2865
22.4k
  lex_env.last_error = ERROR_SUCCESS;
2866
22.4k
  lex_env.last_error_message[0] = '\0';
2867
2868
22.4k
  yr_thread_storage_set_value(
2869
22.4k
      &yr_yyfatal_trampoline_tls,
2870
22.4k
      &recovery_trampoline);
2871
2872
  // setjmp returns a non-zero value only when we are returning to this
2873
  // point via a call to longjmp to the recovery trampoline.
2874
22.4k
  if (setjmp(recovery_trampoline) != 0)
2875
0
    return ERROR_INTERNAL_FATAL_ERROR;
2876
2877
22.4k
  FAIL_ON_ERROR(yr_re_ast_create(re_ast));
2878
2879
22.4k
  if (yylex_init(&yyscanner) != 0)
2880
0
  {
2881
0
    yr_re_ast_destroy(*re_ast);
2882
0
    *re_ast = NULL;
2883
0
    return ERROR_INSUFFICIENT_MEMORY;
2884
0
  }
2885
2886
22.4k
  yyset_extra(*re_ast, yyscanner);
2887
22.4k
  yy_scan_string(re_string, yyscanner);
2888
22.4k
  yyparse(yyscanner, &lex_env);
2889
22.4k
  yylex_destroy(yyscanner);
2890
2891
22.4k
  if (lex_env.last_error != ERROR_SUCCESS)
2892
235
  {
2893
235
    yr_re_ast_destroy(*re_ast);
2894
235
    *re_ast = NULL;
2895
2896
235
    strlcpy(
2897
235
        error->message,
2898
235
        lex_env.last_error_message,
2899
235
        sizeof(error->message));
2900
2901
235
    return lex_env.last_error;
2902
235
  }
2903
2904
22.1k
  return ERROR_SUCCESS;
2905
22.4k
}
2906