Coverage Report

Created: 2025-10-10 06:41

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