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