Coverage Report

Created: 2025-11-01 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/yara/libyara/lexer.c
Line
Count
Source
1
#line 1 "libyara/lexer.c"
2
3
#line 3 "libyara/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 yara_yy_create_buffer_ALREADY_DEFINED
19
#else
20
0
#define yy_create_buffer yara_yy_create_buffer
21
#endif
22
23
#ifdef yy_delete_buffer
24
#define yara_yy_delete_buffer_ALREADY_DEFINED
25
#else
26
1.70k
#define yy_delete_buffer yara_yy_delete_buffer
27
#endif
28
29
#ifdef yy_scan_buffer
30
#define yara_yy_scan_buffer_ALREADY_DEFINED
31
#else
32
1.70k
#define yy_scan_buffer yara_yy_scan_buffer
33
#endif
34
35
#ifdef yy_scan_string
36
#define yara_yy_scan_string_ALREADY_DEFINED
37
#else
38
1.70k
#define yy_scan_string yara_yy_scan_string
39
#endif
40
41
#ifdef yy_scan_bytes
42
#define yara_yy_scan_bytes_ALREADY_DEFINED
43
#else
44
1.70k
#define yy_scan_bytes yara_yy_scan_bytes
45
#endif
46
47
#ifdef yy_init_buffer
48
#define yara_yy_init_buffer_ALREADY_DEFINED
49
#else
50
0
#define yy_init_buffer yara_yy_init_buffer
51
#endif
52
53
#ifdef yy_flush_buffer
54
#define yara_yy_flush_buffer_ALREADY_DEFINED
55
#else
56
0
#define yy_flush_buffer yara_yy_flush_buffer
57
#endif
58
59
#ifdef yy_load_buffer_state
60
#define yara_yy_load_buffer_state_ALREADY_DEFINED
61
#else
62
3.41k
#define yy_load_buffer_state yara_yy_load_buffer_state
63
#endif
64
65
#ifdef yy_switch_to_buffer
66
#define yara_yy_switch_to_buffer_ALREADY_DEFINED
67
#else
68
1.70k
#define yy_switch_to_buffer yara_yy_switch_to_buffer
69
#endif
70
71
#ifdef yypush_buffer_state
72
#define yara_yypush_buffer_state_ALREADY_DEFINED
73
#else
74
0
#define yypush_buffer_state yara_yypush_buffer_state
75
#endif
76
77
#ifdef yypop_buffer_state
78
#define yara_yypop_buffer_state_ALREADY_DEFINED
79
#else
80
1.70k
#define yypop_buffer_state yara_yypop_buffer_state
81
#endif
82
83
#ifdef yyensure_buffer_stack
84
#define yara_yyensure_buffer_stack_ALREADY_DEFINED
85
#else
86
1.70k
#define yyensure_buffer_stack yara_yyensure_buffer_stack
87
#endif
88
89
#ifdef yylex
90
#define yara_yylex_ALREADY_DEFINED
91
#else
92
#define yylex yara_yylex
93
#endif
94
95
#ifdef yyrestart
96
#define yara_yyrestart_ALREADY_DEFINED
97
#else
98
0
#define yyrestart yara_yyrestart
99
#endif
100
101
#ifdef yylex_init
102
#define yara_yylex_init_ALREADY_DEFINED
103
#else
104
1.70k
#define yylex_init yara_yylex_init
105
#endif
106
107
#ifdef yylex_init_extra
108
#define yara_yylex_init_extra_ALREADY_DEFINED
109
#else
110
#define yylex_init_extra yara_yylex_init_extra
111
#endif
112
113
#ifdef yylex_destroy
114
#define yara_yylex_destroy_ALREADY_DEFINED
115
#else
116
1.70k
#define yylex_destroy yara_yylex_destroy
117
#endif
118
119
#ifdef yyget_debug
120
#define yara_yyget_debug_ALREADY_DEFINED
121
#else
122
#define yyget_debug yara_yyget_debug
123
#endif
124
125
#ifdef yyset_debug
126
#define yara_yyset_debug_ALREADY_DEFINED
127
#else
128
#define yyset_debug yara_yyset_debug
129
#endif
130
131
#ifdef yyget_extra
132
#define yara_yyget_extra_ALREADY_DEFINED
133
#else
134
#define yyget_extra yara_yyget_extra
135
#endif
136
137
#ifdef yyset_extra
138
#define yara_yyset_extra_ALREADY_DEFINED
139
#else
140
1.70k
#define yyset_extra yara_yyset_extra
141
#endif
142
143
#ifdef yyget_in
144
#define yara_yyget_in_ALREADY_DEFINED
145
#else
146
#define yyget_in yara_yyget_in
147
#endif
148
149
#ifdef yyset_in
150
#define yara_yyset_in_ALREADY_DEFINED
151
#else
152
0
#define yyset_in yara_yyset_in
153
#endif
154
155
#ifdef yyget_out
156
#define yara_yyget_out_ALREADY_DEFINED
157
#else
158
#define yyget_out yara_yyget_out
159
#endif
160
161
#ifdef yyset_out
162
#define yara_yyset_out_ALREADY_DEFINED
163
#else
164
#define yyset_out yara_yyset_out
165
#endif
166
167
#ifdef yyget_leng
168
#define yara_yyget_leng_ALREADY_DEFINED
169
#else
170
#define yyget_leng yara_yyget_leng
171
#endif
172
173
#ifdef yyget_text
174
#define yara_yyget_text_ALREADY_DEFINED
175
#else
176
#define yyget_text yara_yyget_text
177
#endif
178
179
#ifdef yyget_lineno
180
#define yara_yyget_lineno_ALREADY_DEFINED
181
#else
182
#define yyget_lineno yara_yyget_lineno
183
#endif
184
185
#ifdef yyset_lineno
186
#define yara_yyset_lineno_ALREADY_DEFINED
187
#else
188
1.70k
#define yyset_lineno yara_yyset_lineno
189
#endif
190
191
#ifdef yyget_column
192
#define yara_yyget_column_ALREADY_DEFINED
193
#else
194
#define yyget_column yara_yyget_column
195
#endif
196
197
#ifdef yyset_column
198
#define yara_yyset_column_ALREADY_DEFINED
199
#else
200
#define yyset_column yara_yyset_column
201
#endif
202
203
#ifdef yywrap
204
#define yara_yywrap_ALREADY_DEFINED
205
#else
206
1.23k
#define yywrap yara_yywrap
207
#endif
208
209
#ifdef yyget_lval
210
#define yara_yyget_lval_ALREADY_DEFINED
211
#else
212
#define yyget_lval yara_yyget_lval
213
#endif
214
215
#ifdef yyset_lval
216
#define yara_yyset_lval_ALREADY_DEFINED
217
#else
218
#define yyset_lval yara_yyset_lval
219
#endif
220
221
#ifdef yyalloc
222
#define yara_yyalloc_ALREADY_DEFINED
223
#else
224
6.82k
#define yyalloc yara_yyalloc
225
#endif
226
227
#ifdef yyrealloc
228
#define yara_yyrealloc_ALREADY_DEFINED
229
#else
230
0
#define yyrealloc yara_yyrealloc
231
#endif
232
233
#ifdef yyfree
234
#define yara_yyfree_ALREADY_DEFINED
235
#else
236
8.52k
#define yyfree yara_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
1.70k
#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
4.66M
#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
11.5k
#define yyin yyg->yyin_r
345
6.82k
#define yyout yyg->yyout_r
346
6.82M
#define yyextra yyg->yyextra_r
347
1.55M
#define yyleng yyg->yyleng_r
348
2.02M
#define yytext yyg->yytext_r
349
81.1k
#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
350
38.2k
#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
82.9k
#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
7.00k
#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
6.82k
#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
2.46k
#define EOB_ACT_END_OF_FILE 1
399
2.60k
#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
4.23k
#define YY_BUFFER_NEW 0
487
1.28k
#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
58.0k
#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
510
58.0k
                          ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
511
58.0k
                          : 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
152k
#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
1.23k
#define yara_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
848k
#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
833k
  yyg->yytext_ptr = yy_bp; \
579
833k
  yyleng = (int) (yy_cp - yy_bp); \
580
833k
  yyg->yy_hold_char = *yy_cp; \
581
833k
  *yy_cp = '\0'; \
582
833k
  yyg->yy_c_buf_p = yy_cp;
583
#define YY_NUM_RULES 86
584
1.67M
#define YY_END_OF_BUFFER 87
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[295] =
593
    {   0,
594
        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
595
       87,   85,   84,   84,   59,   81,   57,   56,   85,   82,
596
       62,   62,    2,   85,    3,   58,   61,   61,   61,   61,
597
       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
598
       61,   61,   61,   61,   61,   85,   73,   74,   66,   86,
599
       79,   80,   76,   86,   53,   54,   50,   50,   59,    7,
600
       57,   55,   56,    1,   48,   51,    0,   62,    0,    0,
601
        0,    0,    8,    4,    6,    5,    9,   58,   61,   61,
602
       61,   61,   28,   61,   61,   61,   61,   61,   61,   61,
603
       61,   61,   61,   61,   61,   29,   61,   61,   61,   61,
604
605
       30,   27,   61,   61,   61,   61,   61,   61,   61,   61,
606
        0,    0,   73,   75,   70,   71,   69,   68,   67,   75,
607
       79,   76,   76,   78,   77,   53,   49,   51,   63,   62,
608
       65,   64,   33,   26,   34,   61,   61,   61,   61,   61,
609
       61,   61,   61,   32,   61,   61,   61,   61,   61,   61,
610
       61,   61,   61,   61,   61,   61,   61,   25,   61,   61,
611
       61,   61,   61,   61,   61,   61,   17,   83,    0,    0,
612
        0,   61,   61,   61,   61,   61,   61,   61,   61,   61,
613
       61,   61,   61,   61,   61,   61,   61,   61,   61,   60,
614
       61,   61,   13,   61,   35,   61,   12,   61,   61,   31,
615
616
       23,   16,    0,    0,    0,    0,   72,   15,   61,   61,
617
       61,   61,   61,   61,   24,   61,   61,   61,   61,   61,
618
       61,   61,   61,   61,   61,   61,   61,   61,   61,   61,
619
       18,   61,   61,   61,   61,   61,   61,   61,   11,   61,
620
       61,   61,   46,   61,   60,   61,   61,   21,   61,   61,
621
       61,   61,   61,   61,   47,   61,   61,   61,   61,   61,
622
       61,   45,   61,   61,   38,   10,   61,   14,   61,   61,
623
       39,   41,   61,   37,   20,   61,   61,    0,   61,   61,
624
       61,   22,   61,   42,   44,   52,   61,   61,   19,   36,
625
       61,   40,   43,    0
626
627
    } ;
628
629
static const YY_CHAR yy_ec[256] =
630
    {   0,
631
        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
632
        1,    1,    4,    1,    1,    1,    1,    1,    1,    1,
633
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
634
        1,    2,    5,    6,    7,    8,    1,    1,    1,    9,
635
        9,   10,    1,    1,    9,   11,   12,   13,   14,   15,
636
       16,   17,   18,   19,   18,   20,   21,    1,    1,   22,
637
       23,   24,    9,   25,   26,   27,   26,   26,   26,   26,
638
       28,   28,   28,   28,   29,   28,   30,   28,   28,   28,
639
       28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
640
        9,   31,    9,    1,   32,    1,   33,   34,   35,   36,
641
642
       37,   38,   39,   40,   41,   28,   28,   42,   43,   44,
643
       45,   46,   47,   48,   49,   50,   51,   52,   53,   54,
644
       55,   56,   57,    9,   58,    9,    1,    1,    1,    1,
645
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
646
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
647
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
648
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
649
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
650
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
651
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
652
653
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
654
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
655
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
656
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
657
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
658
        1,    1,    1,    1,    1
659
    } ;
660
661
static const YY_CHAR yy_meta[59] =
662
    {   0,
663
        1,    2,    3,    2,    1,    4,    1,    1,    2,    5,
664
        6,    7,    8,    8,    8,    8,    8,    8,    8,    8,
665
        8,    1,    9,    1,    1,   10,   10,   11,   12,   12,
666
       13,   11,   10,   10,   10,   10,   10,   10,   11,   11,
667
       11,   11,   11,   11,   12,   11,   11,   11,   11,   11,
668
       11,   11,   11,   12,   11,   11,    1,    1
669
    } ;
670
671
static const flex_int16_t yy_base[318] =
672
    {   0,
673
        0,    0,   56,   57,   58,   61,  502,  501,  496,  495,
674
      504,  509,  509,  509,  480,  509,    0,  492,  490,   55,
675
       55,   61,   46,  477,   51,    0,    0,   52,  466,  453,
676
      460,  452,   62,  453,   73,   43,  449,   33,  445,  441,
677
      441,   38,  449,  448,  443,  475,    0,  509,  509,   87,
678
        0,  509,   56,  474,    0,  509,  509,  473,  461,  509,
679
        0,  509,  473,  509,  509,    0,    0,    0,  455,  454,
680
      110,    0,  509,  509,  509,  509,  509,    0,    0,  438,
681
       43,  444,    0,  429,  433,  438,   83,  433,  432,  425,
682
      430,  426,  425,   67,  423,   86,  418,  417,  416,   95,
683
684
        0,    0,  424,  422,   99,  426,  411,  417,  424,  411,
685
       92,  128,    0,  509,  509,  509,  509,  509,  509,    0,
686
        0,  409,  509,  509,  509,    0,  509,    0,    0,  509,
687
      138,    0,    0,    0,    0,  416,  419,   84,  414,  405,
688
      405,  403,  414,    0,  408,  415,  404,  411,  395,  400,
689
      402,  128,  410,  407,  408,  407,  402,    0,  386,  400,
690
      388,  394,  391,  396,  382,  394,    0,  509,  420,  426,
691
        0,  387,  408,  385,  392,  380,  370,  367,  384,  371,
692
      366,  385,  367,  367,  382,  366,  362,  393,  396,  376,
693
      361,  368,    0,  358,    0,  373,    0,  355,  360,    0,
694
695
        0,    0,  393,  148,  399,  131,  509,    0,  384,  350,
696
      358,  361,  356,  349,    0,  325,  318,  309,  306,  272,
697
      275,  263,  253,  251,  234,  244,  243,  229,  224,  229,
698
      212,  223,  219,  225,  206,  209,  197,  200,    0,  147,
699
      146,  137,    0,  148,    0,  135,  134,    0,  145,  128,
700
      131,  138,  133,  128,    0,  136,  134,  137,  137,  128,
701
      121,    0,  168,  116,    0,    0,  127,    0,  131,  122,
702
        0,    0,  121,    0,    0,  115,  122,  157,  120,   99,
703
      109,    0,   62,    0,    0,  509,   49,   43,    0,    0,
704
       42,    0,    0,  509,  189,  202,  215,  228,  234,  239,
705
706
      247,  254,  259,  264,  275,  285,  297,  310,  322,  335,
707
      348,   69,  354,  357,  367,  380,  386
708
    } ;
709
710
static const flex_int16_t yy_def[318] =
711
    {   0,
712
      294,    1,  295,  295,  296,  296,  297,  297,  298,  298,
713
      294,  294,  294,  294,  299,  294,  300,  301,  294,  294,
714
      302,  302,  294,  294,  294,  303,  304,  304,  304,  304,
715
      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
716
      304,  304,  304,  304,  304,  305,  306,  294,  294,  307,
717
      308,  294,  294,  309,  310,  294,  294,  294,  299,  294,
718
      300,  294,  301,  294,  294,  311,  312,   22,  294,  294,
719
      294,  313,  294,  294,  294,  294,  294,  303,  304,  304,
720
      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
721
      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
722
723
      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
724
      305,  294,  306,  294,  294,  294,  294,  294,  294,  314,
725
      308,  294,  294,  294,  294,  310,  294,  311,  312,  294,
726
      294,  313,  304,  304,  304,  304,  304,  304,  304,  304,
727
      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
728
      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
729
      304,  304,  304,  304,  304,  304,  304,  294,  315,  316,
730
      317,  304,  304,  304,  304,  304,  304,  304,  304,  304,
731
      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
732
      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
733
734
      304,  304,  315,  315,  316,  305,  294,  304,  304,  304,
735
      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
736
      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
737
      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
738
      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
739
      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
740
      304,  304,  304,  304,  304,  304,  304,  304,  304,  304,
741
      304,  304,  304,  304,  304,  304,  304,  294,  304,  304,
742
      304,  304,  304,  304,  304,  294,  304,  304,  304,  304,
743
      304,  304,  304,    0,  294,  294,  294,  294,  294,  294,
744
745
      294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
746
      294,  294,  294,  294,  294,  294,  294
747
    } ;
