/src/yara/libyara/lexer.c
Line | Count | Source (jump to first uncovered line) |
1 | | #line 1 "lexer.c" |
2 | | |
3 | | #line 3 "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 | 2 | #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 | 2 | #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 | 2 | #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 | 2 | #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 | 4 | #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 | 2 | #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 | 2 | #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 | 2 | #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 | 2 | #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 | 2 | #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 | 2 | #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 | 2 | #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 | 2 | #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 | 8 | #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 | 10 | #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 | 2 | #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 | 208 | #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 | 14 | #define yyin yyg->yyin_r |
345 | 8 | #define yyout yyg->yyout_r |
346 | 124 | #define yyextra yyg->yyextra_r |
347 | 92 | #define yyleng yyg->yyleng_r |
348 | 58 | #define yytext yyg->yytext_r |
349 | 2 | #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) |
350 | 0 | #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) |
351 | 0 | #define yy_flex_debug yyg->yy_flex_debug_r |
352 | | |
353 | | /* Enter a start condition. This macro really ought to take a parameter, |
354 | | * but we do it the disgusting crufty way forced on us by the ()-less |
355 | | * definition of BEGIN. |
356 | | */ |
357 | 8 | #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 | 12 | #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 | 8 | #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 | 4 | #define EOB_ACT_END_OF_FILE 1 |
399 | 4 | #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 | 6 | #define YY_BUFFER_NEW 0 |
487 | 2 | #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 | 20 | #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ |
510 | 20 | ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ |
511 | 20 | : 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 | 48 | #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 | 2 | #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 | 78 | #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 | 56 | yyg->yytext_ptr = yy_bp; \ |
579 | 56 | yyleng = (int) (yy_cp - yy_bp); \ |
580 | 56 | yyg->yy_hold_char = *yy_cp; \ |
581 | 56 | *yy_cp = '\0'; \ |
582 | 56 | yyg->yy_c_buf_p = yy_cp; |
583 | | #define YY_NUM_RULES 86 |
584 | 128 | #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 | 10 | #define YY_MORE_ADJ 0 |
896 | | #define YY_RESTORE_YY_MORE_OFFSET |
897 | | #line 1 "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 "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 | 0 | { \ |
972 | 0 | compiler->last_error = error_code; \ |
973 | 0 | yyerror(yyscanner, compiler, NULL); \ |
974 | 0 | yyterminate(); \ |
975 | 0 | } |
976 | | |
977 | | #define syntax_error(error_msg) \ |
978 | 0 | { \ |
979 | 0 | yr_compiler_set_error_extra_info(compiler, error_msg); \ |
980 | 0 | error(ERROR_SYNTAX_ERROR); \ |
981 | 0 | } |
982 | | |
983 | | #define lex_check_space_ok(data, current_size, max_length) \ |
984 | 4 | if (strlen(data) + current_size >= max_length - 1) \ |
985 | 4 | { \ |
986 | 0 | yyerror(yyscanner, compiler, "out of space in lex_buf"); \ |
987 | 0 | yyterminate(); \ |
988 | 0 | } |
989 | | |
990 | | #define yytext_to_buffer \ |
991 | 4 | { \ |
992 | 4 | char *yptr = yytext; \ |
993 | 4 | lex_check_space_ok(yptr, yyextra->lex_buf_len, YR_LEX_BUF_SIZE); \ |
994 | 30 | while(*yptr) \ |
995 | 26 | { \ |
996 | 26 | *yyextra->lex_buf_ptr++ = *yptr++; \ |
997 | 26 | yyextra->lex_buf_len++; \ |
998 | 26 | } \ |
999 | 4 | } |
1000 | | |
1001 | | #define alloc_sized_string(str, str_len) \ |
1002 | 4 | SIZED_STRING* str = (SIZED_STRING*) yr_malloc( \ |
1003 | 4 | str_len + sizeof(SIZED_STRING)); \ |
1004 | 4 | if (str == NULL) \ |
1005 | 4 | { \ |
1006 | 0 | yyerror(yyscanner, compiler, "not enough memory"); \ |
1007 | 0 | yyterminate(); \ |
1008 | 0 | } \ |
1009 | 4 | else \ |
1010 | 4 | { \ |
1011 | 4 | str->length = (uint32_t) (str_len); \ |
1012 | 4 | str->flags = 0; \ |
1013 | 4 | } \ |
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 "lexer.c" |
1034 | | #define YY_NO_UNISTD_H 1 |
1035 | | #define YY_NO_INPUT 1 |
1036 | | |
1037 | | #line 1037 "lexer.c" |
1038 | | |
1039 | 4 | #define INITIAL 0 |
1040 | 4 | #define str 1 |
1041 | 0 | #define regexp 2 |
1042 | 0 | #define include 3 |
1043 | 0 | #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 | 48 | # 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 | 0 | #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 | 2 | #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 | 26 | #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 | 28 | { |
1279 | 28 | yy_state_type yy_current_state; |
1280 | 28 | char *yy_cp, *yy_bp; |
1281 | 28 | int yy_act; |
1282 | 28 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
1283 | | |
1284 | 28 | yylval = yylval_param; |
1285 | | |
1286 | 28 | if ( !yyg->yy_init ) |
1287 | 2 | { |
1288 | 2 | yyg->yy_init = 1; |
1289 | | |
1290 | | #ifdef YY_USER_INIT |
1291 | | YY_USER_INIT; |
1292 | | #endif |
1293 | | |
1294 | 2 | if ( ! yyg->yy_start ) |
1295 | 2 | yyg->yy_start = 1; /* first start state */ |
1296 | | |
1297 | 2 | if ( ! yyin ) |
1298 | 2 | yyin = stdin; |
1299 | | |
1300 | 2 | if ( ! yyout ) |
1301 | 2 | yyout = stdout; |
1302 | | |
1303 | 2 | 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 | 2 | yy_load_buffer_state( yyscanner ); |
1310 | 2 | } |
1311 | | |
1312 | 28 | { |
1313 | 28 | #line 163 "lexer.l" |
1314 | | |
1315 | | |
1316 | 28 | #line 1316 "lexer.c" |
1317 | | |
1318 | 54 | while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ |
1319 | 54 | { |
1320 | 54 | yy_cp = yyg->yy_c_buf_p; |
1321 | | |
1322 | | /* Support of yytext. */ |
1323 | 54 | *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 | 54 | yy_bp = yy_cp; |
1329 | | |
1330 | 54 | yy_current_state = yyg->yy_start; |
1331 | 54 | yy_match: |
1332 | 54 | do |
1333 | 206 | { |
1334 | 206 | YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; |
1335 | 206 | if ( yy_accept[yy_current_state] ) |
1336 | 148 | { |
1337 | 148 | yyg->yy_last_accepting_state = yy_current_state; |
1338 | 148 | yyg->yy_last_accepting_cpos = yy_cp; |
1339 | 148 | } |
1340 | 344 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) |
1341 | 138 | { |
1342 | 138 | yy_current_state = (int) yy_def[yy_current_state]; |
1343 | 138 | if ( yy_current_state >= 295 ) |
1344 | 84 | yy_c = yy_meta[yy_c]; |
1345 | 138 | } |
1346 | 206 | yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; |
1347 | 206 | ++yy_cp; |
1348 | 206 | } |
1349 | 206 | while ( yy_current_state != 294 ); |
1350 | 54 | yy_cp = yyg->yy_last_accepting_cpos; |
1351 | 54 | yy_current_state = yyg->yy_last_accepting_state; |
1352 | | |
1353 | 56 | yy_find_action: |
1354 | 56 | yy_act = yy_accept[yy_current_state]; |
1355 | | |
1356 | 56 | YY_DO_BEFORE_ACTION; |
1357 | | |
1358 | 56 | if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) |
1359 | 18 | { |
1360 | 18 | int yyl; |
1361 | 36 | for ( yyl = 0; yyl < yyleng; ++yyl ) |
1362 | 18 | if ( yytext[yyl] == '\n' ) |
1363 | | |
1364 | 0 | do{ yylineno++; |
1365 | 0 | yycolumn=0; |
1366 | 0 | }while(0) |
1367 | 18 | ; |
1368 | 18 | } |
1369 | | |
1370 | 58 | do_action: /* This label is used only to access EOF actions. */ |
1371 | | |
1372 | 58 | switch ( yy_act ) |
1373 | 58 | { /* beginning of action switch */ |
1374 | 0 | case 0: /* must back up */ |
1375 | | /* undo the effects of YY_DO_BEFORE_ACTION */ |
1376 | 0 | *yy_cp = yyg->yy_hold_char; |
1377 | 0 | yy_cp = yyg->yy_last_accepting_cpos; |
1378 | 0 | yy_current_state = yyg->yy_last_accepting_state; |
1379 | 0 | goto yy_find_action; |
1380 | | |
1381 | 0 | case 1: |
1382 | 0 | YY_RULE_SETUP |
1383 | 0 | #line 165 "lexer.l" |
1384 | 0 | { return _DOT_DOT_; } |
1385 | 0 | YY_BREAK |
1386 | 0 | case 2: |
1387 | 0 | YY_RULE_SETUP |
1388 | 0 | #line 166 "lexer.l" |
1389 | 0 | { return _LT_; } |
1390 | 0 | YY_BREAK |
1391 | 0 | case 3: |
1392 | 0 | YY_RULE_SETUP |
1393 | 0 | #line 167 "lexer.l" |
1394 | 0 | { return _GT_; } |
1395 | 0 | YY_BREAK |
1396 | 0 | case 4: |
1397 | 0 | YY_RULE_SETUP |
1398 | 0 | #line 168 "lexer.l" |
1399 | 0 | { return _LE_; } |
1400 | 0 | YY_BREAK |
1401 | 0 | case 5: |
1402 | 0 | YY_RULE_SETUP |
1403 | 0 | #line 169 "lexer.l" |
1404 | 0 | { return _GE_; } |
1405 | 0 | YY_BREAK |
1406 | 2 | case 6: |
1407 | 2 | YY_RULE_SETUP |
1408 | 2 | #line 170 "lexer.l" |
1409 | 2 | { return _EQ_; } |
1410 | 0 | YY_BREAK |
1411 | 0 | case 7: |
1412 | 0 | YY_RULE_SETUP |
1413 | 0 | #line 171 "lexer.l" |
1414 | 0 | { return _NEQ_; } |
1415 | 0 | YY_BREAK |
1416 | 0 | case 8: |
1417 | 0 | YY_RULE_SETUP |
1418 | 0 | #line 172 "lexer.l" |
1419 | 0 | { return _SHIFT_LEFT_; } |
1420 | 0 | YY_BREAK |
1421 | 0 | case 9: |
1422 | 0 | YY_RULE_SETUP |
1423 | 0 | #line 173 "lexer.l" |
1424 | 0 | { return _SHIFT_RIGHT_; } |
1425 | 0 | YY_BREAK |
1426 | 0 | case 10: |
1427 | 0 | YY_RULE_SETUP |
1428 | 0 | #line 174 "lexer.l" |
1429 | 0 | { return _PRIVATE_; } |
1430 | 0 | YY_BREAK |
1431 | 0 | case 11: |
1432 | 0 | YY_RULE_SETUP |
1433 | 0 | #line 175 "lexer.l" |
1434 | 0 | { return _GLOBAL_; } |
1435 | 0 | YY_BREAK |
1436 | 2 | case 12: |
1437 | 2 | YY_RULE_SETUP |
1438 | 2 | #line 176 "lexer.l" |
1439 | 2 | { return _RULE_; } |
1440 | 0 | YY_BREAK |
1441 | 0 | case 13: |
1442 | 0 | YY_RULE_SETUP |
1443 | 0 | #line 177 "lexer.l" |
1444 | 0 | { return _META_; } |
1445 | 0 | YY_BREAK |
1446 | 0 | case 14: |
1447 | 0 | YY_RULE_SETUP |
1448 | 0 | #line 178 "lexer.l" |
1449 | 0 | { return _STRINGS_; } |
1450 | 0 | YY_BREAK |
1451 | 0 | case 15: |
1452 | 0 | YY_RULE_SETUP |
1453 | 0 | #line 179 "lexer.l" |
1454 | 0 | { return _ASCII_; } |
1455 | 0 | YY_BREAK |
1456 | 0 | case 16: |
1457 | 0 | YY_RULE_SETUP |
1458 | 0 | #line 180 "lexer.l" |
1459 | 0 | { return _WIDE_; } |
1460 | 0 | YY_BREAK |
1461 | 0 | case 17: |
1462 | 0 | YY_RULE_SETUP |
1463 | 0 | #line 181 "lexer.l" |
1464 | 0 | { return _XOR_; } |
1465 | 0 | YY_BREAK |
1466 | 0 | case 18: |
1467 | 0 | YY_RULE_SETUP |
1468 | 0 | #line 182 "lexer.l" |
1469 | 0 | { return _BASE64_; } |
1470 | 0 | YY_BREAK |
1471 | 0 | case 19: |
1472 | 0 | YY_RULE_SETUP |
1473 | 0 | #line 183 "lexer.l" |
1474 | 0 | { return _BASE64_WIDE_; } |
1475 | 0 | YY_BREAK |
1476 | 0 | case 20: |
1477 | 0 | YY_RULE_SETUP |
1478 | 0 | #line 184 "lexer.l" |
1479 | 0 | { return _FULLWORD_; } |
1480 | 0 | YY_BREAK |
1481 | 0 | case 21: |
1482 | 0 | YY_RULE_SETUP |
1483 | 0 | #line 185 "lexer.l" |
1484 | 0 | { return _NOCASE_; } |
1485 | 0 | YY_BREAK |
1486 | 2 | case 22: |
1487 | 2 | YY_RULE_SETUP |
1488 | 2 | #line 186 "lexer.l" |
1489 | 2 | { return _CONDITION_; } |
1490 | 0 | YY_BREAK |
1491 | 0 | case 23: |
1492 | 0 | YY_RULE_SETUP |
1493 | 0 | #line 187 "lexer.l" |
1494 | 0 | { return _TRUE_; } |
1495 | 0 | YY_BREAK |
1496 | 0 | case 24: |
1497 | 0 | YY_RULE_SETUP |
1498 | 0 | #line 188 "lexer.l" |
1499 | 0 | { return _FALSE_; } |
1500 | 0 | YY_BREAK |
1501 | 0 | case 25: |
1502 | 0 | YY_RULE_SETUP |
1503 | 0 | #line 189 "lexer.l" |
1504 | 0 | { return _NOT_; } |
1505 | 0 | YY_BREAK |
1506 | 0 | case 26: |
1507 | 0 | YY_RULE_SETUP |
1508 | 0 | #line 190 "lexer.l" |
1509 | 0 | { return _AND_; } |
1510 | 0 | YY_BREAK |
1511 | 0 | case 27: |
1512 | 0 | YY_RULE_SETUP |
1513 | 0 | #line 191 "lexer.l" |
1514 | 0 | { return _OR_; } |
1515 | 0 | YY_BREAK |
1516 | 0 | case 28: |
1517 | 0 | YY_RULE_SETUP |
1518 | 0 | #line 192 "lexer.l" |
1519 | 0 | { return _AT_; } |
1520 | 0 | YY_BREAK |
1521 | 0 | case 29: |
1522 | 0 | YY_RULE_SETUP |
1523 | 0 | #line 193 "lexer.l" |
1524 | 0 | { return _IN_; } |
1525 | 0 | YY_BREAK |
1526 | 0 | case 30: |
1527 | 0 | YY_RULE_SETUP |
1528 | 0 | #line 194 "lexer.l" |
1529 | 0 | { return _OF_; } |
1530 | 0 | YY_BREAK |
1531 | 0 | case 31: |
1532 | 0 | YY_RULE_SETUP |
1533 | 0 | #line 195 "lexer.l" |
1534 | 0 | { return _THEM_; } |
1535 | 0 | YY_BREAK |
1536 | 0 | case 32: |
1537 | 0 | YY_RULE_SETUP |
1538 | 0 | #line 196 "lexer.l" |
1539 | 0 | { return _FOR_; } |
1540 | 0 | YY_BREAK |
1541 | 0 | case 33: |
1542 | 0 | YY_RULE_SETUP |
1543 | 0 | #line 197 "lexer.l" |
1544 | 0 | { return _ALL_; } |
1545 | 0 | YY_BREAK |
1546 | 0 | case 34: |
1547 | 0 | YY_RULE_SETUP |
1548 | 0 | #line 198 "lexer.l" |
1549 | 0 | { return _ANY_; } |
1550 | 0 | YY_BREAK |
1551 | 0 | case 35: |
1552 | 0 | YY_RULE_SETUP |
1553 | 0 | #line 199 "lexer.l" |
1554 | 0 | { return _NONE_; } |
1555 | 0 | YY_BREAK |
1556 | 0 | case 36: |
1557 | 0 | YY_RULE_SETUP |
1558 | 0 | #line 200 "lexer.l" |
1559 | 0 | { return _ENTRYPOINT_; } |
1560 | 0 | YY_BREAK |
1561 | 0 | case 37: |
1562 | 0 | YY_RULE_SETUP |
1563 | 0 | #line 201 "lexer.l" |
1564 | 0 | { return _FILESIZE_; } |
1565 | 0 | YY_BREAK |
1566 | 0 | case 38: |
1567 | 0 | YY_RULE_SETUP |
1568 | 0 | #line 202 "lexer.l" |
1569 | 0 | { return _MATCHES_; } |
1570 | 0 | YY_BREAK |
1571 | 0 | case 39: |
1572 | 0 | YY_RULE_SETUP |
1573 | 0 | #line 203 "lexer.l" |
1574 | 0 | { return _CONTAINS_; } |
1575 | 0 | YY_BREAK |
1576 | 0 | case 40: |
1577 | 0 | YY_RULE_SETUP |
1578 | 0 | #line 204 "lexer.l" |
1579 | 0 | { return _STARTSWITH_; } |
1580 | 0 | YY_BREAK |
1581 | 0 | case 41: |
1582 | 0 | YY_RULE_SETUP |
1583 | 0 | #line 205 "lexer.l" |
1584 | 0 | { return _ENDSWITH_; } |
1585 | 0 | YY_BREAK |
1586 | 0 | case 42: |
1587 | 0 | YY_RULE_SETUP |
1588 | 0 | #line 206 "lexer.l" |
1589 | 0 | { return _ICONTAINS_; } |
1590 | 0 | YY_BREAK |
1591 | 0 | case 43: |
1592 | 0 | YY_RULE_SETUP |
1593 | 0 | #line 207 "lexer.l" |
1594 | 0 | { return _ISTARTSWITH_; } |
1595 | 0 | YY_BREAK |
1596 | 0 | case 44: |
1597 | 0 | YY_RULE_SETUP |
1598 | 0 | #line 208 "lexer.l" |
1599 | 0 | { return _IENDSWITH_; } |
1600 | 0 | YY_BREAK |
1601 | 0 | case 45: |
1602 | 0 | YY_RULE_SETUP |
1603 | 0 | #line 209 "lexer.l" |
1604 | 0 | { return _IEQUALS_; } |
1605 | 0 | YY_BREAK |
1606 | 2 | case 46: |
1607 | 2 | YY_RULE_SETUP |
1608 | 2 | #line 210 "lexer.l" |
1609 | 2 | { return _IMPORT_; } |
1610 | 0 | YY_BREAK |
1611 | 0 | case 47: |
1612 | 0 | YY_RULE_SETUP |
1613 | 0 | #line 211 "lexer.l" |
1614 | 0 | { return _DEFINED_; } |
1615 | 0 | YY_BREAK |
1616 | 0 | case 48: |
1617 | 0 | YY_RULE_SETUP |
1618 | 0 | #line 214 "lexer.l" |
1619 | 0 | { BEGIN(comment); } |
1620 | 0 | YY_BREAK |
1621 | 0 | case 49: |
1622 | 0 | YY_RULE_SETUP |
1623 | 0 | #line 215 "lexer.l" |
1624 | 0 | { BEGIN(INITIAL); } |
1625 | 0 | YY_BREAK |
1626 | 0 | case 50: |
1627 | | /* rule 50 can match eol */ |
1628 | 0 | YY_RULE_SETUP |
1629 | 0 | #line 216 "lexer.l" |
1630 | 0 | { /* skip comments */ } |
1631 | 0 | YY_BREAK |
1632 | 0 | case 51: |
1633 | 0 | YY_RULE_SETUP |
1634 | 0 | #line 219 "lexer.l" |
1635 | 0 | { /* skip single-line comments */ } |
1636 | 0 | YY_BREAK |
1637 | 0 | case 52: |
1638 | 0 | YY_RULE_SETUP |
1639 | 0 | #line 222 "lexer.l" |
1640 | 0 | { |
1641 | 0 | yyextra->lex_buf_ptr = yyextra->lex_buf; |
1642 | 0 | yyextra->lex_buf_len = 0; |
1643 | 0 | BEGIN(include); |
1644 | 0 | } |
1645 | 0 | YY_BREAK |
1646 | 0 | case 53: |
1647 | | /* rule 53 can match eol */ |
1648 | 0 | YY_RULE_SETUP |
1649 | 0 | #line 229 "lexer.l" |
1650 | 0 | { yytext_to_buffer; } |
1651 | 0 | YY_BREAK |
1652 | 0 | case 54: |
1653 | 0 | YY_RULE_SETUP |
1654 | 0 | #line 232 "lexer.l" |
1655 | 0 | { |
1656 | |
|
1657 | 0 | if (compiler->include_callback != NULL) |
1658 | 0 | { |
1659 | | #ifdef _MSC_VER |
1660 | | char* b = NULL; |
1661 | | #endif |
1662 | 0 | char* s = NULL; |
1663 | 0 | char* f; |
1664 | |
|
1665 | 0 | char buffer[1024]; |
1666 | 0 | const char* included_rules; |
1667 | 0 | char* current_file_name; |
1668 | 0 | char* include_path; |
1669 | |
|
1670 | 0 | *yyextra->lex_buf_ptr = '\0'; // null-terminate included file path |
1671 | |
|
1672 | 0 | current_file_name = yr_compiler_get_current_file_name(compiler); |
1673 | |
|
1674 | 0 | if (current_file_name == NULL || |
1675 | 0 | compiler->include_callback != _yr_compiler_default_include_callback || |
1676 | 0 | is_absolute_path(yyextra->lex_buf)) |
1677 | 0 | { |
1678 | 0 | include_path = yyextra->lex_buf; |
1679 | 0 | } |
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 | 0 | YR_NAMESPACE* ns = (YR_NAMESPACE*) yr_arena_get_ptr( |
1711 | 0 | compiler->arena, |
1712 | 0 | YR_NAMESPACES_TABLE, |
1713 | 0 | compiler->current_namespace_idx * sizeof(struct YR_NAMESPACE)); |
1714 | |
|
1715 | 0 | included_rules = compiler->include_callback( |
1716 | 0 | include_path, |
1717 | 0 | current_file_name, |
1718 | 0 | ns->name, |
1719 | 0 | compiler->incl_clbk_user_data); |
1720 | |
|
1721 | 0 | 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 | 0 | else |
1755 | 0 | { |
1756 | 0 | char* err_msg_fmt; |
1757 | 0 | char err_msg[512]; |
1758 | |
|
1759 | 0 | if (compiler->include_callback == _yr_compiler_default_include_callback) |
1760 | 0 | { |
1761 | 0 | err_msg_fmt = "can't open include file: %s"; |
1762 | 0 | } |
1763 | 0 | else |
1764 | 0 | { |
1765 | 0 | err_msg_fmt = "callback failed to provide include resource: %s"; |
1766 | 0 | } |
1767 | |
|
1768 | 0 | snprintf( |
1769 | 0 | err_msg, |
1770 | 0 | sizeof(err_msg), |
1771 | 0 | err_msg_fmt, |
1772 | 0 | yyextra->lex_buf); |
1773 | |
|
1774 | 0 | yyerror(yyscanner, compiler, err_msg); |
1775 | 0 | } |
1776 | |
|
1777 | 0 | } |
1778 | 0 | else // not allowing includes |
1779 | 0 | { |
1780 | 0 | yyerror(yyscanner, compiler, "includes are disabled"); |
1781 | 0 | } |
1782 | | |
1783 | 0 | BEGIN(INITIAL); |
1784 | 0 | } |
1785 | 0 | YY_BREAK |
1786 | 2 | case YY_STATE_EOF(INITIAL): |
1787 | 2 | case YY_STATE_EOF(str): |
1788 | 2 | case YY_STATE_EOF(regexp): |
1789 | 2 | case YY_STATE_EOF(include): |
1790 | 2 | case YY_STATE_EOF(comment): |
1791 | 2 | #line 364 "lexer.l" |
1792 | 2 | { |
1793 | | |
1794 | 2 | yypop_buffer_state(yyscanner); |
1795 | | |
1796 | 2 | if (!YY_CURRENT_BUFFER) |
1797 | 2 | yyterminate(); |
1798 | | |
1799 | 0 | return _END_OF_INCLUDED_FILE_; |
1800 | 2 | } |
1801 | 0 | YY_BREAK |
1802 | 0 | case 55: |
1803 | 0 | YY_RULE_SETUP |
1804 | 0 | #line 375 "lexer.l" |
1805 | 0 | { |
1806 | |
|
1807 | 0 | yylval->c_string = yr_strdup(yytext); |
1808 | |
|
1809 | 0 | if (yylval->c_string == NULL) |
1810 | 0 | error(ERROR_INSUFFICIENT_MEMORY); |
1811 | |
|
1812 | 0 | return _STRING_IDENTIFIER_WITH_WILDCARD_; |
1813 | 0 | } |
1814 | 0 | YY_BREAK |
1815 | 0 | case 56: |
1816 | 0 | YY_RULE_SETUP |
1817 | 0 | #line 386 "lexer.l" |
1818 | 0 | { |
1819 | |
|
1820 | 0 | yylval->c_string = yr_strdup(yytext); |
1821 | |
|
1822 | 0 | if (yylval->c_string == NULL) |
1823 | 0 | error(ERROR_INSUFFICIENT_MEMORY); |
1824 | |
|
1825 | 0 | return _STRING_IDENTIFIER_; |
1826 | 0 | } |
1827 | 0 | YY_BREAK |
1828 | 0 | case 57: |
1829 | 0 | YY_RULE_SETUP |
1830 | 0 | #line 397 "lexer.l" |
1831 | 0 | { |
1832 | |
|
1833 | 0 | yylval->c_string = yr_strdup(yytext); |
1834 | |
|
1835 | 0 | if (yylval->c_string == NULL) |
1836 | 0 | { |
1837 | 0 | error(ERROR_INSUFFICIENT_MEMORY); |
1838 | 0 | } |
1839 | 0 | else |
1840 | 0 | { |
1841 | 0 | yylval->c_string[0] = '$'; /* replace # by $*/ |
1842 | 0 | } |
1843 | | |
1844 | 0 | return _STRING_COUNT_; |
1845 | 0 | } |
1846 | 0 | YY_BREAK |
1847 | 0 | case 58: |
1848 | 0 | YY_RULE_SETUP |
1849 | 0 | #line 414 "lexer.l" |
1850 | 0 | { |
1851 | |
|
1852 | 0 | yylval->c_string = yr_strdup(yytext); |
1853 | |
|
1854 | 0 | if (yylval->c_string == NULL) |
1855 | 0 | { |
1856 | 0 | error(ERROR_INSUFFICIENT_MEMORY); |
1857 | 0 | } |
1858 | 0 | else |
1859 | 0 | { |
1860 | 0 | yylval->c_string[0] = '$'; /* replace @ by $*/ |
1861 | 0 | } |
1862 | | |
1863 | 0 | return _STRING_OFFSET_; |
1864 | 0 | } |
1865 | 0 | YY_BREAK |
1866 | 0 | case 59: |
1867 | 0 | YY_RULE_SETUP |
1868 | 0 | #line 431 "lexer.l" |
1869 | 0 | { |
1870 | |
|
1871 | 0 | yylval->c_string = yr_strdup(yytext); |
1872 | |
|
1873 | 0 | if (yylval->c_string == NULL) |
1874 | 0 | { |
1875 | 0 | error(ERROR_INSUFFICIENT_MEMORY); |
1876 | 0 | } |
1877 | 0 | else |
1878 | 0 | { |
1879 | 0 | yylval->c_string[0] = '$'; /* replace ! by $*/ |
1880 | 0 | } |
1881 | | |
1882 | 0 | return _STRING_LENGTH_; |
1883 | 0 | } |
1884 | 0 | YY_BREAK |
1885 | 0 | case 60: |
1886 | 0 | YY_RULE_SETUP |
1887 | 0 | #line 448 "lexer.l" |
1888 | 0 | { |
1889 | |
|
1890 | 0 | char* text = yytext; |
1891 | |
|
1892 | 0 | if (*text == 'u') |
1893 | 0 | { |
1894 | 0 | yylval->integer = 3; |
1895 | 0 | text++; |
1896 | 0 | } |
1897 | 0 | else |
1898 | 0 | { |
1899 | 0 | yylval->integer = 0; |
1900 | 0 | } |
1901 | |
|
1902 | 0 | if (strstr(text, "int8") == text) |
1903 | 0 | { |
1904 | 0 | yylval->integer += 0; |
1905 | 0 | text += 4; |
1906 | 0 | } |
1907 | 0 | else if (strstr(text, "int16") == text) |
1908 | 0 | { |
1909 | 0 | yylval->integer += 1; |
1910 | 0 | text += 5; |
1911 | 0 | } |
1912 | 0 | else if (strstr(text, "int32") == text) |
1913 | 0 | { |
1914 | 0 | yylval->integer += 2; |
1915 | 0 | text += 5; |
1916 | 0 | } |
1917 | |
|
1918 | 0 | if (strcmp(text, "be") == 0) |
1919 | 0 | { |
1920 | 0 | yylval->integer += 6; |
1921 | 0 | } |
1922 | |
|
1923 | 0 | return _INTEGER_FUNCTION_; |
1924 | 0 | } |
1925 | 0 | YY_BREAK |
1926 | 6 | case 61: |
1927 | 6 | YY_RULE_SETUP |
1928 | 6 | #line 487 "lexer.l" |
1929 | 6 | { |
1930 | | |
1931 | 6 | if (strlen(yytext) > 128) |
1932 | 6 | syntax_error("identifier too long"); |
1933 | | |
1934 | 6 | yylval->c_string = yr_strdup(yytext); |
1935 | | |
1936 | 6 | if (yylval->c_string == NULL) |
1937 | 6 | error(ERROR_INSUFFICIENT_MEMORY); |
1938 | | |
1939 | 6 | return _IDENTIFIER_; |
1940 | 6 | } |
1941 | 0 | YY_BREAK |
1942 | 0 | case 62: |
1943 | 0 | YY_RULE_SETUP |
1944 | 0 | #line 501 "lexer.l" |
1945 | 0 | { |
1946 | |
|
1947 | 0 | char *endptr; |
1948 | |
|
1949 | 0 | errno = 0; |
1950 | 0 | yylval->integer = strtoll(yytext, &endptr, 10); |
1951 | |
|
1952 | 0 | if (yylval->integer == LLONG_MAX && errno == ERANGE) |
1953 | 0 | { |
1954 | 0 | yr_compiler_set_error_extra_info(compiler, yytext); |
1955 | 0 | error(ERROR_INTEGER_OVERFLOW); |
1956 | 0 | } |
1957 | 0 | else if (strstr(yytext, "KB") != NULL) |
1958 | 0 | { |
1959 | 0 | if (yylval->integer > LLONG_MAX / 1024) |
1960 | 0 | { |
1961 | 0 | yr_compiler_set_error_extra_info(compiler, yytext); |
1962 | 0 | error(ERROR_INTEGER_OVERFLOW); |
1963 | 0 | } |
1964 | 0 | else |
1965 | 0 | { |
1966 | 0 | yylval->integer *= 1024; |
1967 | 0 | } |
1968 | 0 | } |
1969 | 0 | else if (strstr(yytext, "MB") != NULL) |
1970 | 0 | { |
1971 | 0 | if (yylval->integer > LLONG_MAX / 1048576) |
1972 | 0 | { |
1973 | 0 | yr_compiler_set_error_extra_info(compiler, yytext); |
1974 | 0 | error(ERROR_INTEGER_OVERFLOW); |
1975 | 0 | } |
1976 | 0 | else |
1977 | 0 | { |
1978 | 0 | yylval->integer *= 1048576; |
1979 | 0 | } |
1980 | 0 | } |
1981 | | |
1982 | 0 | return _NUMBER_; |
1983 | 0 | } |
1984 | 0 | YY_BREAK |
1985 | 0 | case 63: |
1986 | 0 | YY_RULE_SETUP |
1987 | 0 | #line 541 "lexer.l" |
1988 | 0 | { |
1989 | 0 | yylval->double_ = atof(yytext); |
1990 | 0 | return _DOUBLE_; |
1991 | 0 | } |
1992 | 0 | YY_BREAK |
1993 | 0 | case 64: |
1994 | 0 | YY_RULE_SETUP |
1995 | 0 | #line 546 "lexer.l" |
1996 | 0 | { |
1997 | |
|
1998 | 0 | char *endptr; |
1999 | |
|
2000 | 0 | errno = 0; |
2001 | 0 | yylval->integer = strtoll(yytext, &endptr, 16); |
2002 | |
|
2003 | 0 | if (yylval->integer == LLONG_MAX && errno == ERANGE) |
2004 | 0 | { |
2005 | 0 | yr_compiler_set_error_extra_info(compiler, yytext); |
2006 | 0 | error(ERROR_INTEGER_OVERFLOW); |
2007 | 0 | } |
2008 | | |
2009 | 0 | return _NUMBER_; |
2010 | 0 | } |
2011 | 0 | YY_BREAK |
2012 | 0 | case 65: |
2013 | 0 | YY_RULE_SETUP |
2014 | 0 | #line 562 "lexer.l" |
2015 | 0 | { |
2016 | |
|
2017 | 0 | char *endptr; |
2018 | |
|
2019 | 0 | errno = 0; |
2020 | 0 | yylval->integer = strtoll(yytext + 2, &endptr, 8); |
2021 | |
|
2022 | 0 | if (yylval->integer == LLONG_MAX && errno == ERANGE) |
2023 | 0 | { |
2024 | 0 | yr_compiler_set_error_extra_info(compiler, yytext); |
2025 | 0 | error(ERROR_INTEGER_OVERFLOW); |
2026 | 0 | } |
2027 | | |
2028 | 0 | return _NUMBER_; |
2029 | 0 | } |
2030 | 0 | YY_BREAK |
2031 | 4 | case 66: |
2032 | 4 | YY_RULE_SETUP |
2033 | 4 | #line 579 "lexer.l" |
2034 | 4 | { /* saw closing quote - all done */ |
2035 | | |
2036 | 4 | alloc_sized_string(s, yyextra->lex_buf_len); |
2037 | | |
2038 | 4 | *yyextra->lex_buf_ptr = '\0'; |
2039 | 4 | memcpy(s->c_string, yyextra->lex_buf, yyextra->lex_buf_len + 1); |
2040 | | |
2041 | 4 | yylval->sized_string = s; |
2042 | | |
2043 | 4 | BEGIN(INITIAL); |
2044 | | |
2045 | 4 | return _TEXT_STRING_; |
2046 | 4 | } |
2047 | 0 | YY_BREAK |
2048 | 0 | case 67: |
2049 | 0 | YY_RULE_SETUP |
2050 | 0 | #line 594 "lexer.l" |
2051 | 0 | { |
2052 | |
|
2053 | 0 | lex_check_space_ok("\t", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); |
2054 | 0 | *yyextra->lex_buf_ptr++ = '\t'; |
2055 | 0 | yyextra->lex_buf_len++; |
2056 | 0 | } |
2057 | 0 | YY_BREAK |
2058 | 0 | case 68: |
2059 | 0 | YY_RULE_SETUP |
2060 | 0 | #line 602 "lexer.l" |
2061 | 0 | { |
2062 | |
|
2063 | 0 | lex_check_space_ok("\r", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); |
2064 | 0 | *yyextra->lex_buf_ptr++ = '\r'; |
2065 | 0 | yyextra->lex_buf_len++; |
2066 | 0 | } |
2067 | 0 | YY_BREAK |
2068 | 0 | case 69: |
2069 | 0 | YY_RULE_SETUP |
2070 | 0 | #line 610 "lexer.l" |
2071 | 0 | { |
2072 | |
|
2073 | 0 | lex_check_space_ok("\n", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); |
2074 | 0 | *yyextra->lex_buf_ptr++ = '\n'; |
2075 | 0 | yyextra->lex_buf_len++; |
2076 | 0 | } |
2077 | 0 | YY_BREAK |
2078 | 0 | case 70: |
2079 | 0 | YY_RULE_SETUP |
2080 | 0 | #line 618 "lexer.l" |
2081 | 0 | { |
2082 | |
|
2083 | 0 | lex_check_space_ok("\"", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); |
2084 | 0 | *yyextra->lex_buf_ptr++ = '\"'; |
2085 | 0 | yyextra->lex_buf_len++; |
2086 | 0 | } |
2087 | 0 | YY_BREAK |
2088 | 0 | case 71: |
2089 | 0 | YY_RULE_SETUP |
2090 | 0 | #line 626 "lexer.l" |
2091 | 0 | { |
2092 | |
|
2093 | 0 | lex_check_space_ok("\\", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); |
2094 | 0 | *yyextra->lex_buf_ptr++ = '\\'; |
2095 | 0 | yyextra->lex_buf_len++; |
2096 | 0 | } |
2097 | 0 | YY_BREAK |
2098 | 0 | case 72: |
2099 | 0 | YY_RULE_SETUP |
2100 | 0 | #line 634 "lexer.l" |
2101 | 0 | { |
2102 | |
|
2103 | 0 | int result; |
2104 | |
|
2105 | 0 | sscanf(yytext + 2, "%x", &result); |
2106 | 0 | lex_check_space_ok("X", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); |
2107 | 0 | *yyextra->lex_buf_ptr++ = result; |
2108 | 0 | yyextra->lex_buf_len++; |
2109 | 0 | } |
2110 | 0 | YY_BREAK |
2111 | 4 | case 73: |
2112 | 4 | YY_RULE_SETUP |
2113 | 4 | #line 645 "lexer.l" |
2114 | 4 | { yytext_to_buffer; } |
2115 | 4 | YY_BREAK |
2116 | 0 | case 74: |
2117 | | /* rule 74 can match eol */ |
2118 | 0 | YY_RULE_SETUP |
2119 | 0 | #line 648 "lexer.l" |
2120 | 0 | { |
2121 | 0 | syntax_error("unterminated string"); |
2122 | 0 | } |
2123 | 0 | YY_BREAK |
2124 | 0 | case 75: |
2125 | | /* rule 75 can match eol */ |
2126 | 0 | YY_RULE_SETUP |
2127 | 0 | #line 653 "lexer.l" |
2128 | 0 | { |
2129 | 0 | syntax_error("illegal escape sequence"); |
2130 | 0 | } |
2131 | 0 | YY_BREAK |
2132 | 0 | case 76: |
2133 | 0 | YY_RULE_SETUP |
2134 | 0 | #line 658 "lexer.l" |
2135 | 0 | { |
2136 | |
|
2137 | 0 | if (yyextra->lex_buf_len > 0) |
2138 | 0 | { |
2139 | 0 | alloc_sized_string(s, yyextra->lex_buf_len); |
2140 | |
|
2141 | 0 | if (yytext[1] == 'i') |
2142 | 0 | s->flags |= SIZED_STRING_FLAGS_NO_CASE; |
2143 | |
|
2144 | 0 | if (yytext[1] == 's' || yytext[2] == 's') |
2145 | 0 | s->flags |= SIZED_STRING_FLAGS_DOT_ALL; |
2146 | |
|
2147 | 0 | *yyextra->lex_buf_ptr = '\0'; |
2148 | 0 | strlcpy(s->c_string, yyextra->lex_buf, s->length + 1); |
2149 | |
|
2150 | 0 | yylval->sized_string = s; |
2151 | 0 | } |
2152 | 0 | else |
2153 | 0 | { |
2154 | 0 | syntax_error("empty regular expression"); |
2155 | 0 | } |
2156 | | |
2157 | 0 | BEGIN(INITIAL); |
2158 | 0 | return _REGEXP_; |
2159 | 0 | } |
2160 | 0 | YY_BREAK |
2161 | 0 | case 77: |
2162 | 0 | YY_RULE_SETUP |
2163 | 0 | #line 685 "lexer.l" |
2164 | 0 | { |
2165 | |
|
2166 | 0 | lex_check_space_ok("/", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); |
2167 | 0 | *yyextra->lex_buf_ptr++ = '/'; |
2168 | 0 | yyextra->lex_buf_len++ ; |
2169 | 0 | } |
2170 | 0 | YY_BREAK |
2171 | 0 | case 78: |
2172 | 0 | YY_RULE_SETUP |
2173 | 0 | #line 693 "lexer.l" |
2174 | 0 | { |
2175 | |
|
2176 | 0 | lex_check_space_ok("\\.", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); |
2177 | |
|
2178 | 0 | if (yytext[1] == 0) |
2179 | 0 | syntax_error("malformed regular expression"); |
2180 | |
|
2181 | 0 | *yyextra->lex_buf_ptr++ = yytext[0]; |
2182 | 0 | *yyextra->lex_buf_ptr++ = yytext[1]; |
2183 | 0 | yyextra->lex_buf_len += 2; |
2184 | 0 | } |
2185 | 0 | YY_BREAK |
2186 | 0 | case 79: |
2187 | 0 | YY_RULE_SETUP |
2188 | 0 | #line 706 "lexer.l" |
2189 | 0 | { yytext_to_buffer; } |
2190 | 0 | YY_BREAK |
2191 | 0 | case 80: |
2192 | | /* rule 80 can match eol */ |
2193 | 0 | YY_RULE_SETUP |
2194 | 0 | #line 709 "lexer.l" |
2195 | 0 | { |
2196 | 0 | syntax_error("unterminated regular expression"); |
2197 | 0 | } |
2198 | 0 | YY_BREAK |
2199 | 4 | case 81: |
2200 | 4 | YY_RULE_SETUP |
2201 | 4 | #line 714 "lexer.l" |
2202 | 4 | { |
2203 | | |
2204 | 4 | yylval->sized_string = NULL; |
2205 | 4 | yyextra->lex_buf_ptr = yyextra->lex_buf; |
2206 | 4 | yyextra->lex_buf_len = 0; |
2207 | 4 | BEGIN(str); |
2208 | 4 | } |
2209 | 4 | YY_BREAK |
2210 | 0 | case 82: |
2211 | 0 | YY_RULE_SETUP |
2212 | 0 | #line 723 "lexer.l" |
2213 | 0 | { |
2214 | |
|
2215 | 0 | yylval->sized_string = NULL; |
2216 | 0 | yyextra->lex_buf_ptr = yyextra->lex_buf; |
2217 | 0 | yyextra->lex_buf_len = 0; |
2218 | 0 | BEGIN(regexp); |
2219 | 0 | } |
2220 | 0 | YY_BREAK |
2221 | 0 | case 83: |
2222 | | /* rule 83 can match eol */ |
2223 | 0 | YY_RULE_SETUP |
2224 | 0 | #line 732 "lexer.l" |
2225 | 0 | { |
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 | 0 | alloc_sized_string(s, strlen(yytext)); |
2234 | |
|
2235 | 0 | strlcpy(s->c_string, yytext, s->length + 1); |
2236 | 0 | yylval->sized_string = s; |
2237 | |
|
2238 | 0 | return _HEX_STRING_; |
2239 | 0 | } |
2240 | 0 | YY_BREAK |
2241 | 18 | case 84: |
2242 | | /* rule 84 can match eol */ |
2243 | 18 | YY_RULE_SETUP |
2244 | 18 | #line 749 "lexer.l" |
2245 | | /* skip whitespace */ |
2246 | 18 | YY_BREAK |
2247 | 8 | case 85: |
2248 | 8 | YY_RULE_SETUP |
2249 | 8 | #line 751 "lexer.l" |
2250 | 8 | { |
2251 | | |
2252 | 8 | if (yytext[0] >= 32 && yytext[0] < 127) |
2253 | 8 | { |
2254 | 8 | return yytext[0]; |
2255 | 8 | } |
2256 | 0 | else |
2257 | 0 | { |
2258 | 0 | syntax_error("non-ascii character"); |
2259 | 0 | } |
2260 | 8 | } |
2261 | 0 | YY_BREAK |
2262 | 0 | case 86: |
2263 | 0 | YY_RULE_SETUP |
2264 | 0 | #line 763 "lexer.l" |
2265 | 0 | ECHO; |
2266 | 0 | YY_BREAK |
2267 | 0 | #line 2267 "lexer.c" |
2268 | | |
2269 | 4 | case YY_END_OF_BUFFER: |
2270 | 4 | { |
2271 | | /* Amount of text matched not including the EOB char. */ |
2272 | 4 | int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; |
2273 | | |
2274 | | /* Undo the effects of YY_DO_BEFORE_ACTION. */ |
2275 | 4 | *yy_cp = yyg->yy_hold_char; |
2276 | 4 | YY_RESTORE_YY_MORE_OFFSET |
2277 | | |
2278 | 4 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) |
2279 | 2 | { |
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 | 2 | yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; |
2290 | 2 | YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; |
2291 | 2 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; |
2292 | 2 | } |
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 | 4 | 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 | 4 | else switch ( yy_get_next_buffer( yyscanner ) ) |
2339 | 4 | { |
2340 | 2 | case EOB_ACT_END_OF_FILE: |
2341 | 2 | { |
2342 | 2 | yyg->yy_did_buffer_switch_on_eof = 0; |
2343 | | |
2344 | 2 | if ( yywrap( yyscanner ) ) |
2345 | 2 | { |
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 | 2 | yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; |
2356 | | |
2357 | 2 | yy_act = YY_STATE_EOF(YY_START); |
2358 | 2 | goto do_action; |
2359 | 2 | } |
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 | 2 | } |
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 | 2 | case EOB_ACT_LAST_MATCH: |
2380 | 2 | yyg->yy_c_buf_p = |
2381 | 2 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; |
2382 | | |
2383 | 2 | yy_current_state = yy_get_previous_state( yyscanner ); |
2384 | | |
2385 | 2 | yy_cp = yyg->yy_c_buf_p; |
2386 | 2 | yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; |
2387 | 2 | goto yy_find_action; |
2388 | 4 | } |
2389 | 0 | break; |
2390 | 4 | } |
2391 | | |
2392 | 0 | default: |
2393 | 0 | YY_FATAL_ERROR( |
2394 | 58 | "fatal flex scanner internal error--no action found" ); |
2395 | 58 | } /* end of action switch */ |
2396 | 58 | } /* end of scanning one token */ |
2397 | 28 | } /* end of user's declarations */ |
2398 | 28 | } /* 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 | 4 | { |
2409 | 4 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2410 | 4 | char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; |
2411 | 4 | char *source = yyg->yytext_ptr; |
2412 | 4 | int number_to_move, i; |
2413 | 4 | int ret_val; |
2414 | | |
2415 | 4 | if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) |
2416 | 0 | YY_FATAL_ERROR( |
2417 | 4 | "fatal flex scanner internal error--end of buffer missed" ); |
2418 | | |
2419 | 4 | if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) |
2420 | 4 | { /* Don't try to fill the buffer, so this is an EOF. */ |
2421 | 4 | if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) |
2422 | 2 | { |
2423 | | /* We matched a single character, the EOB, so |
2424 | | * treat this as a final EOF. |
2425 | | */ |
2426 | 2 | return EOB_ACT_END_OF_FILE; |
2427 | 2 | } |
2428 | | |
2429 | 2 | else |
2430 | 2 | { |
2431 | | /* We matched some text prior to the EOB, first |
2432 | | * process it. |
2433 | | */ |
2434 | 2 | return EOB_ACT_LAST_MATCH; |
2435 | 2 | } |
2436 | 4 | } |
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 | 4 | } |
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 | 2 | { |
2548 | 2 | yy_state_type yy_current_state; |
2549 | 2 | char *yy_cp; |
2550 | 2 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2551 | | |
2552 | 2 | yy_current_state = yyg->yy_start; |
2553 | | |
2554 | 4 | for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) |
2555 | 2 | { |
2556 | 2 | YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); |
2557 | 2 | if ( yy_accept[yy_current_state] ) |
2558 | 0 | { |
2559 | 0 | yyg->yy_last_accepting_state = yy_current_state; |
2560 | 0 | yyg->yy_last_accepting_cpos = yy_cp; |
2561 | 0 | } |
2562 | 2 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) |
2563 | 0 | { |
2564 | 0 | yy_current_state = (int) yy_def[yy_current_state]; |
2565 | 0 | if ( yy_current_state >= 295 ) |
2566 | 0 | yy_c = yy_meta[yy_c]; |
2567 | 0 | } |
2568 | 2 | yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; |
2569 | 2 | } |
2570 | | |
2571 | 2 | return yy_current_state; |
2572 | 2 | } |
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 | 2 | { |
2715 | 2 | 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 | 2 | yyensure_buffer_stack (yyscanner); |
2723 | 2 | if ( YY_CURRENT_BUFFER == new_buffer ) |
2724 | 0 | return; |
2725 | | |
2726 | 2 | 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 | 2 | YY_CURRENT_BUFFER_LVALUE = new_buffer; |
2735 | 2 | 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 | 2 | yyg->yy_did_buffer_switch_on_eof = 1; |
2743 | 2 | } |
2744 | | |
2745 | | static void yy_load_buffer_state (yyscan_t yyscanner) |
2746 | 4 | { |
2747 | 4 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2748 | 4 | yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; |
2749 | 4 | yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; |
2750 | 4 | yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; |
2751 | 4 | yyg->yy_hold_char = *yyg->yy_c_buf_p; |
2752 | 4 | } |
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 | 2 | { |
2790 | 2 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2791 | | |
2792 | 2 | if ( ! b ) |
2793 | 0 | return; |
2794 | | |
2795 | 2 | if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ |
2796 | 2 | YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; |
2797 | | |
2798 | 2 | if ( b->yy_is_our_buffer ) |
2799 | 2 | yyfree( (void *) b->yy_ch_buf , yyscanner ); |
2800 | | |
2801 | 2 | yyfree( (void *) b , yyscanner ); |
2802 | 2 | } |
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 | 2 | { |
2900 | 2 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2901 | 2 | if (!YY_CURRENT_BUFFER) |
2902 | 0 | return; |
2903 | | |
2904 | 2 | yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); |
2905 | 2 | YY_CURRENT_BUFFER_LVALUE = NULL; |
2906 | 2 | if (yyg->yy_buffer_stack_top > 0) |
2907 | 0 | --yyg->yy_buffer_stack_top; |
2908 | | |
2909 | 2 | if (YY_CURRENT_BUFFER) { |
2910 | 0 | yy_load_buffer_state( yyscanner ); |
2911 | 0 | yyg->yy_did_buffer_switch_on_eof = 1; |
2912 | 0 | } |
2913 | 2 | } |
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 | 2 | { |
2920 | 2 | yy_size_t num_to_alloc; |
2921 | 2 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2922 | | |
2923 | 2 | 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 | 2 | num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ |
2930 | 2 | yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc |
2931 | 2 | (num_to_alloc * sizeof(struct yy_buffer_state*) |
2932 | 2 | , yyscanner); |
2933 | 2 | if ( ! yyg->yy_buffer_stack ) |
2934 | 0 | YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); |
2935 | | |
2936 | 2 | memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); |
2937 | | |
2938 | 2 | yyg->yy_buffer_stack_max = num_to_alloc; |
2939 | 2 | yyg->yy_buffer_stack_top = 0; |
2940 | 2 | return; |
2941 | 2 | } |
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 | 2 | { |
2970 | 2 | YY_BUFFER_STATE b; |
2971 | | |
2972 | 2 | if ( size < 2 || |
2973 | 2 | base[size-2] != YY_END_OF_BUFFER_CHAR || |
2974 | 2 | base[size-1] != YY_END_OF_BUFFER_CHAR ) |
2975 | | /* They forgot to leave room for the EOB's. */ |
2976 | 0 | return NULL; |
2977 | | |
2978 | 2 | b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); |
2979 | 2 | if ( ! b ) |
2980 | 0 | YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); |
2981 | | |
2982 | 2 | b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ |
2983 | 2 | b->yy_buf_pos = b->yy_ch_buf = base; |
2984 | 2 | b->yy_is_our_buffer = 0; |
2985 | 2 | b->yy_input_file = NULL; |
2986 | 2 | b->yy_n_chars = b->yy_buf_size; |
2987 | 2 | b->yy_is_interactive = 0; |
2988 | 2 | b->yy_at_bol = 1; |
2989 | 2 | b->yy_fill_buffer = 0; |
2990 | 2 | b->yy_buffer_status = YY_BUFFER_NEW; |
2991 | | |
2992 | 2 | yy_switch_to_buffer( b , yyscanner ); |
2993 | | |
2994 | 2 | return b; |
2995 | 2 | } |
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 | 2 | { |
3007 | | |
3008 | 2 | return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); |
3009 | 2 | } |
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 | 2 | { |
3020 | 2 | YY_BUFFER_STATE b; |
3021 | 2 | char *buf; |
3022 | 2 | yy_size_t n; |
3023 | 2 | int i; |
3024 | | |
3025 | | /* Get memory for full buffer, including space for trailing EOB's. */ |
3026 | 2 | n = (yy_size_t) (_yybytes_len + 2); |
3027 | 2 | buf = (char *) yyalloc( n , yyscanner ); |
3028 | 2 | if ( ! buf ) |
3029 | 0 | YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); |
3030 | | |
3031 | 146 | for ( i = 0; i < _yybytes_len; ++i ) |
3032 | 144 | buf[i] = yybytes[i]; |
3033 | | |
3034 | 2 | buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; |
3035 | | |
3036 | 2 | b = yy_scan_buffer( buf, n , yyscanner); |
3037 | 2 | 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 | 2 | b->yy_is_our_buffer = 1; |
3044 | | |
3045 | 2 | return b; |
3046 | 2 | } |
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 | 46 | { |
3084 | 46 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
3085 | 46 | return yyextra; |
3086 | 46 | } |
3087 | | |
3088 | | /** Get the current line number. |
3089 | | * @param yyscanner The scanner object. |
3090 | | */ |
3091 | | int yyget_lineno (yyscan_t yyscanner) |
3092 | 0 | { |
3093 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
3094 | |
|
3095 | 0 | if (! YY_CURRENT_BUFFER) |
3096 | 0 | return 0; |
3097 | | |
3098 | 0 | return yylineno; |
3099 | 0 | } |
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 | 2 | { |
3157 | 2 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
3158 | 2 | yyextra = user_defined ; |
3159 | 2 | } |
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 | 2 | { |
3167 | 2 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
3168 | | |
3169 | | /* lineno is only valid if an input buffer exists. */ |
3170 | 2 | if (! YY_CURRENT_BUFFER ) |
3171 | 0 | YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); |
3172 | | |
3173 | 2 | yylineno = _line_number; |
3174 | 2 | } |
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 | 2 | { |
3243 | 2 | if (ptr_yy_globals == NULL){ |
3244 | 0 | errno = EINVAL; |
3245 | 0 | return 1; |
3246 | 0 | } |
3247 | | |
3248 | 2 | *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); |
3249 | | |
3250 | 2 | 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 | 2 | memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); |
3257 | | |
3258 | 2 | return yy_init_globals ( *ptr_yy_globals ); |
3259 | 2 | } |
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 | 4 | { |
3297 | 4 | 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 | 4 | yyg->yy_buffer_stack = NULL; |
3303 | 4 | yyg->yy_buffer_stack_top = 0; |
3304 | 4 | yyg->yy_buffer_stack_max = 0; |
3305 | 4 | yyg->yy_c_buf_p = NULL; |
3306 | 4 | yyg->yy_init = 0; |
3307 | 4 | yyg->yy_start = 0; |
3308 | | |
3309 | 4 | yyg->yy_start_stack_ptr = 0; |
3310 | 4 | yyg->yy_start_stack_depth = 0; |
3311 | 4 | yyg->yy_start_stack = NULL; |
3312 | | |
3313 | | /* Defined in main.c */ |
3314 | | #ifdef YY_STDINIT |
3315 | | yyin = stdin; |
3316 | | yyout = stdout; |
3317 | | #else |
3318 | 4 | yyin = NULL; |
3319 | 4 | yyout = NULL; |
3320 | 4 | #endif |
3321 | | |
3322 | | /* For future reference: Set errno on error, since we are called by |
3323 | | * yylex_init() |
3324 | | */ |
3325 | 4 | return 0; |
3326 | 4 | } |
3327 | | |
3328 | | /* yylex_destroy is for both reentrant and non-reentrant scanners. */ |
3329 | | int yylex_destroy (yyscan_t yyscanner) |
3330 | 2 | { |
3331 | 2 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
3332 | | |
3333 | | /* Pop the buffer stack, destroying each element. */ |
3334 | 2 | while(YY_CURRENT_BUFFER){ |
3335 | 0 | yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); |
3336 | 0 | YY_CURRENT_BUFFER_LVALUE = NULL; |
3337 | 0 | yypop_buffer_state(yyscanner); |
3338 | 0 | } |
3339 | | |
3340 | | /* Destroy the stack itself. */ |
3341 | 2 | yyfree(yyg->yy_buffer_stack , yyscanner); |
3342 | 2 | yyg->yy_buffer_stack = NULL; |
3343 | | |
3344 | | /* Destroy the start condition stack. */ |
3345 | 2 | yyfree( yyg->yy_start_stack , yyscanner ); |
3346 | 2 | 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 | 2 | yy_init_globals( yyscanner); |
3351 | | |
3352 | | /* Destroy the main struct (reentrant only). */ |
3353 | 2 | yyfree ( yyscanner , yyscanner ); |
3354 | 2 | yyscanner = NULL; |
3355 | 2 | return 0; |
3356 | 2 | } |
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 | 8 | { |
3387 | 8 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
3388 | 8 | (void)yyg; |
3389 | 8 | return malloc(size); |
3390 | 8 | } |
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 | 10 | { |
3409 | 10 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
3410 | 10 | (void)yyg; |
3411 | 10 | free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ |
3412 | 10 | } |
3413 | | |
3414 | | #define YYTABLES_NAME "yytables" |
3415 | | |
3416 | | #line 763 "lexer.l" |
3417 | | |
3418 | | |
3419 | | |
3420 | | void yywarning( |
3421 | | yyscan_t yyscanner, |
3422 | | const char *message_fmt, |
3423 | | ...) |
3424 | 0 | { |
3425 | 0 | YR_COMPILER* compiler = yyget_extra(yyscanner); |
3426 | |
|
3427 | 0 | char* file_name; |
3428 | 0 | char message[512]; |
3429 | 0 | va_list message_args; |
3430 | |
|
3431 | 0 | if (compiler->callback == NULL) |
3432 | 0 | return; |
3433 | | |
3434 | 0 | 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 | 0 | { |
3479 | 0 | char message[512] = {'\0'}; |
3480 | 0 | char* file_name = NULL; |
3481 | |
|
3482 | 0 | compiler->errors++; |
3483 | |
|
3484 | 0 | if (compiler->current_line != 0) |
3485 | 0 | compiler->last_error_line = compiler->current_line; |
3486 | 0 | else |
3487 | 0 | compiler->last_error_line = yyget_lineno(yyscanner); |
3488 | |
|
3489 | 0 | compiler->current_line = 0; |
3490 | |
|
3491 | 0 | 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 | 0 | else |
3496 | 0 | { |
3497 | 0 | file_name = NULL; |
3498 | 0 | } |
3499 | |
|
3500 | 0 | YR_RULE* current_rule = NULL; |
3501 | |
|
3502 | 0 | if (compiler->current_rule_idx != UINT32_MAX) |
3503 | 0 | current_rule = yr_arena_get_ptr( |
3504 | 0 | compiler->arena, |
3505 | 0 | YR_RULES_TABLE, |
3506 | 0 | 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 | 0 | if (error_message != NULL) |
3513 | 0 | { |
3514 | 0 | yr_compiler_set_error_extra_info(compiler, error_message); |
3515 | 0 | compiler->last_error = ERROR_SYNTAX_ERROR; |
3516 | |
|
3517 | 0 | 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 | 0 | } |
3528 | 0 | 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 | 0 | } |
3541 | | |
3542 | | |
3543 | | int yr_lex_parse_rules_string( |
3544 | | const char* rules_string, |
3545 | | YR_COMPILER* compiler) |
3546 | 2 | { |
3547 | 2 | yyscan_t yyscanner; |
3548 | | |
3549 | 2 | compiler->errors = 0; |
3550 | | |
3551 | 2 | if (yylex_init(&yyscanner) != 0) |
3552 | 0 | { |
3553 | 0 | compiler->errors = 1; |
3554 | 0 | compiler->last_error = ERROR_INSUFFICIENT_MEMORY; |
3555 | 0 | return compiler->errors; |
3556 | 0 | } |
3557 | | |
3558 | 2 | if (setjmp(compiler->error_recovery) != 0) |
3559 | 0 | return compiler->errors; |
3560 | | |
3561 | | #if YYDEBUG |
3562 | | yydebug = 1; |
3563 | | #endif |
3564 | | |
3565 | 2 | yyset_extra(compiler, yyscanner); |
3566 | 2 | yy_scan_string(rules_string, yyscanner); |
3567 | 2 | yyset_lineno(1, yyscanner); |
3568 | 2 | yyparse(yyscanner, compiler); |
3569 | 2 | yylex_destroy(yyscanner); |
3570 | | |
3571 | 2 | return compiler->errors; |
3572 | 2 | } |
3573 | | |
3574 | | |
3575 | | int yr_lex_parse_rules_file( |
3576 | | FILE* rules_file, |
3577 | | YR_COMPILER* compiler) |
3578 | 0 | { |
3579 | 0 | yyscan_t yyscanner; |
3580 | |
|
3581 | 0 | compiler->errors = 0; |
3582 | |
|
3583 | 0 | if (yylex_init(&yyscanner) != 0) |
3584 | 0 | { |
3585 | 0 | compiler->errors = 1; |
3586 | 0 | compiler->last_error = ERROR_INSUFFICIENT_MEMORY; |
3587 | 0 | return compiler->errors; |
3588 | 0 | } |
3589 | | |
3590 | 0 | if (setjmp(compiler->error_recovery) != 0) |
3591 | 0 | return compiler->errors; |
3592 | | |
3593 | | #if YYDEBUG |
3594 | | yydebug = 1; |
3595 | | #endif |
3596 | | |
3597 | 0 | yyset_in(rules_file, yyscanner); |
3598 | 0 | yyset_extra(compiler, yyscanner); |
3599 | 0 | yyparse(yyscanner, compiler); |
3600 | 0 | yylex_destroy(yyscanner); |
3601 | |
|
3602 | 0 | return compiler->errors; |
3603 | 0 | } |
3604 | | |
3605 | | |
3606 | | int yr_lex_parse_rules_fd( |
3607 | | YR_FILE_DESCRIPTOR rules_fd, |
3608 | | YR_COMPILER* compiler) |
3609 | 0 | { |
3610 | 0 | yyscan_t yyscanner; |
3611 | 0 | size_t file_size; |
3612 | 0 | void* buffer; |
3613 | |
|
3614 | | #if defined(_WIN32) || defined(__CYGWIN__) |
3615 | | DWORD bytes_read; |
3616 | | #endif |
3617 | |
|
3618 | 0 | compiler->errors = 0; |
3619 | |
|
3620 | 0 | if (setjmp(compiler->error_recovery) != 0) |
3621 | 0 | return compiler->errors; |
3622 | | |
3623 | | #if defined(_WIN32) || defined(__CYGWIN__) |
3624 | | file_size = (size_t) GetFileSize(rules_fd, NULL); |
3625 | | #else |
3626 | 0 | struct stat fs; |
3627 | 0 | if (fstat(rules_fd, &fs) != 0) |
3628 | 0 | { |
3629 | 0 | compiler->errors = 1; |
3630 | 0 | compiler->last_error = ERROR_COULD_NOT_READ_FILE; |
3631 | 0 | return compiler->errors; |
3632 | 0 | } |
3633 | 0 | file_size = (size_t) fs.st_size; |
3634 | 0 | #endif |
3635 | |
|
3636 | 0 | buffer = yr_malloc(file_size); |
3637 | |
|
3638 | 0 | if (buffer == NULL) |
3639 | 0 | { |
3640 | 0 | compiler->errors = 1; |
3641 | 0 | compiler->last_error = ERROR_INSUFFICIENT_MEMORY; |
3642 | 0 | return compiler->errors; |
3643 | 0 | } |
3644 | | |
3645 | | #if defined(_WIN32) || defined(__CYGWIN__) |
3646 | | if (!ReadFile(rules_fd, buffer, file_size, &bytes_read, NULL)) |
3647 | | #else |
3648 | 0 | if (read(rules_fd, buffer, file_size) != file_size) |
3649 | 0 | #endif |
3650 | 0 | { |
3651 | 0 | yr_free(buffer); |
3652 | 0 | compiler->errors = 1; |
3653 | 0 | compiler->last_error = ERROR_COULD_NOT_READ_FILE; |
3654 | 0 | return compiler->errors; |
3655 | 0 | } |
3656 | | |
3657 | 0 | if (yylex_init(&yyscanner) != 0) |
3658 | 0 | { |
3659 | 0 | yr_free(buffer); |
3660 | 0 | compiler->errors = 1; |
3661 | 0 | compiler->last_error = ERROR_INSUFFICIENT_MEMORY; |
3662 | 0 | return compiler->errors; |
3663 | 0 | } |
3664 | | |
3665 | | #if YYDEBUG |
3666 | | yydebug = 1; |
3667 | | #endif |
3668 | | |
3669 | 0 | yyset_extra(compiler, yyscanner); |
3670 | 0 | yy_scan_bytes((const char*) buffer, (int) file_size, yyscanner); |
3671 | 0 | yyset_lineno(1, yyscanner); |
3672 | 0 | yyparse(yyscanner, compiler); |
3673 | 0 | yylex_destroy(yyscanner); |
3674 | |
|
3675 | 0 | yr_free(buffer); |
3676 | |
|
3677 | 0 | return compiler->errors; |
3678 | 0 | } |
3679 | | |