/src/yara/libyara/hex_lexer.c
Line | Count | Source (jump to first uncovered line) |
1 | | #line 2 "hex_lexer.c" |
2 | | |
3 | | #line 4 "hex_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 hex_yy_create_buffer_ALREADY_DEFINED |
19 | | #else |
20 | 0 | #define yy_create_buffer hex_yy_create_buffer |
21 | | #endif |
22 | | |
23 | | #ifdef yy_delete_buffer |
24 | | #define hex_yy_delete_buffer_ALREADY_DEFINED |
25 | | #else |
26 | 440 | #define yy_delete_buffer hex_yy_delete_buffer |
27 | | #endif |
28 | | |
29 | | #ifdef yy_scan_buffer |
30 | | #define hex_yy_scan_buffer_ALREADY_DEFINED |
31 | | #else |
32 | 440 | #define yy_scan_buffer hex_yy_scan_buffer |
33 | | #endif |
34 | | |
35 | | #ifdef yy_scan_string |
36 | | #define hex_yy_scan_string_ALREADY_DEFINED |
37 | | #else |
38 | 440 | #define yy_scan_string hex_yy_scan_string |
39 | | #endif |
40 | | |
41 | | #ifdef yy_scan_bytes |
42 | | #define hex_yy_scan_bytes_ALREADY_DEFINED |
43 | | #else |
44 | 440 | #define yy_scan_bytes hex_yy_scan_bytes |
45 | | #endif |
46 | | |
47 | | #ifdef yy_init_buffer |
48 | | #define hex_yy_init_buffer_ALREADY_DEFINED |
49 | | #else |
50 | 0 | #define yy_init_buffer hex_yy_init_buffer |
51 | | #endif |
52 | | |
53 | | #ifdef yy_flush_buffer |
54 | | #define hex_yy_flush_buffer_ALREADY_DEFINED |
55 | | #else |
56 | 0 | #define yy_flush_buffer hex_yy_flush_buffer |
57 | | #endif |
58 | | |
59 | | #ifdef yy_load_buffer_state |
60 | | #define hex_yy_load_buffer_state_ALREADY_DEFINED |
61 | | #else |
62 | 880 | #define yy_load_buffer_state hex_yy_load_buffer_state |
63 | | #endif |
64 | | |
65 | | #ifdef yy_switch_to_buffer |
66 | | #define hex_yy_switch_to_buffer_ALREADY_DEFINED |
67 | | #else |
68 | 440 | #define yy_switch_to_buffer hex_yy_switch_to_buffer |
69 | | #endif |
70 | | |
71 | | #ifdef yypush_buffer_state |
72 | | #define hex_yypush_buffer_state_ALREADY_DEFINED |
73 | | #else |
74 | | #define yypush_buffer_state hex_yypush_buffer_state |
75 | | #endif |
76 | | |
77 | | #ifdef yypop_buffer_state |
78 | | #define hex_yypop_buffer_state_ALREADY_DEFINED |
79 | | #else |
80 | 440 | #define yypop_buffer_state hex_yypop_buffer_state |
81 | | #endif |
82 | | |
83 | | #ifdef yyensure_buffer_stack |
84 | | #define hex_yyensure_buffer_stack_ALREADY_DEFINED |
85 | | #else |
86 | 440 | #define yyensure_buffer_stack hex_yyensure_buffer_stack |
87 | | #endif |
88 | | |
89 | | #ifdef yylex |
90 | | #define hex_yylex_ALREADY_DEFINED |
91 | | #else |
92 | | #define yylex hex_yylex |
93 | | #endif |
94 | | |
95 | | #ifdef yyrestart |
96 | | #define hex_yyrestart_ALREADY_DEFINED |
97 | | #else |
98 | 0 | #define yyrestart hex_yyrestart |
99 | | #endif |
100 | | |
101 | | #ifdef yylex_init |
102 | | #define hex_yylex_init_ALREADY_DEFINED |
103 | | #else |
104 | 440 | #define yylex_init hex_yylex_init |
105 | | #endif |
106 | | |
107 | | #ifdef yylex_init_extra |
108 | | #define hex_yylex_init_extra_ALREADY_DEFINED |
109 | | #else |
110 | | #define yylex_init_extra hex_yylex_init_extra |
111 | | #endif |
112 | | |
113 | | #ifdef yylex_destroy |
114 | | #define hex_yylex_destroy_ALREADY_DEFINED |
115 | | #else |
116 | 440 | #define yylex_destroy hex_yylex_destroy |
117 | | #endif |
118 | | |
119 | | #ifdef yyget_debug |
120 | | #define hex_yyget_debug_ALREADY_DEFINED |
121 | | #else |
122 | | #define yyget_debug hex_yyget_debug |
123 | | #endif |
124 | | |
125 | | #ifdef yyset_debug |
126 | | #define hex_yyset_debug_ALREADY_DEFINED |
127 | | #else |
128 | | #define yyset_debug hex_yyset_debug |
129 | | #endif |
130 | | |
131 | | #ifdef yyget_extra |
132 | | #define hex_yyget_extra_ALREADY_DEFINED |
133 | | #else |
134 | | #define yyget_extra hex_yyget_extra |
135 | | #endif |
136 | | |
137 | | #ifdef yyset_extra |
138 | | #define hex_yyset_extra_ALREADY_DEFINED |
139 | | #else |
140 | 440 | #define yyset_extra hex_yyset_extra |
141 | | #endif |
142 | | |
143 | | #ifdef yyget_in |
144 | | #define hex_yyget_in_ALREADY_DEFINED |
145 | | #else |
146 | | #define yyget_in hex_yyget_in |
147 | | #endif |
148 | | |
149 | | #ifdef yyset_in |
150 | | #define hex_yyset_in_ALREADY_DEFINED |
151 | | #else |
152 | | #define yyset_in hex_yyset_in |
153 | | #endif |
154 | | |
155 | | #ifdef yyget_out |
156 | | #define hex_yyget_out_ALREADY_DEFINED |
157 | | #else |
158 | | #define yyget_out hex_yyget_out |
159 | | #endif |
160 | | |
161 | | #ifdef yyset_out |
162 | | #define hex_yyset_out_ALREADY_DEFINED |
163 | | #else |
164 | | #define yyset_out hex_yyset_out |
165 | | #endif |
166 | | |
167 | | #ifdef yyget_leng |
168 | | #define hex_yyget_leng_ALREADY_DEFINED |
169 | | #else |
170 | | #define yyget_leng hex_yyget_leng |
171 | | #endif |
172 | | |
173 | | #ifdef yyget_text |
174 | | #define hex_yyget_text_ALREADY_DEFINED |
175 | | #else |
176 | | #define yyget_text hex_yyget_text |
177 | | #endif |
178 | | |
179 | | #ifdef yyget_lineno |
180 | | #define hex_yyget_lineno_ALREADY_DEFINED |
181 | | #else |
182 | | #define yyget_lineno hex_yyget_lineno |
183 | | #endif |
184 | | |
185 | | #ifdef yyset_lineno |
186 | | #define hex_yyset_lineno_ALREADY_DEFINED |
187 | | #else |
188 | | #define yyset_lineno hex_yyset_lineno |
189 | | #endif |
190 | | |
191 | | #ifdef yyget_column |
192 | | #define hex_yyget_column_ALREADY_DEFINED |
193 | | #else |
194 | | #define yyget_column hex_yyget_column |
195 | | #endif |
196 | | |
197 | | #ifdef yyset_column |
198 | | #define hex_yyset_column_ALREADY_DEFINED |
199 | | #else |
200 | | #define yyset_column hex_yyset_column |
201 | | #endif |
202 | | |
203 | | #ifdef yywrap |
204 | | #define hex_yywrap_ALREADY_DEFINED |
205 | | #else |
206 | 168 | #define yywrap hex_yywrap |
207 | | #endif |
208 | | |
209 | | #ifdef yyget_lval |
210 | | #define hex_yyget_lval_ALREADY_DEFINED |
211 | | #else |
212 | | #define yyget_lval hex_yyget_lval |
213 | | #endif |
214 | | |
215 | | #ifdef yyset_lval |
216 | | #define hex_yyset_lval_ALREADY_DEFINED |
217 | | #else |
218 | | #define yyset_lval hex_yyset_lval |
219 | | #endif |
220 | | |
221 | | #ifdef yyalloc |
222 | | #define hex_yyalloc_ALREADY_DEFINED |
223 | | #else |
224 | 1.76k | #define yyalloc hex_yyalloc |
225 | | #endif |
226 | | |
227 | | #ifdef yyrealloc |
228 | | #define hex_yyrealloc_ALREADY_DEFINED |
229 | | #else |
230 | 0 | #define yyrealloc hex_yyrealloc |
231 | | #endif |
232 | | |
233 | | #ifdef yyfree |
234 | | #define hex_yyfree_ALREADY_DEFINED |
235 | | #else |
236 | 2.20k | #define yyfree hex_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 | 232 | #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 | 914k | #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 | 2.95k | #define yyin yyg->yyin_r |
345 | 1.76k | #define yyout yyg->yyout_r |
346 | 943 | #define yyextra yyg->yyextra_r |
347 | 1.01M | #define yyleng yyg->yyleng_r |
348 | 434k | #define yytext yyg->yytext_r |
349 | 23.8k | #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) |
350 | 23.8k | #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 | 3.41k | #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 | 672 | #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 | 1.76k | #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 | 336 | #define EOB_ACT_END_OF_FILE 1 |
399 | 634 | #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 | 925 | #define YY_BUFFER_NEW 0 |
487 | 317 | #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 | 3.52k | #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ |
510 | 3.52k | ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ |
511 | 3.52k | : 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 | 55.4k | #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 | 168 | #define hex_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 | 437k | #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 | 434k | yyg->yytext_ptr = yy_bp; \ |
579 | 434k | yyleng = (int) (yy_cp - yy_bp); \ |
580 | 434k | yyg->yy_hold_char = *yy_cp; \ |
581 | 434k | *yy_cp = '\0'; \ |
582 | 434k | yyg->yy_c_buf_p = yy_cp; |
583 | | #define YY_NUM_RULES 23 |
584 | 869k | #define YY_END_OF_BUFFER 24 |
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[40] = |
593 | | { 0, |
594 | | 0, 0, 0, 0, 0, 0, 24, 22, 20, 20, |
595 | | 21, 22, 8, 22, 10, 9, 13, 13, 19, 18, |
596 | | 18, 15, 16, 17, 11, 14, 1, 2, 4, 5, |
597 | | 0, 0, 12, 16, 14, 3, 6, 7, 0 |
598 | | } ; |
599 | | |
600 | | static const YY_CHAR yy_ec[256] = |
601 | | { 0, |
602 | | 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, |
603 | | 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, |
604 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
605 | | 1, 2, 1, 1, 1, 1, 1, 1, 1, 4, |
606 | | 4, 5, 1, 1, 6, 1, 7, 8, 8, 8, |
607 | | 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, |
608 | | 1, 1, 9, 1, 10, 10, 10, 10, 10, 10, |
609 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
610 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
611 | | 11, 1, 12, 1, 1, 1, 10, 10, 10, 10, |
612 | | |
613 | | 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, |
614 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
615 | | 1, 1, 4, 4, 4, 13, 1, 1, 1, 1, |
616 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
617 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
618 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
619 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
620 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
621 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
622 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
623 | | |
624 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
625 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
626 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
627 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
628 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
629 | | 1, 1, 1, 1, 1 |
630 | | } ; |
631 | | |
632 | | static const YY_CHAR yy_meta[14] = |
633 | | { 0, |
634 | | 1, 1, 2, 1, 1, 1, 1, 3, 4, 3, |
635 | | 1, 1, 1 |
636 | | } ; |
637 | | |
638 | | static const flex_int16_t yy_base[48] = |
639 | | { 0, |
640 | | 0, 0, 28, 27, 12, 23, 30, 59, 59, 59, |
641 | | 59, 31, 19, 18, 59, 14, 59, 15, 59, 59, |
642 | | 59, 59, 13, 59, 59, 0, 59, 59, 59, 59, |
643 | | 10, 0, 59, 9, 0, 59, 59, 59, 59, 38, |
644 | | 42, 44, 46, 48, 52, 54, 13 |
645 | | } ; |
646 | | |
647 | | static const flex_int16_t yy_def[48] = |
648 | | { 0, |
649 | | 39, 1, 40, 40, 41, 41, 39, 39, 39, 39, |
650 | | 39, 39, 42, 43, 39, 44, 39, 39, 39, 39, |
651 | | 39, 39, 39, 39, 39, 45, 39, 39, 39, 39, |
652 | | 46, 47, 39, 39, 45, 39, 39, 39, 0, 39, |
653 | | 39, 39, 39, 39, 39, 39, 39 |
654 | | } ; |
655 | | |
656 | | static const flex_int16_t yy_nxt[73] = |
657 | | { 0, |
658 | | 8, 9, 10, 11, 8, 8, 12, 13, 14, 13, |
659 | | 15, 8, 16, 20, 21, 38, 34, 22, 37, 23, |
660 | | 34, 33, 32, 24, 20, 21, 30, 28, 22, 39, |
661 | | 23, 18, 18, 39, 24, 25, 39, 26, 17, 17, |
662 | | 17, 17, 19, 19, 19, 19, 27, 27, 29, 29, |
663 | | 31, 31, 35, 39, 35, 35, 36, 36, 7, 39, |
664 | | 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, |
665 | | 39, 39 |
666 | | } ; |
667 | | |
668 | | static const flex_int16_t yy_chk[73] = |
669 | | { 0, |
670 | | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
671 | | 1, 1, 1, 5, 5, 47, 34, 5, 31, 5, |
672 | | 23, 18, 16, 5, 6, 6, 14, 13, 6, 7, |
673 | | 6, 4, 3, 0, 6, 12, 0, 12, 40, 40, |
674 | | 40, 40, 41, 41, 41, 41, 42, 42, 43, 43, |
675 | | 44, 44, 45, 0, 45, 45, 46, 46, 39, 39, |
676 | | 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, |
677 | | 39, 39 |
678 | | } ; |
679 | | |
680 | | /* Table of booleans, true if rule could match eol. */ |
681 | | static const flex_int32_t yy_rule_can_match_eol[24] = |
682 | | { 0, |
683 | | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, |
684 | | 1, 0, 0, 0, }; |
685 | | |
686 | | /* The intent behind this definition is that it'll catch |
687 | | * any uses of REJECT which flex missed. |
688 | | */ |
689 | | #define REJECT reject_used_but_not_detected |
690 | | #define yymore() yymore_used_but_not_detected |
691 | 1.28k | #define YY_MORE_ADJ 0 |
692 | | #define YY_RESTORE_YY_MORE_OFFSET |
693 | | #line 1 "hex_lexer.l" |
694 | | /* |
695 | | Copyright (c) 2013. The YARA Authors. All Rights Reserved. |
696 | | |
697 | | Redistribution and use in source and binary forms, with or without modification, |
698 | | are permitted provided that the following conditions are met: |
699 | | |
700 | | 1. Redistributions of source code must retain the above copyright notice, this |
701 | | list of conditions and the following disclaimer. |
702 | | |
703 | | 2. Redistributions in binary form must reproduce the above copyright notice, |
704 | | this list of conditions and the following disclaimer in the documentation and/or |
705 | | other materials provided with the distribution. |
706 | | |
707 | | 3. Neither the name of the copyright holder nor the names of its contributors |
708 | | may be used to endorse or promote products derived from this software without |
709 | | specific prior written permission. |
710 | | |
711 | | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
712 | | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
713 | | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
714 | | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
715 | | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
716 | | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
717 | | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
718 | | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
719 | | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
720 | | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
721 | | */ |
722 | | /* Lexical analyzer for hex strings */ |
723 | | #line 33 "hex_lexer.l" |
724 | | |
725 | | /* Disable warnings for unused functions in this file. |
726 | | |
727 | | As we redefine YY_FATAL_ERROR macro to use our own function hex_yyfatal, the |
728 | | yy_fatal_error function generated by Flex is not actually used, causing a |
729 | | compiler warning. Flex doesn't offer any options to remove the yy_fatal_error |
730 | | function. When they include something like %option noyy_fatal_error as they do |
731 | | with noyywrap then we can remove this pragma. |
732 | | */ |
733 | | |
734 | | #ifdef __GNUC__ |
735 | | #pragma GCC diagnostic ignored "-Wunused-function" |
736 | | #endif |
737 | | |
738 | | #include <setjmp.h> |
739 | | |
740 | | #include <yara/globals.h> |
741 | | #include <yara/limits.h> |
742 | | #include <yara/error.h> |
743 | | #include <yara/mem.h> |
744 | | #include <yara/re.h> |
745 | | #include <yara/threading.h> |
746 | | #include <yara/strutils.h> |
747 | | #include <yara/hex_lexer.h> |
748 | | |
749 | | #include "hex_grammar.h" |
750 | | |
751 | | #ifdef _WIN32 |
752 | | #define snprintf _snprintf |
753 | | #endif |
754 | | |
755 | | #define ERROR_IF(x, error) \ |
756 | | if (x) \ |
757 | | { \ |
758 | | RE_AST* re_ast = yyget_extra(yyscanner); \ |
759 | | re_ast->error_code = error; \ |
760 | | YYABORT; \ |
761 | | } \ |
762 | | |
763 | | #line 764 "hex_lexer.c" |
764 | | #define YY_NO_UNISTD_H 1 |
765 | | #define YY_NO_INPUT 1 |
766 | | |
767 | | #line 768 "hex_lexer.c" |
768 | | |
769 | 1.70k | #define INITIAL 0 |
770 | 470 | #define comment 1 |
771 | 1.23k | #define range 2 |
772 | | |
773 | | #ifndef YY_NO_UNISTD_H |
774 | | /* Special case for "unistd.h", since it is non-ANSI. We include it way |
775 | | * down here because we want the user's section 1 to have been scanned first. |
776 | | * The user has a chance to override it with an option. |
777 | | */ |
778 | | #include <unistd.h> |
779 | | #endif |
780 | | |
781 | | #ifndef YY_EXTRA_TYPE |
782 | | #define YY_EXTRA_TYPE void * |
783 | | #endif |
784 | | |
785 | | /* Holds the entire state of the reentrant scanner. */ |
786 | | struct yyguts_t |
787 | | { |
788 | | |
789 | | /* User-defined. Not touched by flex. */ |
790 | | YY_EXTRA_TYPE yyextra_r; |
791 | | |
792 | | /* The rest are the same as the globals declared in the non-reentrant scanner. */ |
793 | | FILE *yyin_r, *yyout_r; |
794 | | size_t yy_buffer_stack_top; /**< index of top of stack. */ |
795 | | size_t yy_buffer_stack_max; /**< capacity of stack. */ |
796 | | YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ |
797 | | char yy_hold_char; |
798 | | int yy_n_chars; |
799 | | int yyleng_r; |
800 | | char *yy_c_buf_p; |
801 | | int yy_init; |
802 | | int yy_start; |
803 | | int yy_did_buffer_switch_on_eof; |
804 | | int yy_start_stack_ptr; |
805 | | int yy_start_stack_depth; |
806 | | int *yy_start_stack; |
807 | | yy_state_type yy_last_accepting_state; |
808 | | char* yy_last_accepting_cpos; |
809 | | |
810 | | int yylineno_r; |
811 | | int yy_flex_debug_r; |
812 | | |
813 | | char *yytext_r; |
814 | | int yy_more_flag; |
815 | | int yy_more_len; |
816 | | |
817 | | YYSTYPE * yylval_r; |
818 | | |
819 | | }; /* end struct yyguts_t */ |
820 | | |
821 | | static int yy_init_globals ( yyscan_t yyscanner ); |
822 | | |
823 | | /* This must go here because YYSTYPE and YYLTYPE are included |
824 | | * from bison output in section 1.*/ |
825 | 180k | # define yylval yyg->yylval_r |
826 | | |
827 | | int yylex_init (yyscan_t* scanner); |
828 | | |
829 | | int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); |
830 | | |
831 | | /* Accessor methods to globals. |
832 | | These are made visible to non-reentrant scanners for convenience. */ |
833 | | |
834 | | int yylex_destroy ( yyscan_t yyscanner ); |
835 | | |
836 | | int yyget_debug ( yyscan_t yyscanner ); |
837 | | |
838 | | void yyset_debug ( int debug_flag , yyscan_t yyscanner ); |
839 | | |
840 | | YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); |
841 | | |
842 | | void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); |
843 | | |
844 | | FILE *yyget_in ( yyscan_t yyscanner ); |
845 | | |
846 | | void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); |
847 | | |
848 | | FILE *yyget_out ( yyscan_t yyscanner ); |
849 | | |
850 | | void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); |
851 | | |
852 | | int yyget_leng ( yyscan_t yyscanner ); |
853 | | |
854 | | char *yyget_text ( yyscan_t yyscanner ); |
855 | | |
856 | | int yyget_lineno ( yyscan_t yyscanner ); |
857 | | |
858 | | void yyset_lineno ( int _line_number , yyscan_t yyscanner ); |
859 | | |
860 | | int yyget_column ( yyscan_t yyscanner ); |
861 | | |
862 | | void yyset_column ( int _column_no , yyscan_t yyscanner ); |
863 | | |
864 | | YYSTYPE * yyget_lval ( yyscan_t yyscanner ); |
865 | | |
866 | | void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); |
867 | | |
868 | | /* Macros after this point can all be overridden by user definitions in |
869 | | * section 1. |
870 | | */ |
871 | | |
872 | | #ifndef YY_SKIP_YYWRAP |
873 | | #ifdef __cplusplus |
874 | | extern "C" int yywrap ( yyscan_t yyscanner ); |
875 | | #else |
876 | | extern int yywrap ( yyscan_t yyscanner ); |
877 | | #endif |
878 | | #endif |
879 | | |
880 | | #ifndef YY_NO_UNPUT |
881 | | |
882 | | #endif |
883 | | |
884 | | #ifndef yytext_ptr |
885 | | static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); |
886 | | #endif |
887 | | |
888 | | #ifdef YY_NEED_STRLEN |
889 | | static int yy_flex_strlen ( const char * , yyscan_t yyscanner); |
890 | | #endif |
891 | | |
892 | | #ifndef YY_NO_INPUT |
893 | | #ifdef __cplusplus |
894 | | static int yyinput ( yyscan_t yyscanner ); |
895 | | #else |
896 | | static int input ( yyscan_t yyscanner ); |
897 | | #endif |
898 | | |
899 | | #endif |
900 | | |
901 | | /* Amount of stuff to slurp up with each read. */ |
902 | | #ifndef YY_READ_BUF_SIZE |
903 | | #ifdef __ia64__ |
904 | | /* On IA-64, the buffer size is 16k, not 8k */ |
905 | | #define YY_READ_BUF_SIZE 16384 |
906 | | #else |
907 | 0 | #define YY_READ_BUF_SIZE 8192 |
908 | | #endif /* __ia64__ */ |
909 | | #endif |
910 | | |
911 | | /* Copy whatever the last rule matched to the standard output. */ |
912 | | #ifndef ECHO |
913 | | /* This used to be an fputs(), but since the string might contain NUL's, |
914 | | * we now use fwrite(). |
915 | | */ |
916 | 0 | #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) |
917 | | #endif |
918 | | |
919 | | /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, |
920 | | * is returned in "result". |
921 | | */ |
922 | | #ifndef YY_INPUT |
923 | | #define YY_INPUT(buf,result,max_size) \ |
924 | 0 | if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ |
925 | 0 | { \ |
926 | 0 | int c = '*'; \ |
927 | 0 | int n; \ |
928 | 0 | for ( n = 0; n < max_size && \ |
929 | 0 | (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ |
930 | 0 | buf[n] = (char) c; \ |
931 | 0 | if ( c == '\n' ) \ |
932 | 0 | buf[n++] = (char) c; \ |
933 | 0 | if ( c == EOF && ferror( yyin ) ) \ |
934 | 0 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ |
935 | 0 | result = n; \ |
936 | 0 | } \ |
937 | 0 | else \ |
938 | 0 | { \ |
939 | 0 | errno=0; \ |
940 | 0 | while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ |
941 | 0 | { \ |
942 | 0 | if( errno != EINTR) \ |
943 | 0 | { \ |
944 | 0 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ |
945 | 0 | break; \ |
946 | 0 | } \ |
947 | 0 | errno=0; \ |
948 | 0 | clearerr(yyin); \ |
949 | 0 | } \ |
950 | 0 | }\ |
951 | | \ |
952 | | |
953 | | #endif |
954 | | |
955 | | /* No semi-colon after return; correct usage is to write "yyterminate();" - |
956 | | * we don't want an extra ';' after the "return" because that will cause |
957 | | * some compilers to complain about unreachable statements. |
958 | | */ |
959 | | #ifndef yyterminate |
960 | 232 | #define yyterminate() return YY_NULL |
961 | | #endif |
962 | | |
963 | | /* Number of entries by which start-condition stack grows. */ |
964 | | #ifndef YY_START_STACK_INCR |
965 | | #define YY_START_STACK_INCR 25 |
966 | | #endif |
967 | | |
968 | | /* Report a fatal error. */ |
969 | | #ifndef YY_FATAL_ERROR |
970 | | #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) |
971 | | #endif |
972 | | |
973 | | /* end tables serialization structures and prototypes */ |
974 | | |
975 | | /* Default declaration of generated scanner - a define so the user can |
976 | | * easily add parameters. |
977 | | */ |
978 | | #ifndef YY_DECL |
979 | | #define YY_DECL_IS_OURS 1 |
980 | | |
981 | | extern int yylex \ |
982 | | (YYSTYPE * yylval_param , yyscan_t yyscanner); |
983 | | |
984 | | #define YY_DECL int yylex \ |
985 | | (YYSTYPE * yylval_param , yyscan_t yyscanner) |
986 | | #endif /* !YY_DECL */ |
987 | | |
988 | | /* Code executed at the beginning of each rule, after yytext and yyleng |
989 | | * have been set up. |
990 | | */ |
991 | | #ifndef YY_USER_ACTION |
992 | | #define YY_USER_ACTION |
993 | | #endif |
994 | | |
995 | | /* Code executed at the end of each rule. */ |
996 | | #ifndef YY_BREAK |
997 | 293k | #define YY_BREAK /*LINTED*/break; |
998 | | #endif |
999 | | |
1000 | | #define YY_RULE_SETUP \ |
1001 | | YY_USER_ACTION |
1002 | | |
1003 | | /** The main scanner function which does all the work. |
1004 | | */ |
1005 | | YY_DECL |
1006 | 140k | { |
1007 | 140k | yy_state_type yy_current_state; |
1008 | 140k | char *yy_cp, *yy_bp; |
1009 | 140k | int yy_act; |
1010 | 140k | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
1011 | | |
1012 | 140k | yylval = yylval_param; |
1013 | | |
1014 | 140k | if ( !yyg->yy_init ) |
1015 | 440 | { |
1016 | 440 | yyg->yy_init = 1; |
1017 | | |
1018 | | #ifdef YY_USER_INIT |
1019 | | YY_USER_INIT; |
1020 | | #endif |
1021 | | |
1022 | 440 | if ( ! yyg->yy_start ) |
1023 | 440 | yyg->yy_start = 1; /* first start state */ |
1024 | | |
1025 | 440 | if ( ! yyin ) |
1026 | 440 | yyin = stdin; |
1027 | | |
1028 | 440 | if ( ! yyout ) |
1029 | 440 | yyout = stdout; |
1030 | | |
1031 | 440 | if ( ! YY_CURRENT_BUFFER ) { |
1032 | 0 | yyensure_buffer_stack (yyscanner); |
1033 | 0 | YY_CURRENT_BUFFER_LVALUE = |
1034 | 0 | yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); |
1035 | 0 | } |
1036 | | |
1037 | 440 | yy_load_buffer_state( yyscanner ); |
1038 | 440 | } |
1039 | | |
1040 | 140k | { |
1041 | 140k | #line 95 "hex_lexer.l" |
1042 | | |
1043 | | |
1044 | | |
1045 | 140k | #line 1046 "hex_lexer.c" |
1046 | | |
1047 | 433k | while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ |
1048 | 433k | { |
1049 | 433k | yy_cp = yyg->yy_c_buf_p; |
1050 | | |
1051 | | /* Support of yytext. */ |
1052 | 433k | *yy_cp = yyg->yy_hold_char; |
1053 | | |
1054 | | /* yy_bp points to the position in yy_ch_buf of the start of |
1055 | | * the current run. |
1056 | | */ |
1057 | 433k | yy_bp = yy_cp; |
1058 | | |
1059 | 433k | yy_current_state = yyg->yy_start; |
1060 | 433k | yy_match: |
1061 | 433k | do |
1062 | 913k | { |
1063 | 913k | YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; |
1064 | 913k | if ( yy_accept[yy_current_state] ) |
1065 | 478k | { |
1066 | 478k | yyg->yy_last_accepting_state = yy_current_state; |
1067 | 478k | yyg->yy_last_accepting_cpos = yy_cp; |
1068 | 478k | } |
1069 | 1.68M | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) |
1070 | 767k | { |
1071 | 767k | yy_current_state = (int) yy_def[yy_current_state]; |
1072 | 767k | if ( yy_current_state >= 40 ) |
1073 | 333k | yy_c = yy_meta[yy_c]; |
1074 | 767k | } |
1075 | 913k | yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; |
1076 | 913k | ++yy_cp; |
1077 | 913k | } |
1078 | 913k | while ( yy_current_state != 39 ); |
1079 | 433k | yy_cp = yyg->yy_last_accepting_cpos; |
1080 | 433k | yy_current_state = yyg->yy_last_accepting_state; |
1081 | | |
1082 | 434k | yy_find_action: |
1083 | 434k | yy_act = yy_accept[yy_current_state]; |
1084 | | |
1085 | 434k | YY_DO_BEFORE_ACTION; |
1086 | | |
1087 | 434k | if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) |
1088 | 292k | { |
1089 | 292k | int yyl; |
1090 | 584k | for ( yyl = 0; yyl < yyleng; ++yyl ) |
1091 | 292k | if ( yytext[yyl] == '\n' ) |
1092 | | |
1093 | 23.8k | do{ yylineno++; |
1094 | 23.8k | yycolumn=0; |
1095 | 23.8k | }while(0) |
1096 | 292k | ; |
1097 | 292k | } |
1098 | | |
1099 | 434k | do_action: /* This label is used only to access EOF actions. */ |
1100 | | |
1101 | 434k | switch ( yy_act ) |
1102 | 434k | { /* beginning of action switch */ |
1103 | 0 | case 0: /* must back up */ |
1104 | | /* undo the effects of YY_DO_BEFORE_ACTION */ |
1105 | 0 | *yy_cp = yyg->yy_hold_char; |
1106 | 0 | yy_cp = yyg->yy_last_accepting_cpos; |
1107 | 0 | yy_current_state = yyg->yy_last_accepting_state; |
1108 | 0 | goto yy_find_action; |
1109 | | |
1110 | 35.7k | case 1: |
1111 | 35.7k | YY_RULE_SETUP |
1112 | 35.7k | #line 98 "hex_lexer.l" |
1113 | 35.7k | { |
1114 | | |
1115 | 35.7k | yylval->integer = xtoi(yytext); |
1116 | 35.7k | return _BYTE_; |
1117 | 0 | } |
1118 | 0 | YY_BREAK |
1119 | 661 | case 2: |
1120 | 661 | YY_RULE_SETUP |
1121 | 661 | #line 104 "hex_lexer.l" |
1122 | 661 | { |
1123 | | |
1124 | 661 | yytext[1] = '0'; // replace ? by 0 |
1125 | 661 | yylval->integer = xtoi(yytext) | 0xF000 ; |
1126 | 661 | return _MASKED_BYTE_; |
1127 | 0 | } |
1128 | 0 | YY_BREAK |
1129 | 147 | case 3: |
1130 | 147 | YY_RULE_SETUP |
1131 | 147 | #line 111 "hex_lexer.l" |
1132 | 147 | { |
1133 | | |
1134 | 147 | yylval->integer = xtoi(&(yytext[1])); |
1135 | 147 | return _NOT_BYTE_; |
1136 | 0 | } |
1137 | 0 | YY_BREAK |
1138 | 1.34k | case 4: |
1139 | 1.34k | YY_RULE_SETUP |
1140 | 1.34k | #line 117 "hex_lexer.l" |
1141 | 1.34k | { |
1142 | | |
1143 | 1.34k | yytext[0] = '0'; // replace ? by 0 |
1144 | 1.34k | yylval->integer = xtoi(yytext) | 0x0F00 ; |
1145 | 1.34k | return _MASKED_BYTE_; |
1146 | 0 | } |
1147 | 0 | YY_BREAK |
1148 | 542 | case 5: |
1149 | 542 | YY_RULE_SETUP |
1150 | 542 | #line 124 "hex_lexer.l" |
1151 | 542 | { |
1152 | | |
1153 | 542 | yylval->integer = 0x0000; |
1154 | 542 | return _MASKED_BYTE_; |
1155 | 0 | } |
1156 | 0 | YY_BREAK |
1157 | 233 | case 6: |
1158 | 233 | YY_RULE_SETUP |
1159 | 233 | #line 130 "hex_lexer.l" |
1160 | 233 | { |
1161 | | |
1162 | 233 | yytext[2] = '0'; // replace ? by 0 |
1163 | 233 | yylval->integer = xtoi(&(yytext[1])) | 0xF000 ; |
1164 | 233 | return _MASKED_NOT_BYTE_; |
1165 | 0 | } |
1166 | 0 | YY_BREAK |
1167 | 488 | case 7: |
1168 | 488 | YY_RULE_SETUP |
1169 | 488 | #line 137 "hex_lexer.l" |
1170 | 488 | { |
1171 | | |
1172 | 488 | yytext[1] = '0'; // replace ? by 0 |
1173 | 488 | yylval->integer = xtoi(&(yytext[1])) | 0x0F00 ; |
1174 | 488 | return _MASKED_NOT_BYTE_; |
1175 | 0 | } |
1176 | 0 | YY_BREAK |
1177 | 44 | case 8: |
1178 | 44 | YY_RULE_SETUP |
1179 | 44 | #line 144 "hex_lexer.l" |
1180 | 44 | { |
1181 | | |
1182 | 44 | yyerror(yyscanner, lex_env, "uneven number of digits in hex string"); |
1183 | 44 | yyterminate(); |
1184 | 0 | } |
1185 | 0 | YY_BREAK |
1186 | 9 | case 9: |
1187 | 9 | YY_RULE_SETUP |
1188 | 9 | #line 150 "hex_lexer.l" |
1189 | 9 | { |
1190 | | |
1191 | 9 | yyerror(yyscanner, lex_env, "invalid not operator (~) in hex string"); |
1192 | 9 | yyterminate(); |
1193 | 0 | } |
1194 | 0 | YY_BREAK |
1195 | 1.23k | case 10: |
1196 | 1.23k | YY_RULE_SETUP |
1197 | 1.23k | #line 157 "hex_lexer.l" |
1198 | 1.23k | { |
1199 | | |
1200 | 1.23k | BEGIN(range); |
1201 | 1.23k | return yytext[0]; |
1202 | 0 | } |
1203 | 0 | YY_BREAK |
1204 | 470 | case 11: |
1205 | 470 | YY_RULE_SETUP |
1206 | 470 | #line 163 "hex_lexer.l" |
1207 | 470 | { |
1208 | | |
1209 | 470 | BEGIN(comment); |
1210 | 470 | } |
1211 | 470 | YY_BREAK |
1212 | 470 | case 12: |
1213 | 470 | YY_RULE_SETUP |
1214 | 470 | #line 168 "hex_lexer.l" |
1215 | 470 | { |
1216 | | |
1217 | 470 | BEGIN(INITIAL); |
1218 | 470 | } |
1219 | 470 | YY_BREAK |
1220 | 291k | case 13: |
1221 | | /* rule 13 can match eol */ |
1222 | 291k | YY_RULE_SETUP |
1223 | 291k | #line 173 "hex_lexer.l" |
1224 | | // skip comments |
1225 | 291k | YY_BREAK |
1226 | 143 | case 14: |
1227 | 143 | YY_RULE_SETUP |
1228 | 143 | #line 175 "hex_lexer.l" |
1229 | | // skip single-line comments |
1230 | 143 | YY_BREAK |
1231 | 627 | case 15: |
1232 | 627 | YY_RULE_SETUP |
1233 | 627 | #line 177 "hex_lexer.l" |
1234 | 627 | { |
1235 | | |
1236 | 627 | return yytext[0]; |
1237 | 0 | } |
1238 | 0 | YY_BREAK |
1239 | 1.08k | case 16: |
1240 | 1.08k | YY_RULE_SETUP |
1241 | 1.08k | #line 182 "hex_lexer.l" |
1242 | 1.08k | { |
1243 | | |
1244 | 1.08k | yylval->integer = atoi(yytext); |
1245 | 1.08k | return _NUMBER_; |
1246 | 0 | } |
1247 | 0 | YY_BREAK |
1248 | 1.23k | case 17: |
1249 | 1.23k | YY_RULE_SETUP |
1250 | 1.23k | #line 188 "hex_lexer.l" |
1251 | 1.23k | { |
1252 | | |
1253 | 1.23k | BEGIN(INITIAL); |
1254 | 1.23k | return yytext[0]; |
1255 | 0 | } |
1256 | 0 | YY_BREAK |
1257 | 181 | case 18: |
1258 | | /* rule 18 can match eol */ |
1259 | 181 | YY_RULE_SETUP |
1260 | 181 | #line 194 "hex_lexer.l" |
1261 | | // skip whitespaces |
1262 | 181 | YY_BREAK |
1263 | 1 | case 19: |
1264 | 1 | YY_RULE_SETUP |
1265 | 1 | #line 196 "hex_lexer.l" |
1266 | 1 | { |
1267 | | |
1268 | 1 | yyerror(yyscanner, lex_env, "invalid character in hex string jump"); |
1269 | 1 | yyterminate(); |
1270 | 0 | } |
1271 | 0 | YY_BREAK |
1272 | 565 | case 20: |
1273 | | /* rule 20 can match eol */ |
1274 | 565 | YY_RULE_SETUP |
1275 | 565 | #line 202 "hex_lexer.l" |
1276 | | // skip whitespaces |
1277 | 565 | YY_BREAK |
1278 | 97.1k | case 21: |
1279 | 97.1k | YY_RULE_SETUP |
1280 | 97.1k | #line 204 "hex_lexer.l" |
1281 | 97.1k | { // pass valid characters to the parser |
1282 | | |
1283 | 97.1k | return yytext[0]; |
1284 | 0 | } |
1285 | 0 | YY_BREAK |
1286 | 10 | case 22: |
1287 | 10 | YY_RULE_SETUP |
1288 | 10 | #line 209 "hex_lexer.l" |
1289 | 10 | { // reject all other characters |
1290 | | |
1291 | 10 | yyerror(yyscanner, lex_env, "invalid character in hex string"); |
1292 | 10 | yyterminate(); |
1293 | 0 | } |
1294 | 0 | YY_BREAK |
1295 | 0 | case 23: |
1296 | 0 | YY_RULE_SETUP |
1297 | 0 | #line 215 "hex_lexer.l" |
1298 | 0 | ECHO; |
1299 | 0 | YY_BREAK |
1300 | 0 | #line 1301 "hex_lexer.c" |
1301 | 168 | case YY_STATE_EOF(INITIAL): |
1302 | 168 | case YY_STATE_EOF(comment): |
1303 | 168 | case YY_STATE_EOF(range): |
1304 | 168 | yyterminate(); |
1305 | | |
1306 | 485 | case YY_END_OF_BUFFER: |
1307 | 485 | { |
1308 | | /* Amount of text matched not including the EOB char. */ |
1309 | 485 | int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; |
1310 | | |
1311 | | /* Undo the effects of YY_DO_BEFORE_ACTION. */ |
1312 | 485 | *yy_cp = yyg->yy_hold_char; |
1313 | 485 | YY_RESTORE_YY_MORE_OFFSET |
1314 | | |
1315 | 485 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) |
1316 | 317 | { |
1317 | | /* We're scanning a new file or input source. It's |
1318 | | * possible that this happened because the user |
1319 | | * just pointed yyin at a new source and called |
1320 | | * yylex(). If so, then we have to assure |
1321 | | * consistency between YY_CURRENT_BUFFER and our |
1322 | | * globals. Here is the right place to do so, because |
1323 | | * this is the first action (other than possibly a |
1324 | | * back-up) that will match for the new input source. |
1325 | | */ |
1326 | 317 | yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; |
1327 | 317 | YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; |
1328 | 317 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; |
1329 | 317 | } |
1330 | | |
1331 | | /* Note that here we test for yy_c_buf_p "<=" to the position |
1332 | | * of the first EOB in the buffer, since yy_c_buf_p will |
1333 | | * already have been incremented past the NUL character |
1334 | | * (since all states make transitions on EOB to the |
1335 | | * end-of-buffer state). Contrast this with the test |
1336 | | * in input(). |
1337 | | */ |
1338 | 485 | if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) |
1339 | 0 | { /* This was really a NUL. */ |
1340 | 0 | yy_state_type yy_next_state; |
1341 | |
|
1342 | 0 | yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; |
1343 | |
|
1344 | 0 | yy_current_state = yy_get_previous_state( yyscanner ); |
1345 | | |
1346 | | /* Okay, we're now positioned to make the NUL |
1347 | | * transition. We couldn't have |
1348 | | * yy_get_previous_state() go ahead and do it |
1349 | | * for us because it doesn't know how to deal |
1350 | | * with the possibility of jamming (and we don't |
1351 | | * want to build jamming into it because then it |
1352 | | * will run more slowly). |
1353 | | */ |
1354 | |
|
1355 | 0 | yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); |
1356 | |
|
1357 | 0 | yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; |
1358 | |
|
1359 | 0 | if ( yy_next_state ) |
1360 | 0 | { |
1361 | | /* Consume the NUL. */ |
1362 | 0 | yy_cp = ++yyg->yy_c_buf_p; |
1363 | 0 | yy_current_state = yy_next_state; |
1364 | 0 | goto yy_match; |
1365 | 0 | } |
1366 | | |
1367 | 0 | else |
1368 | 0 | { |
1369 | 0 | yy_cp = yyg->yy_last_accepting_cpos; |
1370 | 0 | yy_current_state = yyg->yy_last_accepting_state; |
1371 | 0 | goto yy_find_action; |
1372 | 0 | } |
1373 | 0 | } |
1374 | | |
1375 | 485 | else switch ( yy_get_next_buffer( yyscanner ) ) |
1376 | 485 | { |
1377 | 168 | case EOB_ACT_END_OF_FILE: |
1378 | 168 | { |
1379 | 168 | yyg->yy_did_buffer_switch_on_eof = 0; |
1380 | | |
1381 | 168 | if ( yywrap( yyscanner ) ) |
1382 | 168 | { |
1383 | | /* Note: because we've taken care in |
1384 | | * yy_get_next_buffer() to have set up |
1385 | | * yytext, we can now set up |
1386 | | * yy_c_buf_p so that if some total |
1387 | | * hoser (like flex itself) wants to |
1388 | | * call the scanner after we return the |
1389 | | * YY_NULL, it'll still work - another |
1390 | | * YY_NULL will get returned. |
1391 | | */ |
1392 | 168 | yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; |
1393 | | |
1394 | 168 | yy_act = YY_STATE_EOF(YY_START); |
1395 | 168 | goto do_action; |
1396 | 168 | } |
1397 | | |
1398 | 0 | else |
1399 | 0 | { |
1400 | 0 | if ( ! yyg->yy_did_buffer_switch_on_eof ) |
1401 | 0 | YY_NEW_FILE; |
1402 | 0 | } |
1403 | 0 | break; |
1404 | 168 | } |
1405 | | |
1406 | 0 | case EOB_ACT_CONTINUE_SCAN: |
1407 | 0 | yyg->yy_c_buf_p = |
1408 | 0 | yyg->yytext_ptr + yy_amount_of_matched_text; |
1409 | |
|
1410 | 0 | yy_current_state = yy_get_previous_state( yyscanner ); |
1411 | |
|
1412 | 0 | yy_cp = yyg->yy_c_buf_p; |
1413 | 0 | yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; |
1414 | 0 | goto yy_match; |
1415 | | |
1416 | 317 | case EOB_ACT_LAST_MATCH: |
1417 | 317 | yyg->yy_c_buf_p = |
1418 | 317 | &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; |
1419 | | |
1420 | 317 | yy_current_state = yy_get_previous_state( yyscanner ); |
1421 | | |
1422 | 317 | yy_cp = yyg->yy_c_buf_p; |
1423 | 317 | yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; |
1424 | 317 | goto yy_find_action; |
1425 | 485 | } |
1426 | 0 | break; |
1427 | 485 | } |
1428 | | |
1429 | 0 | default: |
1430 | 0 | YY_FATAL_ERROR( |
1431 | 434k | "fatal flex scanner internal error--no action found" ); |
1432 | 434k | } /* end of action switch */ |
1433 | 434k | } /* end of scanning one token */ |
1434 | 140k | } /* end of user's declarations */ |
1435 | 140k | } /* end of yylex */ |
1436 | | |
1437 | | /* yy_get_next_buffer - try to read in a new buffer |
1438 | | * |
1439 | | * Returns a code representing an action: |
1440 | | * EOB_ACT_LAST_MATCH - |
1441 | | * EOB_ACT_CONTINUE_SCAN - continue scanning from current position |
1442 | | * EOB_ACT_END_OF_FILE - end of file |
1443 | | */ |
1444 | | static int yy_get_next_buffer (yyscan_t yyscanner) |
1445 | 485 | { |
1446 | 485 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
1447 | 485 | char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; |
1448 | 485 | char *source = yyg->yytext_ptr; |
1449 | 485 | int number_to_move, i; |
1450 | 485 | int ret_val; |
1451 | | |
1452 | 485 | if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) |
1453 | 0 | YY_FATAL_ERROR( |
1454 | 485 | "fatal flex scanner internal error--end of buffer missed" ); |
1455 | | |
1456 | 485 | if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) |
1457 | 485 | { /* Don't try to fill the buffer, so this is an EOF. */ |
1458 | 485 | if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) |
1459 | 168 | { |
1460 | | /* We matched a single character, the EOB, so |
1461 | | * treat this as a final EOF. |
1462 | | */ |
1463 | 168 | return EOB_ACT_END_OF_FILE; |
1464 | 168 | } |
1465 | | |
1466 | 317 | else |
1467 | 317 | { |
1468 | | /* We matched some text prior to the EOB, first |
1469 | | * process it. |
1470 | | */ |
1471 | 317 | return EOB_ACT_LAST_MATCH; |
1472 | 317 | } |
1473 | 485 | } |
1474 | | |
1475 | | /* Try to read more data. */ |
1476 | | |
1477 | | /* First move last chars to start of buffer. */ |
1478 | 0 | number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); |
1479 | |
|
1480 | 0 | for ( i = 0; i < number_to_move; ++i ) |
1481 | 0 | *(dest++) = *(source++); |
1482 | |
|
1483 | 0 | if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) |
1484 | | /* don't do the read, it's not guaranteed to return an EOF, |
1485 | | * just force an EOF |
1486 | | */ |
1487 | 0 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; |
1488 | | |
1489 | 0 | else |
1490 | 0 | { |
1491 | 0 | int num_to_read = |
1492 | 0 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; |
1493 | |
|
1494 | 0 | while ( num_to_read <= 0 ) |
1495 | 0 | { /* Not enough room in the buffer - grow it. */ |
1496 | | |
1497 | | /* just a shorter name for the current buffer */ |
1498 | 0 | YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; |
1499 | |
|
1500 | 0 | int yy_c_buf_p_offset = |
1501 | 0 | (int) (yyg->yy_c_buf_p - b->yy_ch_buf); |
1502 | |
|
1503 | 0 | if ( b->yy_is_our_buffer ) |
1504 | 0 | { |
1505 | 0 | int new_size = b->yy_buf_size * 2; |
1506 | |
|
1507 | 0 | if ( new_size <= 0 ) |
1508 | 0 | b->yy_buf_size += b->yy_buf_size / 8; |
1509 | 0 | else |
1510 | 0 | b->yy_buf_size *= 2; |
1511 | |
|
1512 | 0 | b->yy_ch_buf = (char *) |
1513 | | /* Include room in for 2 EOB chars. */ |
1514 | 0 | yyrealloc( (void *) b->yy_ch_buf, |
1515 | 0 | (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); |
1516 | 0 | } |
1517 | 0 | else |
1518 | | /* Can't grow it, we don't own it. */ |
1519 | 0 | b->yy_ch_buf = NULL; |
1520 | |
|
1521 | 0 | if ( ! b->yy_ch_buf ) |
1522 | 0 | YY_FATAL_ERROR( |
1523 | 0 | "fatal error - scanner input buffer overflow" ); |
1524 | |
|
1525 | 0 | yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; |
1526 | |
|
1527 | 0 | num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - |
1528 | 0 | number_to_move - 1; |
1529 | |
|
1530 | 0 | } |
1531 | |
|
1532 | 0 | if ( num_to_read > YY_READ_BUF_SIZE ) |
1533 | 0 | num_to_read = YY_READ_BUF_SIZE; |
1534 | | |
1535 | | /* Read in more data. */ |
1536 | 0 | YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), |
1537 | 0 | yyg->yy_n_chars, num_to_read ); |
1538 | |
|
1539 | 0 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; |
1540 | 0 | } |
1541 | |
|
1542 | 0 | if ( yyg->yy_n_chars == 0 ) |
1543 | 0 | { |
1544 | 0 | if ( number_to_move == YY_MORE_ADJ ) |
1545 | 0 | { |
1546 | 0 | ret_val = EOB_ACT_END_OF_FILE; |
1547 | 0 | yyrestart( yyin , yyscanner); |
1548 | 0 | } |
1549 | | |
1550 | 0 | else |
1551 | 0 | { |
1552 | 0 | ret_val = EOB_ACT_LAST_MATCH; |
1553 | 0 | YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = |
1554 | 0 | YY_BUFFER_EOF_PENDING; |
1555 | 0 | } |
1556 | 0 | } |
1557 | | |
1558 | 0 | else |
1559 | 0 | ret_val = EOB_ACT_CONTINUE_SCAN; |
1560 | |
|
1561 | 0 | if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { |
1562 | | /* Extend the array by 50%, plus the number we really need. */ |
1563 | 0 | int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); |
1564 | 0 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( |
1565 | 0 | (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); |
1566 | 0 | if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) |
1567 | 0 | YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); |
1568 | | /* "- 2" to take care of EOB's */ |
1569 | 0 | YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); |
1570 | 0 | } |
1571 | |
|
1572 | 0 | yyg->yy_n_chars += number_to_move; |
1573 | 0 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; |
1574 | 0 | YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; |
1575 | |
|
1576 | 0 | yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; |
1577 | |
|
1578 | 0 | return ret_val; |
1579 | 485 | } |
1580 | | |
1581 | | /* yy_get_previous_state - get the state just before the EOB char was reached */ |
1582 | | |
1583 | | static yy_state_type yy_get_previous_state (yyscan_t yyscanner) |
1584 | 317 | { |
1585 | 317 | yy_state_type yy_current_state; |
1586 | 317 | char *yy_cp; |
1587 | 317 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
1588 | | |
1589 | 317 | yy_current_state = yyg->yy_start; |
1590 | | |
1591 | 634 | for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) |
1592 | 317 | { |
1593 | 317 | YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); |
1594 | 317 | if ( yy_accept[yy_current_state] ) |
1595 | 0 | { |
1596 | 0 | yyg->yy_last_accepting_state = yy_current_state; |
1597 | 0 | yyg->yy_last_accepting_cpos = yy_cp; |
1598 | 0 | } |
1599 | 317 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) |
1600 | 0 | { |
1601 | 0 | yy_current_state = (int) yy_def[yy_current_state]; |
1602 | 0 | if ( yy_current_state >= 40 ) |
1603 | 0 | yy_c = yy_meta[yy_c]; |
1604 | 0 | } |
1605 | 317 | yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; |
1606 | 317 | } |
1607 | | |
1608 | 317 | return yy_current_state; |
1609 | 317 | } |
1610 | | |
1611 | | /* yy_try_NUL_trans - try to make a transition on the NUL character |
1612 | | * |
1613 | | * synopsis |
1614 | | * next_state = yy_try_NUL_trans( current_state ); |
1615 | | */ |
1616 | | static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) |
1617 | 0 | { |
1618 | 0 | int yy_is_jam; |
1619 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ |
1620 | 0 | char *yy_cp = yyg->yy_c_buf_p; |
1621 | |
|
1622 | 0 | YY_CHAR yy_c = 1; |
1623 | 0 | if ( yy_accept[yy_current_state] ) |
1624 | 0 | { |
1625 | 0 | yyg->yy_last_accepting_state = yy_current_state; |
1626 | 0 | yyg->yy_last_accepting_cpos = yy_cp; |
1627 | 0 | } |
1628 | 0 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) |
1629 | 0 | { |
1630 | 0 | yy_current_state = (int) yy_def[yy_current_state]; |
1631 | 0 | if ( yy_current_state >= 40 ) |
1632 | 0 | yy_c = yy_meta[yy_c]; |
1633 | 0 | } |
1634 | 0 | yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; |
1635 | 0 | yy_is_jam = (yy_current_state == 39); |
1636 | |
|
1637 | 0 | (void)yyg; |
1638 | 0 | return yy_is_jam ? 0 : yy_current_state; |
1639 | 0 | } |
1640 | | |
1641 | | #ifndef YY_NO_UNPUT |
1642 | | |
1643 | | #endif |
1644 | | |
1645 | | #ifndef YY_NO_INPUT |
1646 | | #ifdef __cplusplus |
1647 | | static int yyinput (yyscan_t yyscanner) |
1648 | | #else |
1649 | | static int input (yyscan_t yyscanner) |
1650 | | #endif |
1651 | | |
1652 | | { |
1653 | | int c; |
1654 | | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
1655 | | |
1656 | | *yyg->yy_c_buf_p = yyg->yy_hold_char; |
1657 | | |
1658 | | if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) |
1659 | | { |
1660 | | /* yy_c_buf_p now points to the character we want to return. |
1661 | | * If this occurs *before* the EOB characters, then it's a |
1662 | | * valid NUL; if not, then we've hit the end of the buffer. |
1663 | | */ |
1664 | | if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) |
1665 | | /* This was really a NUL. */ |
1666 | | *yyg->yy_c_buf_p = '\0'; |
1667 | | |
1668 | | else |
1669 | | { /* need more input */ |
1670 | | int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); |
1671 | | ++yyg->yy_c_buf_p; |
1672 | | |
1673 | | switch ( yy_get_next_buffer( yyscanner ) ) |
1674 | | { |
1675 | | case EOB_ACT_LAST_MATCH: |
1676 | | /* This happens because yy_g_n_b() |
1677 | | * sees that we've accumulated a |
1678 | | * token and flags that we need to |
1679 | | * try matching the token before |
1680 | | * proceeding. But for input(), |
1681 | | * there's no matching to consider. |
1682 | | * So convert the EOB_ACT_LAST_MATCH |
1683 | | * to EOB_ACT_END_OF_FILE. |
1684 | | */ |
1685 | | |
1686 | | /* Reset buffer status. */ |
1687 | | yyrestart( yyin , yyscanner); |
1688 | | |
1689 | | /*FALLTHROUGH*/ |
1690 | | |
1691 | | case EOB_ACT_END_OF_FILE: |
1692 | | { |
1693 | | if ( yywrap( yyscanner ) ) |
1694 | | return 0; |
1695 | | |
1696 | | if ( ! yyg->yy_did_buffer_switch_on_eof ) |
1697 | | YY_NEW_FILE; |
1698 | | #ifdef __cplusplus |
1699 | | return yyinput(yyscanner); |
1700 | | #else |
1701 | | return input(yyscanner); |
1702 | | #endif |
1703 | | } |
1704 | | |
1705 | | case EOB_ACT_CONTINUE_SCAN: |
1706 | | yyg->yy_c_buf_p = yyg->yytext_ptr + offset; |
1707 | | break; |
1708 | | } |
1709 | | } |
1710 | | } |
1711 | | |
1712 | | c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ |
1713 | | *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ |
1714 | | yyg->yy_hold_char = *++yyg->yy_c_buf_p; |
1715 | | |
1716 | | if ( c == '\n' ) |
1717 | | |
1718 | | do{ yylineno++; |
1719 | | yycolumn=0; |
1720 | | }while(0) |
1721 | | ; |
1722 | | |
1723 | | return c; |
1724 | | } |
1725 | | #endif /* ifndef YY_NO_INPUT */ |
1726 | | |
1727 | | /** Immediately switch to a different input stream. |
1728 | | * @param input_file A readable stream. |
1729 | | * @param yyscanner The scanner object. |
1730 | | * @note This function does not reset the start condition to @c INITIAL . |
1731 | | */ |
1732 | | void yyrestart (FILE * input_file , yyscan_t yyscanner) |
1733 | 0 | { |
1734 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
1735 | |
|
1736 | 0 | if ( ! YY_CURRENT_BUFFER ){ |
1737 | 0 | yyensure_buffer_stack (yyscanner); |
1738 | 0 | YY_CURRENT_BUFFER_LVALUE = |
1739 | 0 | yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); |
1740 | 0 | } |
1741 | |
|
1742 | 0 | yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); |
1743 | 0 | yy_load_buffer_state( yyscanner ); |
1744 | 0 | } |
1745 | | |
1746 | | /** Switch to a different input buffer. |
1747 | | * @param new_buffer The new input buffer. |
1748 | | * @param yyscanner The scanner object. |
1749 | | */ |
1750 | | void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) |
1751 | 440 | { |
1752 | 440 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
1753 | | |
1754 | | /* TODO. We should be able to replace this entire function body |
1755 | | * with |
1756 | | * yypop_buffer_state(); |
1757 | | * yypush_buffer_state(new_buffer); |
1758 | | */ |
1759 | 440 | yyensure_buffer_stack (yyscanner); |
1760 | 440 | if ( YY_CURRENT_BUFFER == new_buffer ) |
1761 | 0 | return; |
1762 | | |
1763 | 440 | if ( YY_CURRENT_BUFFER ) |
1764 | 0 | { |
1765 | | /* Flush out information for old buffer. */ |
1766 | 0 | *yyg->yy_c_buf_p = yyg->yy_hold_char; |
1767 | 0 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; |
1768 | 0 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; |
1769 | 0 | } |
1770 | | |
1771 | 440 | YY_CURRENT_BUFFER_LVALUE = new_buffer; |
1772 | 440 | yy_load_buffer_state( yyscanner ); |
1773 | | |
1774 | | /* We don't actually know whether we did this switch during |
1775 | | * EOF (yywrap()) processing, but the only time this flag |
1776 | | * is looked at is after yywrap() is called, so it's safe |
1777 | | * to go ahead and always set it. |
1778 | | */ |
1779 | 440 | yyg->yy_did_buffer_switch_on_eof = 1; |
1780 | 440 | } |
1781 | | |
1782 | | static void yy_load_buffer_state (yyscan_t yyscanner) |
1783 | 880 | { |
1784 | 880 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
1785 | 880 | yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; |
1786 | 880 | yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; |
1787 | 880 | yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; |
1788 | 880 | yyg->yy_hold_char = *yyg->yy_c_buf_p; |
1789 | 880 | } |
1790 | | |
1791 | | /** Allocate and initialize an input buffer state. |
1792 | | * @param file A readable stream. |
1793 | | * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. |
1794 | | * @param yyscanner The scanner object. |
1795 | | * @return the allocated buffer state. |
1796 | | */ |
1797 | | YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) |
1798 | 0 | { |
1799 | 0 | YY_BUFFER_STATE b; |
1800 | | |
1801 | 0 | b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); |
1802 | 0 | if ( ! b ) |
1803 | 0 | YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); |
1804 | |
|
1805 | 0 | b->yy_buf_size = size; |
1806 | | |
1807 | | /* yy_ch_buf has to be 2 characters longer than the size given because |
1808 | | * we need to put in 2 end-of-buffer characters. |
1809 | | */ |
1810 | 0 | b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); |
1811 | 0 | if ( ! b->yy_ch_buf ) |
1812 | 0 | YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); |
1813 | |
|
1814 | 0 | b->yy_is_our_buffer = 1; |
1815 | |
|
1816 | 0 | yy_init_buffer( b, file , yyscanner); |
1817 | |
|
1818 | 0 | return b; |
1819 | 0 | } |
1820 | | |
1821 | | /** Destroy the buffer. |
1822 | | * @param b a buffer created with yy_create_buffer() |
1823 | | * @param yyscanner The scanner object. |
1824 | | */ |
1825 | | void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) |
1826 | 440 | { |
1827 | 440 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
1828 | | |
1829 | 440 | if ( ! b ) |
1830 | 0 | return; |
1831 | | |
1832 | 440 | if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ |
1833 | 440 | YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; |
1834 | | |
1835 | 440 | if ( b->yy_is_our_buffer ) |
1836 | 440 | yyfree( (void *) b->yy_ch_buf , yyscanner ); |
1837 | | |
1838 | 440 | yyfree( (void *) b , yyscanner ); |
1839 | 440 | } |
1840 | | |
1841 | | /* Initializes or reinitializes a buffer. |
1842 | | * This function is sometimes called more than once on the same buffer, |
1843 | | * such as during a yyrestart() or at EOF. |
1844 | | */ |
1845 | | static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) |
1846 | | |
1847 | 0 | { |
1848 | 0 | int oerrno = errno; |
1849 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
1850 | |
|
1851 | 0 | yy_flush_buffer( b , yyscanner); |
1852 | |
|
1853 | 0 | b->yy_input_file = file; |
1854 | 0 | b->yy_fill_buffer = 1; |
1855 | | |
1856 | | /* If b is the current buffer, then yy_init_buffer was _probably_ |
1857 | | * called from yyrestart() or through yy_get_next_buffer. |
1858 | | * In that case, we don't want to reset the lineno or column. |
1859 | | */ |
1860 | 0 | if (b != YY_CURRENT_BUFFER){ |
1861 | 0 | b->yy_bs_lineno = 1; |
1862 | 0 | b->yy_bs_column = 0; |
1863 | 0 | } |
1864 | |
|
1865 | 0 | b->yy_is_interactive = 0; |
1866 | | |
1867 | 0 | errno = oerrno; |
1868 | 0 | } |
1869 | | |
1870 | | /** Discard all buffered characters. On the next scan, YY_INPUT will be called. |
1871 | | * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. |
1872 | | * @param yyscanner The scanner object. |
1873 | | */ |
1874 | | void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) |
1875 | 0 | { |
1876 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
1877 | 0 | if ( ! b ) |
1878 | 0 | return; |
1879 | | |
1880 | 0 | b->yy_n_chars = 0; |
1881 | | |
1882 | | /* We always need two end-of-buffer characters. The first causes |
1883 | | * a transition to the end-of-buffer state. The second causes |
1884 | | * a jam in that state. |
1885 | | */ |
1886 | 0 | b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; |
1887 | 0 | b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; |
1888 | |
|
1889 | 0 | b->yy_buf_pos = &b->yy_ch_buf[0]; |
1890 | |
|
1891 | 0 | b->yy_at_bol = 1; |
1892 | 0 | b->yy_buffer_status = YY_BUFFER_NEW; |
1893 | |
|
1894 | 0 | if ( b == YY_CURRENT_BUFFER ) |
1895 | 0 | yy_load_buffer_state( yyscanner ); |
1896 | 0 | } |
1897 | | |
1898 | | /** Pushes the new state onto the stack. The new state becomes |
1899 | | * the current state. This function will allocate the stack |
1900 | | * if necessary. |
1901 | | * @param new_buffer The new state. |
1902 | | * @param yyscanner The scanner object. |
1903 | | */ |
1904 | | void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) |
1905 | 0 | { |
1906 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
1907 | 0 | if (new_buffer == NULL) |
1908 | 0 | return; |
1909 | | |
1910 | 0 | yyensure_buffer_stack(yyscanner); |
1911 | | |
1912 | | /* This block is copied from yy_switch_to_buffer. */ |
1913 | 0 | if ( YY_CURRENT_BUFFER ) |
1914 | 0 | { |
1915 | | /* Flush out information for old buffer. */ |
1916 | 0 | *yyg->yy_c_buf_p = yyg->yy_hold_char; |
1917 | 0 | YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; |
1918 | 0 | YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; |
1919 | 0 | } |
1920 | | |
1921 | | /* Only push if top exists. Otherwise, replace top. */ |
1922 | 0 | if (YY_CURRENT_BUFFER) |
1923 | 0 | yyg->yy_buffer_stack_top++; |
1924 | 0 | YY_CURRENT_BUFFER_LVALUE = new_buffer; |
1925 | | |
1926 | | /* copied from yy_switch_to_buffer. */ |
1927 | 0 | yy_load_buffer_state( yyscanner ); |
1928 | 0 | yyg->yy_did_buffer_switch_on_eof = 1; |
1929 | 0 | } |
1930 | | |
1931 | | /** Removes and deletes the top of the stack, if present. |
1932 | | * The next element becomes the new top. |
1933 | | * @param yyscanner The scanner object. |
1934 | | */ |
1935 | | void yypop_buffer_state (yyscan_t yyscanner) |
1936 | 440 | { |
1937 | 440 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
1938 | 440 | if (!YY_CURRENT_BUFFER) |
1939 | 440 | return; |
1940 | | |
1941 | 0 | yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); |
1942 | 0 | YY_CURRENT_BUFFER_LVALUE = NULL; |
1943 | 0 | if (yyg->yy_buffer_stack_top > 0) |
1944 | 0 | --yyg->yy_buffer_stack_top; |
1945 | |
|
1946 | 0 | if (YY_CURRENT_BUFFER) { |
1947 | 0 | yy_load_buffer_state( yyscanner ); |
1948 | 0 | yyg->yy_did_buffer_switch_on_eof = 1; |
1949 | 0 | } |
1950 | 0 | } |
1951 | | |
1952 | | /* Allocates the stack if it does not exist. |
1953 | | * Guarantees space for at least one push. |
1954 | | */ |
1955 | | static void yyensure_buffer_stack (yyscan_t yyscanner) |
1956 | 440 | { |
1957 | 440 | yy_size_t num_to_alloc; |
1958 | 440 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
1959 | | |
1960 | 440 | if (!yyg->yy_buffer_stack) { |
1961 | | |
1962 | | /* First allocation is just for 2 elements, since we don't know if this |
1963 | | * scanner will even need a stack. We use 2 instead of 1 to avoid an |
1964 | | * immediate realloc on the next call. |
1965 | | */ |
1966 | 440 | num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ |
1967 | 440 | yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc |
1968 | 440 | (num_to_alloc * sizeof(struct yy_buffer_state*) |
1969 | 440 | , yyscanner); |
1970 | 440 | if ( ! yyg->yy_buffer_stack ) |
1971 | 0 | YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); |
1972 | | |
1973 | 440 | memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); |
1974 | | |
1975 | 440 | yyg->yy_buffer_stack_max = num_to_alloc; |
1976 | 440 | yyg->yy_buffer_stack_top = 0; |
1977 | 440 | return; |
1978 | 440 | } |
1979 | | |
1980 | 0 | if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ |
1981 | | |
1982 | | /* Increase the buffer to prepare for a possible push. */ |
1983 | 0 | yy_size_t grow_size = 8 /* arbitrary grow size */; |
1984 | |
|
1985 | 0 | num_to_alloc = yyg->yy_buffer_stack_max + grow_size; |
1986 | 0 | yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc |
1987 | 0 | (yyg->yy_buffer_stack, |
1988 | 0 | num_to_alloc * sizeof(struct yy_buffer_state*) |
1989 | 0 | , yyscanner); |
1990 | 0 | if ( ! yyg->yy_buffer_stack ) |
1991 | 0 | YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); |
1992 | | |
1993 | | /* zero only the new slots.*/ |
1994 | 0 | memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); |
1995 | 0 | yyg->yy_buffer_stack_max = num_to_alloc; |
1996 | 0 | } |
1997 | 0 | } |
1998 | | |
1999 | | /** Setup the input buffer state to scan directly from a user-specified character buffer. |
2000 | | * @param base the character buffer |
2001 | | * @param size the size in bytes of the character buffer |
2002 | | * @param yyscanner The scanner object. |
2003 | | * @return the newly allocated buffer state object. |
2004 | | */ |
2005 | | YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) |
2006 | 440 | { |
2007 | 440 | YY_BUFFER_STATE b; |
2008 | | |
2009 | 440 | if ( size < 2 || |
2010 | 440 | base[size-2] != YY_END_OF_BUFFER_CHAR || |
2011 | 440 | base[size-1] != YY_END_OF_BUFFER_CHAR ) |
2012 | | /* They forgot to leave room for the EOB's. */ |
2013 | 0 | return NULL; |
2014 | | |
2015 | 440 | b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); |
2016 | 440 | if ( ! b ) |
2017 | 0 | YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); |
2018 | | |
2019 | 440 | b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ |
2020 | 440 | b->yy_buf_pos = b->yy_ch_buf = base; |
2021 | 440 | b->yy_is_our_buffer = 0; |
2022 | 440 | b->yy_input_file = NULL; |
2023 | 440 | b->yy_n_chars = b->yy_buf_size; |
2024 | 440 | b->yy_is_interactive = 0; |
2025 | 440 | b->yy_at_bol = 1; |
2026 | 440 | b->yy_fill_buffer = 0; |
2027 | 440 | b->yy_buffer_status = YY_BUFFER_NEW; |
2028 | | |
2029 | 440 | yy_switch_to_buffer( b , yyscanner ); |
2030 | | |
2031 | 440 | return b; |
2032 | 440 | } |
2033 | | |
2034 | | /** Setup the input buffer state to scan a string. The next call to yylex() will |
2035 | | * scan from a @e copy of @a str. |
2036 | | * @param yystr a NUL-terminated string to scan |
2037 | | * @param yyscanner The scanner object. |
2038 | | * @return the newly allocated buffer state object. |
2039 | | * @note If you want to scan bytes that may contain NUL values, then use |
2040 | | * yy_scan_bytes() instead. |
2041 | | */ |
2042 | | YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) |
2043 | 440 | { |
2044 | | |
2045 | 440 | return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); |
2046 | 440 | } |
2047 | | |
2048 | | /** Setup the input buffer state to scan the given bytes. The next call to yylex() will |
2049 | | * scan from a @e copy of @a bytes. |
2050 | | * @param yybytes the byte buffer to scan |
2051 | | * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. |
2052 | | * @param yyscanner The scanner object. |
2053 | | * @return the newly allocated buffer state object. |
2054 | | */ |
2055 | | YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) |
2056 | 440 | { |
2057 | 440 | YY_BUFFER_STATE b; |
2058 | 440 | char *buf; |
2059 | 440 | yy_size_t n; |
2060 | 440 | int i; |
2061 | | |
2062 | | /* Get memory for full buffer, including space for trailing EOB's. */ |
2063 | 440 | n = (yy_size_t) (_yybytes_len + 2); |
2064 | 440 | buf = (char *) yyalloc( n , yyscanner ); |
2065 | 440 | if ( ! buf ) |
2066 | 0 | YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); |
2067 | | |
2068 | 480k | for ( i = 0; i < _yybytes_len; ++i ) |
2069 | 480k | buf[i] = yybytes[i]; |
2070 | | |
2071 | 440 | buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; |
2072 | | |
2073 | 440 | b = yy_scan_buffer( buf, n , yyscanner); |
2074 | 440 | if ( ! b ) |
2075 | 0 | YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); |
2076 | | |
2077 | | /* It's okay to grow etc. this buffer, and we should throw it |
2078 | | * away when we're done. |
2079 | | */ |
2080 | 440 | b->yy_is_our_buffer = 1; |
2081 | | |
2082 | 440 | return b; |
2083 | 440 | } |
2084 | | |
2085 | | #ifndef YY_EXIT_FAILURE |
2086 | | #define YY_EXIT_FAILURE 2 |
2087 | | #endif |
2088 | | |
2089 | | static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) |
2090 | 0 | { |
2091 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2092 | 0 | (void)yyg; |
2093 | 0 | fprintf( stderr, "%s\n", msg ); |
2094 | 0 | exit( YY_EXIT_FAILURE ); |
2095 | 0 | } |
2096 | | |
2097 | | /* Redefine yyless() so it works in section 3 code. */ |
2098 | | |
2099 | | #undef yyless |
2100 | | #define yyless(n) \ |
2101 | | do \ |
2102 | | { \ |
2103 | | /* Undo effects of setting up yytext. */ \ |
2104 | | int yyless_macro_arg = (n); \ |
2105 | | YY_LESS_LINENO(yyless_macro_arg);\ |
2106 | | yytext[yyleng] = yyg->yy_hold_char; \ |
2107 | | yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ |
2108 | | yyg->yy_hold_char = *yyg->yy_c_buf_p; \ |
2109 | | *yyg->yy_c_buf_p = '\0'; \ |
2110 | | yyleng = yyless_macro_arg; \ |
2111 | | } \ |
2112 | | while ( 0 ) |
2113 | | |
2114 | | /* Accessor methods (get/set functions) to struct members. */ |
2115 | | |
2116 | | /** Get the user-defined data for this scanner. |
2117 | | * @param yyscanner The scanner object. |
2118 | | */ |
2119 | | YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) |
2120 | 503 | { |
2121 | 503 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2122 | 503 | return yyextra; |
2123 | 503 | } |
2124 | | |
2125 | | /** Get the current line number. |
2126 | | * @param yyscanner The scanner object. |
2127 | | */ |
2128 | | int yyget_lineno (yyscan_t yyscanner) |
2129 | 0 | { |
2130 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2131 | |
|
2132 | 0 | if (! YY_CURRENT_BUFFER) |
2133 | 0 | return 0; |
2134 | | |
2135 | 0 | return yylineno; |
2136 | 0 | } |
2137 | | |
2138 | | /** Get the current column number. |
2139 | | * @param yyscanner The scanner object. |
2140 | | */ |
2141 | | int yyget_column (yyscan_t yyscanner) |
2142 | 0 | { |
2143 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2144 | |
|
2145 | 0 | if (! YY_CURRENT_BUFFER) |
2146 | 0 | return 0; |
2147 | | |
2148 | 0 | return yycolumn; |
2149 | 0 | } |
2150 | | |
2151 | | /** Get the input stream. |
2152 | | * @param yyscanner The scanner object. |
2153 | | */ |
2154 | | FILE *yyget_in (yyscan_t yyscanner) |
2155 | 0 | { |
2156 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2157 | 0 | return yyin; |
2158 | 0 | } |
2159 | | |
2160 | | /** Get the output stream. |
2161 | | * @param yyscanner The scanner object. |
2162 | | */ |
2163 | | FILE *yyget_out (yyscan_t yyscanner) |
2164 | 0 | { |
2165 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2166 | 0 | return yyout; |
2167 | 0 | } |
2168 | | |
2169 | | /** Get the length of the current token. |
2170 | | * @param yyscanner The scanner object. |
2171 | | */ |
2172 | | int yyget_leng (yyscan_t yyscanner) |
2173 | 0 | { |
2174 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2175 | 0 | return yyleng; |
2176 | 0 | } |
2177 | | |
2178 | | /** Get the current token. |
2179 | | * @param yyscanner The scanner object. |
2180 | | */ |
2181 | | |
2182 | | char *yyget_text (yyscan_t yyscanner) |
2183 | 0 | { |
2184 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2185 | 0 | return yytext; |
2186 | 0 | } |
2187 | | |
2188 | | /** Set the user-defined data. This data is never touched by the scanner. |
2189 | | * @param user_defined The data to be associated with this scanner. |
2190 | | * @param yyscanner The scanner object. |
2191 | | */ |
2192 | | void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) |
2193 | 440 | { |
2194 | 440 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2195 | 440 | yyextra = user_defined ; |
2196 | 440 | } |
2197 | | |
2198 | | /** Set the current line number. |
2199 | | * @param _line_number line number |
2200 | | * @param yyscanner The scanner object. |
2201 | | */ |
2202 | | void yyset_lineno (int _line_number , yyscan_t yyscanner) |
2203 | 0 | { |
2204 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2205 | | |
2206 | | /* lineno is only valid if an input buffer exists. */ |
2207 | 0 | if (! YY_CURRENT_BUFFER ) |
2208 | 0 | YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); |
2209 | | |
2210 | 0 | yylineno = _line_number; |
2211 | 0 | } |
2212 | | |
2213 | | /** Set the current column. |
2214 | | * @param _column_no column number |
2215 | | * @param yyscanner The scanner object. |
2216 | | */ |
2217 | | void yyset_column (int _column_no , yyscan_t yyscanner) |
2218 | 0 | { |
2219 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2220 | | |
2221 | | /* column is only valid if an input buffer exists. */ |
2222 | 0 | if (! YY_CURRENT_BUFFER ) |
2223 | 0 | YY_FATAL_ERROR( "yyset_column called with no buffer" ); |
2224 | | |
2225 | 0 | yycolumn = _column_no; |
2226 | 0 | } |
2227 | | |
2228 | | /** Set the input stream. This does not discard the current |
2229 | | * input buffer. |
2230 | | * @param _in_str A readable stream. |
2231 | | * @param yyscanner The scanner object. |
2232 | | * @see yy_switch_to_buffer |
2233 | | */ |
2234 | | void yyset_in (FILE * _in_str , yyscan_t yyscanner) |
2235 | 0 | { |
2236 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2237 | 0 | yyin = _in_str ; |
2238 | 0 | } |
2239 | | |
2240 | | void yyset_out (FILE * _out_str , yyscan_t yyscanner) |
2241 | 0 | { |
2242 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2243 | 0 | yyout = _out_str ; |
2244 | 0 | } |
2245 | | |
2246 | | int yyget_debug (yyscan_t yyscanner) |
2247 | 0 | { |
2248 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2249 | 0 | return yy_flex_debug; |
2250 | 0 | } |
2251 | | |
2252 | | void yyset_debug (int _bdebug , yyscan_t yyscanner) |
2253 | 0 | { |
2254 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2255 | 0 | yy_flex_debug = _bdebug ; |
2256 | 0 | } |
2257 | | |
2258 | | /* Accessor methods for yylval and yylloc */ |
2259 | | |
2260 | | YYSTYPE * yyget_lval (yyscan_t yyscanner) |
2261 | 0 | { |
2262 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2263 | 0 | return yylval; |
2264 | 0 | } |
2265 | | |
2266 | | void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) |
2267 | 0 | { |
2268 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2269 | 0 | yylval = yylval_param; |
2270 | 0 | } |
2271 | | |
2272 | | /* User-visible API */ |
2273 | | |
2274 | | /* yylex_init is special because it creates the scanner itself, so it is |
2275 | | * the ONLY reentrant function that doesn't take the scanner as the last argument. |
2276 | | * That's why we explicitly handle the declaration, instead of using our macros. |
2277 | | */ |
2278 | | int yylex_init(yyscan_t* ptr_yy_globals) |
2279 | 440 | { |
2280 | 440 | if (ptr_yy_globals == NULL){ |
2281 | 0 | errno = EINVAL; |
2282 | 0 | return 1; |
2283 | 0 | } |
2284 | | |
2285 | 440 | *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); |
2286 | | |
2287 | 440 | if (*ptr_yy_globals == NULL){ |
2288 | 0 | errno = ENOMEM; |
2289 | 0 | return 1; |
2290 | 0 | } |
2291 | | |
2292 | | /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ |
2293 | 440 | memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); |
2294 | | |
2295 | 440 | return yy_init_globals ( *ptr_yy_globals ); |
2296 | 440 | } |
2297 | | |
2298 | | /* yylex_init_extra has the same functionality as yylex_init, but follows the |
2299 | | * convention of taking the scanner as the last argument. Note however, that |
2300 | | * this is a *pointer* to a scanner, as it will be allocated by this call (and |
2301 | | * is the reason, too, why this function also must handle its own declaration). |
2302 | | * The user defined value in the first argument will be available to yyalloc in |
2303 | | * the yyextra field. |
2304 | | */ |
2305 | | int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) |
2306 | 0 | { |
2307 | 0 | struct yyguts_t dummy_yyguts; |
2308 | |
|
2309 | 0 | yyset_extra (yy_user_defined, &dummy_yyguts); |
2310 | |
|
2311 | 0 | if (ptr_yy_globals == NULL){ |
2312 | 0 | errno = EINVAL; |
2313 | 0 | return 1; |
2314 | 0 | } |
2315 | | |
2316 | 0 | *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); |
2317 | |
|
2318 | 0 | if (*ptr_yy_globals == NULL){ |
2319 | 0 | errno = ENOMEM; |
2320 | 0 | return 1; |
2321 | 0 | } |
2322 | | |
2323 | | /* By setting to 0xAA, we expose bugs in |
2324 | | yy_init_globals. Leave at 0x00 for releases. */ |
2325 | 0 | memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); |
2326 | |
|
2327 | 0 | yyset_extra (yy_user_defined, *ptr_yy_globals); |
2328 | |
|
2329 | 0 | return yy_init_globals ( *ptr_yy_globals ); |
2330 | 0 | } |
2331 | | |
2332 | | static int yy_init_globals (yyscan_t yyscanner) |
2333 | 880 | { |
2334 | 880 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2335 | | /* Initialization is the same as for the non-reentrant scanner. |
2336 | | * This function is called from yylex_destroy(), so don't allocate here. |
2337 | | */ |
2338 | | |
2339 | 880 | yyg->yy_buffer_stack = NULL; |
2340 | 880 | yyg->yy_buffer_stack_top = 0; |
2341 | 880 | yyg->yy_buffer_stack_max = 0; |
2342 | 880 | yyg->yy_c_buf_p = NULL; |
2343 | 880 | yyg->yy_init = 0; |
2344 | 880 | yyg->yy_start = 0; |
2345 | | |
2346 | 880 | yyg->yy_start_stack_ptr = 0; |
2347 | 880 | yyg->yy_start_stack_depth = 0; |
2348 | 880 | yyg->yy_start_stack = NULL; |
2349 | | |
2350 | | /* Defined in main.c */ |
2351 | | #ifdef YY_STDINIT |
2352 | | yyin = stdin; |
2353 | | yyout = stdout; |
2354 | | #else |
2355 | 880 | yyin = NULL; |
2356 | 880 | yyout = NULL; |
2357 | 880 | #endif |
2358 | | |
2359 | | /* For future reference: Set errno on error, since we are called by |
2360 | | * yylex_init() |
2361 | | */ |
2362 | 880 | return 0; |
2363 | 880 | } |
2364 | | |
2365 | | /* yylex_destroy is for both reentrant and non-reentrant scanners. */ |
2366 | | int yylex_destroy (yyscan_t yyscanner) |
2367 | 440 | { |
2368 | 440 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2369 | | |
2370 | | /* Pop the buffer stack, destroying each element. */ |
2371 | 880 | while(YY_CURRENT_BUFFER){ |
2372 | 440 | yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); |
2373 | 440 | YY_CURRENT_BUFFER_LVALUE = NULL; |
2374 | 440 | yypop_buffer_state(yyscanner); |
2375 | 440 | } |
2376 | | |
2377 | | /* Destroy the stack itself. */ |
2378 | 440 | yyfree(yyg->yy_buffer_stack , yyscanner); |
2379 | 440 | yyg->yy_buffer_stack = NULL; |
2380 | | |
2381 | | /* Destroy the start condition stack. */ |
2382 | 440 | yyfree( yyg->yy_start_stack , yyscanner ); |
2383 | 440 | yyg->yy_start_stack = NULL; |
2384 | | |
2385 | | /* Reset the globals. This is important in a non-reentrant scanner so the next time |
2386 | | * yylex() is called, initialization will occur. */ |
2387 | 440 | yy_init_globals( yyscanner); |
2388 | | |
2389 | | /* Destroy the main struct (reentrant only). */ |
2390 | 440 | yyfree ( yyscanner , yyscanner ); |
2391 | 440 | yyscanner = NULL; |
2392 | 440 | return 0; |
2393 | 440 | } |
2394 | | |
2395 | | /* |
2396 | | * Internal utility routines. |
2397 | | */ |
2398 | | |
2399 | | #ifndef yytext_ptr |
2400 | | static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) |
2401 | | { |
2402 | | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2403 | | (void)yyg; |
2404 | | |
2405 | | int i; |
2406 | | for ( i = 0; i < n; ++i ) |
2407 | | s1[i] = s2[i]; |
2408 | | } |
2409 | | #endif |
2410 | | |
2411 | | #ifdef YY_NEED_STRLEN |
2412 | | static int yy_flex_strlen (const char * s , yyscan_t yyscanner) |
2413 | | { |
2414 | | int n; |
2415 | | for ( n = 0; s[n]; ++n ) |
2416 | | ; |
2417 | | |
2418 | | return n; |
2419 | | } |
2420 | | #endif |
2421 | | |
2422 | | void *yyalloc (yy_size_t size , yyscan_t yyscanner) |
2423 | 1.76k | { |
2424 | 1.76k | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2425 | 1.76k | (void)yyg; |
2426 | 1.76k | return malloc(size); |
2427 | 1.76k | } |
2428 | | |
2429 | | void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) |
2430 | 0 | { |
2431 | 0 | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2432 | 0 | (void)yyg; |
2433 | | |
2434 | | /* The cast to (char *) in the following accommodates both |
2435 | | * implementations that use char* generic pointers, and those |
2436 | | * that use void* generic pointers. It works with the latter |
2437 | | * because both ANSI C and C++ allow castless assignment from |
2438 | | * any pointer type to void*, and deal with argument conversions |
2439 | | * as though doing an assignment. |
2440 | | */ |
2441 | 0 | return realloc(ptr, size); |
2442 | 0 | } |
2443 | | |
2444 | | void yyfree (void * ptr , yyscan_t yyscanner) |
2445 | 2.20k | { |
2446 | 2.20k | struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; |
2447 | 2.20k | (void)yyg; |
2448 | 2.20k | free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ |
2449 | 2.20k | } |
2450 | | |
2451 | | #define YYTABLES_NAME "yytables" |
2452 | | |
2453 | | #line 215 "hex_lexer.l" |
2454 | | |
2455 | | |
2456 | | // |
2457 | | // yyfatal (actually named hex_yyfatal because of the '%option prefix="hex_yy"' |
2458 | | // directive) is called when a fatal error occurs in the parser. When this |
2459 | | // happens we are deep inside the parsing logic generated by flex/bison and |
2460 | | // the only way to exit gracefully from there is using setjmp/longjmp. |
2461 | | // |
2462 | | void yyfatal( |
2463 | | yyscan_t yyscanner, |
2464 | | const char *error_message) |
2465 | 0 | { |
2466 | 0 | jmp_buf* recovery_trampoline = (jmp_buf*) yr_thread_storage_get_value( |
2467 | 0 | &yr_yyfatal_trampoline_tls); |
2468 | | |
2469 | | // Never returns. |
2470 | 0 | longjmp(*recovery_trampoline, 1); |
2471 | 0 | } |
2472 | | |
2473 | | void yyerror( |
2474 | | yyscan_t yyscanner, |
2475 | | HEX_LEX_ENVIRONMENT* lex_env, |
2476 | | const char *error_message) |
2477 | 336 | { |
2478 | | // if lex_env->last_error was set to some error code before |
2479 | | // don't overwrite it, we are interested in the first error, not in |
2480 | | // subsequent errors like "syntax error, unexpected $end" caused by |
2481 | | // early parser termination. |
2482 | | |
2483 | 336 | if (lex_env->last_error == ERROR_SUCCESS) |
2484 | 272 | { |
2485 | 272 | lex_env->last_error = ERROR_INVALID_HEX_STRING; |
2486 | | |
2487 | 272 | strlcpy( |
2488 | 272 | lex_env->last_error_message, |
2489 | 272 | error_message, |
2490 | 272 | sizeof(lex_env->last_error_message)); |
2491 | 272 | } |
2492 | 336 | } |
2493 | | |
2494 | | |
2495 | | int yr_parse_hex_string( |
2496 | | const char* hex_string, |
2497 | | RE_AST** re_ast, |
2498 | | RE_ERROR* error) |
2499 | 440 | { |
2500 | 440 | yyscan_t yyscanner; |
2501 | 440 | jmp_buf recovery_trampoline; |
2502 | 440 | HEX_LEX_ENVIRONMENT lex_env; |
2503 | | |
2504 | 440 | lex_env.last_error = ERROR_SUCCESS; |
2505 | 440 | lex_env.inside_or = 0; |
2506 | | |
2507 | 440 | yr_thread_storage_set_value( |
2508 | 440 | &yr_yyfatal_trampoline_tls, |
2509 | 440 | &recovery_trampoline); |
2510 | | |
2511 | 440 | if (setjmp(recovery_trampoline) != 0) |
2512 | 0 | return ERROR_INTERNAL_FATAL_ERROR; |
2513 | | |
2514 | 440 | FAIL_ON_ERROR(yr_re_ast_create(re_ast)); |
2515 | | |
2516 | | // The RE_FLAGS_FAST_REGEXP flag indicates a regular expression can be |
2517 | | // matched by faster algorithm. These regular expressions come from hex |
2518 | | // strings that do not contain alternatives, like in: |
2519 | | // |
2520 | | // { ( 01 02 | 03 04) 05 06 }. |
2521 | | // |
2522 | | // This flag is unset later during parsing if alternatives are used. |
2523 | | |
2524 | 440 | (*re_ast)->flags |= RE_FLAGS_FAST_REGEXP; |
2525 | | |
2526 | | // Set RE_FLAGS_DOT_ALL because in hex strings the "dot" (?? in this case) |
2527 | | // must match all characters including new-line. |
2528 | | |
2529 | 440 | (*re_ast)->flags |= RE_FLAGS_DOT_ALL; |
2530 | | |
2531 | 440 | if (yylex_init(&yyscanner) != 0) |
2532 | 0 | { |
2533 | 0 | yr_re_ast_destroy(*re_ast); |
2534 | 0 | *re_ast = NULL; |
2535 | 0 | return ERROR_INSUFFICIENT_MEMORY; |
2536 | 0 | } |
2537 | | |
2538 | 440 | yyset_extra(*re_ast, yyscanner); |
2539 | 440 | yy_scan_string(hex_string, yyscanner); |
2540 | 440 | yyparse(yyscanner, &lex_env); |
2541 | 440 | yylex_destroy(yyscanner); |
2542 | | |
2543 | 440 | if (lex_env.last_error != ERROR_SUCCESS) |
2544 | 272 | { |
2545 | 272 | strlcpy(error->message, lex_env.last_error_message, sizeof(error->message)); |
2546 | 272 | return lex_env.last_error; |
2547 | 272 | } |
2548 | | |
2549 | 168 | return ERROR_SUCCESS; |
2550 | 440 | } |
2551 | | |