748
749
static const flex_int16_t yy_nxt[568] =
750
    {   0,
751
       12,   13,   14,   13,   15,   16,   17,   18,   12,   12,
752
       19,   20,   21,   22,   22,   22,   22,   22,   22,   22,
753
       22,   23,   24,   25,   26,   27,   27,   27,   27,   27,
754
       12,   27,   28,   29,   30,   31,   32,   33,   34,   27,
755
       35,   27,   36,   37,   38,   39,   27,   40,   41,   42,
756
       43,   27,   44,   45,   27,   27,   46,   12,   48,   48,
757
       52,   49,   49,   52,   65,   67,   66,   73,   74,   53,
758
      101,   67,   53,   76,   77,   98,  129,  106,  134,   99,
759
      102,  293,  292,   69,   70,  107,   50,   50,   54,   69,
760
       70,   54,  115,   80,   88,   81,  122,  135,  291,   71,
761
762
       82,   83,   89,  112,  123,  294,   90,   93,   72,   94,
763
      148,  290,   91,  149,  294,   95,   96,  116,  140,  174,
764
      151,   97,  131,  131,  131,  131,  131,  131,  131,  156,
765
      117,  161,  141,  175,  118,  152,  119,  169,  157,  170,
766
      120,  188,  112,  189,  158,  289,  162,  190,  288,  168,
767
      131,  131,  131,  131,  131,  131,  131,  204,  278,  111,
768
      287,  285,  286,  284,  283,  282,  281,  280,  279,  278,
769
      277,  276,  275,  274,  273,  272,  271,  270,  269,  268,
770
      267,  266,  265,  264,  263,  262,  261,  260,  168,   47,
771
       47,   47,   47,   47,   47,   47,   47,   47,   47,   47,
772
773
       47,   47,   51,   51,   51,   51,   51,   51,   51,   51,
774
       51,   51,   51,   51,   51,   55,   55,   55,   55,   55,
775
       55,   55,   55,   55,   55,   55,   55,   55,   57,   57,
776
       57,   57,   57,   57,   57,   57,   57,   57,   57,   57,
777
       57,   59,   59,   59,   59,   59,   61,  259,   61,   61,
778
       61,   63,  258,  257,   63,  256,   63,   63,   63,   68,
779
      255,   68,  254,  253,  252,   68,   78,  251,   78,   78,
780
       78,   79,  250,   79,   79,   79,  111,  111,  249,  248,
781
      247,  111,  111,  246,  111,  113,  113,  245,  244,  113,
782
      113,  113,  113,  113,  113,  113,  113,  114,  114,  114,
783
784
      114,  114,  114,  114,  114,  114,  114,  114,  114,  114,
785
      121,  121,  243,  121,  121,  121,  242,  121,  121,  121,
786
      121,  121,  124,  124,  241,  124,  124,  124,  124,  124,
787
      124,  124,  124,  124,  124,  126,  126,  126,  240,  126,
788
      126,  126,  126,  126,  126,  126,  126,  126,  128,  128,
789
      239,  128,  128,  128,  128,  128,  128,  128,  128,  128,
790
      128,  132,  238,  132,  171,  237,  171,  203,  203,  203,
791
      203,  203,  203,  203,  203,  203,  203,  203,  203,  203,
792
      205,  205,  205,  205,  205,  205,  205,  205,  205,  205,
793
      205,  205,  205,  207,  236,  207,  235,  234,  233,  232,
794
795
      231,  206,  204,  230,  229,  228,  227,  226,  225,  224,
796
      190,  190,  223,  222,  221,  220,  219,  218,  217,  216,
797
      215,  214,  213,  212,  211,  210,  209,  208,  206,  204,
798
      202,  152,  201,  200,  199,  198,  197,  196,  195,  194,
799
      193,  192,  191,  187,  186,  185,  184,  183,  182,  181,
800
      180,  179,  178,  177,  176,  173,  172,  123,  167,  166,
801
      165,  164,  163,  160,  159,  155,  154,  153,  150,  147,
802
      146,  145,  144,  143,  142,  139,  138,  137,  136,  133,
803
      130,  130,   62,  294,  127,  125,  112,  110,  109,  108,
804
      105,  104,  103,  100,   92,   87,   86,   85,   84,   75,
805
806
       64,   62,   60,  294,   58,   58,   56,   56,   11,  294,
807
      294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
808
      294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
809
      294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
810
      294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
811
      294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
812
      294,  294,  294,  294,  294,  294,  294
813
    } ;
814
815
static const flex_int16_t yy_chk[568] =
816
    {   0,
817
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
818
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
819
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
820
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
821
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
822
        1,    1,    1,    1,    1,    1,    1,    1,    3,    4,
823
        5,    3,    4,    6,   20,   21,   20,   23,   23,    5,
824
       38,   22,    6,   25,   25,   36,  312,   42,   81,   36,
825
       38,  291,  288,   21,   21,   42,    3,    4,    5,   22,
826
       22,    6,   50,   28,   33,   28,   53,   81,  287,   21,
827
828
       28,   28,   33,  111,   53,   22,   33,   35,   21,   35,
829
       94,  283,   33,   94,   22,   35,   35,   50,   87,  138,
830
       96,   35,   71,   71,   71,   71,   71,   71,   71,  100,
831
       50,  105,   87,  138,   50,   96,   50,  112,  100,  112,
832
       50,  152,  206,  152,  100,  281,  105,  152,  280,  111,
833
      131,  131,  131,  131,  131,  131,  131,  204,  278,  204,
834
      279,  277,  278,  276,  273,  270,  269,  267,  264,  263,
835
      261,  260,  259,  258,  257,  256,  254,  253,  252,  251,
836
      250,  249,  247,  246,  244,  242,  241,  240,  206,  295,
837
      295,  295,  295,  295,  295,  295,  295,  295,  295,  295,
838
839
      295,  295,  296,  296,  296,  296,  296,  296,  296,  296,
840
      296,  296,  296,  296,  296,  297,  297,  297,  297,  297,
841
      297,  297,  297,  297,  297,  297,  297,  297,  298,  298,
842
      298,  298,  298,  298,  298,  298,  298,  298,  298,  298,
843
      298,  299,  299,  299,  299,  299,  300,  238,  300,  300,
844
      300,  301,  237,  236,  301,  235,  301,  301,  301,  302,
845
      234,  302,  233,  232,  231,  302,  303,  230,  303,  303,
846
      303,  304,  229,  304,  304,  304,  305,  305,  228,  227,
847
      226,  305,  305,  225,  305,  306,  306,  224,  223,  306,
848
      306,  306,  306,  306,  306,  306,  306,  307,  307,  307,
849
850
      307,  307,  307,  307,  307,  307,  307,  307,  307,  307,
851
      308,  308,  222,  308,  308,  308,  221,  308,  308,  308,
852
      308,  308,  309,  309,  220,  309,  309,  309,  309,  309,
853
      309,  309,  309,  309,  309,  310,  310,  310,  219,  310,
854
      310,  310,  310,  310,  310,  310,  310,  310,  311,  311,
855
      218,  311,  311,  311,  311,  311,  311,  311,  311,  311,
856
      311,  313,  217,  313,  314,  216,  314,  315,  315,  315,
857
      315,  315,  315,  315,  315,  315,  315,  315,  315,  315,
858
      316,  316,  316,  316,  316,  316,  316,  316,  316,  316,
859
      316,  316,  316,  317,  214,  317,  213,  212,  211,  210,
860
861
      209,  205,  203,  199,  198,  196,  194,  192,  191,  190,
862
      189,  188,  187,  186,  185,  184,  183,  182,  181,  180,
863
      179,  178,  177,  176,  175,  174,  173,  172,  170,  169,
864
      166,  165,  164,  163,  162,  161,  160,  159,  157,  156,
865
      155,  154,  153,  151,  150,  149,  148,  147,  146,  145,
866
      143,  142,  141,  140,  139,  137,  136,  122,  110,  109,
867
      108,  107,  106,  104,  103,   99,   98,   97,   95,   93,
868
       92,   91,   90,   89,   88,   86,   85,   84,   82,   80,
869
       70,   69,   63,   59,   58,   54,   46,   45,   44,   43,
870
       41,   40,   39,   37,   34,   32,   31,   30,   29,   24,
871
872
       19,   18,   15,   11,   10,    9,    8,    7,  294,  294,
873
      294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
874
      294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
875
      294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
876
      294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
877
      294,  294,  294,  294,  294,  294,  294,  294,  294,  294,
878
      294,  294,  294,  294,  294,  294,  294
879
    } ;
880
881
/* Table of booleans, true if rule could match eol. */
882
static const flex_int32_t yy_rule_can_match_eol[87] =
883
    {   0,
884
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
885
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
886
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 
887
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 
888
    1, 0, 0, 1, 1, 0, 0,     };
889
890
/* The intent behind this definition is that it'll catch
891
 * any uses of REJECT which flex missed.
892
 */
893
#define REJECT reject_used_but_not_detected
894
#define yymore() yymore_used_but_not_detected
895
6.36k
#define YY_MORE_ADJ 0
896
#define YY_RESTORE_YY_MORE_OFFSET
897
#line 1 "libyara/lexer.l"
898
/*
899
Copyright (c) 2007-2013. The YARA Authors. All Rights Reserved.
900
901
Redistribution and use in source and binary forms, with or without modification,
902
are permitted provided that the following conditions are met:
903
904
1. Redistributions of source code must retain the above copyright notice, this
905
list of conditions and the following disclaimer.
906
907
2. Redistributions in binary form must reproduce the above copyright notice,
908
this list of conditions and the following disclaimer in the documentation and/or
909
other materials provided with the distribution.
910
911
3. Neither the name of the copyright holder nor the names of its contributors
912
may be used to endorse or promote products derived from this software without
913
specific prior written permission.
914
915
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
916
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
917
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
918
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
919
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
920
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
921
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
922
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
923
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
924
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
925
*/
926
/* Lexical analyzer for YARA */
927
#line 33 "libyara/lexer.l"
928
929
/* Disable warnings for unused functions in this file.
930
931
As we redefine YY_FATAL_ERROR macro to use our own function yara_yyfatal, the
932
yy_fatal_error function generated by Flex is not actually used, causing a
933
compiler warning. Flex doesn't offer any options to remove the yy_fatal_error
934
function. When they include something like %option noyy_fatal_error as they do
935
with noyywrap then we can remove this pragma.
936
*/
937
938
#ifdef __GNUC__
939
#pragma GCC diagnostic ignored "-Wunused-function"
940
#endif
941
942
#include <math.h>
943
#include <stdarg.h>
944
#include <stdio.h>
945
#include <stdlib.h>
946
#include <string.h>
947
#include <setjmp.h>
948
949
#if defined(_WIN32) || defined(__CYGWIN__)
950
#include <windows.h>
951
#else
952
#include <sys/stat.h>
953
#include <unistd.h>
954
#endif
955
956
#if defined(_WIN32)
957
#define strtoll _strtoi64
958
#endif
959
960
#include <yara/integers.h>
961
#include <yara/lexer.h>
962
#include <yara/sizedstr.h>
963
#include <yara/error.h>
964
#include <yara/mem.h>
965
#include <yara/utils.h>
966
#include <yara/strutils.h>
967
968
#include "grammar.h"
969
970
#define error(error_code) \
971
36
    { \
972
36
      compiler->last_error = error_code; \
973
454
      yyerror(yyscanner, compiler, NULL); \
974
454
      yyterminate(); \
975
454
    }
976
977
#define syntax_error(error_msg) \
978
36
    { \
979
437
      yr_compiler_set_error_extra_info(compiler, error_msg); \
980
437
      error(ERROR_SYNTAX_ERROR); \
981
0
    }
982
983
#define lex_check_space_ok(data, current_size, max_length) \
984
83.5k
    if (strlen(data) + current_size >= max_length - 1) \
985
83.5k
    { \
986
19
      yyerror(yyscanner, compiler, "out of space in lex_buf"); \
987
19
      yyterminate(); \
988
19
    }
989
990
#define yytext_to_buffer \
991
46.9k
    { \
992
46.9k
      char *yptr = yytext; \
993
46.9k
      lex_check_space_ok(yptr, yyextra->lex_buf_len, YR_LEX_BUF_SIZE); \
994
1.53M
      while(*yptr) \
995
1.48M
      { \
996
1.48M
        *yyextra->lex_buf_ptr++ = *yptr++; \
997
1.48M
        yyextra->lex_buf_len++; \
998
1.48M
      } \
999
46.9k
    }
1000
1001
#define alloc_sized_string(str, str_len) \
1002
41.7k
  SIZED_STRING* str = (SIZED_STRING*) yr_malloc( \
1003
41.7k
      str_len + sizeof(SIZED_STRING)); \
1004
41.7k
  if (str == NULL) \
1005
41.7k
  { \
1006
0
    yyerror(yyscanner, compiler, "not enough memory"); \
1007
0
    yyterminate(); \
1008
0
  } \
1009
41.7k
  else \
1010
41.7k
  { \
1011
41.7k
    str->length = (uint32_t) (str_len); \
1012
41.7k
    str->flags = 0; \
1013
41.7k
  } \
1014
1015
#ifdef _WIN32
1016
#define snprintf _snprintf
1017
#endif
1018
1019
static bool is_absolute_path(
1020
    char* path)
1021
0
{
1022
0
  if (path == NULL)
1023
0
    return false;
1024
1025
  #if defined(_WIN32) || defined(__CYGWIN__)
1026
  return strlen(path) > 2 &&
1027
      path[1] == ':' && (path[2] == '/' || path[2] == '\\');
1028
  #else
1029
0
  return strlen(path) > 0 && path[0] == '/';
1030
0
  #endif
1031
0
}
1032
1033
#line 1033 "libyara/lexer.c"
1034
#define YY_NO_UNISTD_H 1
1035
#define YY_NO_INPUT 1
1036
1037
#line 1037 "libyara/lexer.c"
1038
1039
41.3k
#define INITIAL 0
1040
14.9k
#define str 1
1041
25.2k
#define regexp 2
1042
1.28k
#define include 3
1043
164
#define comment 4
1044
1045
#ifndef YY_NO_UNISTD_H
1046
/* Special case for "unistd.h", since it is non-ANSI. We include it way
1047
 * down here because we want the user's section 1 to have been scanned first.
1048
 * The user has a chance to override it with an option.
1049
 */
1050
#include <unistd.h>
1051
#endif
1052
1053
#ifndef YY_EXTRA_TYPE
1054
#define YY_EXTRA_TYPE void *
1055
#endif
1056
1057
/* Holds the entire state of the reentrant scanner. */
1058
struct yyguts_t
1059
    {
1060
1061
    /* User-defined. Not touched by flex. */
1062
    YY_EXTRA_TYPE yyextra_r;
1063
1064
    /* The rest are the same as the globals declared in the non-reentrant scanner. */
1065
    FILE *yyin_r, *yyout_r;
1066
    size_t yy_buffer_stack_top; /**< index of top of stack. */
1067
    size_t yy_buffer_stack_max; /**< capacity of stack. */
1068
    YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
1069
    char yy_hold_char;
1070
    int yy_n_chars;
1071
    int yyleng_r;
1072
    char *yy_c_buf_p;
1073
    int yy_init;
1074
    int yy_start;
1075
    int yy_did_buffer_switch_on_eof;
1076
    int yy_start_stack_ptr;
1077
    int yy_start_stack_depth;
1078
    int *yy_start_stack;
1079
    yy_state_type yy_last_accepting_state;
1080
    char* yy_last_accepting_cpos;
1081
1082
    int yylineno_r;
1083
    int yy_flex_debug_r;
1084
1085
    char *yytext_r;
1086
    int yy_more_flag;
1087
    int yy_more_len;
1088
1089
    YYSTYPE * yylval_r;
1090
1091
    }; /* end struct yyguts_t */
1092
1093
static int yy_init_globals ( yyscan_t yyscanner );
1094
1095
    /* This must go here because YYSTYPE and YYLTYPE are included
1096
     * from bison output in section 1.*/
1097
1.08M
    #    define yylval yyg->yylval_r
1098
    
1099
int yylex_init (yyscan_t* scanner);
1100
1101
int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
1102
1103
/* Accessor methods to globals.
1104
   These are made visible to non-reentrant scanners for convenience. */
1105
1106
int yylex_destroy ( yyscan_t yyscanner );
1107
1108
int yyget_debug ( yyscan_t yyscanner );
1109
1110
void yyset_debug ( int debug_flag , yyscan_t yyscanner );
1111
1112
YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
1113
1114
void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
1115
1116
FILE *yyget_in ( yyscan_t yyscanner );
1117
1118
void yyset_in  ( FILE * _in_str , yyscan_t yyscanner );
1119
1120
FILE *yyget_out ( yyscan_t yyscanner );
1121
1122
void yyset_out  ( FILE * _out_str , yyscan_t yyscanner );
1123
1124
      int yyget_leng ( yyscan_t yyscanner );
1125
1126
char *yyget_text ( yyscan_t yyscanner );
1127
1128
int yyget_lineno ( yyscan_t yyscanner );
1129
1130
void yyset_lineno ( int _line_number , yyscan_t yyscanner );
1131
1132
int yyget_column  ( yyscan_t yyscanner );
1133
1134
void yyset_column ( int _column_no , yyscan_t yyscanner );
1135
1136
YYSTYPE * yyget_lval ( yyscan_t yyscanner );
1137
1138
void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );
1139
1140
/* Macros after this point can all be overridden by user definitions in
1141
 * section 1.
1142
 */
1143
1144
#ifndef YY_SKIP_YYWRAP
1145
#ifdef __cplusplus
1146
extern "C" int yywrap ( yyscan_t yyscanner );
1147
#else
1148
extern int yywrap ( yyscan_t yyscanner );
1149
#endif
1150
#endif
1151
1152
#ifndef YY_NO_UNPUT
1153
    
1154
#endif
1155
1156
#ifndef yytext_ptr
1157
static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
1158
#endif
1159
1160
#ifdef YY_NEED_STRLEN
1161
static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
1162
#endif
1163
1164
#ifndef YY_NO_INPUT
1165
#ifdef __cplusplus
1166
static int yyinput ( yyscan_t yyscanner );
1167
#else
1168
static int input ( yyscan_t yyscanner );
1169
#endif
1170
1171
#endif
1172
1173
/* Amount of stuff to slurp up with each read. */
1174
#ifndef YY_READ_BUF_SIZE
1175
#ifdef __ia64__
1176
/* On IA-64, the buffer size is 16k, not 8k */
1177
#define YY_READ_BUF_SIZE 16384
1178
#else
1179
0
#define YY_READ_BUF_SIZE 8192
1180
#endif /* __ia64__ */
1181
#endif
1182
1183
/* Copy whatever the last rule matched to the standard output. */
1184
#ifndef ECHO
1185
/* This used to be an fputs(), but since the string might contain NUL's,
1186
 * we now use fwrite().
1187
 */
1188
#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
1189
#endif
1190
1191
/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
1192
 * is returned in "result".
1193
 */
1194
#ifndef YY_INPUT
1195
#define YY_INPUT(buf,result,max_size) \
1196
0
  if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
1197
0
    { \
1198
0
    int c = '*'; \
1199
0
    int n; \
1200
0
    for ( n = 0; n < max_size && \
1201
0
           (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
1202
0
      buf[n] = (char) c; \
1203
0
    if ( c == '\n' ) \
1204
0
      buf[n++] = (char) c; \
1205
0
    if ( c == EOF && ferror( yyin ) ) \
1206
0
      YY_FATAL_ERROR( "input in flex scanner failed" ); \
1207
0
    result = n; \
1208
0
    } \
1209
0
  else \
1210
0
    { \
1211
0
    errno=0; \
1212
0
    while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
1213
0
      { \
1214
0
      if( errno != EINTR) \
1215
0
        { \
1216
0
        YY_FATAL_ERROR( "input in flex scanner failed" ); \
1217
0
        break; \
1218
0
        } \
1219
0
      errno=0; \
1220
0
      clearerr(yyin); \
1221
0
      } \
1222
0
    }\
1223
\
1224
1225
#endif
1226
1227
/* No semi-colon after return; correct usage is to write "yyterminate();" -
1228
 * we don't want an extra ';' after the "return" because that will cause
1229
 * some compilers to complain about unreachable statements.
1230
 */
1231
#ifndef yyterminate
1232
1.70k
#define yyterminate() return YY_NULL
1233
#endif
1234
1235
/* Number of entries by which start-condition stack grows. */
1236
#ifndef YY_START_STACK_INCR
1237
#define YY_START_STACK_INCR 25
1238
#endif
1239
1240
/* Report a fatal error. */
1241
#ifndef YY_FATAL_ERROR
1242
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
1243
#endif
1244
1245
/* end tables serialization structures and prototypes */
1246
1247
/* Default declaration of generated scanner - a define so the user can
1248
 * easily add parameters.
1249
 */
1250
#ifndef YY_DECL
1251
#define YY_DECL_IS_OURS 1
1252
1253
extern int yylex \
1254
               (YYSTYPE * yylval_param , yyscan_t yyscanner);
1255
1256
#define YY_DECL int yylex \
1257
               (YYSTYPE * yylval_param , yyscan_t yyscanner)
1258
#endif /* !YY_DECL */
1259
1260
/* Code executed at the beginning of each rule, after yytext and yyleng
1261
 * have been set up.
1262
 */
1263
#ifndef YY_USER_ACTION
1264
#define YY_USER_ACTION
1265
#endif
1266
1267
/* Code executed at the end of each rule. */
1268
#ifndef YY_BREAK
1269
225k
#define YY_BREAK /*LINTED*/break;
1270
#endif
1271
1272
#define YY_RULE_SETUP \
1273
  YY_USER_ACTION
1274
1275
/** The main scanner function which does all the work.
1276
 */
1277
YY_DECL
1278
606k
{
1279
606k
  yy_state_type yy_current_state;
1280
606k
  char *yy_cp, *yy_bp;
1281
606k
  int yy_act;
1282
606k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1283
1284
606k
    yylval = yylval_param;
1285
1286
606k
  if ( !yyg->yy_init )
1287
1.70k
    {
1288
1.70k
    yyg->yy_init = 1;
1289
1290
#ifdef YY_USER_INIT
1291
    YY_USER_INIT;
1292
#endif
1293
1294
1.70k
    if ( ! yyg->yy_start )
1295
1.70k
      yyg->yy_start = 1; /* first start state */
1296
1297
1.70k
    if ( ! yyin )
1298
1.70k
      yyin = stdin;
1299
1300
1.70k
    if ( ! yyout )
1301
1.70k
      yyout = stdout;
1302
1303
1.70k
    if ( ! YY_CURRENT_BUFFER ) {
1304
0
      yyensure_buffer_stack (yyscanner);
1305
0
      YY_CURRENT_BUFFER_LVALUE =
1306
0
        yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
1307
0
    }
1308
1309
1.70k
    yy_load_buffer_state( yyscanner );
1310
1.70k
    }
1311
1312
606k
  {
1313
606k
#line 163 "libyara/lexer.l"
1314
1315
1316
606k
#line 1316 "libyara/lexer.c"
1317
1318
831k
  while ( /*CONSTCOND*/1 )    /* loops until end-of-file is reached */
1319
831k
    {
1320
831k
    yy_cp = yyg->yy_c_buf_p;
1321
1322
    /* Support of yytext. */
1323
831k
    *yy_cp = yyg->yy_hold_char;
1324
1325
    /* yy_bp points to the position in yy_ch_buf of the start of
1326
     * the current run.
1327
     */
1328
831k
    yy_bp = yy_cp;
1329
1330
831k
    yy_current_state = yyg->yy_start;
1331
831k
yy_match:
1332
831k
    do
1333
4.36M
      {
1334
4.36M
      YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
1335
4.36M
      if ( yy_accept[yy_current_state] )
1336
3.09M
        {
1337
3.09M
        yyg->yy_last_accepting_state = yy_current_state;
1338
3.09M
        yyg->yy_last_accepting_cpos = yy_cp;
1339
3.09M
        }
1340
7.97M
      while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1341
3.60M
        {
1342
3.60M
        yy_current_state = (int) yy_def[yy_current_state];
1343
3.60M
        if ( yy_current_state >= 295 )
1344
2.73M
          yy_c = yy_meta[yy_c];
1345
3.60M
        }
1346
4.36M
      yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1347
4.36M
      ++yy_cp;
1348
4.36M
      }
1349
4.36M
    while ( yy_current_state != 294 );
1350
831k
    yy_cp = yyg->yy_last_accepting_cpos;
1351
831k
    yy_current_state = yyg->yy_last_accepting_state;
1352
1353
833k
yy_find_action:
1354
833k
    yy_act = yy_accept[yy_current_state];
1355
1356
833k
    YY_DO_BEFORE_ACTION;
1357
1358
833k
    if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
1359
101k
      {
1360
101k
      int yyl;
1361
718k
      for ( yyl = 0; yyl < yyleng; ++yyl )
1362
617k
        if ( yytext[yyl] == '\n' )
1363
          
1364
38.2k
    do{ yylineno++;
1365
38.2k
        yycolumn=0;
1366
38.2k
    }while(0)
1367
101k
;
1368
101k
      }
1369
1370
834k
do_action:  /* This label is used only to access EOF actions. */
1371
1372
834k
    switch ( yy_act )
1373
834k
  { /* beginning of action switch */
1374
18
      case 0: /* must back up */
1375
      /* undo the effects of YY_DO_BEFORE_ACTION */
1376
18
      *yy_cp = yyg->yy_hold_char;
1377
18
      yy_cp = yyg->yy_last_accepting_cpos;
1378
18
      yy_current_state = yyg->yy_last_accepting_state;
1379
18
      goto yy_find_action;
1380
1381
935
case 1:
1382
935
YY_RULE_SETUP
1383
935
#line 165 "libyara/lexer.l"
1384
935
{ return _DOT_DOT_;     }
1385
0
  YY_BREAK
1386
2.18k
case 2:
1387
2.18k
YY_RULE_SETUP
1388
2.18k
#line 166 "libyara/lexer.l"
1389
2.18k
{ return _LT_;          }
1390
0
  YY_BREAK
1391
2.13k
case 3:
1392
2.13k
YY_RULE_SETUP
1393
2.13k
#line 167 "libyara/lexer.l"
1394
2.13k
{ return _GT_;          }
1395
0
  YY_BREAK
1396
630
case 4:
1397
630
YY_RULE_SETUP
1398
630
#line 168 "libyara/lexer.l"
1399
630
{ return _LE_;          }
1400
0
  YY_BREAK
1401
740
case 5:
1402
740
YY_RULE_SETUP
1403
740
#line 169 "libyara/lexer.l"
1404
740
{ return _GE_;          }
1405
0
  YY_BREAK
1406
1.43k
case 6:
1407
1.43k
YY_RULE_SETUP
1408
1.43k
#line 170 "libyara/lexer.l"
1409
1.43k
{ return _EQ_;          }
1410
0
  YY_BREAK
1411
764
case 7:
1412
764
YY_RULE_SETUP
1413
764
#line 171 "libyara/lexer.l"
1414
764
{ return _NEQ_;         }
1415
0
  YY_BREAK
1416
3.25k
case 8:
1417
3.25k
YY_RULE_SETUP
1418
3.25k
#line 172 "libyara/lexer.l"
1419
3.25k
{ return _SHIFT_LEFT_;  }
1420
0
  YY_BREAK
1421
1.80k
case 9:
1422
1.80k
YY_RULE_SETUP
1423
1.80k
#line 173 "libyara/lexer.l"
1424
1.80k
{ return _SHIFT_RIGHT_; }
1425
0
  YY_BREAK
1426
737
case 10:
1427
737
YY_RULE_SETUP
1428
737
#line 174 "libyara/lexer.l"
1429
737
{ return _PRIVATE_;     }
1430
0
  YY_BREAK
1431
1.19k
case 11:
1432
1.19k
YY_RULE_SETUP
1433
1.19k
#line 175 "libyara/lexer.l"
1434
1.19k
{ return _GLOBAL_;      }
1435
0
  YY_BREAK
1436
17.5k
case 12:
1437
17.5k
YY_RULE_SETUP
1438
17.5k
#line 176 "libyara/lexer.l"
1439
17.5k
{ return _RULE_;        }
1440
0
  YY_BREAK
1441
316
case 13:
1442
316
YY_RULE_SETUP
1443
316
#line 177 "libyara/lexer.l"
1444
316
{ return _META_;        }
1445
0
  YY_BREAK
1446
3.98k
case 14:
1447
3.98k
YY_RULE_SETUP
1448
3.98k
#line 178 "libyara/lexer.l"
1449
3.98k
{ return _STRINGS_;     }
1450
0
  YY_BREAK
1451
983
case 15:
1452
983
YY_RULE_SETUP
1453
983
#line 179 "libyara/lexer.l"
1454
983
{ return _ASCII_;       }
1455
0
  YY_BREAK
1456
1.48k
case 16:
1457
1.48k
YY_RULE_SETUP
1458
1.48k
#line 180 "libyara/lexer.l"
1459
1.48k
{ return _WIDE_;        }
1460
0
  YY_BREAK
1461
751
case 17:
1462
751
YY_RULE_SETUP
1463
751
#line 181 "libyara/lexer.l"
1464
751
{ return _XOR_;         }
1465
0
  YY_BREAK
1466
1.52k
case 18:
1467
1.52k
YY_RULE_SETUP
1468
1.52k
#line 182 "libyara/lexer.l"
1469
1.52k
{ return _BASE64_;      }
1470
0
  YY_BREAK
1471
1.83k
case 19:
1472
1.83k
YY_RULE_SETUP
1473
1.83k
#line 183 "libyara/lexer.l"
1474
1.83k
{ return _BASE64_WIDE_; }
1475
0
  YY_BREAK
1476
383
case 20:
1477
383
YY_RULE_SETUP
1478
383
#line 184 "libyara/lexer.l"
1479
383
{ return _FULLWORD_;    }
1480
0
  YY_BREAK
1481
361
case 21:
1482
361
YY_RULE_SETUP
1483
361
#line 185 "libyara/lexer.l"
1484
361
{ return _NOCASE_;      }
1485
0
  YY_BREAK
1486
6.26k
case 22:
1487
6.26k
YY_RULE_SETUP
1488
6.26k
#line 186 "libyara/lexer.l"
1489
6.26k
{ return _CONDITION_;   }
1490
0
  YY_BREAK
1491
234
case 23:
1492
234
YY_RULE_SETUP
1493
234
#line 187 "libyara/lexer.l"
1494
234
{ return _TRUE_;        }
1495
0
  YY_BREAK
1496
460
case 24:
1497
460
YY_RULE_SETUP
1498
460
#line 188 "libyara/lexer.l"
1499
460
{ return _FALSE_;       }
1500
0
  YY_BREAK
1501
225
case 25:
1502
225
YY_RULE_SETUP
1503
225
#line 189 "libyara/lexer.l"
1504
225
{ return _NOT_;         }
1505
0
  YY_BREAK
1506
678
case 26:
1507
678
YY_RULE_SETUP
1508
678
#line 190 "libyara/lexer.l"
1509
678
{ return _AND_;         }
1510
0
  YY_BREAK
1511
11.1k
case 27:
1512
11.1k
YY_RULE_SETUP
1513
11.1k
#line 191 "libyara/lexer.l"
1514
11.1k
{ return _OR_;          }
1515
0
  YY_BREAK
1516
7.39k
case 28:
1517
7.39k
YY_RULE_SETUP
1518
7.39k
#line 192 "libyara/lexer.l"
1519
7.39k
{ return _AT_;          }
1520
0
  YY_BREAK
1521
3.74k
case 29:
1522
3.74k
YY_RULE_SETUP
1523
3.74k
#line 193 "libyara/lexer.l"
1524
3.74k
{ return _IN_;          }
1525
0
  YY_BREAK
1526
10.1k
case 30:
1527
10.1k
YY_RULE_SETUP
1528
10.1k
#line 194 "libyara/lexer.l"
1529
10.1k
{ return _OF_;          }
1530
0
  YY_BREAK
1531
762
case 31:
1532
762
YY_RULE_SETUP
1533
762
#line 195 "libyara/lexer.l"
1534
762
{ return _THEM_;        }
1535
0
  YY_BREAK
1536
4.01k
case 32:
1537
4.01k
YY_RULE_SETUP
1538
4.01k
#line 196 "libyara/lexer.l"
1539
4.01k
{ return _FOR_;         }
1540
0
  YY_BREAK
1541
2.60k
case 33:
1542
2.60k
YY_RULE_SETUP
1543
2.60k
#line 197 "libyara/lexer.l"
1544
2.60k
{ return _ALL_;         }
1545
0
  YY_BREAK
1546
2.61k
case 34:
1547
2.61k
YY_RULE_SETUP
1548
2.61k
#line 198 "libyara/lexer.l"
1549
2.61k
{ return _ANY_;         }
1550
0
  YY_BREAK
1551
221
case 35:
1552
221
YY_RULE_SETUP
1553
221
#line 199 "libyara/lexer.l"
1554
221
{ return _NONE_;        }
1555
0
  YY_BREAK
1556
176
case 36:
1557
176
YY_RULE_SETUP
1558
176
#line 200 "libyara/lexer.l"
1559
176
{ return _ENTRYPOINT_;  }
1560
0
  YY_BREAK
1561
420
case 37:
1562
420
YY_RULE_SETUP
1563
420
#line 201 "libyara/lexer.l"
1564
420
{ return _FILESIZE_;    }
1565
0
  YY_BREAK
1566
226
case 38:
1567
226
YY_RULE_SETUP
1568
226
#line 202 "libyara/lexer.l"
1569
226
{ return _MATCHES_;     }
1570
0
  YY_BREAK
1571
307
case 39:
1572
307
YY_RULE_SETUP
1573
307
#line 203 "libyara/lexer.l"
1574
307
{ return _CONTAINS_;    }
1575
0
  YY_BREAK
1576
296
case 40:
1577
296
YY_RULE_SETUP
1578
296
#line 204 "libyara/lexer.l"
1579
296
{ return _STARTSWITH_;  }
1580
0
  YY_BREAK
1581
193
case 41:
1582
193
YY_RULE_SETUP
1583
193
#line 205 "libyara/lexer.l"
1584
193
{ return _ENDSWITH_;    }
1585
0
  YY_BREAK
1586
375
case 42:
1587
375
YY_RULE_SETUP
1588
375
#line 206 "libyara/lexer.l"
1589
375
{ return _ICONTAINS_;   }
1590
0
  YY_BREAK
1591
543
case 43:
1592
543
YY_RULE_SETUP
1593
543
#line 207 "libyara/lexer.l"
1594
543
{ return _ISTARTSWITH_; }
1595
0
  YY_BREAK
1596
298
case 44:
1597
298
YY_RULE_SETUP
1598
298
#line 208 "libyara/lexer.l"
1599
298
{ return _IENDSWITH_;   }
1600
0
  YY_BREAK
1601
0
case 45:
1602
0
YY_RULE_SETUP
1603
0
#line 209 "libyara/lexer.l"
1604
0
{ return _IEQUALS_;     }
1605
0
  YY_BREAK
1606
3.11k
case 46:
1607
3.11k
YY_RULE_SETUP
1608
3.11k
#line 210 "libyara/lexer.l"
1609
3.11k
{ return _IMPORT_;      }
1610
0
  YY_BREAK
1611
164
case 47:
1612
164
YY_RULE_SETUP
1613
164
#line 211 "libyara/lexer.l"
1614
164
{ return _DEFINED_;     }
1615
0
  YY_BREAK
1616
164
case 48:
1617
164
YY_RULE_SETUP
1618
164
#line 214 "libyara/lexer.l"
1619
164
{ BEGIN(comment);       }
1620
164
  YY_BREAK
1621
161
case 49:
1622
161
YY_RULE_SETUP
1623
161
#line 215 "libyara/lexer.l"
1624
161
{ BEGIN(INITIAL);       }
1625
161
  YY_BREAK
1626
61
case 50:
1627
/* rule 50 can match eol */
1628
61
YY_RULE_SETUP
1629
61
#line 216 "libyara/lexer.l"
1630
61
{ /* skip comments */   }
1631
61
  YY_BREAK
1632
198
case 51:
1633
198
YY_RULE_SETUP
1634
198
#line 219 "libyara/lexer.l"
1635
198
{ /* skip single-line comments */ }
1636
198
  YY_BREAK
1637
1.28k
case 52:
1638
1.28k
YY_RULE_SETUP
1639
1.28k
#line 222 "libyara/lexer.l"
1640
1.28k
{
1641
1.28k
                          yyextra->lex_buf_ptr = yyextra->lex_buf;
1642
1.28k
                          yyextra->lex_buf_len = 0;
1643
1.28k
                          BEGIN(include);
1644
1.28k
                        }
1645
1.28k
  YY_BREAK
1646
967
case 53:
1647
/* rule 53 can match eol */
1648
967
YY_RULE_SETUP
1649
967
#line 229 "libyara/lexer.l"
1650
967
{ yytext_to_buffer; }
1651
964
  YY_BREAK
1652
1.27k
case 54:
1653
1.27k
YY_RULE_SETUP
1654
1.27k
#line 232 "libyara/lexer.l"
1655
1.27k
{
1656
1657
1.27k
  if (compiler->include_callback != NULL)
1658
1.27k
  {
1659
    #ifdef _MSC_VER
1660
    char* b = NULL;
1661
    #endif
1662
1.27k
    char* s = NULL;
1663
1.27k
    char* f;
1664
1665
1.27k
    char buffer[1024];
1666
1.27k
    const char* included_rules;
1667
1.27k
    char* current_file_name;
1668
1.27k
    char* include_path;
1669
1670
1.27k
    *yyextra->lex_buf_ptr = '\0'; // null-terminate included file path
1671
1672
1.27k
    current_file_name = yr_compiler_get_current_file_name(compiler);
1673
1674
1.27k
    if (current_file_name == NULL ||
1675
0
        compiler->include_callback != _yr_compiler_default_include_callback ||
1676
0
        is_absolute_path(yyextra->lex_buf))
1677
1.27k
    {
1678
1.27k
      include_path = yyextra->lex_buf;
1679
1.27k
    }
1680
0
    else
1681
0
    {
1682
0
      strlcpy(buffer, current_file_name, sizeof(buffer));
1683
0
      s = strrchr(buffer, '/');
1684
1685
      #ifdef _MSC_VER
1686
      b = strrchr(buffer, '\\'); // in Windows both path delimiters are accepted
1687
      #endif
1688
1689
      #ifdef _MSC_VER
1690
      if (s != NULL || b != NULL)
1691
      #else
1692
0
      if (s != NULL)
1693
0
      #endif
1694
0
      {
1695
        #ifdef _MSC_VER
1696
        f = (b > s) ? (b + 1) : (s + 1);
1697
        #else
1698
0
        f = s + 1;
1699
0
        #endif
1700
1701
0
        strlcpy(f, yyextra->lex_buf, sizeof(buffer) - (f - buffer));
1702
0
        include_path = buffer;
1703
0
      }
1704
0
      else
1705
0
      {
1706
0
        include_path = yyextra->lex_buf;
1707
0
      }
1708
0
    }
1709
1710
1.27k
    YR_NAMESPACE* ns = (YR_NAMESPACE*) yr_arena_get_ptr(
1711
1.27k
        compiler->arena,
1712
1.27k
        YR_NAMESPACES_TABLE,
1713
1.27k
        compiler->current_namespace_idx * sizeof(struct YR_NAMESPACE));
1714
1715
1.27k
    included_rules = compiler->include_callback(
1716
1.27k
        include_path,
1717
1.27k
        current_file_name,
1718
1.27k
        ns->name,
1719
1.27k
        compiler->incl_clbk_user_data);
1720
1721
1.27k
    if (included_rules != NULL)
1722
0
    {
1723
0
      int error_code = _yr_compiler_push_file_name(compiler, include_path);
1724
1725
0
      if (error_code != ERROR_SUCCESS)
1726
0
      {
1727
0
        if (error_code == ERROR_INCLUDES_CIRCULAR_REFERENCE)
1728
0
        {
1729
0
          yyerror(yyscanner, compiler, "includes circular reference");
1730
0
        }
1731
0
        else if (error_code == ERROR_INCLUDE_DEPTH_EXCEEDED)
1732
0
        {
1733
0
          yyerror(yyscanner, compiler, "includes depth exceeded");
1734
0
        }
1735
1736
0
        if (compiler->include_free != NULL)
1737
0
        {
1738
0
          compiler->include_free(included_rules, compiler->incl_clbk_user_data);
1739
0
        }
1740
1741
0
        yyterminate();
1742
0
      }
1743
1744
      // Workaround for flex issue: https://github.com/westes/flex/issues/58
1745
0
      yypush_buffer_state(YY_CURRENT_BUFFER, yyscanner);
1746
0
      yy_scan_string(included_rules, yyscanner);
1747
0
      yyset_lineno(1, yyscanner);
1748
1749
0
      if (compiler->include_free != NULL)
1750
0
      {
1751
0
        compiler->include_free(included_rules, compiler->incl_clbk_user_data);
1752
0
      }
1753
0
    }
1754
1.27k
    else
1755
1.27k
    {
1756
1.27k
      char* err_msg_fmt;
1757
1.27k
      char err_msg[512];
1758
1759
1.27k
      if (compiler->include_callback == _yr_compiler_default_include_callback)
1760
1.27k
      {
1761
1.27k
        err_msg_fmt = "can't open include file: %s";
1762
1.27k
      }
1763
0
      else
1764
0
      {
1765
0
        err_msg_fmt = "callback failed to provide include resource: %s";
1766
0
      }
1767
1768
1.27k
      snprintf(
1769
1.27k
          err_msg,
1770
1.27k
          sizeof(err_msg),
1771
1.27k
          err_msg_fmt,
1772
1.27k
          yyextra->lex_buf);
1773
1774
1.27k
      yyerror(yyscanner, compiler, err_msg);
1775
1.27k
    }
1776
1777
1.27k
  }
1778
0
  else // not allowing includes
1779
0
  {
1780
0
    yyerror(yyscanner, compiler, "includes are disabled");
1781
0
  }
1782
1783
1.27k
  BEGIN(INITIAL);
1784
1.27k
}
1785
1.27k
  YY_BREAK
1786
991
case YY_STATE_EOF(INITIAL):
1787
1.10k
case YY_STATE_EOF(str):
1788
1.21k
case YY_STATE_EOF(regexp):
1789
1.22k
case YY_STATE_EOF(include):
1790
1.23k
case YY_STATE_EOF(comment):
1791
1.23k
#line 364 "libyara/lexer.l"
1792
1.23k
{
1793
1794
1.23k
  yypop_buffer_state(yyscanner);
1795
1796
1.23k
  if (!YY_CURRENT_BUFFER)
1797
1.23k
    yyterminate();
1798
1799
0
  return _END_OF_INCLUDED_FILE_;
1800
1.23k
}
1801
0
  YY_BREAK
1802
589
case 55:
1803
589
YY_RULE_SETUP
1804
589
#line 375 "libyara/lexer.l"
1805
589
{
1806
1807
589
  yylval->c_string = yr_strdup(yytext);
1808
1809
589
  if (yylval->c_string == NULL)
1810
589
    error(ERROR_INSUFFICIENT_MEMORY);
1811
1812
589
  return _STRING_IDENTIFIER_WITH_WILDCARD_;
1813
589
}
1814
0
  YY_BREAK
1815
41.6k
case 56:
1816
41.6k
YY_RULE_SETUP
1817
41.6k
#line 386 "libyara/lexer.l"
1818
41.6k
{
1819
1820
41.6k
  yylval->c_string = yr_strdup(yytext);
1821
1822
41.6k
  if (yylval->c_string == NULL)
1823
41.6k
    error(ERROR_INSUFFICIENT_MEMORY);
1824
1825
41.6k
  return _STRING_IDENTIFIER_;
1826
41.6k
}
1827
0
  YY_BREAK
1828
3.33k
case 57:
1829
3.33k
YY_RULE_SETUP
1830
3.33k
#line 397 "libyara/lexer.l"
1831
3.33k
{
1832
1833
3.33k
  yylval->c_string = yr_strdup(yytext);
1834
1835
3.33k
  if (yylval->c_string == NULL)
1836
0
  {
1837
0
    error(ERROR_INSUFFICIENT_MEMORY);
1838
0
  }
1839
3.33k
  else
1840
3.33k
  {
1841
3.33k
    yylval->c_string[0] = '$'; /* replace # by $*/
1842
3.33k
  }
1843
1844
3.33k
  return _STRING_COUNT_;
1845
3.33k
}
1846
0
  YY_BREAK
1847
5.96k
case 58:
1848
5.96k
YY_RULE_SETUP
1849
5.96k
#line 414 "libyara/lexer.l"
1850
5.96k
{
1851
1852
5.96k
  yylval->c_string = yr_strdup(yytext);
1853
1854
5.96k
  if (yylval->c_string == NULL)
1855
0
  {
1856
0
    error(ERROR_INSUFFICIENT_MEMORY);
1857
0
  }
1858
5.96k
  else
1859
5.96k
  {
1860
5.96k
    yylval->c_string[0] = '$'; /* replace @ by $*/
1861
5.96k
  }
1862
1863
5.96k
  return _STRING_OFFSET_;
1864
5.96k
}
1865
0
  YY_BREAK
1866
9.71k
case 59:
1867
9.71k
YY_RULE_SETUP
1868
9.71k
#line 431 "libyara/lexer.l"
1869
9.71k
{
1870
1871
9.71k
  yylval->c_string = yr_strdup(yytext);
1872
1873
9.71k
  if (yylval->c_string == NULL)
1874
0
  {
1875
0
    error(ERROR_INSUFFICIENT_MEMORY);
1876
0
  }
1877
9.71k
  else
1878
9.71k
  {
1879
9.71k
    yylval->c_string[0] = '$'; /* replace ! by $*/
1880
9.71k
  }
1881
1882
9.71k
  return _STRING_LENGTH_;
1883
9.71k
}
1884
0
  YY_BREAK
1885
990
case 60:
1886
990
YY_RULE_SETUP
1887
990
#line 448 "libyara/lexer.l"
1888
990
{
1889
1890
990
  char* text = yytext;
1891
1892
990
  if (*text == 'u')
1893
315
  {
1894
315
    yylval->integer = 3;
1895
315
    text++;
1896
315
  }
1897
675
  else
1898
675
  {
1899
675
    yylval->integer = 0;
1900
675
  }
1901
1902
990
  if (strstr(text, "int8") == text)
1903
568
  {
1904
568
    yylval->integer += 0;
1905
568
    text += 4;
1906
568
  }
1907
422
  else if (strstr(text, "int16") == text)
1908
212
  {
1909
212
    yylval->integer += 1;
1910
212
    text += 5;
1911
212
  }
1912
210
  else if (strstr(text, "int32") == text)
1913
210
  {
1914
210
    yylval->integer += 2;
1915
210
    text += 5;
1916
210
  }
1917
1918
990
  if (strcmp(text, "be") == 0)
1919
207
  {
1920
207
    yylval->integer += 6;
1921
207
  }
1922
1923
990
  return _INTEGER_FUNCTION_;
1924
9.71k
}
1925
0
  YY_BREAK
1926
74.6k
case 61:
1927
74.6k
YY_RULE_SETUP
1928
74.6k
#line 487 "libyara/lexer.l"
1929
74.6k
{
1930
1931
74.6k
  if (strlen(yytext) > 128)
1932
74.6k
    syntax_error("identifier too long");
1933
1934
74.6k
  yylval->c_string = yr_strdup(yytext);
1935
1936
74.6k
  if (yylval->c_string == NULL)
1937
74.6k
    error(ERROR_INSUFFICIENT_MEMORY);
1938
1939
74.6k
  return _IDENTIFIER_;
1940
74.6k
}
1941
0
  YY_BREAK
1942
46.6k
case 62:
1943
46.6k
YY_RULE_SETUP
1944
46.6k
#line 501 "libyara/lexer.l"
1945
46.6k
{
1946
1947
46.6k
  char *endptr;
1948
1949
46.6k
  errno = 0;
1950
46.6k
  yylval->integer = strtoll(yytext, &endptr, 10);
1951
1952
46.6k
  if (yylval->integer == LLONG_MAX && errno == ERANGE)
1953
12
  {
1954
12
    yr_compiler_set_error_extra_info(compiler, yytext);
1955
12
    error(ERROR_INTEGER_OVERFLOW);
1956
0
  }
1957
46.6k
  else if (strstr(yytext, "KB") != NULL)
1958
158
  {
1959
158
    if (yylval->integer > LLONG_MAX / 1024)
1960
1
    {
1961
1
      yr_compiler_set_error_extra_info(compiler, yytext);
1962
1
      error(ERROR_INTEGER_OVERFLOW);
1963
0
    }
1964
157
    else
1965
157
    {
1966
157
      yylval->integer *= 1024;
1967
157
    }
1968
158
  }
1969
46.4k
  else if (strstr(yytext, "MB") != NULL)
1970
283
  {
1971
283
    if (yylval->integer > LLONG_MAX / 1048576)
1972
1
    {
1973
1
      yr_compiler_set_error_extra_info(compiler, yytext);
1974
1
      error(ERROR_INTEGER_OVERFLOW);
1975
0
    }
1976
282
    else
1977
282
    {
1978
282
      yylval->integer *= 1048576;
1979
282
    }
1980
283
  }
1981
1982
46.6k
  return _NUMBER_;
1983
46.6k
}
1984
0
  YY_BREAK
1985
2.95k
case 63:
1986
2.95k
YY_RULE_SETUP
1987
2.95k
#line 541 "libyara/lexer.l"
1988
2.95k
{
1989
2.95k
  yylval->double_ = atof(yytext);
1990
2.95k
  return _DOUBLE_;
1991
46.6k
}
1992
0
  YY_BREAK
1993
1.12k
case 64:
1994
1.12k
YY_RULE_SETUP
1995
1.12k
#line 546 "libyara/lexer.l"
1996
1.12k
{
1997
1998
1.12k
  char *endptr;
1999
2000
1.12k
  errno = 0;
2001
1.12k
  yylval->integer = strtoll(yytext, &endptr, 16);
2002
2003
1.12k
  if (yylval->integer == LLONG_MAX && errno == ERANGE)
2004
2
  {
2005
2
    yr_compiler_set_error_extra_info(compiler, yytext);
2006
2
    error(ERROR_INTEGER_OVERFLOW);
2007
0
  }
2008
2009
1.12k
  return _NUMBER_;
2010
1.12k
}
2011
0
  YY_BREAK
2012
396
case 65:
2013
396
YY_RULE_SETUP
2014
396
#line 562 "libyara/lexer.l"
2015
396
{
2016
2017
396
  char *endptr;
2018
2019
396
  errno = 0;
2020
396
  yylval->integer = strtoll(yytext + 2, &endptr, 8);
2021
2022
396
  if (yylval->integer == LLONG_MAX && errno == ERANGE)
2023
1
  {
2024
1
    yr_compiler_set_error_extra_info(compiler, yytext);
2025
1
    error(ERROR_INTEGER_OVERFLOW);
2026
0
  }
2027
2028
395
  return _NUMBER_;
2029
396
}
2030
0
  YY_BREAK
2031
14.8k
case 66:
2032
14.8k
YY_RULE_SETUP
2033
14.8k
#line 579 "libyara/lexer.l"
2034
14.8k
{     /* saw closing quote - all done */
2035
2036
14.8k
  alloc_sized_string(s, yyextra->lex_buf_len);
2037
2038
14.8k
  *yyextra->lex_buf_ptr = '\0';
2039
14.8k
  memcpy(s->c_string, yyextra->lex_buf, yyextra->lex_buf_len + 1);
2040
2041
14.8k
  yylval->sized_string = s;
2042
2043
14.8k
  BEGIN(INITIAL);
2044
2045
14.8k
  return _TEXT_STRING_;
2046
14.8k
}
2047
0
  YY_BREAK
2048
146
case 67:
2049
146
YY_RULE_SETUP
2050
146
#line 594 "libyara/lexer.l"
2051
146
{
2052
2053
146
  lex_check_space_ok("\t", yyextra->lex_buf_len, YR_LEX_BUF_SIZE);
2054
145
  *yyextra->lex_buf_ptr++ = '\t';
2055
145
  yyextra->lex_buf_len++;
2056
145
}
2057
145
  YY_BREAK
2058
374
case 68:
2059
374
YY_RULE_SETUP
2060
374
#line 602 "libyara/lexer.l"
2061
374
{
2062
2063
374
  lex_check_space_ok("\r", yyextra->lex_buf_len, YR_LEX_BUF_SIZE);
2064
373
  *yyextra->lex_buf_ptr++ = '\r';
2065
373
  yyextra->lex_buf_len++;
2066
373
}
2067
373
  YY_BREAK
2068
366
case 69:
2069
366
YY_RULE_SETUP
2070
366
#line 610 "libyara/lexer.l"
2071
366
{
2072
2073
366
  lex_check_space_ok("\n", yyextra->lex_buf_len, YR_LEX_BUF_SIZE);
2074
365
  *yyextra->lex_buf_ptr++ = '\n';
2075
365
  yyextra->lex_buf_len++;
2076
365
}
2077
365
  YY_BREAK
2078
167
case 70:
2079
167
YY_RULE_SETUP
2080
167
#line 618 "libyara/lexer.l"
2081
167
{
2082
2083
167
  lex_check_space_ok("\"", yyextra->lex_buf_len, YR_LEX_BUF_SIZE);
2084
166
  *yyextra->lex_buf_ptr++ = '\"';
2085
166
  yyextra->lex_buf_len++;
2086
166
}
2087
166
  YY_BREAK
2088
434
case 71:
2089
434
YY_RULE_SETUP
2090
434
#line 626 "libyara/lexer.l"
2091
434
{
2092
2093
434
  lex_check_space_ok("\\", yyextra->lex_buf_len, YR_LEX_BUF_SIZE);
2094
433
  *yyextra->lex_buf_ptr++ = '\\';
2095
433
  yyextra->lex_buf_len++;
2096
433
}
2097
433
  YY_BREAK
2098
854
case 72:
2099
854
YY_RULE_SETUP
2100
854
#line 634 "libyara/lexer.l"
2101
854
{
2102
2103
854
  int result;
2104
2105
854
  sscanf(yytext + 2, "%x", &result);
2106
854
  lex_check_space_ok("X", yyextra->lex_buf_len, YR_LEX_BUF_SIZE);
2107
853
  *yyextra->lex_buf_ptr++ = result;
2108
853
  yyextra->lex_buf_len++;
2109
853
}
2110
853
  YY_BREAK
2111
11.3k
case 73:
2112
11.3k
YY_RULE_SETUP
2113
11.3k
#line 645 "libyara/lexer.l"
2114
11.3k
{ yytext_to_buffer; }
2115
11.3k
  YY_BREAK
2116
14
case 74:
2117
/* rule 74 can match eol */
2118
14
YY_RULE_SETUP
2119
14
#line 648 "libyara/lexer.l"
2120
14
{
2121
14
  syntax_error("unterminated string");
2122
0
}
2123
0
  YY_BREAK
2124
16
case 75:
2125
/* rule 75 can match eol */
2126
16
YY_RULE_SETUP
2127
16
#line 653 "libyara/lexer.l"
2128
16
{
2129
16
  syntax_error("illegal escape sequence");
2130
0
}
2131
0
  YY_BREAK
2132
25.1k
case 76:
2133
25.1k
YY_RULE_SETUP
2134
25.1k
#line 658 "libyara/lexer.l"
2135
25.1k
{
2136
2137
25.1k
  if (yyextra->lex_buf_len > 0)
2138
25.1k
  {
2139
25.1k
    alloc_sized_string(s, yyextra->lex_buf_len);
2140
2141
25.1k
    if (yytext[1] == 'i')
2142
4.36k
      s->flags |= SIZED_STRING_FLAGS_NO_CASE;
2143
2144
25.1k
    if (yytext[1] == 's' || yytext[2] == 's')
2145
847
      s->flags |= SIZED_STRING_FLAGS_DOT_ALL;
2146
2147
25.1k
    *yyextra->lex_buf_ptr = '\0';
2148
25.1k
    strlcpy(s->c_string, yyextra->lex_buf, s->length + 1);
2149
2150
25.1k
    yylval->sized_string = s;
2151
25.1k
  }
2152
0
  else
2153
0
  {
2154
0
    syntax_error("empty regular expression");
2155
0
  }
2156
2157
25.1k
  BEGIN(INITIAL);
2158
25.1k
  return _REGEXP_;
2159
25.1k
}
2160
0
  YY_BREAK
2161
159
case 77:
2162
159
YY_RULE_SETUP
2163
159
#line 685 "libyara/lexer.l"
2164
159
{
2165
2166
159
  lex_check_space_ok("/", yyextra->lex_buf_len, YR_LEX_BUF_SIZE);
2167
158
  *yyextra->lex_buf_ptr++ = '/';
2168
158
  yyextra->lex_buf_len++ ;
2169
158
}
2170
158
  YY_BREAK
2171
34.0k
case 78:
2172
34.0k
YY_RULE_SETUP
2173
34.0k
#line 693 "libyara/lexer.l"
2174
34.0k
{
2175
2176
34.0k
  lex_check_space_ok("\\.", yyextra->lex_buf_len, YR_LEX_BUF_SIZE);
2177
2178
34.0k
  if (yytext[1] == 0)
2179
34.0k
    syntax_error("malformed regular expression");
2180
2181
34.0k
  *yyextra->lex_buf_ptr++ = yytext[0];
2182
34.0k
  *yyextra->lex_buf_ptr++ = yytext[1];
2183
34.0k
  yyextra->lex_buf_len += 2;
2184
34.0k
}
2185
34.0k
  YY_BREAK
2186
34.6k
case 79:
2187
34.6k
YY_RULE_SETUP
2188
34.6k
#line 706 "libyara/lexer.l"
2189
34.6k
{ yytext_to_buffer; }
2190
34.6k
  YY_BREAK
2191
6
case 80:
2192
/* rule 80 can match eol */
2193
6
YY_RULE_SETUP
2194
6
#line 709 "libyara/lexer.l"
2195
6
{
2196
6
  syntax_error("unterminated regular expression");
2197
0
}
2198
0
  YY_BREAK
2199
14.9k
case 81:
2200
14.9k
YY_RULE_SETUP
2201
14.9k
#line 714 "libyara/lexer.l"
2202
14.9k
{
2203
2204
14.9k
  yylval->sized_string = NULL;
2205
14.9k
  yyextra->lex_buf_ptr = yyextra->lex_buf;
2206
14.9k
  yyextra->lex_buf_len = 0;
2207
14.9k
  BEGIN(str);
2208
14.9k
}
2209
14.9k
  YY_BREAK
2210
25.2k
case 82:
2211
25.2k
YY_RULE_SETUP
2212
25.2k
#line 723 "libyara/lexer.l"
2213
25.2k
{
2214
2215
25.2k
  yylval->sized_string = NULL;
2216
25.2k
  yyextra->lex_buf_ptr = yyextra->lex_buf;
2217
25.2k
  yyextra->lex_buf_len = 0;
2218
25.2k
  BEGIN(regexp);
2219
25.2k
}
2220
25.2k
  YY_BREAK
2221
1.85k
case 83:
2222
/* rule 83 can match eol */
2223
1.85k
YY_RULE_SETUP
2224
1.85k
#line 732 "libyara/lexer.l"
2225
1.85k
{
2226
  // Match hex-digits with whitespace or comments. The latter are stripped
2227
  // out by hex_lexer.l
2228
  // TODO(vmalvarez): Integrate the hex string lexer and parser into this one,
2229
  // by having a single lexer/parser instead of two different ones we can avoid
2230
  // complex regular expressions like the one above, which is actually trying to
2231
  // do some parsing in the lexer.
2232
2233
1.85k
  alloc_sized_string(s, strlen(yytext));
2234
2235
1.85k
  strlcpy(s->c_string, yytext, s->length + 1);
2236
1.85k
  yylval->sized_string = s;
2237
2238
1.85k
  return _HEX_STRING_;
2239
1.85k
}
2240
0
  YY_BREAK
2241
98.3k
case 84:
2242
/* rule 84 can match eol */
2243
98.3k
YY_RULE_SETUP
2244
98.3k
#line 749 "libyara/lexer.l"
2245
/* skip whitespace */
2246
98.3k
  YY_BREAK
2247
274k
case 85:
2248
274k
YY_RULE_SETUP
2249
274k
#line 751 "libyara/lexer.l"
2250
274k
{
2251
2252
274k
  if (yytext[0] >= 32 && yytext[0] < 127)
2253
273k
  {
2254
273k
    return yytext[0];
2255
273k
  }
2256
394
  else
2257
394
  {
2258
394
    syntax_error("non-ascii character");
2259
0
  }
2260
274k
}
2261
0
  YY_BREAK
2262
5
case 86:
2263
5
YY_RULE_SETUP
2264
5
#line 763 "libyara/lexer.l"
2265
5
ECHO;
2266
5
  YY_BREAK
2267
0
#line 2267 "libyara/lexer.c"
2268
2269
2.53k
  case YY_END_OF_BUFFER:
2270
2.53k
    {
2271
    /* Amount of text matched not including the EOB char. */
2272
2.53k
    int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
2273
2274
    /* Undo the effects of YY_DO_BEFORE_ACTION. */
2275
2.53k
    *yy_cp = yyg->yy_hold_char;
2276
2.53k
    YY_RESTORE_YY_MORE_OFFSET
2277
2278
2.53k
    if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
2279
1.28k
      {
2280
      /* We're scanning a new file or input source.  It's
2281
       * possible that this happened because the user
2282
       * just pointed yyin at a new source and called
2283
       * yylex().  If so, then we have to assure
2284
       * consistency between YY_CURRENT_BUFFER and our
2285
       * globals.  Here is the right place to do so, because
2286
       * this is the first action (other than possibly a
2287
       * back-up) that will match for the new input source.
2288
       */
2289
1.28k
      yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2290
1.28k
      YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
2291
1.28k
      YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
2292
1.28k
      }
2293
2294
    /* Note that here we test for yy_c_buf_p "<=" to the position
2295
     * of the first EOB in the buffer, since yy_c_buf_p will
2296
     * already have been incremented past the NUL character
2297
     * (since all states make transitions on EOB to the
2298
     * end-of-buffer state).  Contrast this with the test
2299
     * in input().
2300
     */
2301
2.53k
    if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
2302
0
      { /* This was really a NUL. */
2303
0
      yy_state_type yy_next_state;
2304
2305
0
      yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
2306
2307
0
      yy_current_state = yy_get_previous_state( yyscanner );
2308
2309
      /* Okay, we're now positioned to make the NUL
2310
       * transition.  We couldn't have
2311
       * yy_get_previous_state() go ahead and do it
2312
       * for us because it doesn't know how to deal
2313
       * with the possibility of jamming (and we don't
2314
       * want to build jamming into it because then it
2315
       * will run more slowly).
2316
       */
2317
2318
0
      yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
2319
2320
0
      yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
2321
2322
0
      if ( yy_next_state )
2323
0
        {
2324
        /* Consume the NUL. */
2325
0
        yy_cp = ++yyg->yy_c_buf_p;
2326
0
        yy_current_state = yy_next_state;
2327
0
        goto yy_match;
2328
0
        }
2329
2330
0
      else
2331
0
        {
2332
0
        yy_cp = yyg->yy_last_accepting_cpos;
2333
0
        yy_current_state = yyg->yy_last_accepting_state;
2334
0
        goto yy_find_action;
2335
0
        }
2336
0
      }
2337
2338
2.53k
    else switch ( yy_get_next_buffer( yyscanner ) )
2339
2.53k
      {
2340
1.23k
      case EOB_ACT_END_OF_FILE:
2341
1.23k
        {
2342
1.23k
        yyg->yy_did_buffer_switch_on_eof = 0;
2343
2344
1.23k
        if ( yywrap( yyscanner ) )
2345
1.23k
          {
2346
          /* Note: because we've taken care in
2347
           * yy_get_next_buffer() to have set up
2348
           * yytext, we can now set up
2349
           * yy_c_buf_p so that if some total
2350
           * hoser (like flex itself) wants to
2351
           * call the scanner after we return the
2352
           * YY_NULL, it'll still work - another
2353
           * YY_NULL will get returned.
2354
           */
2355
1.23k
          yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
2356
2357
1.23k
          yy_act = YY_STATE_EOF(YY_START);
2358
1.23k
          goto do_action;
2359
1.23k
          }
2360
2361
0
        else
2362
0
          {
2363
0
          if ( ! yyg->yy_did_buffer_switch_on_eof )
2364
0
            YY_NEW_FILE;
2365
0
          }
2366
0
        break;
2367
1.23k
        }
2368
2369
0
      case EOB_ACT_CONTINUE_SCAN:
2370
0
        yyg->yy_c_buf_p =
2371
0
          yyg->yytext_ptr + yy_amount_of_matched_text;
2372
2373
0
        yy_current_state = yy_get_previous_state( yyscanner );
2374
2375
0
        yy_cp = yyg->yy_c_buf_p;
2376
0
        yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
2377
0
        goto yy_match;
2378
2379
1.30k
      case EOB_ACT_LAST_MATCH:
2380
1.30k
        yyg->yy_c_buf_p =
2381
1.30k
        &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
2382
2383
1.30k
        yy_current_state = yy_get_previous_state( yyscanner );
2384
2385
1.30k
        yy_cp = yyg->yy_c_buf_p;
2386
1.30k
        yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
2387
1.30k
        goto yy_find_action;
2388
2.53k
      }
2389
0
    break;
2390
2.53k
    }
2391
2392
0
  default:
2393
0
    YY_FATAL_ERROR(
2394
834k
      "fatal flex scanner internal error--no action found" );
2395
834k
  } /* end of action switch */
2396
834k
    } /* end of scanning one token */
2397
606k
  } /* end of user's declarations */
2398
606k
} /* end of yylex */
2399
2400
/* yy_get_next_buffer - try to read in a new buffer
2401
 *
2402
 * Returns a code representing an action:
2403
 *  EOB_ACT_LAST_MATCH -
2404
 *  EOB_ACT_CONTINUE_SCAN - continue scanning from current position
2405
 *  EOB_ACT_END_OF_FILE - end of file
2406
 */
2407
static int yy_get_next_buffer (yyscan_t yyscanner)
2408
2.53k
{
2409
2.53k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2410
2.53k
  char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
2411
2.53k
  char *source = yyg->yytext_ptr;
2412
2.53k
  int number_to_move, i;
2413
2.53k
  int ret_val;
2414
2415
2.53k
  if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
2416
0
    YY_FATAL_ERROR(
2417
2.53k
    "fatal flex scanner internal error--end of buffer missed" );
2418
2419
2.53k
  if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
2420
2.53k
    { /* Don't try to fill the buffer, so this is an EOF. */
2421
2.53k
    if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
2422
1.23k
      {
2423
      /* We matched a single character, the EOB, so
2424
       * treat this as a final EOF.
2425
       */
2426
1.23k
      return EOB_ACT_END_OF_FILE;
2427
1.23k
      }
2428
2429
1.30k
    else
2430
1.30k
      {
2431
      /* We matched some text prior to the EOB, first
2432
       * process it.
2433
       */
2434
1.30k
      return EOB_ACT_LAST_MATCH;
2435
1.30k
      }
2436
2.53k
    }
2437
2438
  /* Try to read more data. */
2439
2440
  /* First move last chars to start of buffer. */
2441
0
  number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
2442
2443
0
  for ( i = 0; i < number_to_move; ++i )
2444
0
    *(dest++) = *(source++);
2445
2446
0
  if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
2447
    /* don't do the read, it's not guaranteed to return an EOF,
2448
     * just force an EOF
2449
     */
2450
0
    YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
2451
2452
0
  else
2453
0
    {
2454
0
      int num_to_read =
2455
0
      YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
2456
2457
0
    while ( num_to_read <= 0 )
2458
0
      { /* Not enough room in the buffer - grow it. */
2459
2460
      /* just a shorter name for the current buffer */
2461
0
      YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
2462
2463
0
      int yy_c_buf_p_offset =
2464
0
        (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
2465
2466
0
      if ( b->yy_is_our_buffer )
2467
0
        {
2468
0
        int new_size = b->yy_buf_size * 2;
2469
2470
0
        if ( new_size <= 0 )
2471
0
          b->yy_buf_size += b->yy_buf_size / 8;
2472
0
        else
2473
0
          b->yy_buf_size *= 2;
2474
2475
0
        b->yy_ch_buf = (char *)
2476
          /* Include room in for 2 EOB chars. */
2477
0
          yyrealloc( (void *) b->yy_ch_buf,
2478
0
               (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
2479
0
        }
2480
0
      else
2481
        /* Can't grow it, we don't own it. */
2482
0
        b->yy_ch_buf = NULL;
2483
2484
0
      if ( ! b->yy_ch_buf )
2485
0
        YY_FATAL_ERROR(
2486
0
        "fatal error - scanner input buffer overflow" );
2487
2488
0
      yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
2489
2490
0
      num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
2491
0
            number_to_move - 1;
2492
2493
0
      }
2494
2495
0
    if ( num_to_read > YY_READ_BUF_SIZE )
2496
0
      num_to_read = YY_READ_BUF_SIZE;
2497
2498
    /* Read in more data. */
2499
0
    YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
2500
0
      yyg->yy_n_chars, num_to_read );
2501
2502
0
    YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2503
0
    }
2504
2505
0
  if ( yyg->yy_n_chars == 0 )
2506
0
    {
2507
0
    if ( number_to_move == YY_MORE_ADJ )
2508
0
      {
2509
0
      ret_val = EOB_ACT_END_OF_FILE;
2510
0
      yyrestart( yyin  , yyscanner);
2511
0
      }
2512
2513
0
    else
2514
0
      {
2515
0
      ret_val = EOB_ACT_LAST_MATCH;
2516
0
      YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
2517
0
        YY_BUFFER_EOF_PENDING;
2518
0
      }
2519
0
    }
2520
2521
0
  else
2522
0
    ret_val = EOB_ACT_CONTINUE_SCAN;
2523
2524
0
  if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
2525
    /* Extend the array by 50%, plus the number we really need. */
2526
0
    int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
2527
0
    YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
2528
0
      (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
2529
0
    if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
2530
0
      YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
2531
    /* "- 2" to take care of EOB's */
2532
0
    YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
2533
0
  }
2534
2535
0
  yyg->yy_n_chars += number_to_move;
2536
0
  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
2537
0
  YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
2538
2539
0
  yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
2540
2541
0
  return ret_val;
2542
2.53k
}
2543
2544
/* yy_get_previous_state - get the state just before the EOB char was reached */
2545
2546
    static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
2547
1.30k
{
2548
1.30k
  yy_state_type yy_current_state;
2549
1.30k
  char *yy_cp;
2550
1.30k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2551
2552
1.30k
  yy_current_state = yyg->yy_start;
2553
2554
299k
  for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
2555
298k
    {
2556
298k
    YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
2557
298k
    if ( yy_accept[yy_current_state] )
2558
134k
      {
2559
134k
      yyg->yy_last_accepting_state = yy_current_state;
2560
134k
      yyg->yy_last_accepting_cpos = yy_cp;
2561
134k
      }
2562
592k
    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
2563
294k
      {
2564
294k
      yy_current_state = (int) yy_def[yy_current_state];
2565
294k
      if ( yy_current_state >= 295 )
2566
294k
        yy_c = yy_meta[yy_c];
2567
294k
      }
2568
298k
    yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
2569
298k
    }
2570
2571
1.30k
  return yy_current_state;
2572
1.30k
}
2573
2574
/* yy_try_NUL_trans - try to make a transition on the NUL character
2575
 *
2576
 * synopsis
2577
 *  next_state = yy_try_NUL_trans( current_state );
2578
 */
2579
    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
2580
0
{
2581
0
  int yy_is_jam;
2582
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
2583
0
  char *yy_cp = yyg->yy_c_buf_p;
2584
2585
0
  YY_CHAR yy_c = 1;
2586
0
  if ( yy_accept[yy_current_state] )
2587
0
    {
2588
0
    yyg->yy_last_accepting_state = yy_current_state;
2589
0
    yyg->yy_last_accepting_cpos = yy_cp;
2590
0
    }
2591
0
  while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
2592
0
    {
2593
0
    yy_current_state = (int) yy_def[yy_current_state];
2594
0
    if ( yy_current_state >= 295 )
2595
0
      yy_c = yy_meta[yy_c];
2596
0
    }
2597
0
  yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
2598
0
  yy_is_jam = (yy_current_state == 294);
2599
2600
0
  (void)yyg;
2601
0
  return yy_is_jam ? 0 : yy_current_state;
2602
0
}
2603
2604
#ifndef YY_NO_UNPUT
2605
2606
#endif
2607
2608
#ifndef YY_NO_INPUT
2609
#ifdef __cplusplus
2610
    static int yyinput (yyscan_t yyscanner)
2611
#else
2612
    static int input  (yyscan_t yyscanner)
2613
#endif
2614
2615
{
2616
  int c;
2617
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2618
2619
  *yyg->yy_c_buf_p = yyg->yy_hold_char;
2620
2621
  if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
2622
    {
2623
    /* yy_c_buf_p now points to the character we want to return.
2624
     * If this occurs *before* the EOB characters, then it's a
2625
     * valid NUL; if not, then we've hit the end of the buffer.
2626
     */
2627
    if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
2628
      /* This was really a NUL. */
2629
      *yyg->yy_c_buf_p = '\0';
2630
2631
    else
2632
      { /* need more input */
2633
      int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
2634
      ++yyg->yy_c_buf_p;
2635
2636
      switch ( yy_get_next_buffer( yyscanner ) )
2637
        {
2638
        case EOB_ACT_LAST_MATCH:
2639
          /* This happens because yy_g_n_b()
2640
           * sees that we've accumulated a
2641
           * token and flags that we need to
2642
           * try matching the token before
2643
           * proceeding.  But for input(),
2644
           * there's no matching to consider.
2645
           * So convert the EOB_ACT_LAST_MATCH
2646
           * to EOB_ACT_END_OF_FILE.
2647
           */
2648
2649
          /* Reset buffer status. */
2650
          yyrestart( yyin , yyscanner);
2651
2652
          /*FALLTHROUGH*/
2653
2654
        case EOB_ACT_END_OF_FILE:
2655
          {
2656
          if ( yywrap( yyscanner ) )
2657
            return 0;
2658
2659
          if ( ! yyg->yy_did_buffer_switch_on_eof )
2660
            YY_NEW_FILE;
2661
#ifdef __cplusplus
2662
          return yyinput(yyscanner);
2663
#else
2664
          return input(yyscanner);
2665
#endif
2666
          }
2667
2668
        case EOB_ACT_CONTINUE_SCAN:
2669
          yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
2670
          break;
2671
        }
2672
      }
2673
    }
2674
2675
  c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
2676
  *yyg->yy_c_buf_p = '\0';  /* preserve yytext */
2677
  yyg->yy_hold_char = *++yyg->yy_c_buf_p;
2678
2679
  if ( c == '\n' )
2680
    
2681
    do{ yylineno++;
2682
        yycolumn=0;
2683
    }while(0)
2684
;
2685
2686
  return c;
2687
}
2688
#endif  /* ifndef YY_NO_INPUT */
2689
2690
/** Immediately switch to a different input stream.
2691
 * @param input_file A readable stream.
2692
 * @param yyscanner The scanner object.
2693
 * @note This function does not reset the start condition to @c INITIAL .
2694
 */
2695
    void yyrestart  (FILE * input_file , yyscan_t yyscanner)
2696
0
{
2697
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2698
2699
0
  if ( ! YY_CURRENT_BUFFER ){
2700
0
        yyensure_buffer_stack (yyscanner);
2701
0
    YY_CURRENT_BUFFER_LVALUE =
2702
0
            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
2703
0
  }
2704
2705
0
  yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
2706
0
  yy_load_buffer_state( yyscanner );
2707
0
}
2708
2709
/** Switch to a different input buffer.
2710
 * @param new_buffer The new input buffer.
2711
 * @param yyscanner The scanner object.
2712
 */
2713
    void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
2714
1.70k
{
2715
1.70k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2716
2717
  /* TODO. We should be able to replace this entire function body
2718
   * with
2719
   *    yypop_buffer_state();
2720
   *    yypush_buffer_state(new_buffer);
2721
     */
2722
1.70k
  yyensure_buffer_stack (yyscanner);
2723
1.70k
  if ( YY_CURRENT_BUFFER == new_buffer )
2724
0
    return;
2725
2726
1.70k
  if ( YY_CURRENT_BUFFER )
2727
0
    {
2728
    /* Flush out information for old buffer. */
2729
0
    *yyg->yy_c_buf_p = yyg->yy_hold_char;
2730
0
    YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2731
0
    YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2732
0
    }
2733
2734
1.70k
  YY_CURRENT_BUFFER_LVALUE = new_buffer;
2735
1.70k
  yy_load_buffer_state( yyscanner );
2736
2737
  /* We don't actually know whether we did this switch during
2738
   * EOF (yywrap()) processing, but the only time this flag
2739
   * is looked at is after yywrap() is called, so it's safe
2740
   * to go ahead and always set it.
2741
   */
2742
1.70k
  yyg->yy_did_buffer_switch_on_eof = 1;
2743
1.70k
}
2744
2745
static void yy_load_buffer_state  (yyscan_t yyscanner)
2746
3.41k
{
2747
3.41k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2748
3.41k
  yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2749
3.41k
  yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
2750
3.41k
  yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
2751
3.41k
  yyg->yy_hold_char = *yyg->yy_c_buf_p;
2752
3.41k
}
2753
2754
/** Allocate and initialize an input buffer state.
2755
 * @param file A readable stream.
2756
 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
2757
 * @param yyscanner The scanner object.
2758
 * @return the allocated buffer state.
2759
 */
2760
    YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
2761
0
{
2762
0
  YY_BUFFER_STATE b;
2763
    
2764
0
  b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
2765
0
  if ( ! b )
2766
0
    YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
2767
2768
0
  b->yy_buf_size = size;
2769
2770
  /* yy_ch_buf has to be 2 characters longer than the size given because
2771
   * we need to put in 2 end-of-buffer characters.
2772
   */
2773
0
  b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
2774
0
  if ( ! b->yy_ch_buf )
2775
0
    YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
2776
2777
0
  b->yy_is_our_buffer = 1;
2778
2779
0
  yy_init_buffer( b, file , yyscanner);
2780
2781
0
  return b;
2782
0
}
2783
2784
/** Destroy the buffer.
2785
 * @param b a buffer created with yy_create_buffer()
2786
 * @param yyscanner The scanner object.
2787
 */
2788
    void yy_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
2789
1.70k
{
2790
1.70k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2791
2792
1.70k
  if ( ! b )
2793
0
    return;
2794
2795
1.70k
  if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
2796
1.70k
    YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
2797
2798
1.70k
  if ( b->yy_is_our_buffer )
2799
1.70k
    yyfree( (void *) b->yy_ch_buf , yyscanner );
2800
2801
1.70k
  yyfree( (void *) b , yyscanner );
2802
1.70k
}
2803
2804
/* Initializes or reinitializes a buffer.
2805
 * This function is sometimes called more than once on the same buffer,
2806
 * such as during a yyrestart() or at EOF.
2807
 */
2808
    static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
2809
2810
0
{
2811
0
  int oerrno = errno;
2812
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2813
2814
0
  yy_flush_buffer( b , yyscanner);
2815
2816
0
  b->yy_input_file = file;
2817
0
  b->yy_fill_buffer = 1;
2818
2819
    /* If b is the current buffer, then yy_init_buffer was _probably_
2820
     * called from yyrestart() or through yy_get_next_buffer.
2821
     * In that case, we don't want to reset the lineno or column.
2822
     */
2823
0
    if (b != YY_CURRENT_BUFFER){
2824
0
        b->yy_bs_lineno = 1;
2825
0
        b->yy_bs_column = 0;
2826
0
    }
2827
2828
0
        b->yy_is_interactive = 0;
2829
    
2830
0
  errno = oerrno;
2831
0
}
2832
2833
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2834
 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2835
 * @param yyscanner The scanner object.
2836
 */
2837
    void yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
2838
0
{
2839
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2840
0
  if ( ! b )
2841
0
    return;
2842
2843
0
  b->yy_n_chars = 0;
2844
2845
  /* We always need two end-of-buffer characters.  The first causes
2846
   * a transition to the end-of-buffer state.  The second causes
2847
   * a jam in that state.
2848
   */
2849
0
  b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2850
0
  b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2851
2852
0
  b->yy_buf_pos = &b->yy_ch_buf[0];
2853
2854
0
  b->yy_at_bol = 1;
2855
0
  b->yy_buffer_status = YY_BUFFER_NEW;
2856
2857
0
  if ( b == YY_CURRENT_BUFFER )
2858
0
    yy_load_buffer_state( yyscanner );
2859
0
}
2860
2861
/** Pushes the new state onto the stack. The new state becomes
2862
 *  the current state. This function will allocate the stack
2863
 *  if necessary.
2864
 *  @param new_buffer The new state.
2865
 *  @param yyscanner The scanner object.
2866
 */
2867
void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
2868
0
{
2869
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2870
0
  if (new_buffer == NULL)
2871
0
    return;
2872
2873
0
  yyensure_buffer_stack(yyscanner);
2874
2875
  /* This block is copied from yy_switch_to_buffer. */
2876
0
  if ( YY_CURRENT_BUFFER )
2877
0
    {
2878
    /* Flush out information for old buffer. */
2879
0
    *yyg->yy_c_buf_p = yyg->yy_hold_char;
2880
0
    YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2881
0
    YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2882
0
    }
2883
2884
  /* Only push if top exists. Otherwise, replace top. */
2885
0
  if (YY_CURRENT_BUFFER)
2886
0
    yyg->yy_buffer_stack_top++;
2887
0
  YY_CURRENT_BUFFER_LVALUE = new_buffer;
2888
2889
  /* copied from yy_switch_to_buffer. */
2890
0
  yy_load_buffer_state( yyscanner );
2891
0
  yyg->yy_did_buffer_switch_on_eof = 1;
2892
0
}
2893
2894
/** Removes and deletes the top of the stack, if present.
2895
 *  The next element becomes the new top.
2896
 *  @param yyscanner The scanner object.
2897
 */
2898
void yypop_buffer_state (yyscan_t yyscanner)
2899
1.70k
{
2900
1.70k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2901
1.70k
  if (!YY_CURRENT_BUFFER)
2902
474
    return;
2903
2904
1.23k
  yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
2905
1.23k
  YY_CURRENT_BUFFER_LVALUE = NULL;
2906
1.23k
  if (yyg->yy_buffer_stack_top > 0)
2907
0
    --yyg->yy_buffer_stack_top;
2908
2909
1.23k
  if (YY_CURRENT_BUFFER) {
2910
0
    yy_load_buffer_state( yyscanner );
2911
0
    yyg->yy_did_buffer_switch_on_eof = 1;
2912
0
  }
2913
1.23k
}
2914
2915
/* Allocates the stack if it does not exist.
2916
 *  Guarantees space for at least one push.
2917
 */
2918
static void yyensure_buffer_stack (yyscan_t yyscanner)
2919
1.70k
{
2920
1.70k
  yy_size_t num_to_alloc;
2921
1.70k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2922
2923
1.70k
  if (!yyg->yy_buffer_stack) {
2924
2925
    /* First allocation is just for 2 elements, since we don't know if this
2926
     * scanner will even need a stack. We use 2 instead of 1 to avoid an
2927
     * immediate realloc on the next call.
2928
         */
2929
1.70k
      num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
2930
1.70k
    yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
2931
1.70k
                (num_to_alloc * sizeof(struct yy_buffer_state*)
2932
1.70k
                , yyscanner);
2933
1.70k
    if ( ! yyg->yy_buffer_stack )
2934
0
      YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2935
2936
1.70k
    memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2937
2938
1.70k
    yyg->yy_buffer_stack_max = num_to_alloc;
2939
1.70k
    yyg->yy_buffer_stack_top = 0;
2940
1.70k
    return;
2941
1.70k
  }
2942
2943
0
  if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
2944
2945
    /* Increase the buffer to prepare for a possible push. */
2946
0
    yy_size_t grow_size = 8 /* arbitrary grow size */;
2947
2948
0
    num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
2949
0
    yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
2950
0
                (yyg->yy_buffer_stack,
2951
0
                num_to_alloc * sizeof(struct yy_buffer_state*)
2952
0
                , yyscanner);
2953
0
    if ( ! yyg->yy_buffer_stack )
2954
0
      YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2955
2956
    /* zero only the new slots.*/
2957
0
    memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
2958
0
    yyg->yy_buffer_stack_max = num_to_alloc;
2959
0
  }
2960
0
}
2961
2962
/** Setup the input buffer state to scan directly from a user-specified character buffer.
2963
 * @param base the character buffer
2964
 * @param size the size in bytes of the character buffer
2965
 * @param yyscanner The scanner object.
2966
 * @return the newly allocated buffer state object.
2967
 */
2968
YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
2969
1.70k
{
2970
1.70k
  YY_BUFFER_STATE b;
2971
    
2972
1.70k
  if ( size < 2 ||
2973
1.70k
       base[size-2] != YY_END_OF_BUFFER_CHAR ||
2974
1.70k
       base[size-1] != YY_END_OF_BUFFER_CHAR )
2975
    /* They forgot to leave room for the EOB's. */
2976
0
    return NULL;
2977
2978
1.70k
  b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
2979
1.70k
  if ( ! b )
2980
0
    YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
2981
2982
1.70k
  b->yy_buf_size = (int) (size - 2);  /* "- 2" to take care of EOB's */
2983
1.70k
  b->yy_buf_pos = b->yy_ch_buf = base;
2984
1.70k
  b->yy_is_our_buffer = 0;
2985
1.70k
  b->yy_input_file = NULL;
2986
1.70k
  b->yy_n_chars = b->yy_buf_size;
2987
1.70k
  b->yy_is_interactive = 0;
2988
1.70k
  b->yy_at_bol = 1;
2989
1.70k
  b->yy_fill_buffer = 0;
2990
1.70k
  b->yy_buffer_status = YY_BUFFER_NEW;
2991
2992
1.70k
  yy_switch_to_buffer( b , yyscanner );
2993
2994
1.70k
  return b;
2995
1.70k
}
2996
2997
/** Setup the input buffer state to scan a string. The next call to yylex() will
2998
 * scan from a @e copy of @a str.
2999
 * @param yystr a NUL-terminated string to scan
3000
 * @param yyscanner The scanner object.
3001
 * @return the newly allocated buffer state object.
3002
 * @note If you want to scan bytes that may contain NUL values, then use
3003
 *       yy_scan_bytes() instead.
3004
 */
3005
YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
3006
1.70k
{
3007
    
3008
1.70k
  return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
3009
1.70k
}
3010
3011
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
3012
 * scan from a @e copy of @a bytes.
3013
 * @param yybytes the byte buffer to scan
3014
 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
3015
 * @param yyscanner The scanner object.
3016
 * @return the newly allocated buffer state object.
3017
 */
3018
YY_BUFFER_STATE yy_scan_bytes  (const char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
3019
1.70k
{
3020
1.70k
  YY_BUFFER_STATE b;
3021
1.70k
  char *buf;
3022
1.70k
  yy_size_t n;
3023
1.70k
  int i;
3024
    
3025
  /* Get memory for full buffer, including space for trailing EOB's. */
3026
1.70k
  n = (yy_size_t) (_yybytes_len + 2);
3027
1.70k
  buf = (char *) yyalloc( n , yyscanner );
3028
1.70k
  if ( ! buf )
3029
0
    YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
3030
3031
3.58M
  for ( i = 0; i < _yybytes_len; ++i )
3032
3.57M
    buf[i] = yybytes[i];
3033
3034
1.70k
  buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
3035
3036
1.70k
  b = yy_scan_buffer( buf, n , yyscanner);
3037
1.70k
  if ( ! b )
3038
0
    YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
3039
3040
  /* It's okay to grow etc. this buffer, and we should throw it
3041
   * away when we're done.
3042
   */
3043
1.70k
  b->yy_is_our_buffer = 1;
3044
3045
1.70k
  return b;
3046
1.70k
}
3047
3048
#ifndef YY_EXIT_FAILURE
3049
#define YY_EXIT_FAILURE 2
3050
#endif
3051
3052
static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
3053
0
{
3054
0
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3055
0
  (void)yyg;
3056
0
  fprintf( stderr, "%s\n", msg );
3057
0
  exit( YY_EXIT_FAILURE );
3058
0
}
3059
3060
/* Redefine yyless() so it works in section 3 code. */
3061
3062
#undef yyless
3063
#define yyless(n) \
3064
  do \
3065
    { \
3066
    /* Undo effects of setting up yytext. */ \
3067
        int yyless_macro_arg = (n); \
3068
        YY_LESS_LINENO(yyless_macro_arg);\
3069
    yytext[yyleng] = yyg->yy_hold_char; \
3070
    yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
3071
    yyg->yy_hold_char = *yyg->yy_c_buf_p; \
3072
    *yyg->yy_c_buf_p = '\0'; \
3073
    yyleng = yyless_macro_arg; \
3074
    } \
3075
  while ( 0 )
3076
3077
/* Accessor  methods (get/set functions) to struct members. */
3078
3079
/** Get the user-defined data for this scanner.
3080
 * @param yyscanner The scanner object.
3081
 */
3082
YY_EXTRA_TYPE yyget_extra  (yyscan_t yyscanner)
3083
3.49M
{
3084
3.49M
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3085
3.49M
    return yyextra;
3086
3.49M
}
3087
3088
/** Get the current line number.
3089
 * @param yyscanner The scanner object.
3090
 */
3091
int yyget_lineno  (yyscan_t yyscanner)
3092
41.4k
{
3093
41.4k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3094
3095
41.4k
        if (! YY_CURRENT_BUFFER)
3096
320
            return 0;
3097
    
3098
41.1k
    return yylineno;
3099
41.4k
}
3100
3101
/** Get the current column number.
3102
 * @param yyscanner The scanner object.
3103
 */
3104
int yyget_column  (yyscan_t yyscanner)
3105
0
{
3106
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3107
3108
0
        if (! YY_CURRENT_BUFFER)
3109
0
            return 0;
3110
    
3111
0
    return yycolumn;
3112
0
}
3113
3114
/** Get the input stream.
3115
 * @param yyscanner The scanner object.
3116
 */
3117
FILE *yyget_in  (yyscan_t yyscanner)
3118
0
{
3119
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3120
0
    return yyin;
3121
0
}
3122
3123
/** Get the output stream.
3124
 * @param yyscanner The scanner object.
3125
 */
3126
FILE *yyget_out  (yyscan_t yyscanner)
3127
0
{
3128
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3129
0
    return yyout;
3130
0
}
3131
3132
/** Get the length of the current token.
3133
 * @param yyscanner The scanner object.
3134
 */
3135
int yyget_leng  (yyscan_t yyscanner)
3136
0
{
3137
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3138
0
    return yyleng;
3139
0
}
3140
3141
/** Get the current token.
3142
 * @param yyscanner The scanner object.
3143
 */
3144
3145
char *yyget_text  (yyscan_t yyscanner)
3146
0
{
3147
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3148
0
    return yytext;
3149
0
}
3150
3151
/** Set the user-defined data. This data is never touched by the scanner.
3152
 * @param user_defined The data to be associated with this scanner.
3153
 * @param yyscanner The scanner object.
3154
 */
3155
void yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
3156
1.70k
{
3157
1.70k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3158
1.70k
    yyextra = user_defined ;
3159
1.70k
}
3160
3161
/** Set the current line number.
3162
 * @param _line_number line number
3163
 * @param yyscanner The scanner object.
3164
 */
3165
void yyset_lineno (int  _line_number , yyscan_t yyscanner)
3166
1.70k
{
3167
1.70k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3168
3169
        /* lineno is only valid if an input buffer exists. */
3170
1.70k
        if (! YY_CURRENT_BUFFER )
3171
0
           YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
3172
    
3173
1.70k
    yylineno = _line_number;
3174
1.70k
}
3175
3176
/** Set the current column.
3177
 * @param _column_no column number
3178
 * @param yyscanner The scanner object.
3179
 */
3180
void yyset_column (int  _column_no , yyscan_t yyscanner)
3181
0
{
3182
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3183
3184
        /* column is only valid if an input buffer exists. */
3185
0
        if (! YY_CURRENT_BUFFER )
3186
0
           YY_FATAL_ERROR( "yyset_column called with no buffer" );
3187
    
3188
0
    yycolumn = _column_no;
3189
0
}
3190
3191
/** Set the input stream. This does not discard the current
3192
 * input buffer.
3193
 * @param _in_str A readable stream.
3194
 * @param yyscanner The scanner object.
3195
 * @see yy_switch_to_buffer
3196
 */
3197
void yyset_in (FILE *  _in_str , yyscan_t yyscanner)
3198
0
{
3199
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3200
0
    yyin = _in_str ;
3201
0
}
3202
3203
void yyset_out (FILE *  _out_str , yyscan_t yyscanner)
3204
0
{
3205
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3206
0
    yyout = _out_str ;
3207
0
}
3208
3209
int yyget_debug  (yyscan_t yyscanner)
3210
0
{
3211
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3212
0
    return yy_flex_debug;
3213
0
}
3214
3215
void yyset_debug (int  _bdebug , yyscan_t yyscanner)
3216
0
{
3217
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3218
0
    yy_flex_debug = _bdebug ;
3219
0
}
3220
3221
/* Accessor methods for yylval and yylloc */
3222
3223
YYSTYPE * yyget_lval  (yyscan_t yyscanner)
3224
0
{
3225
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3226
0
    return yylval;
3227
0
}
3228
3229
void yyset_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)
3230
0
{
3231
0
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3232
0
    yylval = yylval_param;
3233
0
}
3234
3235
/* User-visible API */
3236
3237
/* yylex_init is special because it creates the scanner itself, so it is
3238
 * the ONLY reentrant function that doesn't take the scanner as the last argument.
3239
 * That's why we explicitly handle the declaration, instead of using our macros.
3240
 */
3241
int yylex_init(yyscan_t* ptr_yy_globals)
3242
1.70k
{
3243
1.70k
    if (ptr_yy_globals == NULL){
3244
0
        errno = EINVAL;
3245
0
        return 1;
3246
0
    }
3247
3248
1.70k
    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
3249
3250
1.70k
    if (*ptr_yy_globals == NULL){
3251
0
        errno = ENOMEM;
3252
0
        return 1;
3253
0
    }
3254
3255
    /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
3256
1.70k
    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
3257
3258
1.70k
    return yy_init_globals ( *ptr_yy_globals );
3259
1.70k
}
3260
3261
/* yylex_init_extra has the same functionality as yylex_init, but follows the
3262
 * convention of taking the scanner as the last argument. Note however, that
3263
 * this is a *pointer* to a scanner, as it will be allocated by this call (and
3264
 * is the reason, too, why this function also must handle its own declaration).
3265
 * The user defined value in the first argument will be available to yyalloc in
3266
 * the yyextra field.
3267
 */
3268
int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
3269
0
{
3270
0
    struct yyguts_t dummy_yyguts;
3271
3272
0
    yyset_extra (yy_user_defined, &dummy_yyguts);
3273
3274
0
    if (ptr_yy_globals == NULL){
3275
0
        errno = EINVAL;
3276
0
        return 1;
3277
0
    }
3278
3279
0
    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
3280
3281
0
    if (*ptr_yy_globals == NULL){
3282
0
        errno = ENOMEM;
3283
0
        return 1;
3284
0
    }
3285
3286
    /* By setting to 0xAA, we expose bugs in
3287
    yy_init_globals. Leave at 0x00 for releases. */
3288
0
    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
3289
3290
0
    yyset_extra (yy_user_defined, *ptr_yy_globals);
3291
3292
0
    return yy_init_globals ( *ptr_yy_globals );
3293
0
}
3294
3295
static int yy_init_globals (yyscan_t yyscanner)
3296
3.41k
{
3297
3.41k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3298
    /* Initialization is the same as for the non-reentrant scanner.
3299
     * This function is called from yylex_destroy(), so don't allocate here.
3300
     */
3301
3302
3.41k
    yyg->yy_buffer_stack = NULL;
3303
3.41k
    yyg->yy_buffer_stack_top = 0;
3304
3.41k
    yyg->yy_buffer_stack_max = 0;
3305
3.41k
    yyg->yy_c_buf_p = NULL;
3306
3.41k
    yyg->yy_init = 0;
3307
3.41k
    yyg->yy_start = 0;
3308
3309
3.41k
    yyg->yy_start_stack_ptr = 0;
3310
3.41k
    yyg->yy_start_stack_depth = 0;
3311
3.41k
    yyg->yy_start_stack =  NULL;
3312
3313
/* Defined in main.c */
3314
#ifdef YY_STDINIT
3315
    yyin = stdin;
3316
    yyout = stdout;
3317
#else
3318
3.41k
    yyin = NULL;
3319
3.41k
    yyout = NULL;
3320
3.41k
#endif
3321
3322
    /* For future reference: Set errno on error, since we are called by
3323
     * yylex_init()
3324
     */
3325
3.41k
    return 0;
3326
3.41k
}
3327
3328
/* yylex_destroy is for both reentrant and non-reentrant scanners. */
3329
int yylex_destroy  (yyscan_t yyscanner)
3330
1.70k
{
3331
1.70k
    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3332
3333
    /* Pop the buffer stack, destroying each element. */
3334
2.17k
  while(YY_CURRENT_BUFFER){
3335
474
    yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
3336
474
    YY_CURRENT_BUFFER_LVALUE = NULL;
3337
474
    yypop_buffer_state(yyscanner);
3338
474
  }
3339
3340
  /* Destroy the stack itself. */
3341
1.70k
  yyfree(yyg->yy_buffer_stack , yyscanner);
3342
1.70k
  yyg->yy_buffer_stack = NULL;
3343
3344
    /* Destroy the start condition stack. */
3345
1.70k
        yyfree( yyg->yy_start_stack , yyscanner );
3346
1.70k
        yyg->yy_start_stack = NULL;
3347
3348
    /* Reset the globals. This is important in a non-reentrant scanner so the next time
3349
     * yylex() is called, initialization will occur. */
3350
1.70k
    yy_init_globals( yyscanner);
3351
3352
    /* Destroy the main struct (reentrant only). */
3353
1.70k
    yyfree ( yyscanner , yyscanner );
3354
1.70k
    yyscanner = NULL;
3355
1.70k
    return 0;
3356
1.70k
}
3357
3358
/*
3359
 * Internal utility routines.
3360
 */
3361
3362
#ifndef yytext_ptr
3363
static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
3364
{
3365
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3366
  (void)yyg;
3367
3368
  int i;
3369
  for ( i = 0; i < n; ++i )
3370
    s1[i] = s2[i];
3371
}
3372
#endif
3373
3374
#ifdef YY_NEED_STRLEN
3375
static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
3376
{
3377
  int n;
3378
  for ( n = 0; s[n]; ++n )
3379
    ;
3380
3381
  return n;
3382
}
3383
#endif
3384
3385
void *yyalloc (yy_size_t  size , yyscan_t yyscanner)
3386
6.82k
{
3387
6.82k
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3388
6.82k
  (void)yyg;
3389
6.82k
  return malloc(size);
3390
6.82k
}
3391
3392
void *yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
3393
0
{
3394
0
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3395
0
  (void)yyg;
3396
3397
  /* The cast to (char *) in the following accommodates both
3398
   * implementations that use char* generic pointers, and those
3399
   * that use void* generic pointers.  It works with the latter
3400
   * because both ANSI C and C++ allow castless assignment from
3401
   * any pointer type to void*, and deal with argument conversions
3402
   * as though doing an assignment.
3403
   */
3404
0
  return realloc(ptr, size);
3405
0
}
3406
3407
void yyfree (void * ptr , yyscan_t yyscanner)
3408
8.52k
{
3409
8.52k
  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
3410
8.52k
  (void)yyg;
3411
8.52k
  free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
3412
8.52k
}
3413
3414
#define YYTABLES_NAME "yytables"
3415
3416
#line 763 "libyara/lexer.l"
3417
3418
3419
3420
void yywarning(
3421
    yyscan_t yyscanner,
3422
    const char *message_fmt,
3423
    ...)
3424
11.0k
{
3425
11.0k
  YR_COMPILER* compiler = yyget_extra(yyscanner);
3426
3427
11.0k
  char* file_name;
3428
11.0k
  char message[512];
3429
11.0k
  va_list message_args;
3430
3431
11.0k
  if (compiler->callback == NULL)
3432
11.0k
    return;
3433
3434
11.0k
  va_start(message_args, message_fmt);
3435
3436
0
  if (compiler->file_name_stack_ptr > 0)
3437
0
    file_name = compiler->file_name_stack[compiler->file_name_stack_ptr - 1];
3438
0
  else
3439
0
    file_name = NULL;
3440
3441
0
  vsnprintf(message, sizeof(message), message_fmt, message_args);
3442
3443
0
  YR_RULE* current_rule = NULL;
3444
3445
0
  if (compiler->current_rule_idx != UINT32_MAX)
3446
0
    current_rule = yr_arena_get_ptr(
3447
0
        compiler->arena,
3448
0
        YR_RULES_TABLE,
3449
0
        compiler->current_rule_idx * sizeof(YR_RULE));
3450
3451
0
  compiler->callback(
3452
0
      YARA_ERROR_LEVEL_WARNING,
3453
0
      file_name,
3454
0
      compiler->current_line ? compiler->current_line : yyget_lineno(yyscanner),
3455
0
      current_rule,
3456
0
      message,
3457
0
      compiler->user_data);
3458
3459
0
  va_end(message_args);
3460
0
}
3461
3462
3463
void yyfatal(
3464
    yyscan_t yyscanner,
3465
    const char *error_message)
3466
0
{
3467
0
  YR_COMPILER* compiler = yyget_extra(yyscanner);
3468
3469
0
  yyerror(yyscanner, compiler, error_message);
3470
0
  longjmp(compiler->error_recovery, 1);
3471
0
}
3472
3473
3474
void yyerror(
3475
    yyscan_t yyscanner,
3476
    YR_COMPILER* compiler,
3477
    const char *error_message)
3478
17.7k
{
3479
17.7k
  char message[512] = {'\0'};
3480
17.7k
  char* file_name = NULL;
3481
3482
17.7k
  compiler->errors++;
3483
3484
17.7k
  if (compiler->current_line != 0)
3485
1.21k
    compiler->last_error_line = compiler->current_line;
3486
16.5k
  else
3487
16.5k
    compiler->last_error_line = yyget_lineno(yyscanner);
3488
3489
17.7k
  compiler->current_line = 0;
3490
3491
17.7k
  if (compiler->file_name_stack_ptr > 0)
3492
0
  {
3493
0
    file_name = compiler->file_name_stack[compiler->file_name_stack_ptr - 1];
3494
0
  }
3495
17.7k
  else
3496
17.7k
  {
3497
17.7k
    file_name = NULL;
3498
17.7k
  }
3499
3500
17.7k
  YR_RULE* current_rule = NULL;
3501
3502
17.7k
  if (compiler->current_rule_idx != UINT32_MAX)
3503
14.4k
    current_rule = yr_arena_get_ptr(
3504
14.4k
        compiler->arena,
3505
14.4k
        YR_RULES_TABLE,
3506
14.4k
        compiler->current_rule_idx * sizeof(YR_RULE));
3507
3508
  // if error_message != NULL the error comes from yyparse internal code
3509
  // else the error comes from my code and the error code is set in
3510
  // compiler->last_error
3511
3512
17.7k
  if (error_message != NULL)
3513
8.56k
  {
3514
8.56k
    yr_compiler_set_error_extra_info(compiler, error_message);
3515
8.56k
    compiler->last_error = ERROR_SYNTAX_ERROR;
3516
3517
8.56k
    if (compiler->callback != NULL)
3518
0
    {
3519
0
      compiler->callback(
3520
0
          YARA_ERROR_LEVEL_ERROR,
3521
0
          file_name,
3522
0
          compiler->last_error_line,
3523
0
          current_rule,
3524
0
          error_message,
3525
0
          compiler->user_data);
3526
0
    }
3527
8.56k
  }
3528
9.16k
  else if (compiler->callback != NULL)
3529
0
  {
3530
0
    yr_compiler_get_error_message(compiler, message, sizeof(message));
3531
3532
0
    compiler->callback(
3533
0
        YARA_ERROR_LEVEL_ERROR,
3534
0
        file_name,
3535
0
        compiler->last_error_line,
3536
0
        current_rule,
3537
0
        message,
3538
0
        compiler->user_data);
3539
0
  }
3540
17.7k
}
3541
3542
3543
int yr_lex_parse_rules_bytes(
3544
    const void* rules_data,
3545
    size_t rules_size,
3546
    YR_COMPILER* compiler)
3547
0
{
3548
0
  yyscan_t yyscanner;
3549
3550
0
  compiler->errors = 0;
3551
3552
0
  if (rules_data == NULL)
3553
0
    return 0;
3554
3555
0
  if (yylex_init(&yyscanner) != 0)
3556
0
  {
3557
0
    compiler->errors = 1;
3558
0
    compiler->last_error = ERROR_INSUFFICIENT_MEMORY;
3559
0
    return compiler->errors;
3560
0
  }
3561
3562
0
  if (setjmp(compiler->error_recovery) != 0)
3563
0
    return compiler->errors;
3564
3565
  #if YYDEBUG
3566
  yydebug = 1;
3567
  #endif
3568
3569
0
  yyset_extra(compiler, yyscanner);
3570
0
  yy_scan_bytes(rules_data, rules_size, yyscanner);
3571
0
  yyset_lineno(1, yyscanner);
3572
0
  yyparse(yyscanner, compiler);
3573
0
  yylex_destroy(yyscanner);
3574
3575
0
  return compiler->errors;
3576
0
}
3577
3578
3579
int yr_lex_parse_rules_string(
3580
    const char* rules_string,
3581
    YR_COMPILER* compiler)
3582
1.70k
{
3583
1.70k
  yyscan_t yyscanner;
3584
3585
1.70k
  compiler->errors = 0;
3586
3587
1.70k
  if (rules_string == NULL)
3588
0
    return 0;
3589
3590
1.70k
  if (yylex_init(&yyscanner) != 0)
3591
0
  {
3592
0
    compiler->errors = 1;
3593
0
    compiler->last_error = ERROR_INSUFFICIENT_MEMORY;
3594
0
    return compiler->errors;
3595
0
  }
3596
3597
1.70k
  if (setjmp(compiler->error_recovery) != 0)
3598
0
    return compiler->errors;
3599
3600
  #if YYDEBUG
3601
  yydebug = 1;
3602
  #endif
3603
3604
1.70k
  yyset_extra(compiler, yyscanner);
3605
1.70k
  yy_scan_string(rules_string, yyscanner);
3606
1.70k
  yyset_lineno(1, yyscanner);
3607
1.70k
  yyparse(yyscanner, compiler);
3608
1.70k
  yylex_destroy(yyscanner);
3609
3610
1.70k
  return compiler->errors;
3611
1.70k
}
3612
3613
3614
int yr_lex_parse_rules_file(
3615
    FILE* rules_file,
3616
    YR_COMPILER* compiler)
3617
0
{
3618
0
  yyscan_t yyscanner;
3619
3620
0
  compiler->errors = 0;
3621
3622
0
  if (yylex_init(&yyscanner) != 0)
3623
0
  {
3624
0
    compiler->errors = 1;
3625
0
    compiler->last_error = ERROR_INSUFFICIENT_MEMORY;
3626
0
    return compiler->errors;
3627
0
  }
3628
3629
0
  if (setjmp(compiler->error_recovery) != 0)
3630
0
    return compiler->errors;
3631
3632
  #if YYDEBUG
3633
  yydebug = 1;
3634
  #endif
3635
3636
0
  yyset_in(rules_file, yyscanner);
3637
0
  yyset_extra(compiler, yyscanner);
3638
0
  yyparse(yyscanner, compiler);
3639
0
  yylex_destroy(yyscanner);
3640
3641
0
  return compiler->errors;
3642
0
}
3643
3644
3645
int yr_lex_parse_rules_fd(
3646
    YR_FILE_DESCRIPTOR rules_fd,
3647
    YR_COMPILER* compiler)
3648
0
{
3649
0
  yyscan_t yyscanner;
3650
0
  size_t file_size;
3651
0
  void* buffer;
3652
3653
  #if defined(_WIN32) || defined(__CYGWIN__)
3654
  DWORD bytes_read;
3655
  #endif
3656
3657
0
  compiler->errors = 0;
3658
3659
0
  if (setjmp(compiler->error_recovery) != 0)
3660
0
    return compiler->errors;
3661
3662
  #if defined(_WIN32) || defined(__CYGWIN__)
3663
  file_size = (size_t) GetFileSize(rules_fd, NULL);
3664
  #else
3665
0
  struct stat fs;
3666
0
  if (fstat(rules_fd, &fs) != 0)
3667
0
  {
3668
0
    compiler->errors = 1;
3669
0
    compiler->last_error = ERROR_COULD_NOT_READ_FILE;
3670
0
    return compiler->errors;
3671
0
  }
3672
0
  file_size = (size_t) fs.st_size;
3673
0
  #endif
3674
3675
0
  buffer = yr_malloc(file_size);
3676
3677
0
  if (buffer == NULL)
3678
0
  {
3679
0
    compiler->errors = 1;
3680
0
    compiler->last_error = ERROR_INSUFFICIENT_MEMORY;
3681
0
    return compiler->errors;
3682
0
  }
3683
3684
  #if defined(_WIN32) || defined(__CYGWIN__)
3685
  if (!ReadFile(rules_fd, buffer, file_size, &bytes_read, NULL))
3686
  #else
3687
0
  if (read(rules_fd, buffer, file_size) != file_size)
3688
0
  #endif
3689
0
  {
3690
0
    yr_free(buffer);
3691
0
    compiler->errors = 1;
3692
0
    compiler->last_error = ERROR_COULD_NOT_READ_FILE;
3693
0
    return compiler->errors;
3694
0
  }
3695
3696
0
  if (yylex_init(&yyscanner) != 0)
3697
0
  {
3698
0
    yr_free(buffer);
3699
0
    compiler->errors = 1;
3700
0
    compiler->last_error = ERROR_INSUFFICIENT_MEMORY;
3701
0
    return compiler->errors;
3702
0
  }
3703
3704
  #if YYDEBUG
3705
  yydebug = 1;
3706
  #endif
3707
3708
0
  yyset_extra(compiler, yyscanner);
3709
0
  yy_scan_bytes((const char*) buffer, (int) file_size, yyscanner);
3710
0
  yyset_lineno(1, yyscanner);
3711
0
  yyparse(yyscanner, compiler);
3712
0
  yylex_destroy(yyscanner);
3713
3714
0
  yr_free(buffer);
3715
3716
0
  return compiler->errors;
3717
0
}
3718