Browse code

CMake: Remove Flex & Bison hard build dependency

Flex and Bison are generally available not not particularly easy to
install and on macOS, the Bison version is relatively ancient and not
compatible. Homebrew doesn't necessarily play nice with Xcode, so to
make CMake builds work on macOS without mandating the use of Homebrew,
our best option is to make Flex & Bison optional.

Flex and Bison generated files will be kept in revision control and will
get re-generated only if you use -DMAINTAINER_MODE=ON which will
introduce the Flex and Bison tool dependencies.

CMake: don't emit fullpath in yara generated source

Autotool's ylwrap script has a hack that prevents the full path of the
bison & flex generated source from being included in the debug line
numbers and in the preprocessor include guard macros. CMake doesn't have
this, so when it sets the output file to the full path, the current
user's path is leaked into the generated source.

Added `%output "yara_grammar.c"` to yara_grammar.y and re-generated the
.c & .h file with this change. This overrides the "FILE" setting used
when generating those line numbers and include guard macro names so that
the path isn't included.

Similarly, added `%option outfile="yara_lexer.c` to yara_lexer.l and
re-generated the .c file with this change. This has the same effect but
for flex so that full filepaths are not emitted into the source.

Revert NEWS.md item regarding Flex, Bison change.

Revert placing yara grammar/lexer files in win32 compat.

Micah Snyder (micasnyd) authored on 2020/08/31 08:38:42
Showing 13 changed files
... ...
@@ -65,11 +65,12 @@ find_package(PkgConfig QUIET)
65 65
 # Find Build Tools
66 66
 #
67 67
 
68
-# Bison, Flex required to build Yara module for libclamav.
69
-find_package(BISON REQUIRED)
70
-find_package(FLEX  REQUIRED)
71 68
 if(MAINTAINER_MODE)
72
-    find_package(GPERF REQUIRED)
69
+    # Bison, Flex required to build Yara module for libclamav.
70
+    find_package(BISON REQUIRED)
71
+    find_package(FLEX  REQUIRED)
72
+    # TODO: Gperf required to generate JS-normalization code.
73
+    # find_package(GPERF REQUIRED)
73 74
 endif()
74 75
 
75 76
 #
... ...
@@ -18,7 +18,7 @@ _Known Issues / To-do:_
18 18
   - The built-in LLVM runtime is not supported in the CMake tooling with no
19 19
     plans to add support. It will likely be removed when system-LLVM support
20 20
     is updated.
21
-- Complete the MAINTAINER_MODE option to generate files with GPerf.
21
+- Complete the MAINTAINER_MODE option to generate jsparse files with GPerf.
22 22
 
23 23
 - [Installation Instructions](#installation-instructions)
24 24
   - [CMake Basics](#cmake-basics)
... ...
@@ -244,6 +244,11 @@ cmake --build . --config Debug
244 244
 
245 245
   _Default: `ON`_
246 246
 
247
+- `MAINTAINER_MODE`: Generate Yara lexer and grammar C source with Flex & Bison.
248
+  TODO: Also generate JS parse source with Gperf.
249
+
250
+  _Default: `OFF`_
251
+
247 252
 - `SYSTEMD_UNIT_DIR`: Install systemd service files to a specific directory.
248 253
   This will fail the build if systemd not found.
249 254
 
... ...
@@ -209,10 +209,6 @@ ClamAV 0.103.0 includes the following improvements and changes.
209 209
   you compile ClamAV, run `autogen.sh`.
210 210
   Users building with Autotools from the release tarball should be unaffected.
211 211
 
212
-- Flex and Bison are now required in order to build from a Git clone.
213
-  Flex and Bison are also required to build with CMake.
214
-  Users building with Autotools from the release tarball should be unaffected.
215
-
216 212
 ### Acknowledgements
217 213
 
218 214
 The ClamAV team thanks the following individuals for their code submissions:
... ...
@@ -103,11 +103,13 @@ target_link_libraries( lzma_sdk
103 103
         PCRE2::pcre2
104 104
         JSONC::jsonc )
105 105
 
106
-bison_target( yara_grammar
107
-    yara_grammar.y ${CMAKE_CURRENT_BINARY_DIR}/yara_grammar.c )
108
-flex_target( yara_lexer
109
-    yara_lexer.l ${CMAKE_CURRENT_BINARY_DIR}/yara_lexer.c )
110
-add_flex_bison_dependency(yara_lexer yara_grammar)
106
+if(MAINTAINER_MODE)
107
+    bison_target( yara_grammar
108
+        yara_grammar.y ${CMAKE_CURRENT_SOURCE_DIR}/yara_grammar.c )
109
+    flex_target( yara_lexer
110
+        yara_lexer.l ${CMAKE_CURRENT_SOURCE_DIR}/yara_lexer.c )
111
+    add_flex_bison_dependency(yara_lexer yara_grammar)
112
+endif()
111 113
 
112 114
 add_library( yara OBJECT )
113 115
 target_sources( yara
... ...
@@ -126,6 +128,19 @@ target_sources( yara
126 126
         yara_hash.h
127 127
         yara_exec.h
128 128
         yara_parser.h )
129
+
130
+if(MAINTAINER_MODE)
131
+    target_sources( yara
132
+        PRIVATE
133
+            ${BISON_yara_grammar_OUTPUTS}
134
+            ${FLEX_yara_lexer_OUTPUTS} )
135
+else()
136
+    target_sources( yara
137
+        PRIVATE
138
+            yara_grammar.c
139
+            yara_lexer.c )
140
+endif()
141
+
129 142
 target_include_directories( yara
130 143
     PRIVATE
131 144
         ${CMAKE_BINARY_DIR}
132 145
new file mode 100644
... ...
@@ -0,0 +1,3802 @@
0
+/* A Bison parser, made by GNU Bison 3.5.1.  */
1
+
2
+/* Bison implementation for Yacc-like parsers in C
3
+
4
+   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
5
+   Inc.
6
+
7
+   This program is free software: you can redistribute it and/or modify
8
+   it under the terms of the GNU General Public License as published by
9
+   the Free Software Foundation, either version 3 of the License, or
10
+   (at your option) any later version.
11
+
12
+   This program is distributed in the hope that it will be useful,
13
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+   GNU General Public License for more details.
16
+
17
+   You should have received a copy of the GNU General Public License
18
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
+
20
+/* As a special exception, you may create a larger work that contains
21
+   part or all of the Bison parser skeleton and distribute that work
22
+   under terms of your choice, so long as that work isn't itself a
23
+   parser generator using the skeleton or a modified version thereof
24
+   as a parser skeleton.  Alternatively, if you modify or redistribute
25
+   the parser skeleton itself, you may (at your option) remove this
26
+   special exception, which will cause the skeleton and the resulting
27
+   Bison output files to be licensed under the GNU General Public
28
+   License without this special exception.
29
+
30
+   This special exception was added by the Free Software Foundation in
31
+   version 2.2 of Bison.  */
32
+
33
+/* C LALR(1) parser skeleton written by Richard Stallman, by
34
+   simplifying the original so-called "semantic" parser.  */
35
+
36
+/* All symbols defined below should begin with yy or YY, to avoid
37
+   infringing on user name space.  This should be done even for local
38
+   variables, as they might otherwise be expanded by user macros.
39
+   There are some unavoidable exceptions within include files to
40
+   define necessary library symbols; they are noted "INFRINGES ON
41
+   USER NAME SPACE" below.  */
42
+
43
+/* Undocumented macros, especially those whose name start with YY_,
44
+   are private implementation details.  Do not rely on them.  */
45
+
46
+/* Identify Bison output.  */
47
+#define YYBISON 1
48
+
49
+/* Bison version.  */
50
+#define YYBISON_VERSION "3.5.1"
51
+
52
+/* Skeleton name.  */
53
+#define YYSKELETON_NAME "yacc.c"
54
+
55
+/* Pure parsers.  */
56
+#define YYPURE 1
57
+
58
+/* Push parsers.  */
59
+#define YYPUSH 0
60
+
61
+/* Pull parsers.  */
62
+#define YYPULL 1
63
+
64
+
65
+/* Substitute the variable and function names.  */
66
+#define yyparse         yara_yyparse
67
+#define yylex           yara_yylex
68
+#define yyerror         yara_yyerror
69
+#define yydebug         yara_yydebug
70
+#define yynerrs         yara_yynerrs
71
+
72
+/* First part of user prologue.  */
73
+#line 43 "yara_grammar.y"
74
+
75
+
76
+#include <assert.h>
77
+#include <stdio.h>
78
+#include <stdint.h>
79
+#include <string.h>
80
+#include <limits.h>
81
+#include <stddef.h>
82
+
83
+#ifdef REAL_YARA
84
+#include <yara/utils.h>
85
+#include <yara/compiler.h>
86
+#include <yara/object.h>
87
+#include <yara/sizedstr.h>
88
+#include <yara/exec.h>
89
+#include <yara/error.h>
90
+#include <yara/mem.h>
91
+#include <yara/lexer.h>
92
+#include <yara/parser.h>
93
+#else
94
+#include "yara_clam.h"
95
+#include "yara_compiler.h"
96
+#include "clamav-config.h"
97
+#include "yara_grammar.h"
98
+#include "yara_lexer.h"
99
+#include "yara_parser.h"
100
+#include "yara_exec.h"
101
+#endif
102
+
103
+#define YYERROR_VERBOSE
104
+
105
+#define INTEGER_SET_ENUMERATION   1
106
+#define INTEGER_SET_RANGE         2
107
+
108
+#define EXPRESSION_TYPE_BOOLEAN   1
109
+#define EXPRESSION_TYPE_INTEGER   2
110
+#define EXPRESSION_TYPE_STRING    3
111
+#define EXPRESSION_TYPE_REGEXP    4
112
+
113
+
114
+#define ERROR_IF(x) \
115
+    if (x) \
116
+    { \
117
+      yyerror(yyscanner, compiler, NULL); \
118
+      YYERROR; \
119
+    } \
120
+
121
+#define CHECK_TYPE_WITH_CLEANUP(actual_type, expected_type, op, cleanup) \
122
+    if (actual_type != expected_type) \
123
+    { \
124
+      switch(actual_type) \
125
+      { \
126
+        case EXPRESSION_TYPE_INTEGER: \
127
+          yr_compiler_set_error_extra_info( \
128
+              compiler, "wrong type \"integer\" for " op " operator"); \
129
+          break; \
130
+        case EXPRESSION_TYPE_STRING: \
131
+          yr_compiler_set_error_extra_info( \
132
+              compiler, "wrong type \"string\" for \"" op "\" operator"); \
133
+          break; \
134
+      } \
135
+      compiler->last_result = ERROR_WRONG_TYPE; \
136
+      cleanup; \
137
+      yyerror(yyscanner, compiler, NULL); \
138
+      YYERROR; \
139
+    }
140
+
141
+#define CHECK_TYPE(actual_type, expected_type, op) \
142
+    CHECK_TYPE_WITH_CLEANUP(actual_type, expected_type, op, ) \
143
+
144
+
145
+#define MSG(op)  "wrong type \"string\" for \"" op "\" operator"
146
+
147
+
148
+#line 150 "yara_grammar.c"
149
+
150
+# ifndef YY_CAST
151
+#  ifdef __cplusplus
152
+#   define YY_CAST(Type, Val) static_cast<Type> (Val)
153
+#   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
154
+#  else
155
+#   define YY_CAST(Type, Val) ((Type) (Val))
156
+#   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
157
+#  endif
158
+# endif
159
+# ifndef YY_NULLPTR
160
+#  if defined __cplusplus
161
+#   if 201103L <= __cplusplus
162
+#    define YY_NULLPTR nullptr
163
+#   else
164
+#    define YY_NULLPTR 0
165
+#   endif
166
+#  else
167
+#   define YY_NULLPTR ((void*)0)
168
+#  endif
169
+# endif
170
+
171
+/* Enabling verbose error messages.  */
172
+#ifdef YYERROR_VERBOSE
173
+# undef YYERROR_VERBOSE
174
+# define YYERROR_VERBOSE 1
175
+#else
176
+# define YYERROR_VERBOSE 0
177
+#endif
178
+
179
+/* Use api.header.include to #include this header
180
+   instead of duplicating it here.  */
181
+#ifndef YY_YARA_YY_YARA_GRAMMAR_H_INCLUDED
182
+# define YY_YARA_YY_YARA_GRAMMAR_H_INCLUDED
183
+/* Debug traces.  */
184
+#ifndef YYDEBUG
185
+# define YYDEBUG 0
186
+#endif
187
+#if YYDEBUG
188
+extern int yara_yydebug;
189
+#endif
190
+/* "%code requires" blocks.  */
191
+#line 39 "yara_grammar.y"
192
+
193
+#include "yara_compiler.h"
194
+
195
+#line 197 "yara_grammar.c"
196
+
197
+/* Token type.  */
198
+#ifndef YYTOKENTYPE
199
+# define YYTOKENTYPE
200
+  enum yytokentype
201
+  {
202
+    _RULE_ = 258,
203
+    _PRIVATE_ = 259,
204
+    _GLOBAL_ = 260,
205
+    _META_ = 261,
206
+    _STRINGS_ = 262,
207
+    _CONDITION_ = 263,
208
+    _IDENTIFIER_ = 264,
209
+    _STRING_IDENTIFIER_ = 265,
210
+    _STRING_COUNT_ = 266,
211
+    _STRING_OFFSET_ = 267,
212
+    _STRING_IDENTIFIER_WITH_WILDCARD_ = 268,
213
+    _NUMBER_ = 269,
214
+    _TEXT_STRING_ = 270,
215
+    _HEX_STRING_ = 271,
216
+    _REGEXP_ = 272,
217
+    _ASCII_ = 273,
218
+    _WIDE_ = 274,
219
+    _NOCASE_ = 275,
220
+    _FULLWORD_ = 276,
221
+    _AT_ = 277,
222
+    _FILESIZE_ = 278,
223
+    _ENTRYPOINT_ = 279,
224
+    _ALL_ = 280,
225
+    _ANY_ = 281,
226
+    _IN_ = 282,
227
+    _OF_ = 283,
228
+    _FOR_ = 284,
229
+    _THEM_ = 285,
230
+    _INT8_ = 286,
231
+    _INT16_ = 287,
232
+    _INT32_ = 288,
233
+    _UINT8_ = 289,
234
+    _UINT16_ = 290,
235
+    _UINT32_ = 291,
236
+    _MATCHES_ = 292,
237
+    _CONTAINS_ = 293,
238
+    _IMPORT_ = 294,
239
+    _TRUE_ = 295,
240
+    _FALSE_ = 296,
241
+    _OR_ = 297,
242
+    _AND_ = 298,
243
+    _LT_ = 299,
244
+    _LE_ = 300,
245
+    _GT_ = 301,
246
+    _GE_ = 302,
247
+    _EQ_ = 303,
248
+    _NEQ_ = 304,
249
+    _IS_ = 305,
250
+    _SHIFT_LEFT_ = 306,
251
+    _SHIFT_RIGHT_ = 307,
252
+    _NOT_ = 308
253
+  };
254
+#endif
255
+
256
+/* Value type.  */
257
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
258
+union YYSTYPE
259
+{
260
+#line 219 "yara_grammar.y"
261
+
262
+  SIZED_STRING*   sized_string;
263
+  char*           c_string;
264
+  int8_t          expression_type;
265
+  int64_t         integer;
266
+  YR_STRING*      string;
267
+  YR_META*        meta;
268
+  YR_OBJECT*      object;
269
+
270
+#line 272 "yara_grammar.c"
271
+
272
+};
273
+typedef union YYSTYPE YYSTYPE;
274
+# define YYSTYPE_IS_TRIVIAL 1
275
+# define YYSTYPE_IS_DECLARED 1
276
+#endif
277
+
278
+
279
+
280
+int yara_yyparse (void *yyscanner, YR_COMPILER* compiler);
281
+
282
+#endif /* !YY_YARA_YY_YARA_GRAMMAR_H_INCLUDED  */
283
+
284
+
285
+
286
+#ifdef short
287
+# undef short
288
+#endif
289
+
290
+/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
291
+   <limits.h> and (if available) <stdint.h> are included
292
+   so that the code can choose integer types of a good width.  */
293
+
294
+#ifndef __PTRDIFF_MAX__
295
+# include <limits.h> /* INFRINGES ON USER NAME SPACE */
296
+# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
297
+#  include <stdint.h> /* INFRINGES ON USER NAME SPACE */
298
+#  define YY_STDINT_H
299
+# endif
300
+#endif
301
+
302
+/* Narrow types that promote to a signed type and that can represent a
303
+   signed or unsigned integer of at least N bits.  In tables they can
304
+   save space and decrease cache pressure.  Promoting to a signed type
305
+   helps avoid bugs in integer arithmetic.  */
306
+
307
+#ifdef __INT_LEAST8_MAX__
308
+typedef __INT_LEAST8_TYPE__ yytype_int8;
309
+#elif defined YY_STDINT_H
310
+typedef int_least8_t yytype_int8;
311
+#else
312
+typedef signed char yytype_int8;
313
+#endif
314
+
315
+#ifdef __INT_LEAST16_MAX__
316
+typedef __INT_LEAST16_TYPE__ yytype_int16;
317
+#elif defined YY_STDINT_H
318
+typedef int_least16_t yytype_int16;
319
+#else
320
+typedef short yytype_int16;
321
+#endif
322
+
323
+#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
324
+typedef __UINT_LEAST8_TYPE__ yytype_uint8;
325
+#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
326
+       && UINT_LEAST8_MAX <= INT_MAX)
327
+typedef uint_least8_t yytype_uint8;
328
+#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
329
+typedef unsigned char yytype_uint8;
330
+#else
331
+typedef short yytype_uint8;
332
+#endif
333
+
334
+#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
335
+typedef __UINT_LEAST16_TYPE__ yytype_uint16;
336
+#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
337
+       && UINT_LEAST16_MAX <= INT_MAX)
338
+typedef uint_least16_t yytype_uint16;
339
+#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
340
+typedef unsigned short yytype_uint16;
341
+#else
342
+typedef int yytype_uint16;
343
+#endif
344
+
345
+#ifndef YYPTRDIFF_T
346
+# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
347
+#  define YYPTRDIFF_T __PTRDIFF_TYPE__
348
+#  define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
349
+# elif defined PTRDIFF_MAX
350
+#  ifndef ptrdiff_t
351
+#   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
352
+#  endif
353
+#  define YYPTRDIFF_T ptrdiff_t
354
+#  define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
355
+# else
356
+#  define YYPTRDIFF_T long
357
+#  define YYPTRDIFF_MAXIMUM LONG_MAX
358
+# endif
359
+#endif
360
+
361
+#ifndef YYSIZE_T
362
+# ifdef __SIZE_TYPE__
363
+#  define YYSIZE_T __SIZE_TYPE__
364
+# elif defined size_t
365
+#  define YYSIZE_T size_t
366
+# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
367
+#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
368
+#  define YYSIZE_T size_t
369
+# else
370
+#  define YYSIZE_T unsigned
371
+# endif
372
+#endif
373
+
374
+#define YYSIZE_MAXIMUM                                  \
375
+  YY_CAST (YYPTRDIFF_T,                                 \
376
+           (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \
377
+            ? YYPTRDIFF_MAXIMUM                         \
378
+            : YY_CAST (YYSIZE_T, -1)))
379
+
380
+#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
381
+
382
+/* Stored state numbers (used for stacks). */
383
+typedef yytype_uint8 yy_state_t;
384
+
385
+/* State numbers in computations.  */
386
+typedef int yy_state_fast_t;
387
+
388
+#ifndef YY_
389
+# if defined YYENABLE_NLS && YYENABLE_NLS
390
+#  if ENABLE_NLS
391
+#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
392
+#   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
393
+#  endif
394
+# endif
395
+# ifndef YY_
396
+#  define YY_(Msgid) Msgid
397
+# endif
398
+#endif
399
+
400
+#ifndef YY_ATTRIBUTE_PURE
401
+# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
402
+#  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
403
+# else
404
+#  define YY_ATTRIBUTE_PURE
405
+# endif
406
+#endif
407
+
408
+#ifndef YY_ATTRIBUTE_UNUSED
409
+# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
410
+#  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
411
+# else
412
+#  define YY_ATTRIBUTE_UNUSED
413
+# endif
414
+#endif
415
+
416
+/* Suppress unused-variable warnings by "using" E.  */
417
+#if ! defined lint || defined __GNUC__
418
+# define YYUSE(E) ((void) (E))
419
+#else
420
+# define YYUSE(E) /* empty */
421
+#endif
422
+
423
+#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
424
+/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
425
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                            \
426
+    _Pragma ("GCC diagnostic push")                                     \
427
+    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
428
+    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
429
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
430
+    _Pragma ("GCC diagnostic pop")
431
+#else
432
+# define YY_INITIAL_VALUE(Value) Value
433
+#endif
434
+#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
435
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
436
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END
437
+#endif
438
+#ifndef YY_INITIAL_VALUE
439
+# define YY_INITIAL_VALUE(Value) /* Nothing. */
440
+#endif
441
+
442
+#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
443
+# define YY_IGNORE_USELESS_CAST_BEGIN                          \
444
+    _Pragma ("GCC diagnostic push")                            \
445
+    _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
446
+# define YY_IGNORE_USELESS_CAST_END            \
447
+    _Pragma ("GCC diagnostic pop")
448
+#endif
449
+#ifndef YY_IGNORE_USELESS_CAST_BEGIN
450
+# define YY_IGNORE_USELESS_CAST_BEGIN
451
+# define YY_IGNORE_USELESS_CAST_END
452
+#endif
453
+
454
+
455
+#define YY_ASSERT(E) ((void) (0 && (E)))
456
+
457
+#if ! defined yyoverflow || YYERROR_VERBOSE
458
+
459
+/* The parser invokes alloca or malloc; define the necessary symbols.  */
460
+
461
+# ifdef YYSTACK_USE_ALLOCA
462
+#  if YYSTACK_USE_ALLOCA
463
+#   ifdef __GNUC__
464
+#    define YYSTACK_ALLOC __builtin_alloca
465
+#   elif defined __BUILTIN_VA_ARG_INCR
466
+#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
467
+#   elif defined _AIX
468
+#    define YYSTACK_ALLOC __alloca
469
+#   elif defined _MSC_VER
470
+#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
471
+#    define alloca _alloca
472
+#   else
473
+#    define YYSTACK_ALLOC alloca
474
+#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
475
+#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
476
+      /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
477
+#     ifndef EXIT_SUCCESS
478
+#      define EXIT_SUCCESS 0
479
+#     endif
480
+#    endif
481
+#   endif
482
+#  endif
483
+# endif
484
+
485
+# ifdef YYSTACK_ALLOC
486
+   /* Pacify GCC's 'empty if-body' warning.  */
487
+#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
488
+#  ifndef YYSTACK_ALLOC_MAXIMUM
489
+    /* The OS might guarantee only one guard page at the bottom of the stack,
490
+       and a page size can be as small as 4096 bytes.  So we cannot safely
491
+       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
492
+       to allow for a few compiler-allocated temporary stack slots.  */
493
+#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
494
+#  endif
495
+# else
496
+#  define YYSTACK_ALLOC YYMALLOC
497
+#  define YYSTACK_FREE YYFREE
498
+#  ifndef YYSTACK_ALLOC_MAXIMUM
499
+#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
500
+#  endif
501
+#  if (defined __cplusplus && ! defined EXIT_SUCCESS \
502
+       && ! ((defined YYMALLOC || defined malloc) \
503
+             && (defined YYFREE || defined free)))
504
+#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
505
+#   ifndef EXIT_SUCCESS
506
+#    define EXIT_SUCCESS 0
507
+#   endif
508
+#  endif
509
+#  ifndef YYMALLOC
510
+#   define YYMALLOC malloc
511
+#   if ! defined malloc && ! defined EXIT_SUCCESS
512
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
513
+#   endif
514
+#  endif
515
+#  ifndef YYFREE
516
+#   define YYFREE free
517
+#   if ! defined free && ! defined EXIT_SUCCESS
518
+void free (void *); /* INFRINGES ON USER NAME SPACE */
519
+#   endif
520
+#  endif
521
+# endif
522
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
523
+
524
+
525
+#if (! defined yyoverflow \
526
+     && (! defined __cplusplus \
527
+         || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
528
+
529
+/* A type that is properly aligned for any stack member.  */
530
+union yyalloc
531
+{
532
+  yy_state_t yyss_alloc;
533
+  YYSTYPE yyvs_alloc;
534
+};
535
+
536
+/* The size of the maximum gap between one aligned stack and the next.  */
537
+# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
538
+
539
+/* The size of an array large to enough to hold all stacks, each with
540
+   N elements.  */
541
+# define YYSTACK_BYTES(N) \
542
+     ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
543
+      + YYSTACK_GAP_MAXIMUM)
544
+
545
+# define YYCOPY_NEEDED 1
546
+
547
+/* Relocate STACK from its old location to the new one.  The
548
+   local variables YYSIZE and YYSTACKSIZE give the old and new number of
549
+   elements in the stack, and YYPTR gives the new location of the
550
+   stack.  Advance YYPTR to a properly aligned location for the next
551
+   stack.  */
552
+# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
553
+    do                                                                  \
554
+      {                                                                 \
555
+        YYPTRDIFF_T yynewbytes;                                         \
556
+        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
557
+        Stack = &yyptr->Stack_alloc;                                    \
558
+        yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
559
+        yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \
560
+      }                                                                 \
561
+    while (0)
562
+
563
+#endif
564
+
565
+#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
566
+/* Copy COUNT objects from SRC to DST.  The source and destination do
567
+   not overlap.  */
568
+# ifndef YYCOPY
569
+#  if defined __GNUC__ && 1 < __GNUC__
570
+#   define YYCOPY(Dst, Src, Count) \
571
+      __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
572
+#  else
573
+#   define YYCOPY(Dst, Src, Count)              \
574
+      do                                        \
575
+        {                                       \
576
+          YYPTRDIFF_T yyi;                      \
577
+          for (yyi = 0; yyi < (Count); yyi++)   \
578
+            (Dst)[yyi] = (Src)[yyi];            \
579
+        }                                       \
580
+      while (0)
581
+#  endif
582
+# endif
583
+#endif /* !YYCOPY_NEEDED */
584
+
585
+/* YYFINAL -- State number of the termination state.  */
586
+#define YYFINAL  2
587
+/* YYLAST -- Last index in YYTABLE.  */
588
+#define YYLAST   433
589
+
590
+/* YYNTOKENS -- Number of terminals.  */
591
+#define YYNTOKENS  74
592
+/* YYNNTS -- Number of nonterminals.  */
593
+#define YYNNTS  35
594
+/* YYNRULES -- Number of rules.  */
595
+#define YYNRULES  115
596
+/* YYNSTATES -- Number of states.  */
597
+#define YYNSTATES  216
598
+
599
+#define YYUNDEFTOK  2
600
+#define YYMAXUTOK   309
601
+
602
+
603
+/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
604
+   as returned by yylex, with out-of-bounds checking.  */
605
+#define YYTRANSLATE(YYX)                                                \
606
+  (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
607
+
608
+/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
609
+   as returned by yylex.  */
610
+static const yytype_int8 yytranslate[] =
611
+{
612
+       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
613
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
614
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
615
+       2,     2,     2,     2,     2,     2,     2,    60,    44,     2,
616
+      71,    72,    58,    56,    73,    57,    68,     2,     2,     2,
617
+       2,     2,     2,     2,     2,     2,     2,     2,    66,     2,
618
+       2,    67,     2,     2,     2,     2,     2,     2,     2,     2,
619
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
620
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
621
+       2,    69,    59,    70,    46,     2,     2,     2,     2,     2,
622
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
623
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
624
+       2,     2,     2,    64,    45,    65,    62,     2,     2,     2,
625
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
626
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
627
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
628
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
629
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
630
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
631
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
632
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
633
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
634
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
635
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
636
+       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
637
+       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
638
+       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
639
+      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
640
+      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
641
+      35,    36,    37,    38,    39,    40,    41,    42,    43,    47,
642
+      48,    49,    50,    51,    52,    53,    54,    55,    61,    63
643
+};
644
+
645
+#if YYDEBUG
646
+  /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
647
+static const yytype_int16 yyrline[] =
648
+{
649
+       0,   233,   233,   234,   235,   236,   237,   242,   254,   273,
650
+     276,   306,   310,   338,   343,   344,   349,   350,   356,   359,
651
+     379,   396,   435,   436,   441,   457,   470,   483,   500,   501,
652
+     506,   520,   519,   536,   553,   554,   559,   560,   561,   562,
653
+     567,   652,   702,   725,   765,   768,   790,   823,   870,   888,
654
+     897,   906,   921,   935,   948,   965,   981,  1015,   980,  1126,
655
+    1125,  1201,  1207,  1213,  1219,  1227,  1236,  1245,  1254,  1263,
656
+    1290,  1317,  1344,  1348,  1356,  1357,  1362,  1384,  1396,  1412,
657
+    1411,  1417,  1429,  1430,  1435,  1440,  1449,  1450,  1457,  1468,
658
+    1472,  1481,  1496,  1507,  1518,  1529,  1540,  1551,  1562,  1571,
659
+    1598,  1611,  1626,  1648,  1683,  1692,  1701,  1710,  1719,  1728,
660
+    1737,  1746,  1755,  1763,  1772,  1781
661
+};
662
+#endif
663
+
664
+#if YYDEBUG || YYERROR_VERBOSE || 0
665
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
666
+   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
667
+static const char *const yytname[] =
668
+{
669
+  "$end", "error", "$undefined", "_RULE_", "_PRIVATE_", "_GLOBAL_",
670
+  "_META_", "_STRINGS_", "_CONDITION_", "_IDENTIFIER_",
671
+  "_STRING_IDENTIFIER_", "_STRING_COUNT_", "_STRING_OFFSET_",
672
+  "_STRING_IDENTIFIER_WITH_WILDCARD_", "_NUMBER_", "_TEXT_STRING_",
673
+  "_HEX_STRING_", "_REGEXP_", "_ASCII_", "_WIDE_", "_NOCASE_",
674
+  "_FULLWORD_", "_AT_", "_FILESIZE_", "_ENTRYPOINT_", "_ALL_", "_ANY_",
675
+  "_IN_", "_OF_", "_FOR_", "_THEM_", "_INT8_", "_INT16_", "_INT32_",
676
+  "_UINT8_", "_UINT16_", "_UINT32_", "_MATCHES_", "_CONTAINS_", "_IMPORT_",
677
+  "_TRUE_", "_FALSE_", "_OR_", "_AND_", "'&'", "'|'", "'^'", "_LT_",
678
+  "_LE_", "_GT_", "_GE_", "_EQ_", "_NEQ_", "_IS_", "_SHIFT_LEFT_",
679
+  "_SHIFT_RIGHT_", "'+'", "'-'", "'*'", "'\\\\'", "'%'", "_NOT_", "'~'",
680
+  "\"include\"", "'{'", "'}'", "':'", "'='", "'.'", "'['", "']'", "'('",
681
+  "')'", "','", "$accept", "rules", "import", "rule", "meta", "strings",
682
+  "condition", "rule_modifiers", "rule_modifier", "tags", "tag_list",
683
+  "meta_declarations", "meta_declaration", "string_declarations",
684
+  "string_declaration", "$@1", "string_modifiers", "string_modifier",
685
+  "identifier", "arguments_list", "regexp", "boolean_expression",
686
+  "expression", "$@2", "$@3", "$@4", "integer_set", "range",
687
+  "integer_enumeration", "string_set", "$@5", "string_enumeration",
688
+  "string_enumeration_item", "for_expression", "primary_expression", YY_NULLPTR
689
+};
690
+#endif
691
+
692
+# ifdef YYPRINT
693
+/* YYTOKNUM[NUM] -- (External) token number corresponding to the
694
+   (internal) symbol number NUM (which must be that of a token).  */
695
+static const yytype_int16 yytoknum[] =
696
+{
697
+       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
698
+     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
699
+     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
700
+     285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
701
+     295,   296,   297,   298,    38,   124,    94,   299,   300,   301,
702
+     302,   303,   304,   305,   306,   307,    43,    45,    42,    92,
703
+      37,   308,   126,   309,   123,   125,    58,    61,    46,    91,
704
+      93,    40,    41,    44
705
+};
706
+# endif
707
+
708
+#define YYPACT_NINF (-66)
709
+
710
+#define yypact_value_is_default(Yyn) \
711
+  ((Yyn) == YYPACT_NINF)
712
+
713
+#define YYTABLE_NINF (-87)
714
+
715
+#define yytable_value_is_error(Yyn) \
716
+  0
717
+
718
+  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
719
+     STATE-NUM.  */
720
+static const yytype_int16 yypact[] =
721
+{
722
+     -66,     6,   -66,   -59,     0,   -66,   -66,    59,   -66,   -66,
723
+     -66,     9,   -66,   -66,   -66,   -44,    16,   -24,   -66,    49,
724
+      81,   -66,    26,    88,    92,    43,   115,    54,    92,   -66,
725
+     116,    63,    66,    -2,   -66,    75,   116,   -66,    79,   -66,
726
+     -66,   -66,   -66,   -66,    82,   -66,   -66,    -8,   -66,    83,
727
+     -66,   -66,   -66,   -66,   -66,   -66,   -66,   113,    72,    80,
728
+      84,    94,    96,    97,   -66,   -66,    79,   168,    79,   -42,
729
+     -66,    57,   -66,   125,   205,   -66,   -66,   137,   168,    98,
730
+     168,   168,    -7,   372,   168,   168,   168,   168,   168,   168,
731
+     -66,   -66,    57,   100,   169,   161,   168,    79,    79,    79,
732
+     -29,   156,   168,   168,   168,   168,   168,   168,   168,   168,
733
+     168,   168,   168,   168,   168,   168,   168,   168,   168,   168,
734
+      36,   -66,   372,   168,   -66,   338,   222,   149,   -29,   229,
735
+     251,   258,   280,   287,   309,   -66,   -66,   -66,   345,    34,
736
+      74,   135,   -66,   -66,   -66,   -66,   -66,   372,   104,   104,
737
+     104,   372,   372,   372,   372,   372,   372,   372,   -23,   -23,
738
+      25,    25,   -66,   -66,   -66,   -66,   -66,   -66,   -66,   -66,
739
+      36,   365,   -66,   -66,   120,   -66,   -66,   -66,   -66,   -66,
740
+     -66,   -66,   -66,    79,    -5,   119,   110,   -66,    74,   -66,
741
+     -66,    60,   -66,   168,   168,   122,   -66,   118,   -66,    -5,
742
+     316,    62,   365,   -66,    79,   -66,   -66,   -66,   168,   123,
743
+     -26,   372,    79,   -66,   -19,   -66
744
+};
745
+
746
+  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
747
+     Performed when YYTABLE does not specify something else to do.  Zero
748
+     means the default is an error.  */
749
+static const yytype_int8 yydefact[] =
750
+{
751
+       2,     0,     1,    14,     0,     4,     3,     0,     6,     5,
752
+       7,     0,    16,    17,    15,    18,     0,     0,    20,    19,
753
+       9,    21,     0,    11,     0,     0,     0,     0,    10,    22,
754
+       0,     0,     0,     0,    23,     0,    12,    28,     0,     8,
755
+      25,    24,    26,    27,    31,    29,    40,    53,   100,   102,
756
+      98,    99,    47,    90,    91,    87,    88,     0,     0,     0,
757
+       0,     0,     0,     0,    49,    50,     0,     0,     0,   103,
758
+     115,    13,    48,     0,    72,    34,    33,     0,     0,     0,
759
+       0,     0,     0,    86,     0,     0,     0,     0,     0,     0,
760
+      62,   112,     0,    48,    72,     0,     0,    44,     0,     0,
761
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
762
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
763
+      30,    34,    54,     0,    55,     0,     0,     0,     0,     0,
764
+       0,     0,     0,     0,     0,    73,    89,    41,     0,     0,
765
+      45,    64,    63,    81,    79,    61,    51,    52,   110,   111,
766
+     109,    65,    67,    66,    68,    69,    71,    70,   113,   114,
767
+     104,   105,   106,   107,   108,    37,    36,    38,    39,    35,
768
+      32,     0,   101,    56,     0,    92,    93,    94,    95,    96,
769
+      97,    42,    43,     0,     0,     0,     0,    59,    46,    84,
770
+      85,     0,    82,     0,     0,     0,    75,     0,    80,     0,
771
+       0,     0,    77,    57,     0,    83,    76,    74,     0,     0,
772
+       0,    78,     0,    60,     0,    58
773
+};
774
+
775
+  /* YYPGOTO[NTERM-NUM].  */
776
+static const yytype_int16 yypgoto[] =
777
+{
778
+     -66,   -66,   -66,   187,   -66,   -66,   -66,   -66,   -66,   -66,
779
+     -66,   -66,   165,   -66,   159,   -66,    77,   -66,   -66,   -66,
780
+      95,   -38,   -65,   -66,   -66,   -66,   -66,    19,   -66,   103,
781
+     -66,   -66,    10,   151,   -37
782
+};
783
+
784
+  /* YYDEFGOTO[NTERM-NUM].  */
785
+static const yytype_int16 yydefgoto[] =
786
+{
787
+      -1,     1,     5,     6,    23,    26,    32,     7,    14,    17,
788
+      19,    28,    29,    36,    37,    77,   120,   169,    69,   139,
789
+      70,    92,    72,   186,   209,   197,   195,   124,   201,   145,
790
+     184,   191,   192,    73,    74
791
+};
792
+
793
+  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
794
+     positive, shift that token.  If negative, reduce the rule whose
795
+     number is the opposite.  If YYTABLE_NINF, syntax error.  */
796
+static const yytype_int16 yytable[] =
797
+{
798
+      71,   143,   127,    93,     8,   189,     2,     3,   190,   -14,
799
+     -14,   -14,    40,    41,    78,    10,    98,    99,    15,    79,
800
+      83,   128,    16,    98,    99,    18,    95,    96,    90,    97,
801
+      91,    94,   140,   115,   116,   117,   118,   119,    42,    43,
802
+      20,   122,   144,   125,   126,     4,   213,   129,   130,   131,
803
+     132,   133,   134,   215,   165,   166,   167,   168,    21,   138,
804
+     141,   142,    11,    12,    13,   147,   148,   149,   150,   151,
805
+     152,   153,   154,   155,   156,   157,   158,   159,   160,   161,
806
+     162,   163,   164,   117,   118,   119,   171,    22,    46,    47,
807
+      48,    49,    24,    50,    51,    25,    52,    75,    76,    98,
808
+      99,    27,    53,    54,    55,    56,   182,   183,    57,    30,
809
+      58,    59,    60,    61,    62,    63,   -48,   -48,   188,    64,
810
+      65,    33,    46,    31,    48,    49,    35,    50,    51,    38,
811
+      52,    39,   198,   199,   207,   208,    53,    54,    55,    56,
812
+      66,    67,    44,    84,    58,    59,    60,    61,    62,    63,
813
+      68,    85,    80,   100,   121,    86,   200,   202,   113,   114,
814
+     115,   116,   117,   118,   119,    87,   210,    88,    89,   123,
815
+     137,   211,   135,    52,   214,    67,   173,    46,    99,    48,
816
+      49,   194,    50,    51,    81,    52,   187,   193,   203,   204,
817
+       9,    53,    54,    34,   212,    45,   146,   -86,   170,    58,
818
+      59,    60,    61,    62,    63,   196,   101,   102,    82,   205,
819
+       0,     0,     0,   103,   104,   105,   106,   107,   108,   109,
820
+     110,   111,   112,   113,   114,   115,   116,   117,   118,   119,
821
+      67,   174,     0,   -86,     0,     0,     0,     0,     0,    81,
822
+       0,   136,   101,   102,     0,     0,     0,     0,     0,   103,
823
+     104,   105,   106,   107,   108,   109,   110,   111,   112,   113,
824
+     114,   115,   116,   117,   118,   119,   103,   104,   105,     0,
825
+       0,     0,     0,   103,   104,   105,   113,   114,   115,   116,
826
+     117,   118,   119,   113,   114,   115,   116,   117,   118,   119,
827
+       0,     0,     0,     0,   136,   103,   104,   105,     0,     0,
828
+       0,   175,   103,   104,   105,   113,   114,   115,   116,   117,
829
+     118,   119,   113,   114,   115,   116,   117,   118,   119,     0,
830
+       0,     0,     0,   176,   103,   104,   105,     0,     0,     0,
831
+     177,   103,   104,   105,   113,   114,   115,   116,   117,   118,
832
+     119,   113,   114,   115,   116,   117,   118,   119,     0,     0,
833
+       0,     0,   178,   103,   104,   105,     0,     0,     0,   179,
834
+     103,   104,   105,   113,   114,   115,   116,   117,   118,   119,
835
+     113,   114,   115,   116,   117,   118,   119,     0,     0,     0,
836
+       0,   180,   103,   104,   105,     0,     0,     0,   206,   103,
837
+     104,   105,   113,   114,   115,   116,   117,   118,   119,   113,
838
+     114,   115,   116,   117,   118,   119,     0,     0,   172,   103,
839
+     104,   105,     0,     0,     0,   181,   103,   104,   105,   113,
840
+     114,   115,   116,   117,   118,   119,   113,   114,   115,   116,
841
+     117,   118,   119,   185
842
+};
843
+
844
+static const yytype_int16 yycheck[] =
845
+{
846
+      38,    30,     9,    68,    63,    10,     0,     1,    13,     3,
847
+       4,     5,    14,    15,    22,    15,    42,    43,     9,    27,
848
+      57,    28,    66,    42,    43,     9,    68,    69,    66,    71,
849
+      67,    68,    97,    56,    57,    58,    59,    60,    40,    41,
850
+      64,    78,    71,    80,    81,    39,    72,    84,    85,    86,
851
+      87,    88,    89,    72,    18,    19,    20,    21,     9,    96,
852
+      98,    99,     3,     4,     5,   102,   103,   104,   105,   106,
853
+     107,   108,   109,   110,   111,   112,   113,   114,   115,   116,
854
+     117,   118,   119,    58,    59,    60,   123,     6,     9,    10,
855
+      11,    12,    66,    14,    15,     7,    17,    15,    16,    42,
856
+      43,     9,    23,    24,    25,    26,    72,    73,    29,    66,
857
+      31,    32,    33,    34,    35,    36,    42,    43,   183,    40,
858
+      41,    67,     9,     8,    11,    12,    10,    14,    15,    66,
859
+      17,    65,    72,    73,    72,    73,    23,    24,    25,    26,
860
+      61,    62,    67,    71,    31,    32,    33,    34,    35,    36,
861
+      71,    71,    69,    28,    17,    71,   193,   194,    54,    55,
862
+      56,    57,    58,    59,    60,    71,   204,    71,    71,    71,
863
+       9,   208,    72,    17,   212,    62,    27,     9,    43,    11,
864
+      12,    71,    14,    15,    71,    17,    66,    68,    66,    71,
865
+       3,    23,    24,    28,    71,    36,   101,    28,   121,    31,
866
+      32,    33,    34,    35,    36,   186,    37,    38,    57,   199,
867
+      -1,    -1,    -1,    44,    45,    46,    47,    48,    49,    50,
868
+      51,    52,    53,    54,    55,    56,    57,    58,    59,    60,
869
+      62,   128,    -1,    28,    -1,    -1,    -1,    -1,    -1,    71,
870
+      -1,    72,    37,    38,    -1,    -1,    -1,    -1,    -1,    44,
871
+      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
872
+      55,    56,    57,    58,    59,    60,    44,    45,    46,    -1,
873
+      -1,    -1,    -1,    44,    45,    46,    54,    55,    56,    57,
874
+      58,    59,    60,    54,    55,    56,    57,    58,    59,    60,
875
+      -1,    -1,    -1,    -1,    72,    44,    45,    46,    -1,    -1,
876
+      -1,    72,    44,    45,    46,    54,    55,    56,    57,    58,
877
+      59,    60,    54,    55,    56,    57,    58,    59,    60,    -1,
878
+      -1,    -1,    -1,    72,    44,    45,    46,    -1,    -1,    -1,
879
+      72,    44,    45,    46,    54,    55,    56,    57,    58,    59,
880
+      60,    54,    55,    56,    57,    58,    59,    60,    -1,    -1,
881
+      -1,    -1,    72,    44,    45,    46,    -1,    -1,    -1,    72,
882
+      44,    45,    46,    54,    55,    56,    57,    58,    59,    60,
883
+      54,    55,    56,    57,    58,    59,    60,    -1,    -1,    -1,
884
+      -1,    72,    44,    45,    46,    -1,    -1,    -1,    72,    44,
885
+      45,    46,    54,    55,    56,    57,    58,    59,    60,    54,
886
+      55,    56,    57,    58,    59,    60,    -1,    -1,    70,    44,
887
+      45,    46,    -1,    -1,    -1,    70,    44,    45,    46,    54,
888
+      55,    56,    57,    58,    59,    60,    54,    55,    56,    57,
889
+      58,    59,    60,    68
890
+};
891
+
892
+  /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
893
+     symbol of state STATE-NUM.  */
894
+static const yytype_int8 yystos[] =
895
+{
896
+       0,    75,     0,     1,    39,    76,    77,    81,    63,    77,
897
+      15,     3,     4,     5,    82,     9,    66,    83,     9,    84,
898
+      64,     9,     6,    78,    66,     7,    79,     9,    85,    86,
899
+      66,     8,    80,    67,    86,    10,    87,    88,    66,    65,
900
+      14,    15,    40,    41,    67,    88,     9,    10,    11,    12,
901
+      14,    15,    17,    23,    24,    25,    26,    29,    31,    32,
902
+      33,    34,    35,    36,    40,    41,    61,    62,    71,    92,
903
+      94,    95,    96,   107,   108,    15,    16,    89,    22,    27,
904
+      69,    71,   107,   108,    71,    71,    71,    71,    71,    71,
905
+      95,   108,    95,    96,   108,    68,    69,    71,    42,    43,
906
+      28,    37,    38,    44,    45,    46,    47,    48,    49,    50,
907
+      51,    52,    53,    54,    55,    56,    57,    58,    59,    60,
908
+      90,    17,   108,    71,   101,   108,   108,     9,    28,   108,
909
+     108,   108,   108,   108,   108,    72,    72,     9,   108,    93,
910
+      96,    95,    95,    30,    71,   103,    94,   108,   108,   108,
911
+     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
912
+     108,   108,   108,   108,   108,    18,    19,    20,    21,    91,
913
+      90,   108,    70,    27,   103,    72,    72,    72,    72,    72,
914
+      72,    70,    72,    73,   104,    68,    97,    66,    96,    10,
915
+      13,   105,   106,    68,    71,   100,   101,    99,    72,    73,
916
+     108,   102,   108,    66,    71,   106,    72,    72,    73,    98,
917
+      95,   108,    71,    72,    95,    72
918
+};
919
+
920
+  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
921
+static const yytype_int8 yyr1[] =
922
+{
923
+       0,    74,    75,    75,    75,    75,    75,    76,    77,    78,
924
+      78,    79,    79,    80,    81,    81,    82,    82,    83,    83,
925
+      84,    84,    85,    85,    86,    86,    86,    86,    87,    87,
926
+      88,    89,    88,    88,    90,    90,    91,    91,    91,    91,
927
+      92,    92,    92,    92,    93,    93,    93,    94,    95,    96,
928
+      96,    96,    96,    96,    96,    96,    97,    98,    96,    99,
929
+      96,    96,    96,    96,    96,    96,    96,    96,    96,    96,
930
+      96,    96,    96,    96,   100,   100,   101,   102,   102,   104,
931
+     103,   103,   105,   105,   106,   106,   107,   107,   107,   108,
932
+     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
933
+     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
934
+     108,   108,   108,   108,   108,   108
935
+};
936
+
937
+  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
938
+static const yytype_int8 yyr2[] =
939
+{
940
+       0,     2,     0,     2,     2,     3,     3,     2,     9,     0,
941
+       3,     0,     3,     3,     0,     2,     1,     1,     0,     2,
942
+       1,     2,     1,     2,     3,     3,     3,     3,     1,     2,
943
+       4,     0,     5,     3,     0,     2,     1,     1,     1,     1,
944
+       1,     3,     4,     4,     0,     1,     3,     1,     1,     1,
945
+       1,     3,     3,     1,     3,     3,     0,     0,    11,     0,
946
+       9,     3,     2,     3,     3,     3,     3,     3,     3,     3,
947
+       3,     3,     1,     3,     3,     1,     6,     1,     3,     0,
948
+       4,     1,     1,     3,     1,     1,     1,     1,     1,     3,
949
+       1,     1,     4,     4,     4,     4,     4,     4,     1,     1,
950
+       1,     4,     1,     1,     3,     3,     3,     3,     3,     3,
951
+       3,     3,     2,     3,     3,     1
952
+};
953
+
954
+
955
+#define yyerrok         (yyerrstatus = 0)
956
+#define yyclearin       (yychar = YYEMPTY)
957
+#define YYEMPTY         (-2)
958
+#define YYEOF           0
959
+
960
+#define YYACCEPT        goto yyacceptlab
961
+#define YYABORT         goto yyabortlab
962
+#define YYERROR         goto yyerrorlab
963
+
964
+
965
+#define YYRECOVERING()  (!!yyerrstatus)
966
+
967
+#define YYBACKUP(Token, Value)                                    \
968
+  do                                                              \
969
+    if (yychar == YYEMPTY)                                        \
970
+      {                                                           \
971
+        yychar = (Token);                                         \
972
+        yylval = (Value);                                         \
973
+        YYPOPSTACK (yylen);                                       \
974
+        yystate = *yyssp;                                         \
975
+        goto yybackup;                                            \
976
+      }                                                           \
977
+    else                                                          \
978
+      {                                                           \
979
+        yyerror (yyscanner, compiler, YY_("syntax error: cannot back up")); \
980
+        YYERROR;                                                  \
981
+      }                                                           \
982
+  while (0)
983
+
984
+/* Error token number */
985
+#define YYTERROR        1
986
+#define YYERRCODE       256
987
+
988
+
989
+
990
+/* Enable debugging if requested.  */
991
+#if YYDEBUG
992
+
993
+# ifndef YYFPRINTF
994
+#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
995
+#  define YYFPRINTF fprintf
996
+# endif
997
+
998
+# define YYDPRINTF(Args)                        \
999
+do {                                            \
1000
+  if (yydebug)                                  \
1001
+    YYFPRINTF Args;                             \
1002
+} while (0)
1003
+
1004
+/* This macro is provided for backward compatibility. */
1005
+#ifndef YY_LOCATION_PRINT
1006
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1007
+#endif
1008
+
1009
+
1010
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
1011
+do {                                                                      \
1012
+  if (yydebug)                                                            \
1013
+    {                                                                     \
1014
+      YYFPRINTF (stderr, "%s ", Title);                                   \
1015
+      yy_symbol_print (stderr,                                            \
1016
+                  Type, Value, yyscanner, compiler); \
1017
+      YYFPRINTF (stderr, "\n");                                           \
1018
+    }                                                                     \
1019
+} while (0)
1020
+
1021
+
1022
+/*-----------------------------------.
1023
+| Print this symbol's value on YYO.  |
1024
+`-----------------------------------*/
1025
+
1026
+static void
1027
+yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, void *yyscanner, YR_COMPILER* compiler)
1028
+{
1029
+  FILE *yyoutput = yyo;
1030
+  YYUSE (yyoutput);
1031
+  YYUSE (yyscanner);
1032
+  YYUSE (compiler);
1033
+  if (!yyvaluep)
1034
+    return;
1035
+# ifdef YYPRINT
1036
+  if (yytype < YYNTOKENS)
1037
+    YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
1038
+# endif
1039
+  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1040
+  YYUSE (yytype);
1041
+  YY_IGNORE_MAYBE_UNINITIALIZED_END
1042
+}
1043
+
1044
+
1045
+/*---------------------------.
1046
+| Print this symbol on YYO.  |
1047
+`---------------------------*/
1048
+
1049
+static void
1050
+yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, void *yyscanner, YR_COMPILER* compiler)
1051
+{
1052
+  YYFPRINTF (yyo, "%s %s (",
1053
+             yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
1054
+
1055
+  yy_symbol_value_print (yyo, yytype, yyvaluep, yyscanner, compiler);
1056
+  YYFPRINTF (yyo, ")");
1057
+}
1058
+
1059
+/*------------------------------------------------------------------.
1060
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1061
+| TOP (included).                                                   |
1062
+`------------------------------------------------------------------*/
1063
+
1064
+static void
1065
+yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
1066
+{
1067
+  YYFPRINTF (stderr, "Stack now");
1068
+  for (; yybottom <= yytop; yybottom++)
1069
+    {
1070
+      int yybot = *yybottom;
1071
+      YYFPRINTF (stderr, " %d", yybot);
1072
+    }
1073
+  YYFPRINTF (stderr, "\n");
1074
+}
1075
+
1076
+# define YY_STACK_PRINT(Bottom, Top)                            \
1077
+do {                                                            \
1078
+  if (yydebug)                                                  \
1079
+    yy_stack_print ((Bottom), (Top));                           \
1080
+} while (0)
1081
+
1082
+
1083
+/*------------------------------------------------.
1084
+| Report that the YYRULE is going to be reduced.  |
1085
+`------------------------------------------------*/
1086
+
1087
+static void
1088
+yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, int yyrule, void *yyscanner, YR_COMPILER* compiler)
1089
+{
1090
+  int yylno = yyrline[yyrule];
1091
+  int yynrhs = yyr2[yyrule];
1092
+  int yyi;
1093
+  YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
1094
+             yyrule - 1, yylno);
1095
+  /* The symbols being reduced.  */
1096
+  for (yyi = 0; yyi < yynrhs; yyi++)
1097
+    {
1098
+      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
1099
+      yy_symbol_print (stderr,
1100
+                       yystos[+yyssp[yyi + 1 - yynrhs]],
1101
+                       &yyvsp[(yyi + 1) - (yynrhs)]
1102
+                                              , yyscanner, compiler);
1103
+      YYFPRINTF (stderr, "\n");
1104
+    }
1105
+}
1106
+
1107
+# define YY_REDUCE_PRINT(Rule)          \
1108
+do {                                    \
1109
+  if (yydebug)                          \
1110
+    yy_reduce_print (yyssp, yyvsp, Rule, yyscanner, compiler); \
1111
+} while (0)
1112
+
1113
+/* Nonzero means print parse trace.  It is left uninitialized so that
1114
+   multiple parsers can coexist.  */
1115
+int yydebug;
1116
+#else /* !YYDEBUG */
1117
+# define YYDPRINTF(Args)
1118
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1119
+# define YY_STACK_PRINT(Bottom, Top)
1120
+# define YY_REDUCE_PRINT(Rule)
1121
+#endif /* !YYDEBUG */
1122
+
1123
+
1124
+/* YYINITDEPTH -- initial size of the parser's stacks.  */
1125
+#ifndef YYINITDEPTH
1126
+# define YYINITDEPTH 200
1127
+#endif
1128
+
1129
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1130
+   if the built-in stack extension method is used).
1131
+
1132
+   Do not make this value too large; the results are undefined if
1133
+   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1134
+   evaluated with infinite-precision integer arithmetic.  */
1135
+
1136
+#ifndef YYMAXDEPTH
1137
+# define YYMAXDEPTH 10000
1138
+#endif
1139
+
1140
+
1141
+#if YYERROR_VERBOSE
1142
+
1143
+# ifndef yystrlen
1144
+#  if defined __GLIBC__ && defined _STRING_H
1145
+#   define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
1146
+#  else
1147
+/* Return the length of YYSTR.  */
1148
+static YYPTRDIFF_T
1149
+yystrlen (const char *yystr)
1150
+{
1151
+  YYPTRDIFF_T yylen;
1152
+  for (yylen = 0; yystr[yylen]; yylen++)
1153
+    continue;
1154
+  return yylen;
1155
+}
1156
+#  endif
1157
+# endif
1158
+
1159
+# ifndef yystpcpy
1160
+#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1161
+#   define yystpcpy stpcpy
1162
+#  else
1163
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1164
+   YYDEST.  */
1165
+static char *
1166
+yystpcpy (char *yydest, const char *yysrc)
1167
+{
1168
+  char *yyd = yydest;
1169
+  const char *yys = yysrc;
1170
+
1171
+  while ((*yyd++ = *yys++) != '\0')
1172
+    continue;
1173
+
1174
+  return yyd - 1;
1175
+}
1176
+#  endif
1177
+# endif
1178
+
1179
+# ifndef yytnamerr
1180
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1181
+   quotes and backslashes, so that it's suitable for yyerror.  The
1182
+   heuristic is that double-quoting is unnecessary unless the string
1183
+   contains an apostrophe, a comma, or backslash (other than
1184
+   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1185
+   null, do not copy; instead, return the length of what the result
1186
+   would have been.  */
1187
+static YYPTRDIFF_T
1188
+yytnamerr (char *yyres, const char *yystr)
1189
+{
1190
+  if (*yystr == '"')
1191
+    {
1192
+      YYPTRDIFF_T yyn = 0;
1193
+      char const *yyp = yystr;
1194
+
1195
+      for (;;)
1196
+        switch (*++yyp)
1197
+          {
1198
+          case '\'':
1199
+          case ',':
1200
+            goto do_not_strip_quotes;
1201
+
1202
+          case '\\':
1203
+            if (*++yyp != '\\')
1204
+              goto do_not_strip_quotes;
1205
+            else
1206
+              goto append;
1207
+
1208
+          append:
1209
+          default:
1210
+            if (yyres)
1211
+              yyres[yyn] = *yyp;
1212
+            yyn++;
1213
+            break;
1214
+
1215
+          case '"':
1216
+            if (yyres)
1217
+              yyres[yyn] = '\0';
1218
+            return yyn;
1219
+          }
1220
+    do_not_strip_quotes: ;
1221
+    }
1222
+
1223
+  if (yyres)
1224
+    return yystpcpy (yyres, yystr) - yyres;
1225
+  else
1226
+    return yystrlen (yystr);
1227
+}
1228
+# endif
1229
+
1230
+/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1231
+   about the unexpected token YYTOKEN for the state stack whose top is
1232
+   YYSSP.
1233
+
1234
+   Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
1235
+   not large enough to hold the message.  In that case, also set
1236
+   *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
1237
+   required number of bytes is too large to store.  */
1238
+static int
1239
+yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
1240
+                yy_state_t *yyssp, int yytoken)
1241
+{
1242
+  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1243
+  /* Internationalized format string. */
1244
+  const char *yyformat = YY_NULLPTR;
1245
+  /* Arguments of yyformat: reported tokens (one for the "unexpected",
1246
+     one per "expected"). */
1247
+  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1248
+  /* Actual size of YYARG. */
1249
+  int yycount = 0;
1250
+  /* Cumulated lengths of YYARG.  */
1251
+  YYPTRDIFF_T yysize = 0;
1252
+
1253
+  /* There are many possibilities here to consider:
1254
+     - If this state is a consistent state with a default action, then
1255
+       the only way this function was invoked is if the default action
1256
+       is an error action.  In that case, don't check for expected
1257
+       tokens because there are none.
1258
+     - The only way there can be no lookahead present (in yychar) is if
1259
+       this state is a consistent state with a default action.  Thus,
1260
+       detecting the absence of a lookahead is sufficient to determine
1261
+       that there is no unexpected or expected token to report.  In that
1262
+       case, just report a simple "syntax error".
1263
+     - Don't assume there isn't a lookahead just because this state is a
1264
+       consistent state with a default action.  There might have been a
1265
+       previous inconsistent state, consistent state with a non-default
1266
+       action, or user semantic action that manipulated yychar.
1267
+     - Of course, the expected token list depends on states to have
1268
+       correct lookahead information, and it depends on the parser not
1269
+       to perform extra reductions after fetching a lookahead from the
1270
+       scanner and before detecting a syntax error.  Thus, state merging
1271
+       (from LALR or IELR) and default reductions corrupt the expected
1272
+       token list.  However, the list is correct for canonical LR with
1273
+       one exception: it will still contain any token that will not be
1274
+       accepted due to an error action in a later state.
1275
+  */
1276
+  if (yytoken != YYEMPTY)
1277
+    {
1278
+      int yyn = yypact[+*yyssp];
1279
+      YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1280
+      yysize = yysize0;
1281
+      yyarg[yycount++] = yytname[yytoken];
1282
+      if (!yypact_value_is_default (yyn))
1283
+        {
1284
+          /* Start YYX at -YYN if negative to avoid negative indexes in
1285
+             YYCHECK.  In other words, skip the first -YYN actions for
1286
+             this state because they are default actions.  */
1287
+          int yyxbegin = yyn < 0 ? -yyn : 0;
1288
+          /* Stay within bounds of both yycheck and yytname.  */
1289
+          int yychecklim = YYLAST - yyn + 1;
1290
+          int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1291
+          int yyx;
1292
+
1293
+          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1294
+            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1295
+                && !yytable_value_is_error (yytable[yyx + yyn]))
1296
+              {
1297
+                if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1298
+                  {
1299
+                    yycount = 1;
1300
+                    yysize = yysize0;
1301
+                    break;
1302
+                  }
1303
+                yyarg[yycount++] = yytname[yyx];
1304
+                {
1305
+                  YYPTRDIFF_T yysize1
1306
+                    = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1307
+                  if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1308
+                    yysize = yysize1;
1309
+                  else
1310
+                    return 2;
1311
+                }
1312
+              }
1313
+        }
1314
+    }
1315
+
1316
+  switch (yycount)
1317
+    {
1318
+# define YYCASE_(N, S)                      \
1319
+      case N:                               \
1320
+        yyformat = S;                       \
1321
+      break
1322
+    default: /* Avoid compiler warnings. */
1323
+      YYCASE_(0, YY_("syntax error"));
1324
+      YYCASE_(1, YY_("syntax error, unexpected %s"));
1325
+      YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1326
+      YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1327
+      YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1328
+      YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1329
+# undef YYCASE_
1330
+    }
1331
+
1332
+  {
1333
+    /* Don't count the "%s"s in the final size, but reserve room for
1334
+       the terminator.  */
1335
+    YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1;
1336
+    if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1337
+      yysize = yysize1;
1338
+    else
1339
+      return 2;
1340
+  }
1341
+
1342
+  if (*yymsg_alloc < yysize)
1343
+    {
1344
+      *yymsg_alloc = 2 * yysize;
1345
+      if (! (yysize <= *yymsg_alloc
1346
+             && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1347
+        *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1348
+      return 1;
1349
+    }
1350
+
1351
+  /* Avoid sprintf, as that infringes on the user's name space.
1352
+     Don't have undefined behavior even if the translation
1353
+     produced a string with the wrong number of "%s"s.  */
1354
+  {
1355
+    char *yyp = *yymsg;
1356
+    int yyi = 0;
1357
+    while ((*yyp = *yyformat) != '\0')
1358
+      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1359
+        {
1360
+          yyp += yytnamerr (yyp, yyarg[yyi++]);
1361
+          yyformat += 2;
1362
+        }
1363
+      else
1364
+        {
1365
+          ++yyp;
1366
+          ++yyformat;
1367
+        }
1368
+  }
1369
+  return 0;
1370
+}
1371
+#endif /* YYERROR_VERBOSE */
1372
+
1373
+/*-----------------------------------------------.
1374
+| Release the memory associated to this symbol.  |
1375
+`-----------------------------------------------*/
1376
+
1377
+static void
1378
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *yyscanner, YR_COMPILER* compiler)
1379
+{
1380
+  YYUSE (yyvaluep);
1381
+  YYUSE (yyscanner);
1382
+  YYUSE (compiler);
1383
+  if (!yymsg)
1384
+    yymsg = "Deleting";
1385
+  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1386
+
1387
+  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1388
+  switch (yytype)
1389
+    {
1390
+    case 9: /* _IDENTIFIER_  */
1391
+#line 210 "yara_grammar.y"
1392
+            { yr_free(((*yyvaluep).c_string)); }
1393
+#line 1395 "yara_grammar.c"
1394
+        break;
1395
+
1396
+    case 10: /* _STRING_IDENTIFIER_  */
1397
+#line 211 "yara_grammar.y"
1398
+            { yr_free(((*yyvaluep).c_string)); }
1399
+#line 1401 "yara_grammar.c"
1400
+        break;
1401
+
1402
+    case 11: /* _STRING_COUNT_  */
1403
+#line 212 "yara_grammar.y"
1404
+            { yr_free(((*yyvaluep).c_string)); }
1405
+#line 1407 "yara_grammar.c"
1406
+        break;
1407
+
1408
+    case 12: /* _STRING_OFFSET_  */
1409
+#line 213 "yara_grammar.y"
1410
+            { yr_free(((*yyvaluep).c_string)); }
1411
+#line 1413 "yara_grammar.c"
1412
+        break;
1413
+
1414
+    case 13: /* _STRING_IDENTIFIER_WITH_WILDCARD_  */
1415
+#line 214 "yara_grammar.y"
1416
+            { yr_free(((*yyvaluep).c_string)); }
1417
+#line 1419 "yara_grammar.c"
1418
+        break;
1419
+
1420
+    case 15: /* _TEXT_STRING_  */
1421
+#line 215 "yara_grammar.y"
1422
+            { yr_free(((*yyvaluep).sized_string)); }
1423
+#line 1425 "yara_grammar.c"
1424
+        break;
1425
+
1426
+    case 16: /* _HEX_STRING_  */
1427
+#line 216 "yara_grammar.y"
1428
+            { yr_free(((*yyvaluep).sized_string)); }
1429
+#line 1431 "yara_grammar.c"
1430
+        break;
1431
+
1432
+    case 17: /* _REGEXP_  */
1433
+#line 217 "yara_grammar.y"
1434
+            { yr_free(((*yyvaluep).sized_string)); }
1435
+#line 1437 "yara_grammar.c"
1436
+        break;
1437
+
1438
+      default:
1439
+        break;
1440
+    }
1441
+  YY_IGNORE_MAYBE_UNINITIALIZED_END
1442
+}
1443
+
1444
+
1445
+
1446
+
1447
+/*----------.
1448
+| yyparse.  |
1449
+`----------*/
1450
+
1451
+int
1452
+yyparse (void *yyscanner, YR_COMPILER* compiler)
1453
+{
1454
+/* The lookahead symbol.  */
1455
+int yychar;
1456
+
1457
+
1458
+/* The semantic value of the lookahead symbol.  */
1459
+/* Default value used for initialization, for pacifying older GCCs
1460
+   or non-GCC compilers.  */
1461
+YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1462
+YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1463
+
1464
+    /* Number of syntax errors so far.  */
1465
+    int yynerrs;
1466
+
1467
+    yy_state_fast_t yystate;
1468
+    /* Number of tokens to shift before error messages enabled.  */
1469
+    int yyerrstatus;
1470
+
1471
+    /* The stacks and their tools:
1472
+       'yyss': related to states.
1473
+       'yyvs': related to semantic values.
1474
+
1475
+       Refer to the stacks through separate pointers, to allow yyoverflow
1476
+       to reallocate them elsewhere.  */
1477
+
1478
+    /* The state stack.  */
1479
+    yy_state_t yyssa[YYINITDEPTH];
1480
+    yy_state_t *yyss;
1481
+    yy_state_t *yyssp;
1482
+
1483
+    /* The semantic value stack.  */
1484
+    YYSTYPE yyvsa[YYINITDEPTH];
1485
+    YYSTYPE *yyvs;
1486
+    YYSTYPE *yyvsp;
1487
+
1488
+    YYPTRDIFF_T yystacksize;
1489
+
1490
+  int yyn;
1491
+  int yyresult;
1492
+  /* Lookahead token as an internal (translated) token number.  */
1493
+  int yytoken = 0;
1494
+  /* The variables used to return semantic value and location from the
1495
+     action routines.  */
1496
+  YYSTYPE yyval;
1497
+
1498
+#if YYERROR_VERBOSE
1499
+  /* Buffer for error messages, and its allocated size.  */
1500
+  char yymsgbuf[128];
1501
+  char *yymsg = yymsgbuf;
1502
+  YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;
1503
+#endif
1504
+
1505
+#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1506
+
1507
+  /* The number of symbols on the RHS of the reduced rule.
1508
+     Keep to zero when no symbol should be popped.  */
1509
+  int yylen = 0;
1510
+
1511
+  yyssp = yyss = yyssa;
1512
+  yyvsp = yyvs = yyvsa;
1513
+  yystacksize = YYINITDEPTH;
1514
+
1515
+  YYDPRINTF ((stderr, "Starting parse\n"));
1516
+
1517
+  yystate = 0;
1518
+  yyerrstatus = 0;
1519
+  yynerrs = 0;
1520
+  yychar = YYEMPTY; /* Cause a token to be read.  */
1521
+  goto yysetstate;
1522
+
1523
+
1524
+/*------------------------------------------------------------.
1525
+| yynewstate -- push a new state, which is found in yystate.  |
1526
+`------------------------------------------------------------*/
1527
+yynewstate:
1528
+  /* In all cases, when you get here, the value and location stacks
1529
+     have just been pushed.  So pushing a state here evens the stacks.  */
1530
+  yyssp++;
1531
+
1532
+
1533
+/*--------------------------------------------------------------------.
1534
+| yysetstate -- set current state (the top of the stack) to yystate.  |
1535
+`--------------------------------------------------------------------*/
1536
+yysetstate:
1537
+  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1538
+  YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1539
+  YY_IGNORE_USELESS_CAST_BEGIN
1540
+  *yyssp = YY_CAST (yy_state_t, yystate);
1541
+  YY_IGNORE_USELESS_CAST_END
1542
+
1543
+  if (yyss + yystacksize - 1 <= yyssp)
1544
+#if !defined yyoverflow && !defined YYSTACK_RELOCATE
1545
+    goto yyexhaustedlab;
1546
+#else
1547
+    {
1548
+      /* Get the current used size of the three stacks, in elements.  */
1549
+      YYPTRDIFF_T yysize = yyssp - yyss + 1;
1550
+
1551
+# if defined yyoverflow
1552
+      {
1553
+        /* Give user a chance to reallocate the stack.  Use copies of
1554
+           these so that the &'s don't force the real ones into
1555
+           memory.  */
1556
+        yy_state_t *yyss1 = yyss;
1557
+        YYSTYPE *yyvs1 = yyvs;
1558
+
1559
+        /* Each stack pointer address is followed by the size of the
1560
+           data in use in that stack, in bytes.  This used to be a
1561
+           conditional around just the two extra args, but that might
1562
+           be undefined if yyoverflow is a macro.  */
1563
+        yyoverflow (YY_("memory exhausted"),
1564
+                    &yyss1, yysize * YYSIZEOF (*yyssp),
1565
+                    &yyvs1, yysize * YYSIZEOF (*yyvsp),
1566
+                    &yystacksize);
1567
+        yyss = yyss1;
1568
+        yyvs = yyvs1;
1569
+      }
1570
+# else /* defined YYSTACK_RELOCATE */
1571
+      /* Extend the stack our own way.  */
1572
+      if (YYMAXDEPTH <= yystacksize)
1573
+        goto yyexhaustedlab;
1574
+      yystacksize *= 2;
1575
+      if (YYMAXDEPTH < yystacksize)
1576
+        yystacksize = YYMAXDEPTH;
1577
+
1578
+      {
1579
+        yy_state_t *yyss1 = yyss;
1580
+        union yyalloc *yyptr =
1581
+          YY_CAST (union yyalloc *,
1582
+                   YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1583
+        if (! yyptr)
1584
+          goto yyexhaustedlab;
1585
+        YYSTACK_RELOCATE (yyss_alloc, yyss);
1586
+        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1587
+# undef YYSTACK_RELOCATE
1588
+        if (yyss1 != yyssa)
1589
+          YYSTACK_FREE (yyss1);
1590
+      }
1591
+# endif
1592
+
1593
+      yyssp = yyss + yysize - 1;
1594
+      yyvsp = yyvs + yysize - 1;
1595
+
1596
+      YY_IGNORE_USELESS_CAST_BEGIN
1597
+      YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1598
+                  YY_CAST (long, yystacksize)));
1599
+      YY_IGNORE_USELESS_CAST_END
1600
+
1601
+      if (yyss + yystacksize - 1 <= yyssp)
1602
+        YYABORT;
1603
+    }
1604
+#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1605
+
1606
+  if (yystate == YYFINAL)
1607
+    YYACCEPT;
1608
+
1609
+  goto yybackup;
1610
+
1611
+
1612
+/*-----------.
1613
+| yybackup.  |
1614
+`-----------*/
1615
+yybackup:
1616
+  /* Do appropriate processing given the current state.  Read a
1617
+     lookahead token if we need one and don't already have one.  */
1618
+
1619
+  /* First try to decide what to do without reference to lookahead token.  */
1620
+  yyn = yypact[yystate];
1621
+  if (yypact_value_is_default (yyn))
1622
+    goto yydefault;
1623
+
1624
+  /* Not known => get a lookahead token if don't already have one.  */
1625
+
1626
+  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1627
+  if (yychar == YYEMPTY)
1628
+    {
1629
+      YYDPRINTF ((stderr, "Reading a token: "));
1630
+      yychar = yylex (&yylval, yyscanner, compiler);
1631
+    }
1632
+
1633
+  if (yychar <= YYEOF)
1634
+    {
1635
+      yychar = yytoken = YYEOF;
1636
+      YYDPRINTF ((stderr, "Now at end of input.\n"));
1637
+    }
1638
+  else
1639
+    {
1640
+      yytoken = YYTRANSLATE (yychar);
1641
+      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1642
+    }
1643
+
1644
+  /* If the proper action on seeing token YYTOKEN is to reduce or to
1645
+     detect an error, take that action.  */
1646
+  yyn += yytoken;
1647
+  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1648
+    goto yydefault;
1649
+  yyn = yytable[yyn];
1650
+  if (yyn <= 0)
1651
+    {
1652
+      if (yytable_value_is_error (yyn))
1653
+        goto yyerrlab;
1654
+      yyn = -yyn;
1655
+      goto yyreduce;
1656
+    }
1657
+
1658
+  /* Count tokens shifted since error; after three, turn off error
1659
+     status.  */
1660
+  if (yyerrstatus)
1661
+    yyerrstatus--;
1662
+
1663
+  /* Shift the lookahead token.  */
1664
+  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1665
+  yystate = yyn;
1666
+  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1667
+  *++yyvsp = yylval;
1668
+  YY_IGNORE_MAYBE_UNINITIALIZED_END
1669
+
1670
+  /* Discard the shifted token.  */
1671
+  yychar = YYEMPTY;
1672
+  goto yynewstate;
1673
+
1674
+
1675
+/*-----------------------------------------------------------.
1676
+| yydefault -- do the default action for the current state.  |
1677
+`-----------------------------------------------------------*/
1678
+yydefault:
1679
+  yyn = yydefact[yystate];
1680
+  if (yyn == 0)
1681
+    goto yyerrlab;
1682
+  goto yyreduce;
1683
+
1684
+
1685
+/*-----------------------------.
1686
+| yyreduce -- do a reduction.  |
1687
+`-----------------------------*/
1688
+yyreduce:
1689
+  /* yyn is the number of a rule to reduce with.  */
1690
+  yylen = yyr2[yyn];
1691
+
1692
+  /* If YYLEN is nonzero, implement the default value of the action:
1693
+     '$$ = $1'.
1694
+
1695
+     Otherwise, the following line sets YYVAL to garbage.
1696
+     This behavior is undocumented and Bison
1697
+     users should not rely upon it.  Assigning to YYVAL
1698
+     unconditionally makes the parser a bit smaller, and it avoids a
1699
+     GCC warning that YYVAL may be used uninitialized.  */
1700
+  yyval = yyvsp[1-yylen];
1701
+
1702
+
1703
+  YY_REDUCE_PRINT (yyn);
1704
+  switch (yyn)
1705
+    {
1706
+  case 7:
1707
+#line 243 "yara_grammar.y"
1708
+      {
1709
+        int result = yr_parser_reduce_import(yyscanner, (yyvsp[0].sized_string));
1710
+
1711
+        yr_free((yyvsp[0].sized_string));
1712
+
1713
+        ERROR_IF(result != ERROR_SUCCESS);
1714
+      }
1715
+#line 1717 "yara_grammar.c"
1716
+    break;
1717
+
1718
+  case 8:
1719
+#line 255 "yara_grammar.y"
1720
+      {
1721
+        int result = yr_parser_reduce_rule_declaration(
1722
+            yyscanner,
1723
+            (yyvsp[-8].integer),
1724
+            (yyvsp[-6].c_string),
1725
+            (yyvsp[-5].c_string),
1726
+            (yyvsp[-2].string),
1727
+            (yyvsp[-3].meta));
1728
+
1729
+        yr_free((yyvsp[-6].c_string));
1730
+
1731
+        ERROR_IF(result != ERROR_SUCCESS);
1732
+      }
1733
+#line 1735 "yara_grammar.c"
1734
+    break;
1735
+
1736
+  case 9:
1737
+#line 273 "yara_grammar.y"
1738
+      {
1739
+        (yyval.meta) = NULL;
1740
+      }
1741
+#line 1743 "yara_grammar.c"
1742
+    break;
1743
+
1744
+  case 10:
1745
+#line 277 "yara_grammar.y"
1746
+      {
1747
+#if REAL_YARA //Meta not supported
1748
+        // Each rule have a list of meta-data info, consisting in a
1749
+        // sequence of YR_META structures. The last YR_META structure does
1750
+        // not represent a real meta-data, it's just a end-of-list marker
1751
+        // identified by a specific type (META_TYPE_NULL). Here we
1752
+        // write the end-of-list marker.
1753
+
1754
+        YR_META null_meta;
1755
+
1756
+        memset(&null_meta, 0xFF, sizeof(YR_META));
1757
+        null_meta.type = META_TYPE_NULL;
1758
+
1759
+        compiler->last_result = yr_arena_write_data(
1760
+            compiler->metas_arena,
1761
+            &null_meta,
1762
+            sizeof(YR_META),
1763
+            NULL);
1764
+
1765
+#endif
1766
+        (yyval.meta) = (yyvsp[0].meta);
1767
+
1768
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
1769
+      }
1770
+#line 1772 "yara_grammar.c"
1771
+    break;
1772
+
1773
+  case 11:
1774
+#line 306 "yara_grammar.y"
1775
+      {
1776
+        (yyval.string) = NULL;
1777
+        compiler->current_rule_strings = (yyval.string);
1778
+      }
1779
+#line 1781 "yara_grammar.c"
1780
+    break;
1781
+
1782
+  case 12:
1783
+#line 311 "yara_grammar.y"
1784
+      {
1785
+        // Each rule have a list of strings, consisting in a sequence
1786
+        // of YR_STRING structures. The last YR_STRING structure does not
1787
+        // represent a real string, it's just a end-of-list marker
1788
+        // identified by a specific flag (STRING_FLAGS_NULL). Here we
1789
+        // write the end-of-list marker.
1790
+
1791
+        YR_STRING null_string;
1792
+
1793
+        memset(&null_string, 0xFF, sizeof(YR_STRING));
1794
+        null_string.g_flags = STRING_GFLAGS_NULL;
1795
+
1796
+        compiler->last_result = yr_arena_write_data(
1797
+            compiler->strings_arena,
1798
+            &null_string,
1799
+            sizeof(YR_STRING),
1800
+            NULL);
1801
+
1802
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
1803
+
1804
+        compiler->current_rule_strings = (yyvsp[0].string);
1805
+        (yyval.string) = (yyvsp[0].string);
1806
+      }
1807
+#line 1809 "yara_grammar.c"
1808
+    break;
1809
+
1810
+  case 14:
1811
+#line 343 "yara_grammar.y"
1812
+                                       { (yyval.integer) = 0;  }
1813
+#line 1815 "yara_grammar.c"
1814
+    break;
1815
+
1816
+  case 15:
1817
+#line 344 "yara_grammar.y"
1818
+                                       { (yyval.integer) = (yyvsp[-1].integer) | (yyvsp[0].integer); }
1819
+#line 1821 "yara_grammar.c"
1820
+    break;
1821
+
1822
+  case 16:
1823
+#line 349 "yara_grammar.y"
1824
+                     { (yyval.integer) = RULE_GFLAGS_PRIVATE; }
1825
+#line 1827 "yara_grammar.c"
1826
+    break;
1827
+
1828
+  case 17:
1829
+#line 350 "yara_grammar.y"
1830
+                     { (yyval.integer) = RULE_GFLAGS_GLOBAL; }
1831
+#line 1833 "yara_grammar.c"
1832
+    break;
1833
+
1834
+  case 18:
1835
+#line 356 "yara_grammar.y"
1836
+      {
1837
+        (yyval.c_string) = NULL;
1838
+      }
1839
+#line 1841 "yara_grammar.c"
1840
+    break;
1841
+
1842
+  case 19:
1843
+#line 360 "yara_grammar.y"
1844
+      {
1845
+#if REAL_YARA //tags not supported
1846
+        // Tags list is represented in the arena as a sequence
1847
+        // of null-terminated strings, the sequence ends with an
1848
+        // additional null character. Here we write the ending null
1849
+        //character. Example: tag1\0tag2\0tag3\0\0
1850
+
1851
+        compiler->last_result = yr_arena_write_string(
1852
+            yyget_extra(yyscanner)->sz_arena, "", NULL);
1853
+
1854
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
1855
+#endif
1856
+
1857
+        (yyval.c_string) = (yyvsp[0].c_string);
1858
+      }
1859
+#line 1861 "yara_grammar.c"
1860
+    break;
1861
+
1862
+  case 20:
1863
+#line 380 "yara_grammar.y"
1864
+      {
1865
+#if REAL_YARA //tags not supported
1866
+        char* identifier;
1867
+
1868
+        compiler->last_result = yr_arena_write_string(
1869
+            yyget_extra(yyscanner)->sz_arena, (yyvsp[0].c_string), &identifier);
1870
+
1871
+#endif
1872
+        yr_free((yyvsp[0].c_string));
1873
+
1874
+#if REAL_YARA //tags not supported
1875
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
1876
+
1877
+        (yyval.c_string) = identifier;
1878
+#endif
1879
+      }
1880
+#line 1882 "yara_grammar.c"
1881
+    break;
1882
+
1883
+  case 21:
1884
+#line 397 "yara_grammar.y"
1885
+      {
1886
+#if REAL_YARA //tags not supported
1887
+        char* tag_name = (yyvsp[-1].c_string);
1888
+        size_t tag_length = tag_name != NULL ? strlen(tag_name) : 0;
1889
+
1890
+        while (tag_length > 0)
1891
+        {
1892
+          if (strcmp(tag_name, (yyvsp[0].c_string)) == 0)
1893
+          {
1894
+            yr_compiler_set_error_extra_info(compiler, tag_name);
1895
+            compiler->last_result = ERROR_DUPLICATE_TAG_IDENTIFIER;
1896
+            break;
1897
+          }
1898
+
1899
+          tag_name = yr_arena_next_address(
1900
+              yyget_extra(yyscanner)->sz_arena,
1901
+              tag_name,
1902
+              tag_length + 1);
1903
+
1904
+          tag_length = tag_name != NULL ? strlen(tag_name) : 0;
1905
+        }
1906
+
1907
+        if (compiler->last_result == ERROR_SUCCESS)
1908
+          compiler->last_result = yr_arena_write_string(
1909
+              yyget_extra(yyscanner)->sz_arena, (yyvsp[0].c_string), NULL);
1910
+
1911
+#endif
1912
+        yr_free((yyvsp[0].c_string));
1913
+
1914
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
1915
+
1916
+        (yyval.c_string) = (yyvsp[-1].c_string);
1917
+      }
1918
+#line 1920 "yara_grammar.c"
1919
+    break;
1920
+
1921
+  case 22:
1922
+#line 435 "yara_grammar.y"
1923
+                                          {  (yyval.meta) = (yyvsp[0].meta); }
1924
+#line 1926 "yara_grammar.c"
1925
+    break;
1926
+
1927
+  case 23:
1928
+#line 436 "yara_grammar.y"
1929
+                                          {  (yyval.meta) = (yyvsp[-1].meta); }
1930
+#line 1932 "yara_grammar.c"
1931
+    break;
1932
+
1933
+  case 24:
1934
+#line 442 "yara_grammar.y"
1935
+      {
1936
+        SIZED_STRING* sized_string = (yyvsp[0].sized_string);
1937
+
1938
+        (yyval.meta) = yr_parser_reduce_meta_declaration(
1939
+            yyscanner,
1940
+            META_TYPE_STRING,
1941
+            (yyvsp[-2].c_string),
1942
+            sized_string->c_string,
1943
+            0);
1944
+
1945
+        yr_free((yyvsp[-2].c_string));
1946
+        yr_free((yyvsp[0].sized_string));
1947
+
1948
+        ERROR_IF((yyval.meta) == NULL);
1949
+      }
1950
+#line 1952 "yara_grammar.c"
1951
+    break;
1952
+
1953
+  case 25:
1954
+#line 458 "yara_grammar.y"
1955
+      {
1956
+        (yyval.meta) = yr_parser_reduce_meta_declaration(
1957
+            yyscanner,
1958
+            META_TYPE_INTEGER,
1959
+            (yyvsp[-2].c_string),
1960
+            NULL,
1961
+            (yyvsp[0].integer));
1962
+
1963
+        yr_free((yyvsp[-2].c_string));
1964
+
1965
+        ERROR_IF((yyval.meta) == NULL);
1966
+      }
1967
+#line 1969 "yara_grammar.c"
1968
+    break;
1969
+
1970
+  case 26:
1971
+#line 471 "yara_grammar.y"
1972
+      {
1973
+        (yyval.meta) = yr_parser_reduce_meta_declaration(
1974
+            yyscanner,
1975
+            META_TYPE_BOOLEAN,
1976
+            (yyvsp[-2].c_string),
1977
+            NULL,
1978
+            TRUE);
1979
+
1980
+        yr_free((yyvsp[-2].c_string));
1981
+
1982
+        ERROR_IF((yyval.meta) == NULL);
1983
+      }
1984
+#line 1986 "yara_grammar.c"
1985
+    break;
1986
+
1987
+  case 27:
1988
+#line 484 "yara_grammar.y"
1989
+      {
1990
+        (yyval.meta) = yr_parser_reduce_meta_declaration(
1991
+            yyscanner,
1992
+            META_TYPE_BOOLEAN,
1993
+            (yyvsp[-2].c_string),
1994
+            NULL,
1995
+            FALSE);
1996
+
1997
+        yr_free((yyvsp[-2].c_string));
1998
+
1999
+        ERROR_IF((yyval.meta) == NULL);
2000
+      }
2001
+#line 2003 "yara_grammar.c"
2002
+    break;
2003
+
2004
+  case 28:
2005
+#line 500 "yara_grammar.y"
2006
+                                              { (yyval.string) = (yyvsp[0].string); }
2007
+#line 2009 "yara_grammar.c"
2008
+    break;
2009
+
2010
+  case 29:
2011
+#line 501 "yara_grammar.y"
2012
+                                              { (yyval.string) = (yyvsp[-1].string); }
2013
+#line 2015 "yara_grammar.c"
2014
+    break;
2015
+
2016
+  case 30:
2017
+#line 507 "yara_grammar.y"
2018
+      {
2019
+        (yyval.string) = yr_parser_reduce_string_declaration(
2020
+            yyscanner,
2021
+            (yyvsp[0].integer),
2022
+            (yyvsp[-3].c_string),
2023
+            (yyvsp[-1].sized_string));
2024
+
2025
+        yr_free((yyvsp[-3].c_string));
2026
+        yr_free((yyvsp[-1].sized_string));
2027
+
2028
+        ERROR_IF((yyval.string) == NULL);
2029
+      }
2030
+#line 2032 "yara_grammar.c"
2031
+    break;
2032
+
2033
+  case 31:
2034
+#line 520 "yara_grammar.y"
2035
+      {
2036
+        compiler->error_line = yyget_lineno(yyscanner);
2037
+      }
2038
+#line 2040 "yara_grammar.c"
2039
+    break;
2040
+
2041
+  case 32:
2042
+#line 524 "yara_grammar.y"
2043
+      {
2044
+        (yyval.string) = yr_parser_reduce_string_declaration(
2045
+            yyscanner,
2046
+            (yyvsp[0].integer) | STRING_GFLAGS_REGEXP,
2047
+            (yyvsp[-4].c_string),
2048
+            (yyvsp[-1].sized_string));
2049
+
2050
+        yr_free((yyvsp[-4].c_string));
2051
+        yr_free((yyvsp[-1].sized_string));
2052
+
2053
+        ERROR_IF((yyval.string) == NULL);
2054
+      }
2055
+#line 2057 "yara_grammar.c"
2056
+    break;
2057
+
2058
+  case 33:
2059
+#line 537 "yara_grammar.y"
2060
+      {
2061
+        (yyval.string) = yr_parser_reduce_string_declaration(
2062
+            yyscanner,
2063
+            STRING_GFLAGS_HEXADECIMAL,
2064
+            (yyvsp[-2].c_string),
2065
+            (yyvsp[0].sized_string));
2066
+
2067
+        yr_free((yyvsp[-2].c_string));
2068
+        yr_free((yyvsp[0].sized_string));
2069
+
2070
+        ERROR_IF((yyval.string) == NULL);
2071
+      }
2072
+#line 2074 "yara_grammar.c"
2073
+    break;
2074
+
2075
+  case 34:
2076
+#line 553 "yara_grammar.y"
2077
+                                          { (yyval.integer) = 0; }
2078
+#line 2080 "yara_grammar.c"
2079
+    break;
2080
+
2081
+  case 35:
2082
+#line 554 "yara_grammar.y"
2083
+                                          { (yyval.integer) = (yyvsp[-1].integer) | (yyvsp[0].integer); }
2084
+#line 2086 "yara_grammar.c"
2085
+    break;
2086
+
2087
+  case 36:
2088
+#line 559 "yara_grammar.y"
2089
+                    { (yyval.integer) = STRING_GFLAGS_WIDE; }
2090
+#line 2092 "yara_grammar.c"
2091
+    break;
2092
+
2093
+  case 37:
2094
+#line 560 "yara_grammar.y"
2095
+                    { (yyval.integer) = STRING_GFLAGS_ASCII; }
2096
+#line 2098 "yara_grammar.c"
2097
+    break;
2098
+
2099
+  case 38:
2100
+#line 561 "yara_grammar.y"
2101
+                    { (yyval.integer) = STRING_GFLAGS_NO_CASE; }
2102
+#line 2104 "yara_grammar.c"
2103
+    break;
2104
+
2105
+  case 39:
2106
+#line 562 "yara_grammar.y"
2107
+                    { (yyval.integer) = STRING_GFLAGS_FULL_WORD; }
2108
+#line 2110 "yara_grammar.c"
2109
+    break;
2110
+
2111
+  case 40:
2112
+#line 568 "yara_grammar.y"
2113
+      {
2114
+        YR_OBJECT* object = NULL;
2115
+        YR_RULE* rule;
2116
+
2117
+        char* id;
2118
+        char* ns = NULL;
2119
+
2120
+        int var_index;
2121
+
2122
+        var_index = yr_parser_lookup_loop_variable(yyscanner, (yyvsp[0].c_string));
2123
+
2124
+        if (var_index >= 0)
2125
+        {
2126
+         compiler->last_result = yr_parser_emit_with_arg(
2127
+            yyscanner,
2128
+            OP_PUSH_M,
2129
+            LOOP_LOCAL_VARS * var_index,
2130
+            NULL);
2131
+
2132
+          (yyval.object) = (YR_OBJECT*) -1;
2133
+        }
2134
+        else
2135
+        {
2136
+          // Search for identifier within the global namespace, where the
2137
+          // externals variables reside.
2138
+          object = (YR_OBJECT*) yr_hash_table_lookup(
2139
+                compiler->objects_table,
2140
+                (yyvsp[0].c_string),
2141
+                NULL);
2142
+          if (object == NULL)
2143
+          {
2144
+            // If not found, search within the current namespace.
2145
+
2146
+            ns = compiler->current_namespace->name;
2147
+            object = (YR_OBJECT*) yr_hash_table_lookup(
2148
+                compiler->objects_table,
2149
+                (yyvsp[0].c_string),
2150
+                ns);
2151
+          }
2152
+
2153
+          if (object != NULL)
2154
+          {
2155
+            compiler->last_result = yr_arena_write_string(
2156
+                compiler->sz_arena,
2157
+                (yyvsp[0].c_string),
2158
+                &id);
2159
+
2160
+            if (compiler->last_result == ERROR_SUCCESS)
2161
+              compiler->last_result = yr_parser_emit_with_arg_reloc(
2162
+                  yyscanner,
2163
+                  OP_OBJ_LOAD,
2164
+                  PTR_TO_UINT64(id),
2165
+                  NULL);
2166
+
2167
+            (yyval.object) = object;
2168
+          }
2169
+          else
2170
+          {
2171
+           rule = (YR_RULE*) yr_hash_table_lookup(
2172
+                compiler->rules_table,
2173
+                (yyvsp[0].c_string),
2174
+                compiler->current_namespace->name);
2175
+            if (rule != NULL)
2176
+            {
2177
+              compiler->last_result = yr_parser_emit_with_arg_reloc(
2178
+                  yyscanner,
2179
+                  OP_PUSH_RULE,
2180
+                  PTR_TO_UINT64(rule),
2181
+                  NULL);
2182
+            }
2183
+            else
2184
+            {
2185
+              yr_compiler_set_error_extra_info(compiler, (yyvsp[0].c_string));
2186
+              compiler->last_result = ERROR_UNDEFINED_IDENTIFIER;
2187
+            }
2188
+
2189
+            (yyval.object) = (YR_OBJECT*) -2;
2190
+          }
2191
+        }
2192
+
2193
+        yr_free((yyvsp[0].c_string));
2194
+
2195
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2196
+      }
2197
+#line 2199 "yara_grammar.c"
2198
+    break;
2199
+
2200
+  case 41:
2201
+#line 653 "yara_grammar.y"
2202
+      {
2203
+        YR_OBJECT* object = (yyvsp[-2].object);
2204
+        YR_OBJECT* field = NULL;
2205
+
2206
+        char* ident;
2207
+
2208
+        if (object != NULL &&
2209
+            object != (YR_OBJECT*) -1 &&    // not a loop variable identifier
2210
+            object != (YR_OBJECT*) -2 &&    // not a rule identifier
2211
+            object->type == OBJECT_TYPE_STRUCTURE)
2212
+        {
2213
+#if REAL_YARA
2214
+         field = yr_object_lookup_field(object, (yyvsp[0].c_string));
2215
+#endif
2216
+          if (field != NULL)
2217
+          {
2218
+            compiler->last_result = yr_arena_write_string(
2219
+              compiler->sz_arena,
2220
+              (yyvsp[0].c_string),
2221
+              &ident);
2222
+
2223
+            if (compiler->last_result == ERROR_SUCCESS)
2224
+              compiler->last_result = yr_parser_emit_with_arg_reloc(
2225
+                  yyscanner,
2226
+                  OP_OBJ_FIELD,
2227
+                  PTR_TO_UINT64(ident),
2228
+                  NULL);
2229
+          }
2230
+          else
2231
+          {
2232
+            yr_compiler_set_error_extra_info(compiler, (yyvsp[0].c_string));
2233
+            compiler->last_result = ERROR_INVALID_FIELD_NAME;
2234
+          }
2235
+        }
2236
+        else
2237
+        {
2238
+          yr_compiler_set_error_extra_info(
2239
+              compiler,
2240
+              object->identifier);
2241
+
2242
+          compiler->last_result = ERROR_NOT_A_STRUCTURE;
2243
+        }
2244
+
2245
+        (yyval.object) = field;
2246
+
2247
+        yr_free((yyvsp[0].c_string));
2248
+
2249
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2250
+      }
2251
+#line 2253 "yara_grammar.c"
2252
+    break;
2253
+
2254
+  case 42:
2255
+#line 703 "yara_grammar.y"
2256
+      {
2257
+        if ((yyvsp[-3].object) != NULL && (yyvsp[-3].object)->type == OBJECT_TYPE_ARRAY)
2258
+        {
2259
+          compiler->last_result = yr_parser_emit(
2260
+              yyscanner,
2261
+              OP_INDEX_ARRAY,
2262
+              NULL);
2263
+
2264
+          (yyval.object) = ((YR_OBJECT_ARRAY*) (yyvsp[-3].object))->items->objects[0];
2265
+        }
2266
+        else
2267
+        {
2268
+          yr_compiler_set_error_extra_info(
2269
+              compiler,
2270
+              (yyvsp[-3].object)->identifier);
2271
+
2272
+          compiler->last_result = ERROR_NOT_AN_ARRAY;
2273
+        }
2274
+
2275
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2276
+      }
2277
+#line 2279 "yara_grammar.c"
2278
+    break;
2279
+
2280
+  case 43:
2281
+#line 726 "yara_grammar.y"
2282
+      {
2283
+        int args_count;
2284
+
2285
+        if ((yyvsp[-3].object) != NULL && (yyvsp[-3].object)->type == OBJECT_TYPE_FUNCTION)
2286
+        {
2287
+          compiler->last_result = yr_parser_check_types(
2288
+              compiler, (YR_OBJECT_FUNCTION*) (yyvsp[-3].object), (yyvsp[-1].c_string));
2289
+
2290
+          if (compiler->last_result == ERROR_SUCCESS)
2291
+          {
2292
+            args_count = strlen((yyvsp[-1].c_string));
2293
+
2294
+            compiler->last_result = yr_parser_emit_with_arg(
2295
+                yyscanner,
2296
+                OP_CALL,
2297
+                args_count,
2298
+                NULL);
2299
+          }
2300
+
2301
+          (yyval.object) = ((YR_OBJECT_FUNCTION*) (yyvsp[-3].object))->return_obj;
2302
+        }
2303
+        else
2304
+        {
2305
+          yr_compiler_set_error_extra_info(
2306
+              compiler,
2307
+              (yyvsp[-3].object)->identifier);
2308
+
2309
+          compiler->last_result = ERROR_NOT_A_FUNCTION;
2310
+        }
2311
+
2312
+        yr_free((yyvsp[-1].c_string));
2313
+
2314
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2315
+      }
2316
+#line 2318 "yara_grammar.c"
2317
+    break;
2318
+
2319
+  case 44:
2320
+#line 765 "yara_grammar.y"
2321
+      {
2322
+        (yyval.c_string) = yr_strdup("");
2323
+      }
2324
+#line 2326 "yara_grammar.c"
2325
+    break;
2326
+
2327
+  case 45:
2328
+#line 769 "yara_grammar.y"
2329
+      {
2330
+        (yyval.c_string) = yr_malloc(MAX_FUNCTION_ARGS + 1);
2331
+
2332
+        switch((yyvsp[0].expression_type))
2333
+        {
2334
+          case EXPRESSION_TYPE_INTEGER:
2335
+            strlcpy((yyval.c_string), "i", MAX_FUNCTION_ARGS);
2336
+            break;
2337
+          case EXPRESSION_TYPE_BOOLEAN:
2338
+            strlcpy((yyval.c_string), "b", MAX_FUNCTION_ARGS);
2339
+            break;
2340
+          case EXPRESSION_TYPE_STRING:
2341
+            strlcpy((yyval.c_string), "s", MAX_FUNCTION_ARGS);
2342
+            break;
2343
+          case EXPRESSION_TYPE_REGEXP:
2344
+            strlcpy((yyval.c_string), "r", MAX_FUNCTION_ARGS);
2345
+            break;
2346
+        }
2347
+
2348
+        ERROR_IF((yyval.c_string) == NULL);
2349
+      }
2350
+#line 2352 "yara_grammar.c"
2351
+    break;
2352
+
2353
+  case 46:
2354
+#line 791 "yara_grammar.y"
2355
+      {
2356
+        if (strlen((yyvsp[-2].c_string)) == MAX_FUNCTION_ARGS)
2357
+        {
2358
+          compiler->last_result = ERROR_TOO_MANY_ARGUMENTS;
2359
+        }
2360
+        else
2361
+        {
2362
+          switch((yyvsp[0].expression_type))
2363
+          {
2364
+            case EXPRESSION_TYPE_INTEGER:
2365
+              strlcat((yyvsp[-2].c_string), "i", MAX_FUNCTION_ARGS);
2366
+              break;
2367
+            case EXPRESSION_TYPE_BOOLEAN:
2368
+              strlcat((yyvsp[-2].c_string), "b", MAX_FUNCTION_ARGS);
2369
+              break;
2370
+            case EXPRESSION_TYPE_STRING:
2371
+              strlcat((yyvsp[-2].c_string), "s", MAX_FUNCTION_ARGS);
2372
+              break;
2373
+            case EXPRESSION_TYPE_REGEXP:
2374
+              strlcat((yyvsp[-2].c_string), "r", MAX_FUNCTION_ARGS);
2375
+              break;
2376
+          }
2377
+        }
2378
+
2379
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2380
+
2381
+        (yyval.c_string) = (yyvsp[-2].c_string);
2382
+      }
2383
+#line 2385 "yara_grammar.c"
2384
+    break;
2385
+
2386
+  case 47:
2387
+#line 824 "yara_grammar.y"
2388
+      {
2389
+#ifdef REAL_YARA
2390
+        SIZED_STRING* sized_string = (yyvsp[0].sized_string);
2391
+        RE* re;
2392
+        RE_ERROR error;
2393
+
2394
+        int re_flags = 0;
2395
+
2396
+        if (sized_string->flags & SIZED_STRING_FLAGS_NO_CASE)
2397
+          re_flags |= RE_FLAGS_NO_CASE;
2398
+
2399
+        if (sized_string->flags & SIZED_STRING_FLAGS_DOT_ALL)
2400
+          re_flags |= RE_FLAGS_DOT_ALL;
2401
+
2402
+        compiler->last_result = yr_re_compile(
2403
+            sized_string->c_string,
2404
+            re_flags,
2405
+            compiler->re_code_arena,
2406
+            &re,
2407
+            &error);
2408
+
2409
+        yr_free((yyvsp[0].sized_string));
2410
+
2411
+        if (compiler->last_result == ERROR_INVALID_REGULAR_EXPRESSION)
2412
+          yr_compiler_set_error_extra_info(compiler, error.message);
2413
+
2414
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2415
+
2416
+        if (compiler->last_result == ERROR_SUCCESS)
2417
+          compiler->last_result = yr_parser_emit_with_arg_reloc(
2418
+              yyscanner,
2419
+              OP_PUSH,
2420
+              PTR_TO_UINT64(re->root_node->forward_code),
2421
+              NULL);
2422
+
2423
+        yr_re_destroy(re);
2424
+
2425
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2426
+#endif
2427
+
2428
+        (yyval.expression_type) = EXPRESSION_TYPE_REGEXP;
2429
+      }
2430
+#line 2432 "yara_grammar.c"
2431
+    break;
2432
+
2433
+  case 48:
2434
+#line 871 "yara_grammar.y"
2435
+      {
2436
+        if ((yyvsp[0].expression_type) == EXPRESSION_TYPE_STRING)
2437
+        {
2438
+          compiler->last_result = yr_parser_emit(
2439
+              yyscanner,
2440
+              OP_SZ_TO_BOOL,
2441
+              NULL);
2442
+
2443
+          ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2444
+        }
2445
+
2446
+
2447
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2448
+      }
2449
+#line 2451 "yara_grammar.c"
2450
+    break;
2451
+
2452
+  case 49:
2453
+#line 889 "yara_grammar.y"
2454
+      {
2455
+        compiler->last_result = yr_parser_emit_with_arg(
2456
+            yyscanner, OP_PUSH, 1, NULL);
2457
+
2458
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2459
+
2460
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2461
+      }
2462
+#line 2464 "yara_grammar.c"
2463
+    break;
2464
+
2465
+  case 50:
2466
+#line 898 "yara_grammar.y"
2467
+      {
2468
+        compiler->last_result = yr_parser_emit_with_arg(
2469
+            yyscanner, OP_PUSH, 0, NULL);
2470
+
2471
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2472
+
2473
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2474
+      }
2475
+#line 2477 "yara_grammar.c"
2476
+    break;
2477
+
2478
+  case 51:
2479
+#line 907 "yara_grammar.y"
2480
+      {
2481
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_STRING, "matches");
2482
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_REGEXP, "matches");
2483
+
2484
+        if (compiler->last_result == ERROR_SUCCESS)
2485
+          compiler->last_result = yr_parser_emit(
2486
+              yyscanner,
2487
+              OP_MATCHES,
2488
+              NULL);
2489
+
2490
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2491
+
2492
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2493
+      }
2494
+#line 2496 "yara_grammar.c"
2495
+    break;
2496
+
2497
+  case 52:
2498
+#line 922 "yara_grammar.y"
2499
+      {
2500
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_STRING, "contains");
2501
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_STRING, "contains");
2502
+
2503
+        compiler->last_result = yr_parser_emit(
2504
+            yyscanner,
2505
+            OP_CONTAINS,
2506
+            NULL);
2507
+
2508
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2509
+
2510
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2511
+      }
2512
+#line 2514 "yara_grammar.c"
2513
+    break;
2514
+
2515
+  case 53:
2516
+#line 936 "yara_grammar.y"
2517
+      {
2518
+        int result = yr_parser_reduce_string_identifier(
2519
+            yyscanner,
2520
+            (yyvsp[0].c_string),
2521
+            OP_STR_FOUND);
2522
+
2523
+        yr_free((yyvsp[0].c_string));
2524
+
2525
+        ERROR_IF(result != ERROR_SUCCESS);
2526
+
2527
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2528
+      }
2529
+#line 2531 "yara_grammar.c"
2530
+    break;
2531
+
2532
+  case 54:
2533
+#line 949 "yara_grammar.y"
2534
+      {
2535
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, "at");
2536
+
2537
+        compiler->last_result = yr_parser_reduce_string_identifier(
2538
+            yyscanner,
2539
+            (yyvsp[-2].c_string),
2540
+            OP_STR_FOUND_AT);
2541
+
2542
+        yr_free((yyvsp[-2].c_string));
2543
+
2544
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2545
+
2546
+        compiler->current_rule_clflags |= RULE_OFFSETS;
2547
+
2548
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2549
+      }
2550
+#line 2552 "yara_grammar.c"
2551
+    break;
2552
+
2553
+  case 55:
2554
+#line 966 "yara_grammar.y"
2555
+      {
2556
+        compiler->last_result = yr_parser_reduce_string_identifier(
2557
+            yyscanner,
2558
+            (yyvsp[-2].c_string),
2559
+            OP_STR_FOUND_IN);
2560
+
2561
+        yr_free((yyvsp[-2].c_string));
2562
+
2563
+        ERROR_IF(compiler->last_result!= ERROR_SUCCESS);
2564
+
2565
+        compiler->current_rule_clflags |= RULE_OFFSETS;
2566
+
2567
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2568
+      }
2569
+#line 2571 "yara_grammar.c"
2570
+    break;
2571
+
2572
+  case 56:
2573
+#line 981 "yara_grammar.y"
2574
+      {
2575
+        int var_index;
2576
+
2577
+        if (compiler->loop_depth == MAX_LOOP_NESTING)
2578
+          compiler->last_result = \
2579
+              ERROR_LOOP_NESTING_LIMIT_EXCEEDED;
2580
+
2581
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2582
+
2583
+        var_index = yr_parser_lookup_loop_variable(
2584
+            yyscanner,
2585
+            (yyvsp[-1].c_string));
2586
+
2587
+        if (var_index >= 0)
2588
+        {
2589
+          yr_compiler_set_error_extra_info(
2590
+              compiler,
2591
+              (yyvsp[-1].c_string));
2592
+
2593
+          compiler->last_result = \
2594
+              ERROR_DUPLICATE_LOOP_IDENTIFIER;
2595
+        }
2596
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2597
+
2598
+        // Push end-of-list marker
2599
+        compiler->last_result = yr_parser_emit_with_arg(
2600
+            yyscanner,
2601
+            OP_PUSH,
2602
+            UNDEFINED,
2603
+            NULL);
2604
+
2605
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2606
+      }
2607
+#line 2609 "yara_grammar.c"
2608
+    break;
2609
+
2610
+  case 57:
2611
+#line 1015 "yara_grammar.y"
2612
+      {
2613
+        int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
2614
+
2615
+        int8_t* addr;
2616
+
2617
+        // Clear counter for number of expressions evaluating
2618
+        // to TRUE.
2619
+        yr_parser_emit_with_arg(
2620
+            yyscanner, OP_CLEAR_M, mem_offset + 1, NULL);
2621
+
2622
+        // Clear iterations counter
2623
+        yr_parser_emit_with_arg(
2624
+            yyscanner, OP_CLEAR_M, mem_offset + 2, NULL);
2625
+
2626
+        if ((yyvsp[-1].integer) == INTEGER_SET_ENUMERATION)
2627
+        {
2628
+          // Pop the first integer
2629
+          yr_parser_emit_with_arg(
2630
+              yyscanner, OP_POP_M, mem_offset, &addr);
2631
+        }
2632
+        else // INTEGER_SET_RANGE
2633
+        {
2634
+          // Pop higher bound of set range
2635
+          yr_parser_emit_with_arg(
2636
+              yyscanner, OP_POP_M, mem_offset + 3, &addr);
2637
+
2638
+          // Pop lower bound of set range
2639
+          yr_parser_emit_with_arg(
2640
+              yyscanner, OP_POP_M, mem_offset, NULL);
2641
+        }
2642
+        compiler->loop_address[compiler->loop_depth] = addr;
2643
+        compiler->loop_identifier[compiler->loop_depth] = (yyvsp[-4].c_string);
2644
+        compiler->loop_depth++;
2645
+      }
2646
+#line 2648 "yara_grammar.c"
2647
+    break;
2648
+
2649
+  case 58:
2650
+#line 1050 "yara_grammar.y"
2651
+      {
2652
+        int mem_offset;
2653
+
2654
+        compiler->loop_depth--;
2655
+        mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
2656
+
2657
+        // The value at the top of the stack is 1 if latest
2658
+        // expression was true or 0 otherwise. Add this value
2659
+        // to the counter for number of expressions evaluating
2660
+        // to true.
2661
+        yr_parser_emit_with_arg(
2662
+            yyscanner, OP_ADD_M, mem_offset + 1, NULL);
2663
+
2664
+        // Increment iterations counter
2665
+        yr_parser_emit_with_arg(
2666
+            yyscanner, OP_INCR_M, mem_offset + 2, NULL);
2667
+
2668
+        if ((yyvsp[-5].integer) == INTEGER_SET_ENUMERATION)
2669
+        {
2670
+          yr_parser_emit_with_arg_reloc(
2671
+              yyscanner,
2672
+              OP_JNUNDEF,
2673
+              PTR_TO_UINT64(
2674
+                  compiler->loop_address[compiler->loop_depth]),
2675
+              NULL);
2676
+        }
2677
+        else // INTEGER_SET_RANGE
2678
+        {
2679
+          // Increment lower bound of integer set
2680
+          yr_parser_emit_with_arg(
2681
+              yyscanner, OP_INCR_M, mem_offset, NULL);
2682
+
2683
+          // Push lower bound of integer set
2684
+          yr_parser_emit_with_arg(
2685
+              yyscanner, OP_PUSH_M, mem_offset, NULL);
2686
+
2687
+          // Push higher bound of integer set
2688
+          yr_parser_emit_with_arg(
2689
+              yyscanner, OP_PUSH_M, mem_offset + 3, NULL);
2690
+
2691
+          // Compare higher bound with lower bound, do loop again
2692
+          // if lower bound is still lower or equal than higher bound
2693
+          yr_parser_emit_with_arg_reloc(
2694
+              yyscanner,
2695
+              OP_JLE,
2696
+              PTR_TO_UINT64(
2697
+                compiler->loop_address[compiler->loop_depth]),
2698
+              NULL);
2699
+
2700
+          yr_parser_emit(yyscanner, OP_POP, NULL);
2701
+          yr_parser_emit(yyscanner, OP_POP, NULL);
2702
+        }
2703
+
2704
+        // Pop end-of-list marker.
2705
+        yr_parser_emit(yyscanner, OP_POP, NULL);
2706
+
2707
+        // At this point the loop quantifier (any, all, 1, 2,..)
2708
+        // is at the top of the stack. Check if the quantifier
2709
+        // is undefined (meaning "all") and replace it with the
2710
+        // iterations counter in that case.
2711
+        yr_parser_emit_with_arg(
2712
+            yyscanner, OP_SWAPUNDEF, mem_offset + 2, NULL);
2713
+
2714
+        // Compare the loop quantifier with the number of
2715
+        // expressions evaluating to TRUE.
2716
+        yr_parser_emit_with_arg(
2717
+            yyscanner, OP_PUSH_M, mem_offset + 1, NULL);
2718
+
2719
+        yr_parser_emit(yyscanner, OP_LE, NULL);
2720
+
2721
+        compiler->loop_identifier[compiler->loop_depth] = NULL;
2722
+        yr_free((yyvsp[-8].c_string));
2723
+
2724
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2725
+      }
2726
+#line 2728 "yara_grammar.c"
2727
+    break;
2728
+
2729
+  case 59:
2730
+#line 1126 "yara_grammar.y"
2731
+      {
2732
+        int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
2733
+        int8_t* addr;
2734
+
2735
+        if (compiler->loop_depth == MAX_LOOP_NESTING)
2736
+          compiler->last_result = \
2737
+            ERROR_LOOP_NESTING_LIMIT_EXCEEDED;
2738
+
2739
+        if (compiler->loop_for_of_mem_offset != -1)
2740
+          compiler->last_result = \
2741
+            ERROR_NESTED_FOR_OF_LOOP;
2742
+
2743
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2744
+
2745
+        yr_parser_emit_with_arg(
2746
+            yyscanner, OP_CLEAR_M, mem_offset + 1, NULL);
2747
+
2748
+        yr_parser_emit_with_arg(
2749
+            yyscanner, OP_CLEAR_M, mem_offset + 2, NULL);
2750
+
2751
+        // Pop the first string.
2752
+        yr_parser_emit_with_arg(
2753
+            yyscanner, OP_POP_M, mem_offset, &addr);
2754
+
2755
+        compiler->loop_for_of_mem_offset = mem_offset;
2756
+        compiler->loop_address[compiler->loop_depth] = addr;
2757
+        compiler->loop_identifier[compiler->loop_depth] = NULL;
2758
+        compiler->loop_depth++;
2759
+      }
2760
+#line 2762 "yara_grammar.c"
2761
+    break;
2762
+
2763
+  case 60:
2764
+#line 1156 "yara_grammar.y"
2765
+      {
2766
+        int mem_offset;
2767
+
2768
+        compiler->loop_depth--;
2769
+        compiler->loop_for_of_mem_offset = -1;
2770
+
2771
+        mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
2772
+
2773
+        // Increment counter by the value returned by the
2774
+        // boolean expression (0 or 1).
2775
+        yr_parser_emit_with_arg(
2776
+            yyscanner, OP_ADD_M, mem_offset + 1, NULL);
2777
+
2778
+        // Increment iterations counter.
2779
+        yr_parser_emit_with_arg(
2780
+            yyscanner, OP_INCR_M, mem_offset + 2, NULL);
2781
+
2782
+        // If next string is not undefined, go back to the
2783
+        // beginning of the loop.
2784
+        yr_parser_emit_with_arg_reloc(
2785
+            yyscanner,
2786
+            OP_JNUNDEF,
2787
+            PTR_TO_UINT64(
2788
+                compiler->loop_address[compiler->loop_depth]),
2789
+            NULL);
2790
+
2791
+        // Pop end-of-list marker.
2792
+        yr_parser_emit(yyscanner, OP_POP, NULL);
2793
+
2794
+        // At this point the loop quantifier (any, all, 1, 2,..)
2795
+        // is at top of the stack. Check if the quantifier is
2796
+        // undefined (meaning "all") and replace it with the
2797
+        // iterations counter in that case.
2798
+        yr_parser_emit_with_arg(
2799
+            yyscanner, OP_SWAPUNDEF, mem_offset + 2, NULL);
2800
+
2801
+        // Compare the loop quantifier with the number of
2802
+        // expressions evaluating to TRUE.
2803
+        yr_parser_emit_with_arg(
2804
+            yyscanner, OP_PUSH_M, mem_offset + 1, NULL);
2805
+
2806
+        yr_parser_emit(yyscanner, OP_LE, NULL);
2807
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2808
+
2809
+      }
2810
+#line 2812 "yara_grammar.c"
2811
+    break;
2812
+
2813
+  case 61:
2814
+#line 1202 "yara_grammar.y"
2815
+      {
2816
+        yr_parser_emit(yyscanner, OP_OF, NULL);
2817
+
2818
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2819
+      }
2820
+#line 2822 "yara_grammar.c"
2821
+    break;
2822
+
2823
+  case 62:
2824
+#line 1208 "yara_grammar.y"
2825
+      {
2826
+        yr_parser_emit(yyscanner, OP_NOT, NULL);
2827
+
2828
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2829
+      }
2830
+#line 2832 "yara_grammar.c"
2831
+    break;
2832
+
2833
+  case 63:
2834
+#line 1214 "yara_grammar.y"
2835
+      {
2836
+        yr_parser_emit(yyscanner, OP_AND, NULL);
2837
+
2838
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2839
+      }
2840
+#line 2842 "yara_grammar.c"
2841
+    break;
2842
+
2843
+  case 64:
2844
+#line 1220 "yara_grammar.y"
2845
+      {
2846
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_BOOLEAN, "or");
2847
+
2848
+        yr_parser_emit(yyscanner, OP_OR, NULL);
2849
+
2850
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2851
+      }
2852
+#line 2854 "yara_grammar.c"
2853
+    break;
2854
+
2855
+  case 65:
2856
+#line 1228 "yara_grammar.y"
2857
+      {
2858
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_INTEGER, "<");
2859
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, "<");
2860
+
2861
+        yr_parser_emit(yyscanner, OP_LT, NULL);
2862
+
2863
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2864
+      }
2865
+#line 2867 "yara_grammar.c"
2866
+    break;
2867
+
2868
+  case 66:
2869
+#line 1237 "yara_grammar.y"
2870
+      {
2871
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_INTEGER, ">");
2872
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, ">");
2873
+
2874
+        yr_parser_emit(yyscanner, OP_GT, NULL);
2875
+
2876
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2877
+      }
2878
+#line 2880 "yara_grammar.c"
2879
+    break;
2880
+
2881
+  case 67:
2882
+#line 1246 "yara_grammar.y"
2883
+      {
2884
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_INTEGER, "<=");
2885
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, "<=");
2886
+
2887
+        yr_parser_emit(yyscanner, OP_LE, NULL);
2888
+
2889
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2890
+      }
2891
+#line 2893 "yara_grammar.c"
2892
+    break;
2893
+
2894
+  case 68:
2895
+#line 1255 "yara_grammar.y"
2896
+      {
2897
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_INTEGER, ">=");
2898
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, ">=");
2899
+
2900
+        yr_parser_emit(yyscanner, OP_GE, NULL);
2901
+
2902
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2903
+      }
2904
+#line 2906 "yara_grammar.c"
2905
+    break;
2906
+
2907
+  case 69:
2908
+#line 1264 "yara_grammar.y"
2909
+      {
2910
+        if ((yyvsp[-2].expression_type) != (yyvsp[0].expression_type))
2911
+        {
2912
+          yr_compiler_set_error_extra_info(
2913
+              compiler, "mismatching types for == operator");
2914
+          compiler->last_result = ERROR_WRONG_TYPE;
2915
+        }
2916
+        else if ((yyvsp[-2].expression_type) == EXPRESSION_TYPE_STRING)
2917
+        {
2918
+          compiler->last_result = yr_parser_emit(
2919
+              yyscanner,
2920
+              OP_SZ_EQ,
2921
+              NULL);
2922
+        }
2923
+        else
2924
+        {
2925
+          compiler->last_result = yr_parser_emit(
2926
+              yyscanner,
2927
+              OP_EQ,
2928
+              NULL);
2929
+        }
2930
+
2931
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2932
+
2933
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2934
+      }
2935
+#line 2937 "yara_grammar.c"
2936
+    break;
2937
+
2938
+  case 70:
2939
+#line 1291 "yara_grammar.y"
2940
+      {
2941
+        if ((yyvsp[-2].expression_type) != (yyvsp[0].expression_type))
2942
+        {
2943
+          yr_compiler_set_error_extra_info(
2944
+              compiler, "mismatching types for == operator");
2945
+          compiler->last_result = ERROR_WRONG_TYPE;
2946
+        }
2947
+        else if ((yyvsp[-2].expression_type) == EXPRESSION_TYPE_STRING)
2948
+        {
2949
+          compiler->last_result = yr_parser_emit(
2950
+              yyscanner,
2951
+              OP_SZ_EQ,
2952
+              NULL);
2953
+        }
2954
+        else
2955
+        {
2956
+          compiler->last_result = yr_parser_emit(
2957
+              yyscanner,
2958
+              OP_EQ,
2959
+              NULL);
2960
+        }
2961
+
2962
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2963
+
2964
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2965
+      }
2966
+#line 2968 "yara_grammar.c"
2967
+    break;
2968
+
2969
+  case 71:
2970
+#line 1318 "yara_grammar.y"
2971
+      {
2972
+        if ((yyvsp[-2].expression_type) != (yyvsp[0].expression_type))
2973
+        {
2974
+          yr_compiler_set_error_extra_info(
2975
+              compiler, "mismatching types for != operator");
2976
+          compiler->last_result = ERROR_WRONG_TYPE;
2977
+        }
2978
+        else if ((yyvsp[-2].expression_type) == EXPRESSION_TYPE_STRING)
2979
+        {
2980
+          compiler->last_result = yr_parser_emit(
2981
+              yyscanner,
2982
+              OP_SZ_NEQ,
2983
+              NULL);
2984
+        }
2985
+        else
2986
+        {
2987
+          compiler->last_result = yr_parser_emit(
2988
+              yyscanner,
2989
+              OP_NEQ,
2990
+              NULL);
2991
+        }
2992
+
2993
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2994
+
2995
+        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2996
+      }
2997
+#line 2999 "yara_grammar.c"
2998
+    break;
2999
+
3000
+  case 72:
3001
+#line 1345 "yara_grammar.y"
3002
+      {
3003
+        (yyval.expression_type) = (yyvsp[0].expression_type);
3004
+      }
3005
+#line 3007 "yara_grammar.c"
3006
+    break;
3007
+
3008
+  case 73:
3009
+#line 1349 "yara_grammar.y"
3010
+      {
3011
+        (yyval.expression_type) = (yyvsp[-1].expression_type);
3012
+      }
3013
+#line 3015 "yara_grammar.c"
3014
+    break;
3015
+
3016
+  case 74:
3017
+#line 1356 "yara_grammar.y"
3018
+                                   { (yyval.integer) = INTEGER_SET_ENUMERATION; }
3019
+#line 3021 "yara_grammar.c"
3020
+    break;
3021
+
3022
+  case 75:
3023
+#line 1357 "yara_grammar.y"
3024
+                                   { (yyval.integer) = INTEGER_SET_RANGE; }
3025
+#line 3027 "yara_grammar.c"
3026
+    break;
3027
+
3028
+  case 76:
3029
+#line 1363 "yara_grammar.y"
3030
+      {
3031
+        if ((yyvsp[-4].expression_type) != EXPRESSION_TYPE_INTEGER)
3032
+        {
3033
+          yr_compiler_set_error_extra_info(
3034
+              compiler, "wrong type for range's lower bound");
3035
+          compiler->last_result = ERROR_WRONG_TYPE;
3036
+        }
3037
+
3038
+        if ((yyvsp[-1].expression_type) != EXPRESSION_TYPE_INTEGER)
3039
+        {
3040
+          yr_compiler_set_error_extra_info(
3041
+              compiler, "wrong type for range's upper bound");
3042
+          compiler->last_result = ERROR_WRONG_TYPE;
3043
+        }
3044
+
3045
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3046
+      }
3047
+#line 3049 "yara_grammar.c"
3048
+    break;
3049
+
3050
+  case 77:
3051
+#line 1385 "yara_grammar.y"
3052
+      {
3053
+        if ((yyvsp[0].expression_type) != EXPRESSION_TYPE_INTEGER)
3054
+        {
3055
+          yr_compiler_set_error_extra_info(
3056
+              compiler, "wrong type for enumeration item");
3057
+          compiler->last_result = ERROR_WRONG_TYPE;
3058
+
3059
+        }
3060
+
3061
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3062
+      }
3063
+#line 3065 "yara_grammar.c"
3064
+    break;
3065
+
3066
+  case 78:
3067
+#line 1397 "yara_grammar.y"
3068
+      {
3069
+        if ((yyvsp[0].expression_type) != EXPRESSION_TYPE_INTEGER)
3070
+        {
3071
+          yr_compiler_set_error_extra_info(
3072
+              compiler, "wrong type for enumeration item");
3073
+          compiler->last_result = ERROR_WRONG_TYPE;
3074
+        }
3075
+
3076
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3077
+      }
3078
+#line 3080 "yara_grammar.c"
3079
+    break;
3080
+
3081
+  case 79:
3082
+#line 1412 "yara_grammar.y"
3083
+      {
3084
+        // Push end-of-list marker
3085
+        yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
3086
+      }
3087
+#line 3089 "yara_grammar.c"
3088
+    break;
3089
+
3090
+  case 81:
3091
+#line 1418 "yara_grammar.y"
3092
+      {
3093
+        yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
3094
+        yr_parser_emit_pushes_for_strings(yyscanner, "$*");
3095
+#ifdef YARA_PROTO
3096
+        compiler->current_rule_clflags |= RULE_THEM;
3097
+#endif
3098
+      }
3099
+#line 3101 "yara_grammar.c"
3100
+    break;
3101
+
3102
+  case 84:
3103
+#line 1436 "yara_grammar.y"
3104
+      {
3105
+        yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[0].c_string));
3106
+        yr_free((yyvsp[0].c_string));
3107
+      }
3108
+#line 3110 "yara_grammar.c"
3109
+    break;
3110
+
3111
+  case 85:
3112
+#line 1441 "yara_grammar.y"
3113
+      {
3114
+        yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[0].c_string));
3115
+        yr_free((yyvsp[0].c_string));
3116
+      }
3117
+#line 3119 "yara_grammar.c"
3118
+    break;
3119
+
3120
+  case 87:
3121
+#line 1451 "yara_grammar.y"
3122
+      {
3123
+        yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
3124
+#ifdef YARA_PROTO
3125
+        compiler->current_rule_clflags |= RULE_ALL;
3126
+#endif
3127
+      }
3128
+#line 3130 "yara_grammar.c"
3129
+    break;
3130
+
3131
+  case 88:
3132
+#line 1458 "yara_grammar.y"
3133
+      {
3134
+        yr_parser_emit_with_arg(yyscanner, OP_PUSH, 1, NULL);
3135
+#ifdef YARA_PROTO
3136
+        compiler->current_rule_clflags |= RULE_ANY;
3137
+#endif
3138
+      }
3139
+#line 3141 "yara_grammar.c"
3140
+    break;
3141
+
3142
+  case 89:
3143
+#line 1469 "yara_grammar.y"
3144
+      {
3145
+        (yyval.expression_type) = (yyvsp[-1].expression_type);
3146
+      }
3147
+#line 3149 "yara_grammar.c"
3148
+    break;
3149
+
3150
+  case 90:
3151
+#line 1473 "yara_grammar.y"
3152
+      {
3153
+        compiler->last_result = yr_parser_emit(
3154
+            yyscanner, OP_FILESIZE, NULL);
3155
+
3156
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3157
+
3158
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3159
+      }
3160
+#line 3162 "yara_grammar.c"
3161
+    break;
3162
+
3163
+  case 91:
3164
+#line 1482 "yara_grammar.y"
3165
+      {
3166
+#ifndef YARA_PROTO
3167
+        yywarning(yyscanner,
3168
+            "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " "function from PE module instead.");
3169
+#else
3170
+        compiler->current_rule_clflags |= RULE_EP;
3171
+#endif
3172
+        compiler->last_result = yr_parser_emit(
3173
+            yyscanner, OP_ENTRYPOINT, NULL);
3174
+
3175
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3176
+
3177
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3178
+      }
3179
+#line 3181 "yara_grammar.c"
3180
+    break;
3181
+
3182
+  case 92:
3183
+#line 1497 "yara_grammar.y"
3184
+      {
3185
+        CHECK_TYPE((yyvsp[-1].expression_type), EXPRESSION_TYPE_INTEGER, "int8");
3186
+
3187
+        compiler->last_result = yr_parser_emit(
3188
+            yyscanner, OP_INT8, NULL);
3189
+
3190
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3191
+
3192
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3193
+      }
3194
+#line 3196 "yara_grammar.c"
3195
+    break;
3196
+
3197
+  case 93:
3198
+#line 1508 "yara_grammar.y"
3199
+      {
3200
+        CHECK_TYPE((yyvsp[-1].expression_type), EXPRESSION_TYPE_INTEGER, "int16");
3201
+
3202
+        compiler->last_result = yr_parser_emit(
3203
+            yyscanner, OP_INT16, NULL);
3204
+
3205
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3206
+
3207
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3208
+      }
3209
+#line 3211 "yara_grammar.c"
3210
+    break;
3211
+
3212
+  case 94:
3213
+#line 1519 "yara_grammar.y"
3214
+      {
3215
+        CHECK_TYPE((yyvsp[-1].expression_type), EXPRESSION_TYPE_INTEGER, "int32");
3216
+
3217
+        compiler->last_result = yr_parser_emit(
3218
+            yyscanner, OP_INT32, NULL);
3219
+
3220
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3221
+
3222
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3223
+      }
3224
+#line 3226 "yara_grammar.c"
3225
+    break;
3226
+
3227
+  case 95:
3228
+#line 1530 "yara_grammar.y"
3229
+      {
3230
+        CHECK_TYPE((yyvsp[-1].expression_type), EXPRESSION_TYPE_INTEGER, "uint8");
3231
+
3232
+        compiler->last_result = yr_parser_emit(
3233
+            yyscanner, OP_UINT8, NULL);
3234
+
3235
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3236
+
3237
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3238
+      }
3239
+#line 3241 "yara_grammar.c"
3240
+    break;
3241
+
3242
+  case 96:
3243
+#line 1541 "yara_grammar.y"
3244
+      {
3245
+        CHECK_TYPE((yyvsp[-1].expression_type), EXPRESSION_TYPE_INTEGER, "uint16");
3246
+
3247
+        compiler->last_result = yr_parser_emit(
3248
+            yyscanner, OP_UINT16, NULL);
3249
+
3250
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3251
+
3252
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3253
+      }
3254
+#line 3256 "yara_grammar.c"
3255
+    break;
3256
+
3257
+  case 97:
3258
+#line 1552 "yara_grammar.y"
3259
+      {
3260
+        CHECK_TYPE((yyvsp[-1].expression_type), EXPRESSION_TYPE_INTEGER, "uint32");
3261
+
3262
+        compiler->last_result = yr_parser_emit(
3263
+            yyscanner, OP_UINT32, NULL);
3264
+
3265
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3266
+
3267
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3268
+      }
3269
+#line 3271 "yara_grammar.c"
3270
+    break;
3271
+
3272
+  case 98:
3273
+#line 1563 "yara_grammar.y"
3274
+      {
3275
+        compiler->last_result = yr_parser_emit_with_arg(
3276
+            yyscanner, OP_PUSH, (yyvsp[0].integer), NULL);
3277
+
3278
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3279
+
3280
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3281
+      }
3282
+#line 3284 "yara_grammar.c"
3283
+    break;
3284
+
3285
+  case 99:
3286
+#line 1572 "yara_grammar.y"
3287
+      {
3288
+#if REAL_YARA
3289
+        SIZED_STRING* sized_string = (yyvsp[0].sized_string);
3290
+#endif
3291
+        char* string = NULL;
3292
+
3293
+#if REAL_YARA
3294
+        compiler->last_result = yr_arena_write_string(
3295
+            compiler->sz_arena,
3296
+            sized_string->c_string,
3297
+            &string);
3298
+#endif
3299
+
3300
+        yr_free((yyvsp[0].sized_string));
3301
+
3302
+        if (compiler->last_result == ERROR_SUCCESS)
3303
+          compiler->last_result = yr_parser_emit_with_arg_reloc(
3304
+              yyscanner,
3305
+              OP_PUSH,
3306
+              PTR_TO_UINT64(string),
3307
+              NULL);
3308
+
3309
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3310
+
3311
+        (yyval.expression_type) = EXPRESSION_TYPE_STRING;
3312
+      }
3313
+#line 3315 "yara_grammar.c"
3314
+    break;
3315
+
3316
+  case 100:
3317
+#line 1599 "yara_grammar.y"
3318
+      {
3319
+        compiler->last_result = yr_parser_reduce_string_identifier(
3320
+            yyscanner,
3321
+            (yyvsp[0].c_string),
3322
+            OP_STR_COUNT);
3323
+
3324
+        yr_free((yyvsp[0].c_string));
3325
+
3326
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3327
+
3328
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3329
+      }
3330
+#line 3332 "yara_grammar.c"
3331
+    break;
3332
+
3333
+  case 101:
3334
+#line 1612 "yara_grammar.y"
3335
+      {
3336
+        compiler->last_result = yr_parser_reduce_string_identifier(
3337
+            yyscanner,
3338
+            (yyvsp[-3].c_string),
3339
+            OP_STR_OFFSET);
3340
+
3341
+        yr_free((yyvsp[-3].c_string));
3342
+
3343
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3344
+
3345
+        compiler->current_rule_clflags |= RULE_OFFSETS;
3346
+
3347
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3348
+      }
3349
+#line 3351 "yara_grammar.c"
3350
+    break;
3351
+
3352
+  case 102:
3353
+#line 1627 "yara_grammar.y"
3354
+      {
3355
+        compiler->last_result = yr_parser_emit_with_arg(
3356
+            yyscanner,
3357
+            OP_PUSH,
3358
+            1,
3359
+            NULL);
3360
+
3361
+        if (compiler->last_result == ERROR_SUCCESS)
3362
+          compiler->last_result = yr_parser_reduce_string_identifier(
3363
+              yyscanner,
3364
+              (yyvsp[0].c_string),
3365
+              OP_STR_OFFSET);
3366
+
3367
+        yr_free((yyvsp[0].c_string));
3368
+
3369
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3370
+
3371
+        compiler->current_rule_clflags |= RULE_OFFSETS;
3372
+
3373
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3374
+      }
3375
+#line 3377 "yara_grammar.c"
3376
+    break;
3377
+
3378
+  case 103:
3379
+#line 1649 "yara_grammar.y"
3380
+      {
3381
+        if ((yyvsp[0].object) == (YR_OBJECT*) -1)  // loop identifier
3382
+        {
3383
+          (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3384
+        }
3385
+        else if ((yyvsp[0].object) == (YR_OBJECT*) -2)  // rule identifier
3386
+        {
3387
+          (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
3388
+        }
3389
+        else if ((yyvsp[0].object) != NULL)
3390
+        {
3391
+          compiler->last_result = yr_parser_emit(
3392
+              yyscanner, OP_OBJ_VALUE, NULL);
3393
+
3394
+          switch((yyvsp[0].object)->type)
3395
+          {
3396
+            case OBJECT_TYPE_INTEGER:
3397
+              (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3398
+              break;
3399
+            case OBJECT_TYPE_STRING:
3400
+              (yyval.expression_type) = EXPRESSION_TYPE_STRING;
3401
+              break;
3402
+            default:
3403
+              assert(FALSE);
3404
+          }
3405
+        }
3406
+        else
3407
+        {
3408
+          yr_compiler_set_error_extra_info(compiler, (yyvsp[0].object)->identifier);
3409
+          compiler->last_result = ERROR_WRONG_TYPE;
3410
+        }
3411
+
3412
+        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3413
+      }
3414
+#line 3416 "yara_grammar.c"
3415
+    break;
3416
+
3417
+  case 104:
3418
+#line 1684 "yara_grammar.y"
3419
+      {
3420
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_INTEGER, "+");
3421
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, "+");
3422
+
3423
+        yr_parser_emit(yyscanner, OP_ADD, NULL);
3424
+
3425
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3426
+      }
3427
+#line 3429 "yara_grammar.c"
3428
+    break;
3429
+
3430
+  case 105:
3431
+#line 1693 "yara_grammar.y"
3432
+      {
3433
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_INTEGER, "-");
3434
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, "-");
3435
+
3436
+        yr_parser_emit(yyscanner, OP_SUB, NULL);
3437
+
3438
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3439
+      }
3440
+#line 3442 "yara_grammar.c"
3441
+    break;
3442
+
3443
+  case 106:
3444
+#line 1702 "yara_grammar.y"
3445
+      {
3446
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_INTEGER, "*");
3447
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, "*");
3448
+
3449
+        yr_parser_emit(yyscanner, OP_MUL, NULL);
3450
+
3451
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3452
+      }
3453
+#line 3455 "yara_grammar.c"
3454
+    break;
3455
+
3456
+  case 107:
3457
+#line 1711 "yara_grammar.y"
3458
+      {
3459
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_INTEGER, "\\");
3460
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, "\\");
3461
+
3462
+        yr_parser_emit(yyscanner, OP_DIV, NULL);
3463
+
3464
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3465
+      }
3466
+#line 3468 "yara_grammar.c"
3467
+    break;
3468
+
3469
+  case 108:
3470
+#line 1720 "yara_grammar.y"
3471
+      {
3472
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_INTEGER, "%");
3473
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, "%");
3474
+
3475
+        yr_parser_emit(yyscanner, OP_MOD, NULL);
3476
+
3477
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3478
+      }
3479
+#line 3481 "yara_grammar.c"
3480
+    break;
3481
+
3482
+  case 109:
3483
+#line 1729 "yara_grammar.y"
3484
+      {
3485
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_INTEGER, "^");
3486
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, "^");
3487
+
3488
+        yr_parser_emit(yyscanner, OP_XOR, NULL);
3489
+
3490
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3491
+      }
3492
+#line 3494 "yara_grammar.c"
3493
+    break;
3494
+
3495
+  case 110:
3496
+#line 1738 "yara_grammar.y"
3497
+      {
3498
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_INTEGER, "^");
3499
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, "^");
3500
+
3501
+        yr_parser_emit(yyscanner, OP_AND, NULL);
3502
+
3503
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3504
+      }
3505
+#line 3507 "yara_grammar.c"
3506
+    break;
3507
+
3508
+  case 111:
3509
+#line 1747 "yara_grammar.y"
3510
+      {
3511
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_INTEGER, "|");
3512
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, "|");
3513
+
3514
+        yr_parser_emit(yyscanner, OP_OR, NULL);
3515
+
3516
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3517
+      }
3518
+#line 3520 "yara_grammar.c"
3519
+    break;
3520
+
3521
+  case 112:
3522
+#line 1756 "yara_grammar.y"
3523
+      {
3524
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, "~");
3525
+
3526
+        yr_parser_emit(yyscanner, OP_NEG, NULL);
3527
+
3528
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3529
+      }
3530
+#line 3532 "yara_grammar.c"
3531
+    break;
3532
+
3533
+  case 113:
3534
+#line 1764 "yara_grammar.y"
3535
+      {
3536
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_INTEGER, "<<");
3537
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, "<<");
3538
+
3539
+        yr_parser_emit(yyscanner, OP_SHL, NULL);
3540
+
3541
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3542
+      }
3543
+#line 3545 "yara_grammar.c"
3544
+    break;
3545
+
3546
+  case 114:
3547
+#line 1773 "yara_grammar.y"
3548
+      {
3549
+        CHECK_TYPE((yyvsp[-2].expression_type), EXPRESSION_TYPE_INTEGER, ">>");
3550
+        CHECK_TYPE((yyvsp[0].expression_type), EXPRESSION_TYPE_INTEGER, ">>");
3551
+
3552
+        yr_parser_emit(yyscanner, OP_SHR, NULL);
3553
+
3554
+        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3555
+      }
3556
+#line 3558 "yara_grammar.c"
3557
+    break;
3558
+
3559
+  case 115:
3560
+#line 1782 "yara_grammar.y"
3561
+      {
3562
+        (yyval.expression_type) = (yyvsp[0].expression_type);
3563
+      }
3564
+#line 3566 "yara_grammar.c"
3565
+    break;
3566
+
3567
+
3568
+#line 3570 "yara_grammar.c"
3569
+
3570
+      default: break;
3571
+    }
3572
+  /* User semantic actions sometimes alter yychar, and that requires
3573
+     that yytoken be updated with the new translation.  We take the
3574
+     approach of translating immediately before every use of yytoken.
3575
+     One alternative is translating here after every semantic action,
3576
+     but that translation would be missed if the semantic action invokes
3577
+     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
3578
+     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
3579
+     incorrect destructor might then be invoked immediately.  In the
3580
+     case of YYERROR or YYBACKUP, subsequent parser actions might lead
3581
+     to an incorrect destructor call or verbose syntax error message
3582
+     before the lookahead is translated.  */
3583
+  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
3584
+
3585
+  YYPOPSTACK (yylen);
3586
+  yylen = 0;
3587
+  YY_STACK_PRINT (yyss, yyssp);
3588
+
3589
+  *++yyvsp = yyval;
3590
+
3591
+  /* Now 'shift' the result of the reduction.  Determine what state
3592
+     that goes to, based on the state we popped back to and the rule
3593
+     number reduced by.  */
3594
+  {
3595
+    const int yylhs = yyr1[yyn] - YYNTOKENS;
3596
+    const int yyi = yypgoto[yylhs] + *yyssp;
3597
+    yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
3598
+               ? yytable[yyi]
3599
+               : yydefgoto[yylhs]);
3600
+  }
3601
+
3602
+  goto yynewstate;
3603
+
3604
+
3605
+/*--------------------------------------.
3606
+| yyerrlab -- here on detecting error.  |
3607
+`--------------------------------------*/
3608
+yyerrlab:
3609
+  /* Make sure we have latest lookahead translation.  See comments at
3610
+     user semantic actions for why this is necessary.  */
3611
+  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
3612
+
3613
+  /* If not already recovering from an error, report this error.  */
3614
+  if (!yyerrstatus)
3615
+    {
3616
+      ++yynerrs;
3617
+#if ! YYERROR_VERBOSE
3618
+      yyerror (yyscanner, compiler, YY_("syntax error"));
3619
+#else
3620
+# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
3621
+                                        yyssp, yytoken)
3622
+      {
3623
+        char const *yymsgp = YY_("syntax error");
3624
+        int yysyntax_error_status;
3625
+        yysyntax_error_status = YYSYNTAX_ERROR;
3626
+        if (yysyntax_error_status == 0)
3627
+          yymsgp = yymsg;
3628
+        else if (yysyntax_error_status == 1)
3629
+          {
3630
+            if (yymsg != yymsgbuf)
3631
+              YYSTACK_FREE (yymsg);
3632
+            yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
3633
+            if (!yymsg)
3634
+              {
3635
+                yymsg = yymsgbuf;
3636
+                yymsg_alloc = sizeof yymsgbuf;
3637
+                yysyntax_error_status = 2;
3638
+              }
3639
+            else
3640
+              {
3641
+                yysyntax_error_status = YYSYNTAX_ERROR;
3642
+                yymsgp = yymsg;
3643
+              }
3644
+          }
3645
+        yyerror (yyscanner, compiler, yymsgp);
3646
+        if (yysyntax_error_status == 2)
3647
+          goto yyexhaustedlab;
3648
+      }
3649
+# undef YYSYNTAX_ERROR
3650
+#endif
3651
+    }
3652
+
3653
+
3654
+
3655
+  if (yyerrstatus == 3)
3656
+    {
3657
+      /* If just tried and failed to reuse lookahead token after an
3658
+         error, discard it.  */
3659
+
3660
+      if (yychar <= YYEOF)
3661
+        {
3662
+          /* Return failure if at end of input.  */
3663
+          if (yychar == YYEOF)
3664
+            YYABORT;
3665
+        }
3666
+      else
3667
+        {
3668
+          yydestruct ("Error: discarding",
3669
+                      yytoken, &yylval, yyscanner, compiler);
3670
+          yychar = YYEMPTY;
3671
+        }
3672
+    }
3673
+
3674
+  /* Else will try to reuse lookahead token after shifting the error
3675
+     token.  */
3676
+  goto yyerrlab1;
3677
+
3678
+
3679
+/*---------------------------------------------------.
3680
+| yyerrorlab -- error raised explicitly by YYERROR.  |
3681
+`---------------------------------------------------*/
3682
+yyerrorlab:
3683
+  /* Pacify compilers when the user code never invokes YYERROR and the
3684
+     label yyerrorlab therefore never appears in user code.  */
3685
+  if (0)
3686
+    YYERROR;
3687
+
3688
+  /* Do not reclaim the symbols of the rule whose action triggered
3689
+     this YYERROR.  */
3690
+  YYPOPSTACK (yylen);
3691
+  yylen = 0;
3692
+  YY_STACK_PRINT (yyss, yyssp);
3693
+  yystate = *yyssp;
3694
+  goto yyerrlab1;
3695
+
3696
+
3697
+/*-------------------------------------------------------------.
3698
+| yyerrlab1 -- common code for both syntax error and YYERROR.  |
3699
+`-------------------------------------------------------------*/
3700
+yyerrlab1:
3701
+  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
3702
+
3703
+  for (;;)
3704
+    {
3705
+      yyn = yypact[yystate];
3706
+      if (!yypact_value_is_default (yyn))
3707
+        {
3708
+          yyn += YYTERROR;
3709
+          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
3710
+            {
3711
+              yyn = yytable[yyn];
3712
+              if (0 < yyn)
3713
+                break;
3714
+            }
3715
+        }
3716
+
3717
+      /* Pop the current state because it cannot handle the error token.  */
3718
+      if (yyssp == yyss)
3719
+        YYABORT;
3720
+
3721
+
3722
+      yydestruct ("Error: popping",
3723
+                  yystos[yystate], yyvsp, yyscanner, compiler);
3724
+      YYPOPSTACK (1);
3725
+      yystate = *yyssp;
3726
+      YY_STACK_PRINT (yyss, yyssp);
3727
+    }
3728
+
3729
+  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
3730
+  *++yyvsp = yylval;
3731
+  YY_IGNORE_MAYBE_UNINITIALIZED_END
3732
+
3733
+
3734
+  /* Shift the error token.  */
3735
+  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
3736
+
3737
+  yystate = yyn;
3738
+  goto yynewstate;
3739
+
3740
+
3741
+/*-------------------------------------.
3742
+| yyacceptlab -- YYACCEPT comes here.  |
3743
+`-------------------------------------*/
3744
+yyacceptlab:
3745
+  yyresult = 0;
3746
+  goto yyreturn;
3747
+
3748
+
3749
+/*-----------------------------------.
3750
+| yyabortlab -- YYABORT comes here.  |
3751
+`-----------------------------------*/
3752
+yyabortlab:
3753
+  yyresult = 1;
3754
+  goto yyreturn;
3755
+
3756
+
3757
+#if !defined yyoverflow || YYERROR_VERBOSE
3758
+/*-------------------------------------------------.
3759
+| yyexhaustedlab -- memory exhaustion comes here.  |
3760
+`-------------------------------------------------*/
3761
+yyexhaustedlab:
3762
+  yyerror (yyscanner, compiler, YY_("memory exhausted"));
3763
+  yyresult = 2;
3764
+  /* Fall through.  */
3765
+#endif
3766
+
3767
+
3768
+/*-----------------------------------------------------.
3769
+| yyreturn -- parsing is finished, return the result.  |
3770
+`-----------------------------------------------------*/
3771
+yyreturn:
3772
+  if (yychar != YYEMPTY)
3773
+    {
3774
+      /* Make sure we have latest lookahead translation.  See comments at
3775
+         user semantic actions for why this is necessary.  */
3776
+      yytoken = YYTRANSLATE (yychar);
3777
+      yydestruct ("Cleanup: discarding lookahead",
3778
+                  yytoken, &yylval, yyscanner, compiler);
3779
+    }
3780
+  /* Do not reclaim the symbols of the rule whose action triggered
3781
+     this YYABORT or YYACCEPT.  */
3782
+  YYPOPSTACK (yylen);
3783
+  YY_STACK_PRINT (yyss, yyssp);
3784
+  while (yyssp != yyss)
3785
+    {
3786
+      yydestruct ("Cleanup: popping",
3787
+                  yystos[+*yyssp], yyvsp, yyscanner, compiler);
3788
+      YYPOPSTACK (1);
3789
+    }
3790
+#ifndef yyoverflow
3791
+  if (yyss != yyssa)
3792
+    YYSTACK_FREE (yyss);
3793
+#endif
3794
+#if YYERROR_VERBOSE
3795
+  if (yymsg != yymsgbuf)
3796
+    YYSTACK_FREE (yymsg);
3797
+#endif
3798
+  return yyresult;
3799
+}
3800
+#line 1787 "yara_grammar.y"
3801
+
0 3802
new file mode 100644
... ...
@@ -0,0 +1,138 @@
0
+/* A Bison parser, made by GNU Bison 3.5.1.  */
1
+
2
+/* Bison interface for Yacc-like parsers in C
3
+
4
+   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
5
+   Inc.
6
+
7
+   This program is free software: you can redistribute it and/or modify
8
+   it under the terms of the GNU General Public License as published by
9
+   the Free Software Foundation, either version 3 of the License, or
10
+   (at your option) any later version.
11
+
12
+   This program is distributed in the hope that it will be useful,
13
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+   GNU General Public License for more details.
16
+
17
+   You should have received a copy of the GNU General Public License
18
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
+
20
+/* As a special exception, you may create a larger work that contains
21
+   part or all of the Bison parser skeleton and distribute that work
22
+   under terms of your choice, so long as that work isn't itself a
23
+   parser generator using the skeleton or a modified version thereof
24
+   as a parser skeleton.  Alternatively, if you modify or redistribute
25
+   the parser skeleton itself, you may (at your option) remove this
26
+   special exception, which will cause the skeleton and the resulting
27
+   Bison output files to be licensed under the GNU General Public
28
+   License without this special exception.
29
+
30
+   This special exception was added by the Free Software Foundation in
31
+   version 2.2 of Bison.  */
32
+
33
+/* Undocumented macros, especially those whose name start with YY_,
34
+   are private implementation details.  Do not rely on them.  */
35
+
36
+#ifndef YY_YARA_YY_YARA_GRAMMAR_H_INCLUDED
37
+# define YY_YARA_YY_YARA_GRAMMAR_H_INCLUDED
38
+/* Debug traces.  */
39
+#ifndef YYDEBUG
40
+# define YYDEBUG 0
41
+#endif
42
+#if YYDEBUG
43
+extern int yara_yydebug;
44
+#endif
45
+/* "%code requires" blocks.  */
46
+#line 39 "yara_grammar.y"
47
+
48
+#include "yara_compiler.h"
49
+
50
+#line 52 "yara_grammar.h"
51
+
52
+/* Token type.  */
53
+#ifndef YYTOKENTYPE
54
+# define YYTOKENTYPE
55
+  enum yytokentype
56
+  {
57
+    _RULE_ = 258,
58
+    _PRIVATE_ = 259,
59
+    _GLOBAL_ = 260,
60
+    _META_ = 261,
61
+    _STRINGS_ = 262,
62
+    _CONDITION_ = 263,
63
+    _IDENTIFIER_ = 264,
64
+    _STRING_IDENTIFIER_ = 265,
65
+    _STRING_COUNT_ = 266,
66
+    _STRING_OFFSET_ = 267,
67
+    _STRING_IDENTIFIER_WITH_WILDCARD_ = 268,
68
+    _NUMBER_ = 269,
69
+    _TEXT_STRING_ = 270,
70
+    _HEX_STRING_ = 271,
71
+    _REGEXP_ = 272,
72
+    _ASCII_ = 273,
73
+    _WIDE_ = 274,
74
+    _NOCASE_ = 275,
75
+    _FULLWORD_ = 276,
76
+    _AT_ = 277,
77
+    _FILESIZE_ = 278,
78
+    _ENTRYPOINT_ = 279,
79
+    _ALL_ = 280,
80
+    _ANY_ = 281,
81
+    _IN_ = 282,
82
+    _OF_ = 283,
83
+    _FOR_ = 284,
84
+    _THEM_ = 285,
85
+    _INT8_ = 286,
86
+    _INT16_ = 287,
87
+    _INT32_ = 288,
88
+    _UINT8_ = 289,
89
+    _UINT16_ = 290,
90
+    _UINT32_ = 291,
91
+    _MATCHES_ = 292,
92
+    _CONTAINS_ = 293,
93
+    _IMPORT_ = 294,
94
+    _TRUE_ = 295,
95
+    _FALSE_ = 296,
96
+    _OR_ = 297,
97
+    _AND_ = 298,
98
+    _LT_ = 299,
99
+    _LE_ = 300,
100
+    _GT_ = 301,
101
+    _GE_ = 302,
102
+    _EQ_ = 303,
103
+    _NEQ_ = 304,
104
+    _IS_ = 305,
105
+    _SHIFT_LEFT_ = 306,
106
+    _SHIFT_RIGHT_ = 307,
107
+    _NOT_ = 308
108
+  };
109
+#endif
110
+
111
+/* Value type.  */
112
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
113
+union YYSTYPE
114
+{
115
+#line 219 "yara_grammar.y"
116
+
117
+  SIZED_STRING*   sized_string;
118
+  char*           c_string;
119
+  int8_t          expression_type;
120
+  int64_t         integer;
121
+  YR_STRING*      string;
122
+  YR_META*        meta;
123
+  YR_OBJECT*      object;
124
+
125
+#line 127 "yara_grammar.h"
126
+
127
+};
128
+typedef union YYSTYPE YYSTYPE;
129
+# define YYSTYPE_IS_TRIVIAL 1
130
+# define YYSTYPE_IS_DECLARED 1
131
+#endif
132
+
133
+
134
+
135
+int yara_yyparse (void *yyscanner, YR_COMPILER* compiler);
136
+
137
+#endif /* !YY_YARA_YY_YARA_GRAMMAR_H_INCLUDED  */
... ...
@@ -120,6 +120,7 @@ limitations under the License.
120 120
 
121 121
 // %debug
122 122
 %name-prefix="yara_yy"
123
+%output "yara_grammar.c"
123 124
 %pure-parser
124 125
 %parse-param {void *yyscanner}
125 126
 %parse-param {YR_COMPILER* compiler}
126 127
new file mode 100644
... ...
@@ -0,0 +1,3111 @@
0
+#line 2 "yara_lexer.c"
1
+
2
+#line 4 "yara_lexer.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 6
11
+#define YY_FLEX_SUBMINOR_VERSION 4
12
+#if YY_FLEX_SUBMINOR_VERSION > 0
13
+#define FLEX_BETA
14
+#endif
15
+
16
+#ifdef yyget_lval
17
+#define yyget_lval_ALREADY_DEFINED
18
+#else
19
+#define yyget_lval yyget_lval
20
+#endif
21
+
22
+#ifdef yyset_lval
23
+#define yyset_lval_ALREADY_DEFINED
24
+#else
25
+#define yyset_lval yyset_lval
26
+#endif
27
+
28
+/* First, we deal with  platform-specific or compiler-specific issues. */
29
+
30
+/* begin standard C headers. */
31
+#include <stdio.h>
32
+#include <string.h>
33
+#include <errno.h>
34
+#include <stdlib.h>
35
+
36
+/* end standard C headers. */
37
+
38
+/* flex integer type definitions */
39
+
40
+#ifndef FLEXINT_H
41
+#define FLEXINT_H
42
+
43
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
44
+
45
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
46
+
47
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
48
+ * if you want the limit (max/min) macros for int types. 
49
+ */
50
+#ifndef __STDC_LIMIT_MACROS
51
+#define __STDC_LIMIT_MACROS 1
52
+#endif
53
+
54
+#include <inttypes.h>
55
+typedef int8_t flex_int8_t;
56
+typedef uint8_t flex_uint8_t;
57
+typedef int16_t flex_int16_t;
58
+typedef uint16_t flex_uint16_t;
59
+typedef int32_t flex_int32_t;
60
+typedef uint32_t flex_uint32_t;
61
+#else
62
+typedef signed char flex_int8_t;
63
+typedef short int flex_int16_t;
64
+typedef int flex_int32_t;
65
+typedef unsigned char flex_uint8_t; 
66
+typedef unsigned short int flex_uint16_t;
67
+typedef unsigned int flex_uint32_t;
68
+
69
+/* Limits of integral types. */
70
+#ifndef INT8_MIN
71
+#define INT8_MIN               (-128)
72
+#endif
73
+#ifndef INT16_MIN
74
+#define INT16_MIN              (-32767-1)
75
+#endif
76
+#ifndef INT32_MIN
77
+#define INT32_MIN              (-2147483647-1)
78
+#endif
79
+#ifndef INT8_MAX
80
+#define INT8_MAX               (127)
81
+#endif
82
+#ifndef INT16_MAX
83
+#define INT16_MAX              (32767)
84
+#endif
85
+#ifndef INT32_MAX
86
+#define INT32_MAX              (2147483647)
87
+#endif
88
+#ifndef UINT8_MAX
89
+#define UINT8_MAX              (255U)
90
+#endif
91
+#ifndef UINT16_MAX
92
+#define UINT16_MAX             (65535U)
93
+#endif
94
+#ifndef UINT32_MAX
95
+#define UINT32_MAX             (4294967295U)
96
+#endif
97
+
98
+#ifndef SIZE_MAX
99
+#define SIZE_MAX               (~(size_t)0)
100
+#endif
101
+
102
+#endif /* ! C99 */
103
+
104
+#endif /* ! FLEXINT_H */
105
+
106
+/* begin standard C++ headers. */
107
+
108
+/* TODO: this is always defined, so inline it */
109
+#define yyconst const
110
+
111
+#if defined(__GNUC__) && __GNUC__ >= 3
112
+#define yynoreturn __attribute__((__noreturn__))
113
+#else
114
+#define yynoreturn
115
+#endif
116
+
117
+/* Returned upon end-of-file. */
118
+#define YY_NULL 0
119
+
120
+/* Promotes a possibly negative, possibly signed char to an
121
+ *   integer in range [0..255] for use as an array index.
122
+ */
123
+#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
124
+
125
+/* An opaque pointer. */
126
+#ifndef YY_TYPEDEF_YY_SCANNER_T
127
+#define YY_TYPEDEF_YY_SCANNER_T
128
+typedef void* yyscan_t;
129
+#endif
130
+
131
+/* For convenience, these vars (plus the bison vars far below)
132
+   are macros in the reentrant scanner. */
133
+#define yyin yyg->yyin_r
134
+#define yyout yyg->yyout_r
135
+#define yyextra yyg->yyextra_r
136
+#define yyleng yyg->yyleng_r
137
+#define yytext yyg->yytext_r
138
+#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
139
+#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
140
+#define yy_flex_debug yyg->yy_flex_debug_r
141
+
142
+/* Enter a start condition.  This macro really ought to take a parameter,
143
+ * but we do it the disgusting crufty way forced on us by the ()-less
144
+ * definition of BEGIN.
145
+ */
146
+#define BEGIN yyg->yy_start = 1 + 2 *
147
+/* Translate the current start state into a value that can be later handed
148
+ * to BEGIN to return to the state.  The YYSTATE alias is for lex
149
+ * compatibility.
150
+ */
151
+#define YY_START ((yyg->yy_start - 1) / 2)
152
+#define YYSTATE YY_START
153
+/* Action number for EOF rule of a given start state. */
154
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
155
+/* Special action meaning "start processing a new file". */
156
+#define YY_NEW_FILE yyrestart( yyin , yyscanner )
157
+#define YY_END_OF_BUFFER_CHAR 0
158
+
159
+/* Size of default input buffer. */
160
+#ifndef YY_BUF_SIZE
161
+#ifdef __ia64__
162
+/* On IA-64, the buffer size is 16k, not 8k.
163
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
164
+ * Ditto for the __ia64__ case accordingly.
165
+ */
166
+#define YY_BUF_SIZE 32768
167
+#else
168
+#define YY_BUF_SIZE 16384
169
+#endif /* __ia64__ */
170
+#endif
171
+
172
+/* The state buf must be large enough to hold one state per character in the main buffer.
173
+ */
174
+#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
175
+
176
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
177
+#define YY_TYPEDEF_YY_BUFFER_STATE
178
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
179
+#endif
180
+
181
+#ifndef YY_TYPEDEF_YY_SIZE_T
182
+#define YY_TYPEDEF_YY_SIZE_T
183
+typedef size_t yy_size_t;
184
+#endif
185
+
186
+#define EOB_ACT_CONTINUE_SCAN 0
187
+#define EOB_ACT_END_OF_FILE 1
188
+#define EOB_ACT_LAST_MATCH 2
189
+    
190
+    /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
191
+     *       access to the local variable yy_act. Since yyless() is a macro, it would break
192
+     *       existing scanners that call yyless() from OUTSIDE yylex.
193
+     *       One obvious solution it to make yy_act a global. I tried that, and saw
194
+     *       a 5% performance hit in a non-yylineno scanner, because yy_act is
195
+     *       normally declared as a register variable-- so it is not worth it.
196
+     */
197
+    #define  YY_LESS_LINENO(n) \
198
+            do { \
199
+                int yyl;\
200
+                for ( yyl = n; yyl < yyleng; ++yyl )\
201
+                    if ( yytext[yyl] == '\n' )\
202
+                        --yylineno;\
203
+            }while(0)
204
+    #define YY_LINENO_REWIND_TO(dst) \
205
+            do {\
206
+                const char *p;\
207
+                for ( p = yy_cp-1; p >= (dst); --p)\
208
+                    if ( *p == '\n' )\
209
+                        --yylineno;\
210
+            }while(0)
211
+    
212
+/* Return all but the first "n" matched characters back to the input stream. */
213
+#define yyless(n) \
214
+	do \
215
+		{ \
216
+		/* Undo effects of setting up yytext. */ \
217
+        int yyless_macro_arg = (n); \
218
+        YY_LESS_LINENO(yyless_macro_arg);\
219
+		*yy_cp = yyg->yy_hold_char; \
220
+		YY_RESTORE_YY_MORE_OFFSET \
221
+		yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
222
+		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
223
+		} \
224
+	while ( 0 )
225
+#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
226
+
227
+#ifndef YY_STRUCT_YY_BUFFER_STATE
228
+#define YY_STRUCT_YY_BUFFER_STATE
229
+struct yy_buffer_state
230
+	{
231
+	FILE *yy_input_file;
232
+
233
+	char *yy_ch_buf;		/* input buffer */
234
+	char *yy_buf_pos;		/* current position in input buffer */
235
+
236
+	/* Size of input buffer in bytes, not including room for EOB
237
+	 * characters.
238
+	 */
239
+	int yy_buf_size;
240
+
241
+	/* Number of characters read into yy_ch_buf, not including EOB
242
+	 * characters.
243
+	 */
244
+	int yy_n_chars;
245
+
246
+	/* Whether we "own" the buffer - i.e., we know we created it,
247
+	 * and can realloc() it to grow it, and should free() it to
248
+	 * delete it.
249
+	 */
250
+	int yy_is_our_buffer;
251
+
252
+	/* Whether this is an "interactive" input source; if so, and
253
+	 * if we're using stdio for input, then we want to use getc()
254
+	 * instead of fread(), to make sure we stop fetching input after
255
+	 * each newline.
256
+	 */
257
+	int yy_is_interactive;
258
+
259
+	/* Whether we're considered to be at the beginning of a line.
260
+	 * If so, '^' rules will be active on the next match, otherwise
261
+	 * not.
262
+	 */
263
+	int yy_at_bol;
264
+
265
+    int yy_bs_lineno; /**< The line count. */
266
+    int yy_bs_column; /**< The column count. */
267
+
268
+	/* Whether to try to fill the input buffer when we reach the
269
+	 * end of it.
270
+	 */
271
+	int yy_fill_buffer;
272
+
273
+	int yy_buffer_status;
274
+
275
+#define YY_BUFFER_NEW 0
276
+#define YY_BUFFER_NORMAL 1
277
+	/* When an EOF's been seen but there's still some text to process
278
+	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
279
+	 * shouldn't try reading from the input source any more.  We might
280
+	 * still have a bunch of tokens to match, though, because of
281
+	 * possible backing-up.
282
+	 *
283
+	 * When we actually see the EOF, we change the status to "new"
284
+	 * (via yyrestart()), so that the user can continue scanning by
285
+	 * just pointing yyin at a new input file.
286
+	 */
287
+#define YY_BUFFER_EOF_PENDING 2
288
+
289
+	};
290
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
291
+
292
+/* We provide macros for accessing buffer states in case in the
293
+ * future we want to put the buffer states in a more general
294
+ * "scanner state".
295
+ *
296
+ * Returns the top of the stack, or NULL.
297
+ */
298
+#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
299
+                          ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
300
+                          : NULL)
301
+/* Same as previous macro, but useful when we know that the buffer stack is not
302
+ * NULL or when we need an lvalue. For internal use only.
303
+ */
304
+#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
305
+
306
+void yyrestart ( FILE *input_file , yyscan_t yyscanner );
307
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
308
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
309
+void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
310
+void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
311
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
312
+void yypop_buffer_state ( yyscan_t yyscanner );
313
+
314
+static void yyensure_buffer_stack ( yyscan_t yyscanner );
315
+static void yy_load_buffer_state ( yyscan_t yyscanner );
316
+static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
317
+#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)
318
+
319
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
320
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
321
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
322
+
323
+void *yyalloc ( yy_size_t , yyscan_t yyscanner );
324
+void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
325
+void yyfree ( void * , yyscan_t yyscanner );
326
+
327
+#define yy_new_buffer yy_create_buffer
328
+#define yy_set_interactive(is_interactive) \
329
+	{ \
330
+	if ( ! YY_CURRENT_BUFFER ){ \
331
+        yyensure_buffer_stack (yyscanner); \
332
+		YY_CURRENT_BUFFER_LVALUE =    \
333
+            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
334
+	} \
335
+	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
336
+	}
337
+#define yy_set_bol(at_bol) \
338
+	{ \
339
+	if ( ! YY_CURRENT_BUFFER ){\
340
+        yyensure_buffer_stack (yyscanner); \
341
+		YY_CURRENT_BUFFER_LVALUE =    \
342
+            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
343
+	} \
344
+	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
345
+	}
346
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
347
+
348
+/* Begin user sect3 */
349
+
350
+#define yywrap(yyscanner) (/*CONSTCOND*/1)
351
+#define YY_SKIP_YYWRAP
352
+typedef flex_uint8_t YY_CHAR;
353
+
354
+typedef int yy_state_type;
355
+
356
+#define yytext_ptr yytext_r
357
+
358
+static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
359
+static yy_state_type yy_try_NUL_trans ( yy_state_type current_state  , yyscan_t yyscanner);
360
+static int yy_get_next_buffer ( yyscan_t yyscanner );
361
+static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
362
+
363
+/* Done after the current pattern has been matched and before the
364
+ * corresponding action - sets up yytext.
365
+ */
366
+#define YY_DO_BEFORE_ACTION \
367
+	yyg->yytext_ptr = yy_bp; \
368
+	yyleng = (int) (yy_cp - yy_bp); \
369
+	yyg->yy_hold_char = *yy_cp; \
370
+	*yy_cp = '\0'; \
371
+	yyg->yy_c_buf_p = yy_cp;
372
+#define YY_NUM_RULES 75
373
+#define YY_END_OF_BUFFER 76
374
+/* This struct is not used in this scanner,
375
+   but its presence is necessary. */
376
+struct yy_trans_info
377
+	{
378
+	flex_int32_t yy_verify;
379
+	flex_int32_t yy_nxt;
380
+	};
381
+static const flex_int16_t yy_accept[219] =
382
+    {   0,
383
+        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
384
+       76,   74,   73,   73,   74,   70,   51,   50,   71,   54,
385
+       54,    1,   74,    2,   52,   53,   53,   53,   53,   53,
386
+       53,   53,   53,   53,   53,   53,   53,   53,   53,   53,
387
+       53,   74,   62,   63,   56,   75,   68,   69,   65,   75,
388
+       47,   48,   44,   44,    6,   51,   49,   50,   42,   45,
389
+       54,    0,    0,    0,    7,    3,    5,    4,    8,   52,
390
+       53,   53,   53,   53,   24,   53,   53,   53,   53,   53,
391
+       53,   53,   53,   25,   53,   53,   53,   26,   23,   53,
392
+       53,   53,   53,   53,   53,   53,    0,   62,   64,   59,
393
+
394
+       60,   58,   57,   64,   68,   65,   65,   67,   66,   47,
395
+       43,   45,   54,   55,   29,   22,   30,   53,   53,   53,
396
+       53,   53,   28,   53,   53,   53,   53,   53,   53,   53,
397
+       53,   21,   53,   53,   53,   53,   53,   53,   53,   72,
398
+        0,   53,   53,   53,   53,   53,   53,   53,   53,   53,
399
+       53,   53,   53,   36,   53,   12,   53,   53,   11,   53,
400
+       27,   19,   53,   15,   61,   14,   53,   53,   53,   20,
401
+       53,   53,   53,   53,   53,   37,   38,   53,   53,   53,
402
+       53,   53,   53,   33,   53,   53,   53,   53,   53,   10,
403
+       41,   53,   53,   17,   53,   53,   34,   35,   53,   53,
404
+
405
+       53,   53,   53,   53,   39,    9,   13,   53,   40,   53,
406
+       32,   16,    0,   18,   53,   46,   31,    0
407
+    } ;
408
+
409
+static const YY_CHAR yy_ec[256] =
410
+    {   0,
411
+        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
412
+        1,    1,    4,    1,    1,    1,    1,    1,    1,    1,
413
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
414
+        1,    2,    5,    6,    7,    8,    1,    1,    1,    9,
415
+        9,   10,    1,    1,    9,    1,   11,   12,   13,   14,
416
+       15,   16,   16,   17,   16,   18,   16,    1,    1,   19,
417
+       20,   21,    9,   22,   23,   24,   23,   23,   23,   23,
418
+       25,   25,   25,   25,   26,   25,   27,   25,   25,   25,
419
+       25,   25,   25,   25,   25,   25,   25,   25,   25,   25,
420
+        9,   28,    9,    1,   29,    1,   30,   31,   32,   33,
421
+
422
+       34,   35,   36,   37,   38,   25,   25,   39,   40,   41,
423
+       42,   43,   25,   44,   45,   46,   47,   48,   49,   50,
424
+       51,   52,   53,    9,   54,    1,    1,    1,    1,    1,
425
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
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,    1,    1,    1,    1,    1,
432
+
433
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
434
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
435
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
436
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
437
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
438
+        1,    1,    1,    1,    1
439
+    } ;
440
+
441
+static const YY_CHAR yy_meta[55] =
442
+    {   0,
443
+        1,    2,    3,    1,    1,    4,    1,    1,    2,    5,
444
+        6,    7,    7,    7,    7,    7,    7,    7,    1,    1,
445
+        1,    1,    8,    8,    9,   10,   10,   11,    9,    8,
446
+        8,    8,    8,    8,    8,    9,    9,    9,    9,    9,
447
+        9,    9,    9,    9,    9,    9,    9,    9,    9,   10,
448
+        9,    9,    1,    1
449
+    } ;
450
+
451
+static const flex_int16_t yy_base[238] =
452
+    {   0,
453
+        0,    0,   52,   53,   54,   57,  350,  349,  344,  343,
454
+      352,  357,  357,  357,  331,  357,    0,  340,   51,   37,
455
+       40,   50,  329,   51,    0,    0,   38,  306,  306,   56,
456
+      307,   33,   58,  303,   56,  300,  296,  296,   52,  303,
457
+      302,    0,    0,  357,  357,   69,    0,  357,   57,  328,
458
+        0,  357,  357,  327,  357,    0,  357,  327,  357,    0,
459
+        0,  312,  311,    0,  357,  357,  357,  357,  357,    0,
460
+        0,  295,   60,  301,    0,  291,  285,  291,  290,  284,
461
+      288,  284,  282,   67,  278,  277,   72,    0,    0,  284,
462
+      282,  276,  285,  271,  276,  283,  261,    0,  357,  357,
463
+
464
+      357,  357,  357,    0,    0,  269,  357,  357,  357,    0,
465
+      357,    0,  357,    0,    0,    0,    0,  275,   68,  268,
466
+      266,  276,    0,  270,  277,  265,  267,   94,  273,  274,
467
+      273,    0,  254,  267,  262,  259,  264,  251,  262,  357,
468
+        0,  257,  256,  263,  241,  257,  245,  240,  258,  243,
469
+      239,  268,  270,    0,  246,    0,  237,  251,    0,  239,
470
+        0,    0,  107,    0,  357,    0,  233,  240,  234,    0,
471
+      238,  233,  235,  227,  239,    0,    0,  237,  236,  223,
472
+      218,  227,  218,    0,  187,  181,  160,  149,  152,    0,
473
+        0,  161,  149,    0,  148,  136,    0,    0,  133,   79,
474
+
475
+       85,   82,   75,  104,    0,    0,    0,   64,    0,   37,
476
+        0,    0,  115,    0,   30,  357,    0,  357,  125,  136,
477
+      147,  158,  163,  169,  173,  177,  181,  190,  198,  208,
478
+      219,  229,  240,  251,  256,  258,  260
479
+    } ;
480
+
481
+static const flex_int16_t yy_def[238] =
482
+    {   0,
483
+      218,    1,  219,  219,  220,  220,  221,  221,  222,  222,
484
+      218,  218,  218,  218,  218,  218,  223,  224,  218,  225,
485
+      225,  218,  218,  218,  226,  227,  227,  227,  227,  227,
486
+      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
487
+      227,  228,  229,  218,  218,  230,  231,  218,  218,  232,
488
+      233,  218,  218,  218,  218,  223,  218,  224,  218,  234,
489
+       21,  218,  218,  235,  218,  218,  218,  218,  218,  226,
490
+      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
491
+      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
492
+      227,  227,  227,  227,  227,  227,  228,  229,  218,  218,
493
+
494
+      218,  218,  218,  236,  231,  218,  218,  218,  218,  233,
495
+      218,  234,  218,  235,  227,  227,  227,  227,  227,  227,
496
+      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
497
+      227,  227,  227,  227,  227,  227,  227,  227,  227,  218,
498
+      237,  227,  227,  227,  227,  227,  227,  227,  227,  227,
499
+      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
500
+      227,  227,  227,  227,  218,  227,  227,  227,  227,  227,
501
+      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
502
+      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
503
+      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
504
+
505
+      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
506
+      227,  227,  218,  227,  227,  218,  227,    0,  218,  218,
507
+      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
508
+      218,  218,  218,  218,  218,  218,  218
509
+    } ;
510
+
511
+static const flex_int16_t yy_nxt[412] =
512
+    {   0,
513
+       12,   13,   14,   13,   15,   16,   17,   18,   12,   12,
514
+       19,   20,   21,   21,   21,   21,   21,   21,   22,   23,
515
+       24,   25,   26,   26,   26,   26,   26,   12,   26,   27,
516
+       26,   28,   26,   29,   30,   31,   26,   32,   26,   33,
517
+       34,   35,   36,   37,   38,   39,   40,   26,   41,   26,
518
+       26,   26,   42,   12,   44,   44,   48,   45,   45,   48,
519
+       59,   60,   62,   63,   49,   62,   63,   49,   65,   66,
520
+       68,   69,   83,   84,  100,  217,   72,  215,   73,   46,
521
+       46,   50,   74,   75,   50,   78,   64,   85,   93,  218,
522
+       88,   86,  116,   79,  106,   94,  101,   80,  127,   89,
523
+
524
+      143,  107,   81,  131,  214,  213,  152,  212,  153,  102,
525
+      117,  154,  128,  144,  103,  211,  213,  132,  104,  182,
526
+      216,  183,  210,  209,  184,   43,   43,   43,   43,   43,
527
+       43,   43,   43,   43,   43,   43,   47,   47,   47,   47,
528
+       47,   47,   47,   47,   47,   47,   47,   51,   51,   51,
529
+       51,   51,   51,   51,   51,   51,   51,   51,   53,   53,
530
+       53,   53,   53,   53,   53,   53,   53,   53,   53,   56,
531
+       56,   56,   56,   58,  208,   58,   58,   58,   58,   61,
532
+      207,  206,   61,   70,   70,   70,   70,   71,   71,   71,
533
+       71,   97,   97,  205,  204,  203,   97,   97,   98,   98,
534
+
535
+      202,  201,   98,   98,   98,   98,   98,   98,   99,   99,
536
+       99,   99,   99,   99,   99,   99,   99,   99,   99,  105,
537
+      105,  200,  105,  105,  199,  105,  105,  105,  105,  108,
538
+      108,  198,  108,  108,  108,  108,  108,  108,  108,  108,
539
+      110,  110,  110,  197,  110,  110,  110,  110,  110,  110,
540
+      110,  112,  112,  196,  112,  112,  112,  112,  112,  112,
541
+      112,  112,  114,  114,  141,  141,  165,  165,  195,  194,
542
+      193,  192,  191,  190,  189,  188,  187,  186,  185,  181,
543
+      180,  179,  178,  177,  176,  175,  174,  173,  172,  171,
544
+      170,  169,  168,  167,  166,  164,  163,  162,  161,  160,
545
+
546
+      159,  158,  157,  156,  155,  151,  150,  149,  148,  147,
547
+      146,  145,  142,  107,  140,  139,  138,  137,  136,  135,
548
+      134,  133,  130,  129,  126,  125,  124,  123,  122,  121,
549
+      120,  119,  118,  115,  113,  113,   57,  111,  109,   96,
550
+       95,   92,   91,   90,   87,   82,   77,   76,   67,   57,
551
+       55,  218,   54,   54,   52,   52,   11,  218,  218,  218,
552
+      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
553
+      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
554
+      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
555
+      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
556
+
557
+      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
558
+      218
559
+    } ;
560
+
561
+static const flex_int16_t yy_chk[412] =
562
+    {   0,
563
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
564
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
565
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
566
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
567
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
568
+        1,    1,    1,    1,    3,    4,    5,    3,    4,    6,
569
+       19,   19,   20,   20,    5,   21,   21,    6,   22,   22,
570
+       24,   24,   32,   32,   46,  215,   27,  210,   27,    3,
571
+        4,    5,   27,   27,    6,   30,   20,   33,   39,   21,
572
+       35,   33,   73,   30,   49,   39,   46,   30,   84,   35,
573
+
574
+      119,   49,   30,   87,  208,  204,  128,  203,  128,   46,
575
+       73,  128,   84,  119,   46,  202,  213,   87,   46,  163,
576
+      213,  163,  201,  200,  163,  219,  219,  219,  219,  219,
577
+      219,  219,  219,  219,  219,  219,  220,  220,  220,  220,
578
+      220,  220,  220,  220,  220,  220,  220,  221,  221,  221,
579
+      221,  221,  221,  221,  221,  221,  221,  221,  222,  222,
580
+      222,  222,  222,  222,  222,  222,  222,  222,  222,  223,
581
+      223,  223,  223,  224,  199,  224,  224,  224,  224,  225,
582
+      196,  195,  225,  226,  226,  226,  226,  227,  227,  227,
583
+      227,  228,  228,  193,  192,  189,  228,  228,  229,  229,
584
+
585
+      188,  187,  229,  229,  229,  229,  229,  229,  230,  230,
586
+      230,  230,  230,  230,  230,  230,  230,  230,  230,  231,
587
+      231,  186,  231,  231,  185,  231,  231,  231,  231,  232,
588
+      232,  183,  232,  232,  232,  232,  232,  232,  232,  232,
589
+      233,  233,  233,  182,  233,  233,  233,  233,  233,  233,
590
+      233,  234,  234,  181,  234,  234,  234,  234,  234,  234,
591
+      234,  234,  235,  235,  236,  236,  237,  237,  180,  179,
592
+      178,  175,  174,  173,  172,  171,  169,  168,  167,  160,
593
+      158,  157,  155,  153,  152,  151,  150,  149,  148,  147,
594
+      146,  145,  144,  143,  142,  139,  138,  137,  136,  135,
595
+
596
+      134,  133,  131,  130,  129,  127,  126,  125,  124,  122,
597
+      121,  120,  118,  106,   97,   96,   95,   94,   93,   92,
598
+       91,   90,   86,   85,   83,   82,   81,   80,   79,   78,
599
+       77,   76,   74,   72,   63,   62,   58,   54,   50,   41,
600
+       40,   38,   37,   36,   34,   31,   29,   28,   23,   18,
601
+       15,   11,   10,    9,    8,    7,  218,  218,  218,  218,
602
+      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
603
+      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
604
+      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
605
+      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
606
+
607
+      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
608
+      218
609
+    } ;
610
+
611
+/* Table of booleans, true if rule could match eol. */
612
+static const flex_int32_t yy_rule_can_match_eol[76] =
613
+    {   0,
614
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
615
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
616
+    0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
617
+    0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0,     };
618
+
619
+/* The intent behind this definition is that it'll catch
620
+ * any uses of REJECT which flex missed.
621
+ */
622
+#define REJECT reject_used_but_not_detected
623
+#define yymore() yymore_used_but_not_detected
624
+#define YY_MORE_ADJ 0
625
+#define YY_RESTORE_YY_MORE_OFFSET
626
+#line 1 "yara_lexer.l"
627
+/*
628
+ * YARA rule lexer for ClamAV
629
+ *
630
+ * Copyright (C) 2014-2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
631
+ *
632
+ * Authors: Steven Morgan
633
+ *
634
+ * This program is free software; you can redistribute it and/or modify it under
635
+ * the terms of the GNU General Public License version 2 as published by the
636
+ * Free Software Foundation.
637
+ *
638
+ * This program is distributed in the hope that it will be useful, but WITHOUT
639
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
640
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
641
+ * more details.
642
+ *
643
+ * You should have received a copy of the GNU General Public License along with
644
+ * this program; if not, write to the Free Software Foundation, Inc., 51
645
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
646
+ */
647
+/* This file was originally derived from yara 3.1.0 libyara/lexer.l and is
648
+   revised for running YARA rules in ClamAV. Following is the YARA copyright. */
649
+/*
650
+Copyright (c) 2007-2013. The YARA Authors. All Rights Reserved.
651
+
652
+Licensed under the Apache License, Version 2.0 (the "License");
653
+you may not use this file except in compliance with the License.
654
+You may obtain a copy of the License at
655
+
656
+   http://www.apache.org/licenses/LICENSE-2.0
657
+
658
+Unless required by applicable law or agreed to in writing, software
659
+distributed under the License is distributed on an "AS IS" BASIS,
660
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
661
+See the License for the specific language governing permissions and
662
+limitations under the License.
663
+*/
664
+/* Lexical analyzer for YARA */
665
+#line 42 "yara_lexer.l"
666
+
667
+#include <math.h>
668
+#include <stdio.h>
669
+#ifdef REAL_YARA
670
+#include <stdint.h>
671
+#endif
672
+#include <string.h>
673
+#include <setjmp.h>
674
+
675
+#ifdef REAL_YARA
676
+#include <yara/lexer.h>
677
+#include <yara/rules.h>
678
+#include <yara/sizedstr.h>
679
+#include <yara/error.h>
680
+#include <yara/mem.h>
681
+#include <yara/utils.h>
682
+
683
+#include "grammar.h"
684
+#else
685
+#include "others.h"
686
+#include "yara_clam.h"
687
+#include "yara_grammar.h"
688
+#include "yara_lexer.h"
689
+#endif
690
+
691
+#define LEX_CHECK_SPACE_OK(data, current_size, max_length) \
692
+    if (strlen(data) + current_size >= max_length - 1) \
693
+    { \
694
+      yyerror(yyscanner, compiler, "out of space in lex_buf"); \
695
+      yyterminate(); \
696
+    }
697
+
698
+#define YYTEXT_TO_BUFFER \
699
+    { \
700
+      char *yptr = yytext; \
701
+      LEX_CHECK_SPACE_OK(yptr, yyextra->lex_buf_len, LEX_BUF_SIZE); \
702
+      while(*yptr) \
703
+      { \
704
+        *yyextra->lex_buf_ptr++ = *yptr++; \
705
+        yyextra->lex_buf_len++; \
706
+      } \
707
+    }
708
+
709
+#ifdef _WIN32
710
+#define snprintf _snprintf
711
+#endif
712
+
713
+#line 715 "yara_lexer.c"
714
+#define YY_NO_UNISTD_H 1
715
+#define YY_NO_INPUT 1
716
+/* %option prefix="yara_yy" */
717
+
718
+#line 720 "yara_lexer.c"
719
+
720
+#define INITIAL 0
721
+#define str 1
722
+#define regexp 2
723
+#define include 3
724
+#define comment 4
725
+
726
+#ifndef YY_NO_UNISTD_H
727
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
728
+ * down here because we want the user's section 1 to have been scanned first.
729
+ * The user has a chance to override it with an option.
730
+ */
731
+#include <unistd.h>
732
+#endif
733
+
734
+#ifndef YY_EXTRA_TYPE
735
+#define YY_EXTRA_TYPE void *
736
+#endif
737
+
738
+/* Holds the entire state of the reentrant scanner. */
739
+struct yyguts_t
740
+    {
741
+
742
+    /* User-defined. Not touched by flex. */
743
+    YY_EXTRA_TYPE yyextra_r;
744
+
745
+    /* The rest are the same as the globals declared in the non-reentrant scanner. */
746
+    FILE *yyin_r, *yyout_r;
747
+    size_t yy_buffer_stack_top; /**< index of top of stack. */
748
+    size_t yy_buffer_stack_max; /**< capacity of stack. */
749
+    YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
750
+    char yy_hold_char;
751
+    int yy_n_chars;
752
+    int yyleng_r;
753
+    char *yy_c_buf_p;
754
+    int yy_init;
755
+    int yy_start;
756
+    int yy_did_buffer_switch_on_eof;
757
+    int yy_start_stack_ptr;
758
+    int yy_start_stack_depth;
759
+    int *yy_start_stack;
760
+    yy_state_type yy_last_accepting_state;
761
+    char* yy_last_accepting_cpos;
762
+
763
+    int yylineno_r;
764
+    int yy_flex_debug_r;
765
+
766
+    char *yytext_r;
767
+    int yy_more_flag;
768
+    int yy_more_len;
769
+
770
+    YYSTYPE * yylval_r;
771
+
772
+    }; /* end struct yyguts_t */
773
+
774
+static int yy_init_globals ( yyscan_t yyscanner );
775
+
776
+    /* This must go here because YYSTYPE and YYLTYPE are included
777
+     * from bison output in section 1.*/
778
+    #    define yylval yyg->yylval_r
779
+    
780
+int yylex_init (yyscan_t* scanner);
781
+
782
+int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
783
+
784
+/* Accessor methods to globals.
785
+   These are made visible to non-reentrant scanners for convenience. */
786
+
787
+int yylex_destroy ( yyscan_t yyscanner );
788
+
789
+int yyget_debug ( yyscan_t yyscanner );
790
+
791
+void yyset_debug ( int debug_flag , yyscan_t yyscanner );
792
+
793
+YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
794
+
795
+void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
796
+
797
+FILE *yyget_in ( yyscan_t yyscanner );
798
+
799
+void yyset_in  ( FILE * _in_str , yyscan_t yyscanner );
800
+
801
+FILE *yyget_out ( yyscan_t yyscanner );
802
+
803
+void yyset_out  ( FILE * _out_str , yyscan_t yyscanner );
804
+
805
+			int yyget_leng ( yyscan_t yyscanner );
806
+
807
+char *yyget_text ( yyscan_t yyscanner );
808
+
809
+int yyget_lineno ( yyscan_t yyscanner );
810
+
811
+void yyset_lineno ( int _line_number , yyscan_t yyscanner );
812
+
813
+int yyget_column  ( yyscan_t yyscanner );
814
+
815
+void yyset_column ( int _column_no , yyscan_t yyscanner );
816
+
817
+YYSTYPE * yyget_lval ( yyscan_t yyscanner );
818
+
819
+void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );
820
+
821
+/* Macros after this point can all be overridden by user definitions in
822
+ * section 1.
823
+ */
824
+
825
+#ifndef YY_SKIP_YYWRAP
826
+#ifdef __cplusplus
827
+extern "C" int yywrap ( yyscan_t yyscanner );
828
+#else
829
+extern int yywrap ( yyscan_t yyscanner );
830
+#endif
831
+#endif
832
+
833
+#ifndef YY_NO_UNPUT
834
+    
835
+#endif
836
+
837
+#ifndef yytext_ptr
838
+static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
839
+#endif
840
+
841
+#ifdef YY_NEED_STRLEN
842
+static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
843
+#endif
844
+
845
+#ifndef YY_NO_INPUT
846
+#ifdef __cplusplus
847
+static int yyinput ( yyscan_t yyscanner );
848
+#else
849
+static int input ( yyscan_t yyscanner );
850
+#endif
851
+
852
+#endif
853
+
854
+/* Amount of stuff to slurp up with each read. */
855
+#ifndef YY_READ_BUF_SIZE
856
+#ifdef __ia64__
857
+/* On IA-64, the buffer size is 16k, not 8k */
858
+#define YY_READ_BUF_SIZE 16384
859
+#else
860
+#define YY_READ_BUF_SIZE 8192
861
+#endif /* __ia64__ */
862
+#endif
863
+
864
+/* Copy whatever the last rule matched to the standard output. */
865
+#ifndef ECHO
866
+/* This used to be an fputs(), but since the string might contain NUL's,
867
+ * we now use fwrite().
868
+ */
869
+#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
870
+#endif
871
+
872
+/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
873
+ * is returned in "result".
874
+ */
875
+#ifndef YY_INPUT
876
+#define YY_INPUT(buf,result,max_size) \
877
+	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
878
+		{ \
879
+		int c = '*'; \
880
+		int n; \
881
+		for ( n = 0; n < max_size && \
882
+			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
883
+			buf[n] = (char) c; \
884
+		if ( c == '\n' ) \
885
+			buf[n++] = (char) c; \
886
+		if ( c == EOF && ferror( yyin ) ) \
887
+			YY_FATAL_ERROR( "input in flex scanner failed" ); \
888
+		result = n; \
889
+		} \
890
+	else \
891
+		{ \
892
+		errno=0; \
893
+		while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
894
+			{ \
895
+			if( errno != EINTR) \
896
+				{ \
897
+				YY_FATAL_ERROR( "input in flex scanner failed" ); \
898
+				break; \
899
+				} \
900
+			errno=0; \
901
+			clearerr(yyin); \
902
+			} \
903
+		}\
904
+\
905
+
906
+#endif
907
+
908
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
909
+ * we don't want an extra ';' after the "return" because that will cause
910
+ * some compilers to complain about unreachable statements.
911
+ */
912
+#ifndef yyterminate
913
+#define yyterminate() return YY_NULL
914
+#endif
915
+
916
+/* Number of entries by which start-condition stack grows. */
917
+#ifndef YY_START_STACK_INCR
918
+#define YY_START_STACK_INCR 25
919
+#endif
920
+
921
+/* Report a fatal error. */
922
+#ifndef YY_FATAL_ERROR
923
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
924
+#endif
925
+
926
+/* end tables serialization structures and prototypes */
927
+
928
+/* Default declaration of generated scanner - a define so the user can
929
+ * easily add parameters.
930
+ */
931
+#ifndef YY_DECL
932
+#define YY_DECL_IS_OURS 1
933
+
934
+extern int yylex \
935
+               (YYSTYPE * yylval_param , yyscan_t yyscanner);
936
+
937
+#define YY_DECL int yylex \
938
+               (YYSTYPE * yylval_param , yyscan_t yyscanner)
939
+#endif /* !YY_DECL */
940
+
941
+/* Code executed at the beginning of each rule, after yytext and yyleng
942
+ * have been set up.
943
+ */
944
+#ifndef YY_USER_ACTION
945
+#define YY_USER_ACTION
946
+#endif
947
+
948
+/* Code executed at the end of each rule. */
949
+#ifndef YY_BREAK
950
+#define YY_BREAK /*LINTED*/break;
951
+#endif
952
+
953
+#define YY_RULE_SETUP \
954
+	YY_USER_ACTION
955
+
956
+/** The main scanner function which does all the work.
957
+ */
958
+YY_DECL
959
+{
960
+	yy_state_type yy_current_state;
961
+	char *yy_cp, *yy_bp;
962
+	int yy_act;
963
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
964
+
965
+    yylval = yylval_param;
966
+
967
+	if ( !yyg->yy_init )
968
+		{
969
+		yyg->yy_init = 1;
970
+
971
+#ifdef YY_USER_INIT
972
+		YY_USER_INIT;
973
+#endif
974
+
975
+		if ( ! yyg->yy_start )
976
+			yyg->yy_start = 1;	/* first start state */
977
+
978
+		if ( ! yyin )
979
+			yyin = stdin;
980
+
981
+		if ( ! yyout )
982
+			yyout = stdout;
983
+
984
+		if ( ! YY_CURRENT_BUFFER ) {
985
+			yyensure_buffer_stack (yyscanner);
986
+			YY_CURRENT_BUFFER_LVALUE =
987
+				yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
988
+		}
989
+
990
+		yy_load_buffer_state( yyscanner );
991
+		}
992
+
993
+	{
994
+#line 112 "yara_lexer.l"
995
+
996
+
997
+#line 999 "yara_lexer.c"
998
+
999
+	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
1000
+		{
1001
+		yy_cp = yyg->yy_c_buf_p;
1002
+
1003
+		/* Support of yytext. */
1004
+		*yy_cp = yyg->yy_hold_char;
1005
+
1006
+		/* yy_bp points to the position in yy_ch_buf of the start of
1007
+		 * the current run.
1008
+		 */
1009
+		yy_bp = yy_cp;
1010
+
1011
+		yy_current_state = yyg->yy_start;
1012
+yy_match:
1013
+		do
1014
+			{
1015
+			YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
1016
+			if ( yy_accept[yy_current_state] )
1017
+				{
1018
+				yyg->yy_last_accepting_state = yy_current_state;
1019
+				yyg->yy_last_accepting_cpos = yy_cp;
1020
+				}
1021
+			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1022
+				{
1023
+				yy_current_state = (int) yy_def[yy_current_state];
1024
+				if ( yy_current_state >= 219 )
1025
+					yy_c = yy_meta[yy_c];
1026
+				}
1027
+			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1028
+			++yy_cp;
1029
+			}
1030
+		while ( yy_base[yy_current_state] != 357 );
1031
+
1032
+yy_find_action:
1033
+		yy_act = yy_accept[yy_current_state];
1034
+		if ( yy_act == 0 )
1035
+			{ /* have to back up */
1036
+			yy_cp = yyg->yy_last_accepting_cpos;
1037
+			yy_current_state = yyg->yy_last_accepting_state;
1038
+			yy_act = yy_accept[yy_current_state];
1039
+			}
1040
+
1041
+		YY_DO_BEFORE_ACTION;
1042
+
1043
+		if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
1044
+			{
1045
+			int yyl;
1046
+			for ( yyl = 0; yyl < yyleng; ++yyl )
1047
+				if ( yytext[yyl] == '\n' )
1048
+					
1049
+    do{ yylineno++;
1050
+        yycolumn=0;
1051
+    }while(0)
1052
+;
1053
+			}
1054
+
1055
+do_action:	/* This label is used only to access EOF actions. */
1056
+
1057
+		switch ( yy_act )
1058
+	{ /* beginning of action switch */
1059
+			case 0: /* must back up */
1060
+			/* undo the effects of YY_DO_BEFORE_ACTION */
1061
+			*yy_cp = yyg->yy_hold_char;
1062
+			yy_cp = yyg->yy_last_accepting_cpos;
1063
+			yy_current_state = yyg->yy_last_accepting_state;
1064
+			goto yy_find_action;
1065
+
1066
+case 1:
1067
+YY_RULE_SETUP
1068
+#line 114 "yara_lexer.l"
1069
+{ return _LT_;          }
1070
+	YY_BREAK
1071
+case 2:
1072
+YY_RULE_SETUP
1073
+#line 115 "yara_lexer.l"
1074
+{ return _GT_;          }
1075
+	YY_BREAK
1076
+case 3:
1077
+YY_RULE_SETUP
1078
+#line 116 "yara_lexer.l"
1079
+{ return _LE_;          }
1080
+	YY_BREAK
1081
+case 4:
1082
+YY_RULE_SETUP
1083
+#line 117 "yara_lexer.l"
1084
+{ return _GE_;          }
1085
+	YY_BREAK
1086
+case 5:
1087
+YY_RULE_SETUP
1088
+#line 118 "yara_lexer.l"
1089
+{ return _EQ_;          }
1090
+	YY_BREAK
1091
+case 6:
1092
+YY_RULE_SETUP
1093
+#line 119 "yara_lexer.l"
1094
+{ return _NEQ_;         }
1095
+	YY_BREAK
1096
+case 7:
1097
+YY_RULE_SETUP
1098
+#line 120 "yara_lexer.l"
1099
+{ return _SHIFT_LEFT_;  }
1100
+	YY_BREAK
1101
+case 8:
1102
+YY_RULE_SETUP
1103
+#line 121 "yara_lexer.l"
1104
+{ return _SHIFT_RIGHT_; }
1105
+	YY_BREAK
1106
+case 9:
1107
+YY_RULE_SETUP
1108
+#line 122 "yara_lexer.l"
1109
+{ return _PRIVATE_;     }
1110
+	YY_BREAK
1111
+case 10:
1112
+YY_RULE_SETUP
1113
+#line 123 "yara_lexer.l"
1114
+{ return _GLOBAL_;      }
1115
+	YY_BREAK
1116
+case 11:
1117
+YY_RULE_SETUP
1118
+#line 124 "yara_lexer.l"
1119
+{ return _RULE_;        }
1120
+	YY_BREAK
1121
+case 12:
1122
+YY_RULE_SETUP
1123
+#line 125 "yara_lexer.l"
1124
+{ return _META_;        }
1125
+	YY_BREAK
1126
+case 13:
1127
+YY_RULE_SETUP
1128
+#line 126 "yara_lexer.l"
1129
+{ return _STRINGS_;     }
1130
+	YY_BREAK
1131
+case 14:
1132
+YY_RULE_SETUP
1133
+#line 127 "yara_lexer.l"
1134
+{ return _ASCII_;       }
1135
+	YY_BREAK
1136
+case 15:
1137
+YY_RULE_SETUP
1138
+#line 128 "yara_lexer.l"
1139
+{ return _WIDE_;        }
1140
+	YY_BREAK
1141
+case 16:
1142
+YY_RULE_SETUP
1143
+#line 129 "yara_lexer.l"
1144
+{ return _FULLWORD_;    }
1145
+	YY_BREAK
1146
+case 17:
1147
+YY_RULE_SETUP
1148
+#line 130 "yara_lexer.l"
1149
+{ return _NOCASE_;      }
1150
+	YY_BREAK
1151
+case 18:
1152
+YY_RULE_SETUP
1153
+#line 131 "yara_lexer.l"
1154
+{ return _CONDITION_;   }
1155
+	YY_BREAK
1156
+case 19:
1157
+YY_RULE_SETUP
1158
+#line 132 "yara_lexer.l"
1159
+{ return _TRUE_;        }
1160
+	YY_BREAK
1161
+case 20:
1162
+YY_RULE_SETUP
1163
+#line 133 "yara_lexer.l"
1164
+{ return _FALSE_;       }
1165
+	YY_BREAK
1166
+case 21:
1167
+YY_RULE_SETUP
1168
+#line 134 "yara_lexer.l"
1169
+{ return _NOT_;         }
1170
+	YY_BREAK
1171
+case 22:
1172
+YY_RULE_SETUP
1173
+#line 135 "yara_lexer.l"
1174
+{ return _AND_;         }
1175
+	YY_BREAK
1176
+case 23:
1177
+YY_RULE_SETUP
1178
+#line 136 "yara_lexer.l"
1179
+{ return _OR_;          }
1180
+	YY_BREAK
1181
+case 24:
1182
+YY_RULE_SETUP
1183
+#line 137 "yara_lexer.l"
1184
+{ return _AT_;          }
1185
+	YY_BREAK
1186
+case 25:
1187
+YY_RULE_SETUP
1188
+#line 138 "yara_lexer.l"
1189
+{ return _IN_;          }
1190
+	YY_BREAK
1191
+case 26:
1192
+YY_RULE_SETUP
1193
+#line 139 "yara_lexer.l"
1194
+{ return _OF_;          }
1195
+	YY_BREAK
1196
+case 27:
1197
+YY_RULE_SETUP
1198
+#line 140 "yara_lexer.l"
1199
+{ return _THEM_;        }
1200
+	YY_BREAK
1201
+case 28:
1202
+YY_RULE_SETUP
1203
+#line 141 "yara_lexer.l"
1204
+{ return _FOR_;         }
1205
+	YY_BREAK
1206
+case 29:
1207
+YY_RULE_SETUP
1208
+#line 142 "yara_lexer.l"
1209
+{ return _ALL_;         }
1210
+	YY_BREAK
1211
+case 30:
1212
+YY_RULE_SETUP
1213
+#line 143 "yara_lexer.l"
1214
+{ return _ANY_;         }
1215
+	YY_BREAK
1216
+case 31:
1217
+YY_RULE_SETUP
1218
+#line 144 "yara_lexer.l"
1219
+{ return _ENTRYPOINT_;  }
1220
+	YY_BREAK
1221
+case 32:
1222
+YY_RULE_SETUP
1223
+#line 145 "yara_lexer.l"
1224
+{ return _FILESIZE_;    }
1225
+	YY_BREAK
1226
+case 33:
1227
+YY_RULE_SETUP
1228
+#line 146 "yara_lexer.l"
1229
+{ return _UINT8_;       }
1230
+	YY_BREAK
1231
+case 34:
1232
+YY_RULE_SETUP
1233
+#line 147 "yara_lexer.l"
1234
+{ return _UINT16_;      }
1235
+	YY_BREAK
1236
+case 35:
1237
+YY_RULE_SETUP
1238
+#line 148 "yara_lexer.l"
1239
+{ return _UINT32_;      }
1240
+	YY_BREAK
1241
+case 36:
1242
+YY_RULE_SETUP
1243
+#line 149 "yara_lexer.l"
1244
+{ return _INT8_;        }
1245
+	YY_BREAK
1246
+case 37:
1247
+YY_RULE_SETUP
1248
+#line 150 "yara_lexer.l"
1249
+{ return _INT16_;       }
1250
+	YY_BREAK
1251
+case 38:
1252
+YY_RULE_SETUP
1253
+#line 151 "yara_lexer.l"
1254
+{ return _INT32_;       }
1255
+	YY_BREAK
1256
+case 39:
1257
+YY_RULE_SETUP
1258
+#line 152 "yara_lexer.l"
1259
+{ return _MATCHES_;     }
1260
+	YY_BREAK
1261
+case 40:
1262
+YY_RULE_SETUP
1263
+#line 153 "yara_lexer.l"
1264
+{ return _CONTAINS_;    }
1265
+	YY_BREAK
1266
+case 41:
1267
+YY_RULE_SETUP
1268
+#line 154 "yara_lexer.l"
1269
+{ return _IMPORT_;      }
1270
+	YY_BREAK
1271
+case 42:
1272
+YY_RULE_SETUP
1273
+#line 157 "yara_lexer.l"
1274
+{ BEGIN(comment);       }
1275
+	YY_BREAK
1276
+case 43:
1277
+YY_RULE_SETUP
1278
+#line 158 "yara_lexer.l"
1279
+{ BEGIN(INITIAL);       }
1280
+	YY_BREAK
1281
+case 44:
1282
+/* rule 44 can match eol */
1283
+YY_RULE_SETUP
1284
+#line 159 "yara_lexer.l"
1285
+{ /* skip comments */   }
1286
+	YY_BREAK
1287
+case 45:
1288
+YY_RULE_SETUP
1289
+#line 162 "yara_lexer.l"
1290
+{ /* skip single-line comments */ }
1291
+	YY_BREAK
1292
+case 46:
1293
+YY_RULE_SETUP
1294
+#line 165 "yara_lexer.l"
1295
+{
1296
+                          yyextra->lex_buf_ptr = yyextra->lex_buf;
1297
+                          yyextra->lex_buf_len = 0;
1298
+                          BEGIN(include);
1299
+                        }
1300
+	YY_BREAK
1301
+case 47:
1302
+/* rule 47 can match eol */
1303
+YY_RULE_SETUP
1304
+#line 172 "yara_lexer.l"
1305
+{ YYTEXT_TO_BUFFER; }
1306
+	YY_BREAK
1307
+case 48:
1308
+YY_RULE_SETUP
1309
+#line 175 "yara_lexer.l"
1310
+{
1311
+
1312
+  char            buffer[1024];
1313
+  char            *current_file_name;
1314
+  char            *s = NULL;
1315
+  char            *b = NULL;
1316
+  char            *f;
1317
+  FILE*           fh;
1318
+
1319
+  if (compiler->allow_includes)
1320
+  {
1321
+    *yyextra->lex_buf_ptr = '\0'; // null-terminate included file path
1322
+
1323
+    // move path of current source file into buffer
1324
+    current_file_name = yr_compiler_get_current_file_name(compiler);
1325
+
1326
+    if (current_file_name != NULL)
1327
+    {
1328
+      strlcpy(buffer, current_file_name, sizeof(buffer));
1329
+    }
1330
+    else
1331
+    {
1332
+      buffer[0] = '\0';
1333
+    }
1334
+
1335
+    // make included file path relative to current source file
1336
+    s = strrchr(buffer, '/');
1337
+
1338
+    #ifdef _WIN32
1339
+    b = strrchr(buffer, '\\'); // in Windows both path delimiters are accepted
1340
+    #endif
1341
+
1342
+    if (s != NULL || b != NULL)
1343
+    {
1344
+      f = (b > s)? (b + 1): (s + 1);
1345
+
1346
+      strlcpy(f, yyextra->lex_buf, sizeof(buffer) - (f - buffer));
1347
+
1348
+      f = buffer;
1349
+
1350
+      // SECURITY: Potential for directory traversal here.
1351
+      fh = fopen(buffer, "r");
1352
+
1353
+      // if include file was not found relative to current source file,
1354
+      // try to open it with path as specified by user (maybe user wrote
1355
+      // a full path)
1356
+
1357
+      if (fh == NULL)
1358
+      {
1359
+        f = yyextra->lex_buf;
1360
+
1361
+        // SECURITY: Potential for directory traversal here.
1362
+        fh = fopen(yyextra->lex_buf, "r");
1363
+      }
1364
+    }
1365
+    else
1366
+    {
1367
+      f = yyextra->lex_buf;
1368
+
1369
+      // SECURITY: Potential for directory traversal here.
1370
+      fh = fopen(yyextra->lex_buf, "r");
1371
+    }
1372
+
1373
+    if (fh != NULL)
1374
+    {
1375
+      int error_code = _yr_compiler_push_file_name(compiler, f);
1376
+
1377
+      if (error_code != ERROR_SUCCESS)
1378
+      {
1379
+        if (error_code == ERROR_INCLUDES_CIRCULAR_REFERENCE)
1380
+        {
1381
+          yyerror(yyscanner, compiler, "includes circular reference");
1382
+        }
1383
+        else if (error_code == ERROR_INCLUDE_DEPTH_EXCEEDED)
1384
+        {
1385
+          yyerror(yyscanner, compiler, "includes depth exceeded");
1386
+        }
1387
+
1388
+        yyterminate();
1389
+      }
1390
+
1391
+      _yr_compiler_push_file(compiler, fh);
1392
+      yypush_buffer_state(
1393
+          yy_create_buffer(fh, YY_BUF_SIZE, yyscanner), yyscanner);
1394
+    }
1395
+    else
1396
+    {
1397
+      snprintf(buffer, sizeof(buffer),
1398
+               "can't open include file: %s", yyextra->lex_buf);
1399
+      yyerror(yyscanner, compiler, buffer);
1400
+    }
1401
+  }
1402
+  else // not allowing includes
1403
+  {
1404
+    yyerror(yyscanner, compiler, "includes are disabled");
1405
+    yyterminate();
1406
+  }
1407
+
1408
+  BEGIN(INITIAL);
1409
+}
1410
+	YY_BREAK
1411
+case YY_STATE_EOF(INITIAL):
1412
+case YY_STATE_EOF(str):
1413
+case YY_STATE_EOF(regexp):
1414
+case YY_STATE_EOF(include):
1415
+case YY_STATE_EOF(comment):
1416
+#line 277 "yara_lexer.l"
1417
+{
1418
+
1419
+  YR_COMPILER* compiler = yyget_extra(yyscanner);
1420
+  FILE* file = _yr_compiler_pop_file(compiler);
1421
+
1422
+  if (file != NULL)
1423
+  {
1424
+    fclose(file);
1425
+  }
1426
+
1427
+  _yr_compiler_pop_file_name(compiler);
1428
+  yypop_buffer_state(yyscanner);
1429
+
1430
+  if (!YY_CURRENT_BUFFER)
1431
+  {
1432
+    yyterminate();
1433
+  }
1434
+}
1435
+	YY_BREAK
1436
+case 49:
1437
+YY_RULE_SETUP
1438
+#line 297 "yara_lexer.l"
1439
+{
1440
+
1441
+  yylval->c_string = yr_strdup(yytext);
1442
+
1443
+  if (yylval->c_string == NULL)
1444
+  {
1445
+    yyerror(yyscanner, compiler, "not enough memory");
1446
+    yyterminate();
1447
+  }
1448
+
1449
+  return _STRING_IDENTIFIER_WITH_WILDCARD_;
1450
+}
1451
+	YY_BREAK
1452
+case 50:
1453
+YY_RULE_SETUP
1454
+#line 311 "yara_lexer.l"
1455
+{
1456
+
1457
+  yylval->c_string = yr_strdup(yytext);
1458
+
1459
+  if (yylval->c_string == NULL)
1460
+  {
1461
+    yyerror(yyscanner, compiler, "not enough memory");
1462
+    yyterminate();
1463
+  }
1464
+
1465
+  return _STRING_IDENTIFIER_;
1466
+}
1467
+	YY_BREAK
1468
+case 51:
1469
+YY_RULE_SETUP
1470
+#line 325 "yara_lexer.l"
1471
+{
1472
+
1473
+  yylval->c_string = yr_strdup(yytext);
1474
+
1475
+  if (yylval->c_string == NULL)
1476
+  {
1477
+    yyerror(yyscanner, compiler, "not enough memory");
1478
+    yyterminate();
1479
+  }
1480
+
1481
+  yylval->c_string[0] = '$'; /* replace # by $*/
1482
+  return _STRING_COUNT_;
1483
+}
1484
+	YY_BREAK
1485
+case 52:
1486
+YY_RULE_SETUP
1487
+#line 340 "yara_lexer.l"
1488
+{
1489
+
1490
+  yylval->c_string = yr_strdup(yytext);
1491
+
1492
+  if (yylval->c_string == NULL)
1493
+  {
1494
+    yyerror(yyscanner, compiler, "not enough memory");
1495
+    yyterminate();
1496
+  }
1497
+
1498
+  yylval->c_string[0] = '$'; /* replace @ by $*/
1499
+  return _STRING_OFFSET_;
1500
+}
1501
+	YY_BREAK
1502
+case 53:
1503
+YY_RULE_SETUP
1504
+#line 355 "yara_lexer.l"
1505
+{
1506
+
1507
+  if (strlen(yytext) > 128)
1508
+  {
1509
+    yyerror(yyscanner, compiler, "indentifier too long");
1510
+  }
1511
+
1512
+  yylval->c_string = yr_strdup(yytext);
1513
+
1514
+  if (yylval->c_string == NULL)
1515
+  {
1516
+    yyerror(yyscanner, compiler, "not enough memory");
1517
+    yyterminate();
1518
+  }
1519
+  return _IDENTIFIER_;
1520
+}
1521
+	YY_BREAK
1522
+case 54:
1523
+YY_RULE_SETUP
1524
+#line 373 "yara_lexer.l"
1525
+{
1526
+
1527
+  yylval->integer = (size_t) atol(yytext);
1528
+
1529
+  if (strstr(yytext, "KB") != NULL)
1530
+  {
1531
+     yylval->integer *= 1024;
1532
+  }
1533
+  else if (strstr(yytext, "MB") != NULL)
1534
+  {
1535
+     yylval->integer *= 1048576;
1536
+  }
1537
+  return _NUMBER_;
1538
+}
1539
+	YY_BREAK
1540
+case 55:
1541
+YY_RULE_SETUP
1542
+#line 389 "yara_lexer.l"
1543
+{
1544
+
1545
+  yylval->integer = xtoi(yytext + 2);
1546
+  return _NUMBER_;
1547
+}
1548
+	YY_BREAK
1549
+case 56:
1550
+YY_RULE_SETUP
1551
+#line 396 "yara_lexer.l"
1552
+{     /* saw closing quote - all done */
1553
+
1554
+  SIZED_STRING* s;
1555
+
1556
+  if (yyextra->lex_buf_len == 0)
1557
+  {
1558
+    yyerror(yyscanner, compiler, "empty string");
1559
+  }
1560
+
1561
+  *yyextra->lex_buf_ptr = '\0';
1562
+
1563
+  BEGIN(INITIAL);
1564
+
1565
+  s = (SIZED_STRING*) yr_malloc(yyextra->lex_buf_len + sizeof(SIZED_STRING));
1566
+  s->length = yyextra->lex_buf_len;
1567
+  s->flags = 0;
1568
+
1569
+  memcpy(s->c_string, yyextra->lex_buf, yyextra->lex_buf_len + 1);
1570
+  yylval->sized_string = s;
1571
+
1572
+  return _TEXT_STRING_;
1573
+}
1574
+	YY_BREAK
1575
+case 57:
1576
+YY_RULE_SETUP
1577
+#line 420 "yara_lexer.l"
1578
+{
1579
+
1580
+  LEX_CHECK_SPACE_OK("\t", yyextra->lex_buf_len, LEX_BUF_SIZE);
1581
+  *yyextra->lex_buf_ptr++ = '\t';
1582
+  yyextra->lex_buf_len++;
1583
+}
1584
+	YY_BREAK
1585
+case 58:
1586
+YY_RULE_SETUP
1587
+#line 428 "yara_lexer.l"
1588
+{
1589
+
1590
+  LEX_CHECK_SPACE_OK("\n", yyextra->lex_buf_len, LEX_BUF_SIZE);
1591
+  *yyextra->lex_buf_ptr++ = '\n';
1592
+  yyextra->lex_buf_len++;
1593
+}
1594
+	YY_BREAK
1595
+case 59:
1596
+YY_RULE_SETUP
1597
+#line 436 "yara_lexer.l"
1598
+{
1599
+
1600
+  LEX_CHECK_SPACE_OK("\"", yyextra->lex_buf_len, LEX_BUF_SIZE);
1601
+  *yyextra->lex_buf_ptr++ = '\"';
1602
+  yyextra->lex_buf_len++;
1603
+}
1604
+	YY_BREAK
1605
+case 60:
1606
+YY_RULE_SETUP
1607
+#line 444 "yara_lexer.l"
1608
+{
1609
+
1610
+  LEX_CHECK_SPACE_OK("\\", yyextra->lex_buf_len, LEX_BUF_SIZE);
1611
+  *yyextra->lex_buf_ptr++ = '\\';
1612
+  yyextra->lex_buf_len++;
1613
+}
1614
+	YY_BREAK
1615
+case 61:
1616
+YY_RULE_SETUP
1617
+#line 452 "yara_lexer.l"
1618
+{
1619
+
1620
+   int result;
1621
+
1622
+   sscanf( yytext + 2, "%x", &result );
1623
+   LEX_CHECK_SPACE_OK("X", yyextra->lex_buf_len, LEX_BUF_SIZE);
1624
+   *yyextra->lex_buf_ptr++ = result;
1625
+   yyextra->lex_buf_len++;
1626
+}
1627
+	YY_BREAK
1628
+case 62:
1629
+YY_RULE_SETUP
1630
+#line 463 "yara_lexer.l"
1631
+{ YYTEXT_TO_BUFFER; }
1632
+	YY_BREAK
1633
+case 63:
1634
+/* rule 63 can match eol */
1635
+YY_RULE_SETUP
1636
+#line 466 "yara_lexer.l"
1637
+{
1638
+
1639
+  yyerror(yyscanner, compiler, "unterminated string");
1640
+  yyterminate();
1641
+}
1642
+	YY_BREAK
1643
+case 64:
1644
+/* rule 64 can match eol */
1645
+YY_RULE_SETUP
1646
+#line 472 "yara_lexer.l"
1647
+{
1648
+
1649
+  yyerror(yyscanner, compiler, "illegal escape sequence");
1650
+}
1651
+	YY_BREAK
1652
+case 65:
1653
+YY_RULE_SETUP
1654
+#line 478 "yara_lexer.l"
1655
+{
1656
+
1657
+  SIZED_STRING* s;
1658
+
1659
+  if (yyextra->lex_buf_len == 0)
1660
+  {
1661
+    yyerror(yyscanner, compiler, "empty regular expression");
1662
+  }
1663
+
1664
+  *yyextra->lex_buf_ptr = '\0';
1665
+
1666
+  BEGIN(INITIAL);
1667
+
1668
+  s = (SIZED_STRING*) yr_malloc(yyextra->lex_buf_len + sizeof(SIZED_STRING));
1669
+  s->flags = 0;
1670
+
1671
+  if (yytext[1] == 'i')
1672
+    s->flags |= SIZED_STRING_FLAGS_NO_CASE;
1673
+
1674
+  if (yytext[1] == 's' || yytext[2] == 's')
1675
+    s->flags |= SIZED_STRING_FLAGS_DOT_ALL;
1676
+
1677
+  s->length = yyextra->lex_buf_len;
1678
+  strlcpy(s->c_string, yyextra->lex_buf, s->length + 1);
1679
+
1680
+  yylval->sized_string = s;
1681
+
1682
+  return _REGEXP_;
1683
+}
1684
+	YY_BREAK
1685
+case 66:
1686
+YY_RULE_SETUP
1687
+#line 509 "yara_lexer.l"
1688
+{
1689
+
1690
+  LEX_CHECK_SPACE_OK("/", yyextra->lex_buf_len, LEX_BUF_SIZE);
1691
+  *yyextra->lex_buf_ptr++ = '/';
1692
+  yyextra->lex_buf_len++ ;
1693
+}
1694
+	YY_BREAK
1695
+case 67:
1696
+YY_RULE_SETUP
1697
+#line 517 "yara_lexer.l"
1698
+{
1699
+
1700
+  LEX_CHECK_SPACE_OK("\\.", yyextra->lex_buf_len, LEX_BUF_SIZE);
1701
+  *yyextra->lex_buf_ptr++ = yytext[0];
1702
+  *yyextra->lex_buf_ptr++ = yytext[1];
1703
+  yyextra->lex_buf_len += 2;
1704
+}
1705
+	YY_BREAK
1706
+case 68:
1707
+YY_RULE_SETUP
1708
+#line 526 "yara_lexer.l"
1709
+{ YYTEXT_TO_BUFFER; }
1710
+	YY_BREAK
1711
+case 69:
1712
+/* rule 69 can match eol */
1713
+YY_RULE_SETUP
1714
+#line 529 "yara_lexer.l"
1715
+{
1716
+
1717
+  yyerror(yyscanner, compiler, "unterminated regular expression");
1718
+  yyterminate();
1719
+}
1720
+	YY_BREAK
1721
+case 70:
1722
+YY_RULE_SETUP
1723
+#line 536 "yara_lexer.l"
1724
+{
1725
+
1726
+  yyextra->lex_buf_ptr = yyextra->lex_buf;
1727
+  yyextra->lex_buf_len = 0;
1728
+  BEGIN(str);
1729
+}
1730
+	YY_BREAK
1731
+case 71:
1732
+YY_RULE_SETUP
1733
+#line 544 "yara_lexer.l"
1734
+{
1735
+
1736
+  yyextra->lex_buf_ptr = yyextra->lex_buf;
1737
+  yyextra->lex_buf_len = 0;
1738
+  BEGIN(regexp);
1739
+}
1740
+	YY_BREAK
1741
+case 72:
1742
+/* rule 72 can match eol */
1743
+YY_RULE_SETUP
1744
+#line 552 "yara_lexer.l"
1745
+{
1746
+
1747
+  int len = strlen(yytext);
1748
+  SIZED_STRING* s = (SIZED_STRING*) yr_malloc(len + sizeof(SIZED_STRING));
1749
+
1750
+  s->length = len;
1751
+  s->flags = 0;
1752
+
1753
+  strlcpy(s->c_string, yytext, s->length + 1);
1754
+  yylval->sized_string = s;
1755
+
1756
+  return _HEX_STRING_;
1757
+}
1758
+	YY_BREAK
1759
+case 73:
1760
+/* rule 73 can match eol */
1761
+YY_RULE_SETUP
1762
+#line 567 "yara_lexer.l"
1763
+/* skip whitespace */
1764
+	YY_BREAK
1765
+case 74:
1766
+YY_RULE_SETUP
1767
+#line 569 "yara_lexer.l"
1768
+{
1769
+
1770
+  if (yytext[0] >= 32 && yytext[0] < 127)
1771
+  {
1772
+    return yytext[0];
1773
+  }
1774
+  else
1775
+  {
1776
+    yyerror(yyscanner, compiler, "non-ascii character");
1777
+    yyterminate();
1778
+  }
1779
+}
1780
+	YY_BREAK
1781
+case 75:
1782
+YY_RULE_SETUP
1783
+#line 582 "yara_lexer.l"
1784
+ECHO;
1785
+	YY_BREAK
1786
+#line 1788 "yara_lexer.c"
1787
+
1788
+	case YY_END_OF_BUFFER:
1789
+		{
1790
+		/* Amount of text matched not including the EOB char. */
1791
+		int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1792
+
1793
+		/* Undo the effects of YY_DO_BEFORE_ACTION. */
1794
+		*yy_cp = yyg->yy_hold_char;
1795
+		YY_RESTORE_YY_MORE_OFFSET
1796
+
1797
+		if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1798
+			{
1799
+			/* We're scanning a new file or input source.  It's
1800
+			 * possible that this happened because the user
1801
+			 * just pointed yyin at a new source and called
1802
+			 * yylex().  If so, then we have to assure
1803
+			 * consistency between YY_CURRENT_BUFFER and our
1804
+			 * globals.  Here is the right place to do so, because
1805
+			 * this is the first action (other than possibly a
1806
+			 * back-up) that will match for the new input source.
1807
+			 */
1808
+			yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1809
+			YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1810
+			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1811
+			}
1812
+
1813
+		/* Note that here we test for yy_c_buf_p "<=" to the position
1814
+		 * of the first EOB in the buffer, since yy_c_buf_p will
1815
+		 * already have been incremented past the NUL character
1816
+		 * (since all states make transitions on EOB to the
1817
+		 * end-of-buffer state).  Contrast this with the test
1818
+		 * in input().
1819
+		 */
1820
+		if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1821
+			{ /* This was really a NUL. */
1822
+			yy_state_type yy_next_state;
1823
+
1824
+			yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1825
+
1826
+			yy_current_state = yy_get_previous_state( yyscanner );
1827
+
1828
+			/* Okay, we're now positioned to make the NUL
1829
+			 * transition.  We couldn't have
1830
+			 * yy_get_previous_state() go ahead and do it
1831
+			 * for us because it doesn't know how to deal
1832
+			 * with the possibility of jamming (and we don't
1833
+			 * want to build jamming into it because then it
1834
+			 * will run more slowly).
1835
+			 */
1836
+
1837
+			yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1838
+
1839
+			yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1840
+
1841
+			if ( yy_next_state )
1842
+				{
1843
+				/* Consume the NUL. */
1844
+				yy_cp = ++yyg->yy_c_buf_p;
1845
+				yy_current_state = yy_next_state;
1846
+				goto yy_match;
1847
+				}
1848
+
1849
+			else
1850
+				{
1851
+				yy_cp = yyg->yy_c_buf_p;
1852
+				goto yy_find_action;
1853
+				}
1854
+			}
1855
+
1856
+		else switch ( yy_get_next_buffer( yyscanner ) )
1857
+			{
1858
+			case EOB_ACT_END_OF_FILE:
1859
+				{
1860
+				yyg->yy_did_buffer_switch_on_eof = 0;
1861
+
1862
+				if ( yywrap( yyscanner ) )
1863
+					{
1864
+					/* Note: because we've taken care in
1865
+					 * yy_get_next_buffer() to have set up
1866
+					 * yytext, we can now set up
1867
+					 * yy_c_buf_p so that if some total
1868
+					 * hoser (like flex itself) wants to
1869
+					 * call the scanner after we return the
1870
+					 * YY_NULL, it'll still work - another
1871
+					 * YY_NULL will get returned.
1872
+					 */
1873
+					yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1874
+
1875
+					yy_act = YY_STATE_EOF(YY_START);
1876
+					goto do_action;
1877
+					}
1878
+
1879
+				else
1880
+					{
1881
+					if ( ! yyg->yy_did_buffer_switch_on_eof )
1882
+						YY_NEW_FILE;
1883
+					}
1884
+				break;
1885
+				}
1886
+
1887
+			case EOB_ACT_CONTINUE_SCAN:
1888
+				yyg->yy_c_buf_p =
1889
+					yyg->yytext_ptr + yy_amount_of_matched_text;
1890
+
1891
+				yy_current_state = yy_get_previous_state( yyscanner );
1892
+
1893
+				yy_cp = yyg->yy_c_buf_p;
1894
+				yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1895
+				goto yy_match;
1896
+
1897
+			case EOB_ACT_LAST_MATCH:
1898
+				yyg->yy_c_buf_p =
1899
+				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1900
+
1901
+				yy_current_state = yy_get_previous_state( yyscanner );
1902
+
1903
+				yy_cp = yyg->yy_c_buf_p;
1904
+				yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1905
+				goto yy_find_action;
1906
+			}
1907
+		break;
1908
+		}
1909
+
1910
+	default:
1911
+		YY_FATAL_ERROR(
1912
+			"fatal flex scanner internal error--no action found" );
1913
+	} /* end of action switch */
1914
+		} /* end of scanning one token */
1915
+	} /* end of user's declarations */
1916
+} /* end of yylex */
1917
+
1918
+/* yy_get_next_buffer - try to read in a new buffer
1919
+ *
1920
+ * Returns a code representing an action:
1921
+ *	EOB_ACT_LAST_MATCH -
1922
+ *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1923
+ *	EOB_ACT_END_OF_FILE - end of file
1924
+ */
1925
+static int yy_get_next_buffer (yyscan_t yyscanner)
1926
+{
1927
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1928
+	char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1929
+	char *source = yyg->yytext_ptr;
1930
+	int number_to_move, i;
1931
+	int ret_val;
1932
+
1933
+	if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1934
+		YY_FATAL_ERROR(
1935
+		"fatal flex scanner internal error--end of buffer missed" );
1936
+
1937
+	if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1938
+		{ /* Don't try to fill the buffer, so this is an EOF. */
1939
+		if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1940
+			{
1941
+			/* We matched a single character, the EOB, so
1942
+			 * treat this as a final EOF.
1943
+			 */
1944
+			return EOB_ACT_END_OF_FILE;
1945
+			}
1946
+
1947
+		else
1948
+			{
1949
+			/* We matched some text prior to the EOB, first
1950
+			 * process it.
1951
+			 */
1952
+			return EOB_ACT_LAST_MATCH;
1953
+			}
1954
+		}
1955
+
1956
+	/* Try to read more data. */
1957
+
1958
+	/* First move last chars to start of buffer. */
1959
+	number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
1960
+
1961
+	for ( i = 0; i < number_to_move; ++i )
1962
+		*(dest++) = *(source++);
1963
+
1964
+	if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1965
+		/* don't do the read, it's not guaranteed to return an EOF,
1966
+		 * just force an EOF
1967
+		 */
1968
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1969
+
1970
+	else
1971
+		{
1972
+			int num_to_read =
1973
+			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1974
+
1975
+		while ( num_to_read <= 0 )
1976
+			{ /* Not enough room in the buffer - grow it. */
1977
+
1978
+			/* just a shorter name for the current buffer */
1979
+			YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1980
+
1981
+			int yy_c_buf_p_offset =
1982
+				(int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1983
+
1984
+			if ( b->yy_is_our_buffer )
1985
+				{
1986
+				int new_size = b->yy_buf_size * 2;
1987
+
1988
+				if ( new_size <= 0 )
1989
+					b->yy_buf_size += b->yy_buf_size / 8;
1990
+				else
1991
+					b->yy_buf_size *= 2;
1992
+
1993
+				b->yy_ch_buf = (char *)
1994
+					/* Include room in for 2 EOB chars. */
1995
+					yyrealloc( (void *) b->yy_ch_buf,
1996
+							 (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
1997
+				}
1998
+			else
1999
+				/* Can't grow it, we don't own it. */
2000
+				b->yy_ch_buf = NULL;
2001
+
2002
+			if ( ! b->yy_ch_buf )
2003
+				YY_FATAL_ERROR(
2004
+				"fatal error - scanner input buffer overflow" );
2005
+
2006
+			yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
2007
+
2008
+			num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
2009
+						number_to_move - 1;
2010
+
2011
+			}
2012
+
2013
+		if ( num_to_read > YY_READ_BUF_SIZE )
2014
+			num_to_read = YY_READ_BUF_SIZE;
2015
+
2016
+		/* Read in more data. */
2017
+		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
2018
+			yyg->yy_n_chars, num_to_read );
2019
+
2020
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2021
+		}
2022
+
2023
+	if ( yyg->yy_n_chars == 0 )
2024
+		{
2025
+		if ( number_to_move == YY_MORE_ADJ )
2026
+			{
2027
+			ret_val = EOB_ACT_END_OF_FILE;
2028
+			yyrestart( yyin  , yyscanner);
2029
+			}
2030
+
2031
+		else
2032
+			{
2033
+			ret_val = EOB_ACT_LAST_MATCH;
2034
+			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
2035
+				YY_BUFFER_EOF_PENDING;
2036
+			}
2037
+		}
2038
+
2039
+	else
2040
+		ret_val = EOB_ACT_CONTINUE_SCAN;
2041
+
2042
+	if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
2043
+		/* Extend the array by 50%, plus the number we really need. */
2044
+		int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
2045
+		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
2046
+			(void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
2047
+		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
2048
+			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
2049
+		/* "- 2" to take care of EOB's */
2050
+		YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
2051
+	}
2052
+
2053
+	yyg->yy_n_chars += number_to_move;
2054
+	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
2055
+	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
2056
+
2057
+	yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
2058
+
2059
+	return ret_val;
2060
+}
2061
+
2062
+/* yy_get_previous_state - get the state just before the EOB char was reached */
2063
+
2064
+    static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
2065
+{
2066
+	yy_state_type yy_current_state;
2067
+	char *yy_cp;
2068
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2069
+
2070
+	yy_current_state = yyg->yy_start;
2071
+
2072
+	for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
2073
+		{
2074
+		YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
2075
+		if ( yy_accept[yy_current_state] )
2076
+			{
2077
+			yyg->yy_last_accepting_state = yy_current_state;
2078
+			yyg->yy_last_accepting_cpos = yy_cp;
2079
+			}
2080
+		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
2081
+			{
2082
+			yy_current_state = (int) yy_def[yy_current_state];
2083
+			if ( yy_current_state >= 219 )
2084
+				yy_c = yy_meta[yy_c];
2085
+			}
2086
+		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
2087
+		}
2088
+
2089
+	return yy_current_state;
2090
+}
2091
+
2092
+/* yy_try_NUL_trans - try to make a transition on the NUL character
2093
+ *
2094
+ * synopsis
2095
+ *	next_state = yy_try_NUL_trans( current_state );
2096
+ */
2097
+    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
2098
+{
2099
+	int yy_is_jam;
2100
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
2101
+	char *yy_cp = yyg->yy_c_buf_p;
2102
+
2103
+	YY_CHAR yy_c = 1;
2104
+	if ( yy_accept[yy_current_state] )
2105
+		{
2106
+		yyg->yy_last_accepting_state = yy_current_state;
2107
+		yyg->yy_last_accepting_cpos = yy_cp;
2108
+		}
2109
+	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
2110
+		{
2111
+		yy_current_state = (int) yy_def[yy_current_state];
2112
+		if ( yy_current_state >= 219 )
2113
+			yy_c = yy_meta[yy_c];
2114
+		}
2115
+	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
2116
+	yy_is_jam = (yy_current_state == 218);
2117
+
2118
+	(void)yyg;
2119
+	return yy_is_jam ? 0 : yy_current_state;
2120
+}
2121
+
2122
+#ifndef YY_NO_UNPUT
2123
+
2124
+#endif
2125
+
2126
+#ifndef YY_NO_INPUT
2127
+#ifdef __cplusplus
2128
+    static int yyinput (yyscan_t yyscanner)
2129
+#else
2130
+    static int input  (yyscan_t yyscanner)
2131
+#endif
2132
+
2133
+{
2134
+	int c;
2135
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2136
+
2137
+	*yyg->yy_c_buf_p = yyg->yy_hold_char;
2138
+
2139
+	if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
2140
+		{
2141
+		/* yy_c_buf_p now points to the character we want to return.
2142
+		 * If this occurs *before* the EOB characters, then it's a
2143
+		 * valid NUL; if not, then we've hit the end of the buffer.
2144
+		 */
2145
+		if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
2146
+			/* This was really a NUL. */
2147
+			*yyg->yy_c_buf_p = '\0';
2148
+
2149
+		else
2150
+			{ /* need more input */
2151
+			int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
2152
+			++yyg->yy_c_buf_p;
2153
+
2154
+			switch ( yy_get_next_buffer( yyscanner ) )
2155
+				{
2156
+				case EOB_ACT_LAST_MATCH:
2157
+					/* This happens because yy_g_n_b()
2158
+					 * sees that we've accumulated a
2159
+					 * token and flags that we need to
2160
+					 * try matching the token before
2161
+					 * proceeding.  But for input(),
2162
+					 * there's no matching to consider.
2163
+					 * So convert the EOB_ACT_LAST_MATCH
2164
+					 * to EOB_ACT_END_OF_FILE.
2165
+					 */
2166
+
2167
+					/* Reset buffer status. */
2168
+					yyrestart( yyin , yyscanner);
2169
+
2170
+					/*FALLTHROUGH*/
2171
+
2172
+				case EOB_ACT_END_OF_FILE:
2173
+					{
2174
+					if ( yywrap( yyscanner ) )
2175
+						return 0;
2176
+
2177
+					if ( ! yyg->yy_did_buffer_switch_on_eof )
2178
+						YY_NEW_FILE;
2179
+#ifdef __cplusplus
2180
+					return yyinput(yyscanner);
2181
+#else
2182
+					return input(yyscanner);
2183
+#endif
2184
+					}
2185
+
2186
+				case EOB_ACT_CONTINUE_SCAN:
2187
+					yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
2188
+					break;
2189
+				}
2190
+			}
2191
+		}
2192
+
2193
+	c = *(unsigned char *) yyg->yy_c_buf_p;	/* cast for 8-bit char's */
2194
+	*yyg->yy_c_buf_p = '\0';	/* preserve yytext */
2195
+	yyg->yy_hold_char = *++yyg->yy_c_buf_p;
2196
+
2197
+	if ( c == '\n' )
2198
+		
2199
+    do{ yylineno++;
2200
+        yycolumn=0;
2201
+    }while(0)
2202
+;
2203
+
2204
+	return c;
2205
+}
2206
+#endif	/* ifndef YY_NO_INPUT */
2207
+
2208
+/** Immediately switch to a different input stream.
2209
+ * @param input_file A readable stream.
2210
+ * @param yyscanner The scanner object.
2211
+ * @note This function does not reset the start condition to @c INITIAL .
2212
+ */
2213
+    void yyrestart  (FILE * input_file , yyscan_t yyscanner)
2214
+{
2215
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2216
+
2217
+	if ( ! YY_CURRENT_BUFFER ){
2218
+        yyensure_buffer_stack (yyscanner);
2219
+		YY_CURRENT_BUFFER_LVALUE =
2220
+            yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
2221
+	}
2222
+
2223
+	yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
2224
+	yy_load_buffer_state( yyscanner );
2225
+}
2226
+
2227
+/** Switch to a different input buffer.
2228
+ * @param new_buffer The new input buffer.
2229
+ * @param yyscanner The scanner object.
2230
+ */
2231
+    void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
2232
+{
2233
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2234
+
2235
+	/* TODO. We should be able to replace this entire function body
2236
+	 * with
2237
+	 *		yypop_buffer_state();
2238
+	 *		yypush_buffer_state(new_buffer);
2239
+     */
2240
+	yyensure_buffer_stack (yyscanner);
2241
+	if ( YY_CURRENT_BUFFER == new_buffer )
2242
+		return;
2243
+
2244
+	if ( YY_CURRENT_BUFFER )
2245
+		{
2246
+		/* Flush out information for old buffer. */
2247
+		*yyg->yy_c_buf_p = yyg->yy_hold_char;
2248
+		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2249
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2250
+		}
2251
+
2252
+	YY_CURRENT_BUFFER_LVALUE = new_buffer;
2253
+	yy_load_buffer_state( yyscanner );
2254
+
2255
+	/* We don't actually know whether we did this switch during
2256
+	 * EOF (yywrap()) processing, but the only time this flag
2257
+	 * is looked at is after yywrap() is called, so it's safe
2258
+	 * to go ahead and always set it.
2259
+	 */
2260
+	yyg->yy_did_buffer_switch_on_eof = 1;
2261
+}
2262
+
2263
+static void yy_load_buffer_state  (yyscan_t yyscanner)
2264
+{
2265
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2266
+	yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2267
+	yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
2268
+	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
2269
+	yyg->yy_hold_char = *yyg->yy_c_buf_p;
2270
+}
2271
+
2272
+/** Allocate and initialize an input buffer state.
2273
+ * @param file A readable stream.
2274
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
2275
+ * @param yyscanner The scanner object.
2276
+ * @return the allocated buffer state.
2277
+ */
2278
+    YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
2279
+{
2280
+	YY_BUFFER_STATE b;
2281
+    
2282
+	b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
2283
+	if ( ! b )
2284
+		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
2285
+
2286
+	b->yy_buf_size = size;
2287
+
2288
+	/* yy_ch_buf has to be 2 characters longer than the size given because
2289
+	 * we need to put in 2 end-of-buffer characters.
2290
+	 */
2291
+	b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
2292
+	if ( ! b->yy_ch_buf )
2293
+		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
2294
+
2295
+	b->yy_is_our_buffer = 1;
2296
+
2297
+	yy_init_buffer( b, file , yyscanner);
2298
+
2299
+	return b;
2300
+}
2301
+
2302
+/** Destroy the buffer.
2303
+ * @param b a buffer created with yy_create_buffer()
2304
+ * @param yyscanner The scanner object.
2305
+ */
2306
+    void yy_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
2307
+{
2308
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2309
+
2310
+	if ( ! b )
2311
+		return;
2312
+
2313
+	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
2314
+		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
2315
+
2316
+	if ( b->yy_is_our_buffer )
2317
+		yyfree( (void *) b->yy_ch_buf , yyscanner );
2318
+
2319
+	yyfree( (void *) b , yyscanner );
2320
+}
2321
+
2322
+/* Initializes or reinitializes a buffer.
2323
+ * This function is sometimes called more than once on the same buffer,
2324
+ * such as during a yyrestart() or at EOF.
2325
+ */
2326
+    static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
2327
+
2328
+{
2329
+	int oerrno = errno;
2330
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2331
+
2332
+	yy_flush_buffer( b , yyscanner);
2333
+
2334
+	b->yy_input_file = file;
2335
+	b->yy_fill_buffer = 1;
2336
+
2337
+    /* If b is the current buffer, then yy_init_buffer was _probably_
2338
+     * called from yyrestart() or through yy_get_next_buffer.
2339
+     * In that case, we don't want to reset the lineno or column.
2340
+     */
2341
+    if (b != YY_CURRENT_BUFFER){
2342
+        b->yy_bs_lineno = 1;
2343
+        b->yy_bs_column = 0;
2344
+    }
2345
+
2346
+        b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
2347
+    
2348
+	errno = oerrno;
2349
+}
2350
+
2351
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2352
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2353
+ * @param yyscanner The scanner object.
2354
+ */
2355
+    void yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
2356
+{
2357
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2358
+	if ( ! b )
2359
+		return;
2360
+
2361
+	b->yy_n_chars = 0;
2362
+
2363
+	/* We always need two end-of-buffer characters.  The first causes
2364
+	 * a transition to the end-of-buffer state.  The second causes
2365
+	 * a jam in that state.
2366
+	 */
2367
+	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2368
+	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2369
+
2370
+	b->yy_buf_pos = &b->yy_ch_buf[0];
2371
+
2372
+	b->yy_at_bol = 1;
2373
+	b->yy_buffer_status = YY_BUFFER_NEW;
2374
+
2375
+	if ( b == YY_CURRENT_BUFFER )
2376
+		yy_load_buffer_state( yyscanner );
2377
+}
2378
+
2379
+/** Pushes the new state onto the stack. The new state becomes
2380
+ *  the current state. This function will allocate the stack
2381
+ *  if necessary.
2382
+ *  @param new_buffer The new state.
2383
+ *  @param yyscanner The scanner object.
2384
+ */
2385
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
2386
+{
2387
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2388
+	if (new_buffer == NULL)
2389
+		return;
2390
+
2391
+	yyensure_buffer_stack(yyscanner);
2392
+
2393
+	/* This block is copied from yy_switch_to_buffer. */
2394
+	if ( YY_CURRENT_BUFFER )
2395
+		{
2396
+		/* Flush out information for old buffer. */
2397
+		*yyg->yy_c_buf_p = yyg->yy_hold_char;
2398
+		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2399
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2400
+		}
2401
+
2402
+	/* Only push if top exists. Otherwise, replace top. */
2403
+	if (YY_CURRENT_BUFFER)
2404
+		yyg->yy_buffer_stack_top++;
2405
+	YY_CURRENT_BUFFER_LVALUE = new_buffer;
2406
+
2407
+	/* copied from yy_switch_to_buffer. */
2408
+	yy_load_buffer_state( yyscanner );
2409
+	yyg->yy_did_buffer_switch_on_eof = 1;
2410
+}
2411
+
2412
+/** Removes and deletes the top of the stack, if present.
2413
+ *  The next element becomes the new top.
2414
+ *  @param yyscanner The scanner object.
2415
+ */
2416
+void yypop_buffer_state (yyscan_t yyscanner)
2417
+{
2418
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2419
+	if (!YY_CURRENT_BUFFER)
2420
+		return;
2421
+
2422
+	yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
2423
+	YY_CURRENT_BUFFER_LVALUE = NULL;
2424
+	if (yyg->yy_buffer_stack_top > 0)
2425
+		--yyg->yy_buffer_stack_top;
2426
+
2427
+	if (YY_CURRENT_BUFFER) {
2428
+		yy_load_buffer_state( yyscanner );
2429
+		yyg->yy_did_buffer_switch_on_eof = 1;
2430
+	}
2431
+}
2432
+
2433
+/* Allocates the stack if it does not exist.
2434
+ *  Guarantees space for at least one push.
2435
+ */
2436
+static void yyensure_buffer_stack (yyscan_t yyscanner)
2437
+{
2438
+	yy_size_t num_to_alloc;
2439
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2440
+
2441
+	if (!yyg->yy_buffer_stack) {
2442
+
2443
+		/* First allocation is just for 2 elements, since we don't know if this
2444
+		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2445
+		 * immediate realloc on the next call.
2446
+         */
2447
+      num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
2448
+		yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
2449
+								(num_to_alloc * sizeof(struct yy_buffer_state*)
2450
+								, yyscanner);
2451
+		if ( ! yyg->yy_buffer_stack )
2452
+			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2453
+
2454
+		memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2455
+
2456
+		yyg->yy_buffer_stack_max = num_to_alloc;
2457
+		yyg->yy_buffer_stack_top = 0;
2458
+		return;
2459
+	}
2460
+
2461
+	if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
2462
+
2463
+		/* Increase the buffer to prepare for a possible push. */
2464
+		yy_size_t grow_size = 8 /* arbitrary grow size */;
2465
+
2466
+		num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
2467
+		yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
2468
+								(yyg->yy_buffer_stack,
2469
+								num_to_alloc * sizeof(struct yy_buffer_state*)
2470
+								, yyscanner);
2471
+		if ( ! yyg->yy_buffer_stack )
2472
+			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2473
+
2474
+		/* zero only the new slots.*/
2475
+		memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
2476
+		yyg->yy_buffer_stack_max = num_to_alloc;
2477
+	}
2478
+}
2479
+
2480
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
2481
+ * @param base the character buffer
2482
+ * @param size the size in bytes of the character buffer
2483
+ * @param yyscanner The scanner object.
2484
+ * @return the newly allocated buffer state object.
2485
+ */
2486
+YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
2487
+{
2488
+	YY_BUFFER_STATE b;
2489
+    
2490
+	if ( size < 2 ||
2491
+	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
2492
+	     base[size-1] != YY_END_OF_BUFFER_CHAR )
2493
+		/* They forgot to leave room for the EOB's. */
2494
+		return NULL;
2495
+
2496
+	b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
2497
+	if ( ! b )
2498
+		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
2499
+
2500
+	b->yy_buf_size = (int) (size - 2);	/* "- 2" to take care of EOB's */
2501
+	b->yy_buf_pos = b->yy_ch_buf = base;
2502
+	b->yy_is_our_buffer = 0;
2503
+	b->yy_input_file = NULL;
2504
+	b->yy_n_chars = b->yy_buf_size;
2505
+	b->yy_is_interactive = 0;
2506
+	b->yy_at_bol = 1;
2507
+	b->yy_fill_buffer = 0;
2508
+	b->yy_buffer_status = YY_BUFFER_NEW;
2509
+
2510
+	yy_switch_to_buffer( b , yyscanner );
2511
+
2512
+	return b;
2513
+}
2514
+
2515
+/** Setup the input buffer state to scan a string. The next call to yylex() will
2516
+ * scan from a @e copy of @a str.
2517
+ * @param yystr a NUL-terminated string to scan
2518
+ * @param yyscanner The scanner object.
2519
+ * @return the newly allocated buffer state object.
2520
+ * @note If you want to scan bytes that may contain NUL values, then use
2521
+ *       yy_scan_bytes() instead.
2522
+ */
2523
+YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
2524
+{
2525
+    
2526
+	return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
2527
+}
2528
+
2529
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
2530
+ * scan from a @e copy of @a bytes.
2531
+ * @param yybytes the byte buffer to scan
2532
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2533
+ * @param yyscanner The scanner object.
2534
+ * @return the newly allocated buffer state object.
2535
+ */
2536
+YY_BUFFER_STATE yy_scan_bytes  (const char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
2537
+{
2538
+	YY_BUFFER_STATE b;
2539
+	char *buf;
2540
+	yy_size_t n;
2541
+	int i;
2542
+    
2543
+	/* Get memory for full buffer, including space for trailing EOB's. */
2544
+	n = (yy_size_t) (_yybytes_len + 2);
2545
+	buf = (char *) yyalloc( n , yyscanner );
2546
+	if ( ! buf )
2547
+		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
2548
+
2549
+	for ( i = 0; i < _yybytes_len; ++i )
2550
+		buf[i] = yybytes[i];
2551
+
2552
+	buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2553
+
2554
+	b = yy_scan_buffer( buf, n , yyscanner);
2555
+	if ( ! b )
2556
+		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
2557
+
2558
+	/* It's okay to grow etc. this buffer, and we should throw it
2559
+	 * away when we're done.
2560
+	 */
2561
+	b->yy_is_our_buffer = 1;
2562
+
2563
+	return b;
2564
+}
2565
+
2566
+#ifndef YY_EXIT_FAILURE
2567
+#define YY_EXIT_FAILURE 2
2568
+#endif
2569
+
2570
+static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
2571
+{
2572
+	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2573
+	(void)yyg;
2574
+	fprintf( stderr, "%s\n", msg );
2575
+	exit( YY_EXIT_FAILURE );
2576
+}
2577
+
2578
+/* Redefine yyless() so it works in section 3 code. */
2579
+
2580
+#undef yyless
2581
+#define yyless(n) \
2582
+	do \
2583
+		{ \
2584
+		/* Undo effects of setting up yytext. */ \
2585
+        int yyless_macro_arg = (n); \
2586
+        YY_LESS_LINENO(yyless_macro_arg);\
2587
+		yytext[yyleng] = yyg->yy_hold_char; \
2588
+		yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
2589
+		yyg->yy_hold_char = *yyg->yy_c_buf_p; \
2590
+		*yyg->yy_c_buf_p = '\0'; \
2591
+		yyleng = yyless_macro_arg; \
2592
+		} \
2593
+	while ( 0 )
2594
+
2595
+/* Accessor  methods (get/set functions) to struct members. */
2596
+
2597
+/** Get the user-defined data for this scanner.
2598
+ * @param yyscanner The scanner object.
2599
+ */
2600
+YY_EXTRA_TYPE yyget_extra  (yyscan_t yyscanner)
2601
+{
2602
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2603
+    return yyextra;
2604
+}
2605
+
2606
+/** Get the current line number.
2607
+ * @param yyscanner The scanner object.
2608
+ */
2609
+int yyget_lineno  (yyscan_t yyscanner)
2610
+{
2611
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2612
+
2613
+        if (! YY_CURRENT_BUFFER)
2614
+            return 0;
2615
+    
2616
+    return yylineno;
2617
+}
2618
+
2619
+/** Get the current column number.
2620
+ * @param yyscanner The scanner object.
2621
+ */
2622
+int yyget_column  (yyscan_t yyscanner)
2623
+{
2624
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2625
+
2626
+        if (! YY_CURRENT_BUFFER)
2627
+            return 0;
2628
+    
2629
+    return yycolumn;
2630
+}
2631
+
2632
+/** Get the input stream.
2633
+ * @param yyscanner The scanner object.
2634
+ */
2635
+FILE *yyget_in  (yyscan_t yyscanner)
2636
+{
2637
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2638
+    return yyin;
2639
+}
2640
+
2641
+/** Get the output stream.
2642
+ * @param yyscanner The scanner object.
2643
+ */
2644
+FILE *yyget_out  (yyscan_t yyscanner)
2645
+{
2646
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2647
+    return yyout;
2648
+}
2649
+
2650
+/** Get the length of the current token.
2651
+ * @param yyscanner The scanner object.
2652
+ */
2653
+int yyget_leng  (yyscan_t yyscanner)
2654
+{
2655
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2656
+    return yyleng;
2657
+}
2658
+
2659
+/** Get the current token.
2660
+ * @param yyscanner The scanner object.
2661
+ */
2662
+
2663
+char *yyget_text  (yyscan_t yyscanner)
2664
+{
2665
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2666
+    return yytext;
2667
+}
2668
+
2669
+/** Set the user-defined data. This data is never touched by the scanner.
2670
+ * @param user_defined The data to be associated with this scanner.
2671
+ * @param yyscanner The scanner object.
2672
+ */
2673
+void yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
2674
+{
2675
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2676
+    yyextra = user_defined ;
2677
+}
2678
+
2679
+/** Set the current line number.
2680
+ * @param _line_number line number
2681
+ * @param yyscanner The scanner object.
2682
+ */
2683
+void yyset_lineno (int  _line_number , yyscan_t yyscanner)
2684
+{
2685
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2686
+
2687
+        /* lineno is only valid if an input buffer exists. */
2688
+        if (! YY_CURRENT_BUFFER )
2689
+           YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
2690
+    
2691
+    yylineno = _line_number;
2692
+}
2693
+
2694
+/** Set the current column.
2695
+ * @param _column_no column number
2696
+ * @param yyscanner The scanner object.
2697
+ */
2698
+void yyset_column (int  _column_no , yyscan_t yyscanner)
2699
+{
2700
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2701
+
2702
+        /* column is only valid if an input buffer exists. */
2703
+        if (! YY_CURRENT_BUFFER )
2704
+           YY_FATAL_ERROR( "yyset_column called with no buffer" );
2705
+    
2706
+    yycolumn = _column_no;
2707
+}
2708
+
2709
+/** Set the input stream. This does not discard the current
2710
+ * input buffer.
2711
+ * @param _in_str A readable stream.
2712
+ * @param yyscanner The scanner object.
2713
+ * @see yy_switch_to_buffer
2714
+ */
2715
+void yyset_in (FILE *  _in_str , yyscan_t yyscanner)
2716
+{
2717
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2718
+    yyin = _in_str ;
2719
+}
2720
+
2721
+void yyset_out (FILE *  _out_str , yyscan_t yyscanner)
2722
+{
2723
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2724
+    yyout = _out_str ;
2725
+}
2726
+
2727
+int yyget_debug  (yyscan_t yyscanner)
2728
+{
2729
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2730
+    return yy_flex_debug;
2731
+}
2732
+
2733
+void yyset_debug (int  _bdebug , yyscan_t yyscanner)
2734
+{
2735
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2736
+    yy_flex_debug = _bdebug ;
2737
+}
2738
+
2739
+/* Accessor methods for yylval and yylloc */
2740
+
2741
+YYSTYPE * yyget_lval  (yyscan_t yyscanner)
2742
+{
2743
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2744
+    return yylval;
2745
+}
2746
+
2747
+void yyset_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)
2748
+{
2749
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2750
+    yylval = yylval_param;
2751
+}
2752
+
2753
+/* User-visible API */
2754
+
2755
+/* yylex_init is special because it creates the scanner itself, so it is
2756
+ * the ONLY reentrant function that doesn't take the scanner as the last argument.
2757
+ * That's why we explicitly handle the declaration, instead of using our macros.
2758
+ */
2759
+int yylex_init(yyscan_t* ptr_yy_globals)
2760
+{
2761
+    if (ptr_yy_globals == NULL){
2762
+        errno = EINVAL;
2763
+        return 1;
2764
+    }
2765
+
2766
+    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
2767
+
2768
+    if (*ptr_yy_globals == NULL){
2769
+        errno = ENOMEM;
2770
+        return 1;
2771
+    }
2772
+
2773
+    /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2774
+    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2775
+
2776
+    return yy_init_globals ( *ptr_yy_globals );
2777
+}
2778
+
2779
+/* yylex_init_extra has the same functionality as yylex_init, but follows the
2780
+ * convention of taking the scanner as the last argument. Note however, that
2781
+ * this is a *pointer* to a scanner, as it will be allocated by this call (and
2782
+ * is the reason, too, why this function also must handle its own declaration).
2783
+ * The user defined value in the first argument will be available to yyalloc in
2784
+ * the yyextra field.
2785
+ */
2786
+int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
2787
+{
2788
+    struct yyguts_t dummy_yyguts;
2789
+
2790
+    yyset_extra (yy_user_defined, &dummy_yyguts);
2791
+
2792
+    if (ptr_yy_globals == NULL){
2793
+        errno = EINVAL;
2794
+        return 1;
2795
+    }
2796
+
2797
+    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2798
+
2799
+    if (*ptr_yy_globals == NULL){
2800
+        errno = ENOMEM;
2801
+        return 1;
2802
+    }
2803
+
2804
+    /* By setting to 0xAA, we expose bugs in
2805
+    yy_init_globals. Leave at 0x00 for releases. */
2806
+    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2807
+
2808
+    yyset_extra (yy_user_defined, *ptr_yy_globals);
2809
+
2810
+    return yy_init_globals ( *ptr_yy_globals );
2811
+}
2812
+
2813
+static int yy_init_globals (yyscan_t yyscanner)
2814
+{
2815
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2816
+    /* Initialization is the same as for the non-reentrant scanner.
2817
+     * This function is called from yylex_destroy(), so don't allocate here.
2818
+     */
2819
+
2820
+    yyg->yy_buffer_stack = NULL;
2821
+    yyg->yy_buffer_stack_top = 0;
2822
+    yyg->yy_buffer_stack_max = 0;
2823
+    yyg->yy_c_buf_p = NULL;
2824
+    yyg->yy_init = 0;
2825
+    yyg->yy_start = 0;
2826
+
2827
+    yyg->yy_start_stack_ptr = 0;
2828
+    yyg->yy_start_stack_depth = 0;
2829
+    yyg->yy_start_stack =  NULL;
2830
+
2831
+/* Defined in main.c */
2832
+#ifdef YY_STDINIT
2833
+    yyin = stdin;
2834
+    yyout = stdout;
2835
+#else
2836
+    yyin = NULL;
2837
+    yyout = NULL;
2838
+#endif
2839
+
2840
+    /* For future reference: Set errno on error, since we are called by
2841
+     * yylex_init()
2842
+     */
2843
+    return 0;
2844
+}
2845
+
2846
+/* yylex_destroy is for both reentrant and non-reentrant scanners. */
2847
+int yylex_destroy  (yyscan_t yyscanner)
2848
+{
2849
+    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2850
+
2851
+    /* Pop the buffer stack, destroying each element. */
2852
+	while(YY_CURRENT_BUFFER){
2853
+		yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
2854
+		YY_CURRENT_BUFFER_LVALUE = NULL;
2855
+		yypop_buffer_state(yyscanner);
2856
+	}
2857
+
2858
+	/* Destroy the stack itself. */
2859
+	yyfree(yyg->yy_buffer_stack , yyscanner);
2860
+	yyg->yy_buffer_stack = NULL;
2861
+
2862
+    /* Destroy the start condition stack. */
2863
+        yyfree( yyg->yy_start_stack , yyscanner );
2864
+        yyg->yy_start_stack = NULL;
2865
+
2866
+    /* Reset the globals. This is important in a non-reentrant scanner so the next time
2867
+     * yylex() is called, initialization will occur. */
2868
+    yy_init_globals( yyscanner);
2869
+
2870
+    /* Destroy the main struct (reentrant only). */
2871
+    yyfree ( yyscanner , yyscanner );
2872
+    yyscanner = NULL;
2873
+    return 0;
2874
+}
2875
+
2876
+/*
2877
+ * Internal utility routines.
2878
+ */
2879
+
2880
+#ifndef yytext_ptr
2881
+static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
2882
+{
2883
+	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2884
+	(void)yyg;
2885
+
2886
+	int i;
2887
+	for ( i = 0; i < n; ++i )
2888
+		s1[i] = s2[i];
2889
+}
2890
+#endif
2891
+
2892
+#ifdef YY_NEED_STRLEN
2893
+static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
2894
+{
2895
+	int n;
2896
+	for ( n = 0; s[n]; ++n )
2897
+		;
2898
+
2899
+	return n;
2900
+}
2901
+#endif
2902
+
2903
+void *yyalloc (yy_size_t  size , yyscan_t yyscanner)
2904
+{
2905
+	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2906
+	(void)yyg;
2907
+	return malloc(size);
2908
+}
2909
+
2910
+void *yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
2911
+{
2912
+	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2913
+	(void)yyg;
2914
+
2915
+	/* The cast to (char *) in the following accommodates both
2916
+	 * implementations that use char* generic pointers, and those
2917
+	 * that use void* generic pointers.  It works with the latter
2918
+	 * because both ANSI C and C++ allow castless assignment from
2919
+	 * any pointer type to void*, and deal with argument conversions
2920
+	 * as though doing an assignment.
2921
+	 */
2922
+	return realloc(ptr, size);
2923
+}
2924
+
2925
+void yyfree (void * ptr , yyscan_t yyscanner)
2926
+{
2927
+	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2928
+	(void)yyg;
2929
+	free( (char *) ptr );	/* see yyrealloc() for (char *) cast */
2930
+}
2931
+
2932
+#define YYTABLES_NAME "yytables"
2933
+
2934
+#line 582 "yara_lexer.l"
2935
+
2936
+
2937
+
2938
+void yywarning(
2939
+    yyscan_t yyscanner,
2940
+    const char *warning_message)
2941
+{
2942
+  YR_COMPILER* compiler = yyget_extra(yyscanner);
2943
+  char* file_name;
2944
+
2945
+  if (compiler->file_name_stack_ptr > 0)
2946
+    file_name = compiler->file_name_stack[compiler->file_name_stack_ptr - 1];
2947
+  else
2948
+    file_name = NULL;
2949
+
2950
+#ifdef REAL_YARA
2951
+  compiler->callback(
2952
+      YARA_ERROR_LEVEL_WARNING,
2953
+      file_name,
2954
+      yyget_lineno(yyscanner),
2955
+      warning_message);
2956
+#else
2957
+    cli_warnmsg("yywarning(): %s line %d %s\n", file_name?file_name:"(file name missing)", compiler->last_error_line, warning_message);
2958
+#endif
2959
+}
2960
+
2961
+
2962
+void yyfatal(
2963
+    yyscan_t yyscanner,
2964
+    const char *error_message)
2965
+{
2966
+  YR_COMPILER* compiler = yyget_extra(yyscanner);
2967
+  int last_result = compiler->last_result;
2968
+
2969
+  yyerror(yyscanner, compiler, error_message);
2970
+  compiler->last_result = last_result;
2971
+  longjmp(compiler->error_recovery, 1);
2972
+}
2973
+
2974
+
2975
+void yyerror(
2976
+    yyscan_t yyscanner,
2977
+    YR_COMPILER* compiler,
2978
+    const char *error_message)
2979
+{
2980
+  char message[512] = {'\0'};
2981
+  char* file_name = NULL;
2982
+
2983
+  /*
2984
+    if error_message != NULL the error comes from yyparse internal code
2985
+    else the error comes from my code and the error code is set in
2986
+    compiler->last_result
2987
+  */
2988
+
2989
+  compiler->errors++;
2990
+
2991
+  if (compiler->error_line != 0)
2992
+    compiler->last_error_line = compiler->error_line;
2993
+  else
2994
+    compiler->last_error_line = yyget_lineno(yyscanner);
2995
+
2996
+  compiler->error_line = 0;
2997
+
2998
+  if (compiler->file_name_stack_ptr > 0)
2999
+  {
3000
+    file_name = compiler->file_name_stack[compiler->file_name_stack_ptr - 1];
3001
+  }
3002
+  else
3003
+  {
3004
+    file_name = NULL;
3005
+  }
3006
+
3007
+  if (error_message != NULL)
3008
+  {
3009
+    yr_compiler_set_error_extra_info(compiler, error_message);
3010
+    compiler->last_error = ERROR_SYNTAX_ERROR;
3011
+
3012
+#ifdef REAL_YARA
3013
+    if (compiler->callback != NULL)
3014
+    {
3015
+      compiler->callback(
3016
+          YARA_ERROR_LEVEL_ERROR,
3017
+          file_name,
3018
+          compiler->last_error_line,
3019
+          error_message);
3020
+    }
3021
+#else
3022
+    cli_errmsg("yyerror(): %s line %d %s\n", file_name?file_name:"(file name missing)", compiler->last_error_line, error_message);
3023
+#endif
3024
+  }
3025
+  else
3026
+  {
3027
+    compiler->last_error = compiler->last_result;
3028
+
3029
+#ifdef REAL_YARA
3030
+    if (compiler->callback != NULL)
3031
+    {
3032
+      yr_compiler_get_error_message(compiler, message, sizeof(message));
3033
+
3034
+      compiler->callback(
3035
+        YARA_ERROR_LEVEL_ERROR,
3036
+        file_name,
3037
+        compiler->last_error_line,
3038
+        message);
3039
+    }
3040
+#else
3041
+    yr_compiler_get_error_message(compiler, message, sizeof(message));
3042
+    cli_errmsg("yyerror(): %s line %d %s\n", file_name?file_name:"NULL filename", compiler->last_error_line, message);
3043
+#endif
3044
+  }
3045
+
3046
+  compiler->last_result = ERROR_SUCCESS;
3047
+}
3048
+
3049
+
3050
+int yr_lex_parse_rules_string(
3051
+  const char* rules_string,
3052
+  YR_COMPILER* compiler)
3053
+{
3054
+#ifdef REAL_YARA
3055
+  yyscan_t yyscanner;
3056
+
3057
+  compiler->errors = 0;
3058
+
3059
+  if (setjmp(compiler->error_recovery) != 0)
3060
+    return compiler->errors;
3061
+
3062
+  yylex_init(&yyscanner);
3063
+
3064
+  yyset_debug(1, yyscanner);
3065
+
3066
+  yyset_extra(compiler, yyscanner);
3067
+
3068
+  yy_scan_string(rules_string, yyscanner);
3069
+
3070
+  yyset_lineno(1, yyscanner);
3071
+  yyparse(yyscanner, compiler);
3072
+  yylex_destroy(yyscanner);
3073
+
3074
+  return compiler->errors;
3075
+#else
3076
+  (void)rules_string;
3077
+  (void)compiler;
3078
+  cli_errmsg("yara_lexer:yr_lex_parse_rules_string() disabled\n");
3079
+  return 0;
3080
+#endif
3081
+}
3082
+
3083
+
3084
+int yr_lex_parse_rules_file(
3085
+  FILE* rules_file,
3086
+  YR_COMPILER* compiler)
3087
+{
3088
+  yyscan_t yyscanner;
3089
+
3090
+  compiler->errors = 0;
3091
+
3092
+  if (setjmp(compiler->error_recovery) != 0)
3093
+    return compiler->errors;
3094
+
3095
+  yylex_init(&yyscanner);
3096
+
3097
+  #if YYDEBUG
3098
+  printf("debug enabled");
3099
+  #endif
3100
+
3101
+  yyset_debug(1, yyscanner);
3102
+
3103
+  yyset_in(rules_file, yyscanner);
3104
+  yyset_extra(compiler, yyscanner);
3105
+  yyparse(yyscanner, compiler);
3106
+  yylex_destroy(yyscanner);
3107
+
3108
+  return compiler->errors;
3109
+}
3110
+
... ...
@@ -95,6 +95,7 @@ limitations under the License.
95 95
 %option nounput
96 96
 %option yylineno
97 97
 /* %option prefix="yara_yy" */
98
+%option outfile="yara_lexer.c"
98 99
 
99 100
 %option verbose
100 101
 %option warn
101 102
deleted file mode 100644
... ...
@@ -1,3909 +0,0 @@
1
-/* A Bison parser, made by GNU Bison 2.7.  */
2
-
3
-/* Bison implementation for Yacc-like parsers in C
4
-   
5
-      Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
6
-   
7
-   This program is free software: you can redistribute it and/or modify
8
-   it under the terms of the GNU General Public License as published by
9
-   the Free Software Foundation, either version 3 of the License, or
10
-   (at your option) any later version.
11
-   
12
-   This program is distributed in the hope that it will be useful,
13
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
-   GNU General Public License for more details.
16
-   
17
-   You should have received a copy of the GNU General Public License
18
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
-
20
-/* As a special exception, you may create a larger work that contains
21
-   part or all of the Bison parser skeleton and distribute that work
22
-   under terms of your choice, so long as that work isn't itself a
23
-   parser generator using the skeleton or a modified version thereof
24
-   as a parser skeleton.  Alternatively, if you modify or redistribute
25
-   the parser skeleton itself, you may (at your option) remove this
26
-   special exception, which will cause the skeleton and the resulting
27
-   Bison output files to be licensed under the GNU General Public
28
-   License without this special exception.
29
-   
30
-   This special exception was added by the Free Software Foundation in
31
-   version 2.2 of Bison.  */
32
-
33
-/* C LALR(1) parser skeleton written by Richard Stallman, by
34
-   simplifying the original so-called "semantic" parser.  */
35
-
36
-/* All symbols defined below should begin with yy or YY, to avoid
37
-   infringing on user name space.  This should be done even for local
38
-   variables, as they might otherwise be expanded by user macros.
39
-   There are some unavoidable exceptions within include files to
40
-   define necessary library symbols; they are noted "INFRINGES ON
41
-   USER NAME SPACE" below.  */
42
-
43
-/* Identify Bison output.  */
44
-#define YYBISON 1
45
-
46
-/* Bison version.  */
47
-#define YYBISON_VERSION "2.7"
48
-
49
-/* Skeleton name.  */
50
-#define YYSKELETON_NAME "yacc.c"
51
-
52
-/* Pure parsers.  */
53
-#define YYPURE 1
54
-
55
-/* Push parsers.  */
56
-#define YYPUSH 0
57
-
58
-/* Pull parsers.  */
59
-#define YYPULL 1
60
-
61
-
62
-/* Substitute the variable and function names.  */
63
-#define yyparse         yara_yyparse
64
-#define yylex           yara_yylex
65
-#define yyerror         yara_yyerror
66
-#define yylval          yara_yylval
67
-#define yychar          yara_yychar
68
-#define yydebug         yara_yydebug
69
-#define yynerrs         yara_yynerrs
70
-
71
-/* Copy the first part of user declarations.  */
72
-/* Line 371 of yacc.c  */
73
-#line 43 "yara_grammar.y"
74
-
75
-
76
-#include <assert.h>
77
-#include <stdio.h>
78
-#include <stdint.h>
79
-#include <string.h>
80
-#include <limits.h>
81
-#include <stddef.h>
82
-
83
-#ifdef REAL_YARA
84
-#include <yara/utils.h>
85
-#include <yara/compiler.h>
86
-#include <yara/object.h>
87
-#include <yara/sizedstr.h>
88
-#include <yara/exec.h>
89
-#include <yara/error.h>
90
-#include <yara/mem.h>
91
-#include <yara/lexer.h>
92
-#include <yara/parser.h>
93
-#else
94
-#include "yara_clam.h"
95
-#include "yara_compiler.h"
96
-#include "clamav-config.h"
97
-#include "yara_grammar.h"
98
-#include "yara_lexer.h"
99
-#include "yara_parser.h"
100
-#include "yara_exec.h"
101
-#endif
102
-
103
-#define YYERROR_VERBOSE
104
-
105
-#define INTEGER_SET_ENUMERATION   1
106
-#define INTEGER_SET_RANGE         2
107
-
108
-#define EXPRESSION_TYPE_BOOLEAN   1
109
-#define EXPRESSION_TYPE_INTEGER   2
110
-#define EXPRESSION_TYPE_STRING    3
111
-#define EXPRESSION_TYPE_REGEXP    4
112
-
113
-
114
-#define ERROR_IF(x) \
115
-    if (x) \
116
-    { \
117
-      yyerror(yyscanner, compiler, NULL); \
118
-      YYERROR; \
119
-    } \
120
-
121
-#define CHECK_TYPE_WITH_CLEANUP(actual_type, expected_type, op, cleanup) \
122
-    if (actual_type != expected_type) \
123
-    { \
124
-      switch(actual_type) \
125
-      { \
126
-        case EXPRESSION_TYPE_INTEGER: \
127
-          yr_compiler_set_error_extra_info( \
128
-              compiler, "wrong type \"integer\" for " op " operator"); \
129
-          break; \
130
-        case EXPRESSION_TYPE_STRING: \
131
-          yr_compiler_set_error_extra_info( \
132
-              compiler, "wrong type \"string\" for \"" op "\" operator"); \
133
-          break; \
134
-      } \
135
-      compiler->last_result = ERROR_WRONG_TYPE; \
136
-      cleanup; \
137
-      yyerror(yyscanner, compiler, NULL); \
138
-      YYERROR; \
139
-    }
140
-
141
-#define CHECK_TYPE(actual_type, expected_type, op) \
142
-    CHECK_TYPE_WITH_CLEANUP(actual_type, expected_type, op, ) \
143
-
144
-
145
-#define MSG(op)  "wrong type \"string\" for \"" op "\" operator"
146
-
147
-
148
-/* Line 371 of yacc.c  */
149
-#line 150 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.c"
150
-
151
-# ifndef YY_NULL
152
-#  if defined __cplusplus && 201103L <= __cplusplus
153
-#   define YY_NULL nullptr
154
-#  else
155
-#   define YY_NULL 0
156
-#  endif
157
-# endif
158
-
159
-/* Enabling verbose error messages.  */
160
-#ifdef YYERROR_VERBOSE
161
-# undef YYERROR_VERBOSE
162
-# define YYERROR_VERBOSE 1
163
-#else
164
-# define YYERROR_VERBOSE 0
165
-#endif
166
-
167
-/* In a future release of Bison, this section will be replaced
168
-   by #include "yara_grammar.h".  */
169
-#ifndef YY_YARA_YY_C_USERS_MICASNYD_WORKSPACE_CLAMAV_MICASNYD_BUILD_LIBCLAMAV_YARA_GRAMMAR_H_INCLUDED
170
-# define YY_YARA_YY_C_USERS_MICASNYD_WORKSPACE_CLAMAV_MICASNYD_BUILD_LIBCLAMAV_YARA_GRAMMAR_H_INCLUDED
171
-/* Enabling traces.  */
172
-#ifndef YYDEBUG
173
-# define YYDEBUG 0
174
-#endif
175
-#if YYDEBUG
176
-extern int yara_yydebug;
177
-#endif
178
-/* "%code requires" blocks.  */
179
-/* Line 387 of yacc.c  */
180
-#line 39 "yara_grammar.y"
181
-
182
-#include "yara_compiler.h"
183
-
184
-
185
-/* Line 387 of yacc.c  */
186
-#line 187 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.c"
187
-
188
-/* Tokens.  */
189
-#ifndef YYTOKENTYPE
190
-# define YYTOKENTYPE
191
-   /* Put the tokens into the symbol table, so that GDB and other debuggers
192
-      know about them.  */
193
-   enum yytokentype {
194
-     _RULE_ = 258,
195
-     _PRIVATE_ = 259,
196
-     _GLOBAL_ = 260,
197
-     _META_ = 261,
198
-     _STRINGS_ = 262,
199
-     _CONDITION_ = 263,
200
-     _IDENTIFIER_ = 264,
201
-     _STRING_IDENTIFIER_ = 265,
202
-     _STRING_COUNT_ = 266,
203
-     _STRING_OFFSET_ = 267,
204
-     _STRING_IDENTIFIER_WITH_WILDCARD_ = 268,
205
-     _NUMBER_ = 269,
206
-     _TEXT_STRING_ = 270,
207
-     _HEX_STRING_ = 271,
208
-     _REGEXP_ = 272,
209
-     _ASCII_ = 273,
210
-     _WIDE_ = 274,
211
-     _NOCASE_ = 275,
212
-     _FULLWORD_ = 276,
213
-     _AT_ = 277,
214
-     _FILESIZE_ = 278,
215
-     _ENTRYPOINT_ = 279,
216
-     _ALL_ = 280,
217
-     _ANY_ = 281,
218
-     _IN_ = 282,
219
-     _OF_ = 283,
220
-     _FOR_ = 284,
221
-     _THEM_ = 285,
222
-     _INT8_ = 286,
223
-     _INT16_ = 287,
224
-     _INT32_ = 288,
225
-     _UINT8_ = 289,
226
-     _UINT16_ = 290,
227
-     _UINT32_ = 291,
228
-     _MATCHES_ = 292,
229
-     _CONTAINS_ = 293,
230
-     _IMPORT_ = 294,
231
-     _TRUE_ = 295,
232
-     _FALSE_ = 296,
233
-     _OR_ = 297,
234
-     _AND_ = 298,
235
-     _IS_ = 299,
236
-     _NEQ_ = 300,
237
-     _EQ_ = 301,
238
-     _GE_ = 302,
239
-     _GT_ = 303,
240
-     _LE_ = 304,
241
-     _LT_ = 305,
242
-     _SHIFT_RIGHT_ = 306,
243
-     _SHIFT_LEFT_ = 307,
244
-     _NOT_ = 308
245
-   };
246
-#endif
247
-
248
-
249
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
250
-typedef union YYSTYPE
251
-{
252
-/* Line 387 of yacc.c  */
253
-#line 218 "yara_grammar.y"
254
-
255
-  SIZED_STRING*   sized_string;
256
-  char*           c_string;
257
-  int8_t          expression_type;
258
-  int64_t         integer;
259
-  YR_STRING*      string;
260
-  YR_META*        meta;
261
-  YR_OBJECT*      object;
262
-
263
-
264
-/* Line 387 of yacc.c  */
265
-#line 266 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.c"
266
-} YYSTYPE;
267
-# define YYSTYPE_IS_TRIVIAL 1
268
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
269
-# define YYSTYPE_IS_DECLARED 1
270
-#endif
271
-
272
-
273
-#ifdef YYPARSE_PARAM
274
-#if defined __STDC__ || defined __cplusplus
275
-int yara_yyparse (void *YYPARSE_PARAM);
276
-#else
277
-int yara_yyparse ();
278
-#endif
279
-#else /* ! YYPARSE_PARAM */
280
-#if defined __STDC__ || defined __cplusplus
281
-int yara_yyparse (void *yyscanner, YR_COMPILER* compiler);
282
-#else
283
-int yara_yyparse ();
284
-#endif
285
-#endif /* ! YYPARSE_PARAM */
286
-
287
-#endif /* !YY_YARA_YY_C_USERS_MICASNYD_WORKSPACE_CLAMAV_MICASNYD_BUILD_LIBCLAMAV_YARA_GRAMMAR_H_INCLUDED  */
288
-
289
-/* Copy the second part of user declarations.  */
290
-
291
-/* Line 390 of yacc.c  */
292
-#line 293 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.c"
293
-
294
-#ifdef short
295
-# undef short
296
-#endif
297
-
298
-#ifdef YYTYPE_UINT8
299
-typedef YYTYPE_UINT8 yytype_uint8;
300
-#else
301
-typedef unsigned char yytype_uint8;
302
-#endif
303
-
304
-#ifdef YYTYPE_INT8
305
-typedef YYTYPE_INT8 yytype_int8;
306
-#elif (defined __STDC__ || defined __C99__FUNC__ \
307
-     || defined __cplusplus || defined _MSC_VER)
308
-typedef signed char yytype_int8;
309
-#else
310
-typedef short int yytype_int8;
311
-#endif
312
-
313
-#ifdef YYTYPE_UINT16
314
-typedef YYTYPE_UINT16 yytype_uint16;
315
-#else
316
-typedef unsigned short int yytype_uint16;
317
-#endif
318
-
319
-#ifdef YYTYPE_INT16
320
-typedef YYTYPE_INT16 yytype_int16;
321
-#else
322
-typedef short int yytype_int16;
323
-#endif
324
-
325
-#ifndef YYSIZE_T
326
-# ifdef __SIZE_TYPE__
327
-#  define YYSIZE_T __SIZE_TYPE__
328
-# elif defined size_t
329
-#  define YYSIZE_T size_t
330
-# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
331
-     || defined __cplusplus || defined _MSC_VER)
332
-#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
333
-#  define YYSIZE_T size_t
334
-# else
335
-#  define YYSIZE_T unsigned int
336
-# endif
337
-#endif
338
-
339
-#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
340
-
341
-#ifndef YY_
342
-# if defined YYENABLE_NLS && YYENABLE_NLS
343
-#  if ENABLE_NLS
344
-#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
345
-#   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
346
-#  endif
347
-# endif
348
-# ifndef YY_
349
-#  define YY_(Msgid) Msgid
350
-# endif
351
-#endif
352
-
353
-/* Suppress unused-variable warnings by "using" E.  */
354
-#if ! defined lint || defined __GNUC__
355
-# define YYUSE(E) ((void) (E))
356
-#else
357
-# define YYUSE(E) /* empty */
358
-#endif
359
-
360
-/* Identity function, used to suppress warnings about constant conditions.  */
361
-#ifndef lint
362
-# define YYID(N) (N)
363
-#else
364
-#if (defined __STDC__ || defined __C99__FUNC__ \
365
-     || defined __cplusplus || defined _MSC_VER)
366
-static int
367
-YYID (int yyi)
368
-#else
369
-static int
370
-YYID (yyi)
371
-    int yyi;
372
-#endif
373
-{
374
-  return yyi;
375
-}
376
-#endif
377
-
378
-#if ! defined yyoverflow || YYERROR_VERBOSE
379
-
380
-/* The parser invokes alloca or malloc; define the necessary symbols.  */
381
-
382
-# ifdef YYSTACK_USE_ALLOCA
383
-#  if YYSTACK_USE_ALLOCA
384
-#   ifdef __GNUC__
385
-#    define YYSTACK_ALLOC __builtin_alloca
386
-#   elif defined __BUILTIN_VA_ARG_INCR
387
-#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
388
-#   elif defined _AIX
389
-#    define YYSTACK_ALLOC __alloca
390
-#   elif defined _MSC_VER
391
-#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
392
-#    define alloca _alloca
393
-#   else
394
-#    define YYSTACK_ALLOC alloca
395
-#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
396
-     || defined __cplusplus || defined _MSC_VER)
397
-#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
398
-      /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
399
-#     ifndef EXIT_SUCCESS
400
-#      define EXIT_SUCCESS 0
401
-#     endif
402
-#    endif
403
-#   endif
404
-#  endif
405
-# endif
406
-
407
-# ifdef YYSTACK_ALLOC
408
-   /* Pacify GCC's `empty if-body' warning.  */
409
-#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
410
-#  ifndef YYSTACK_ALLOC_MAXIMUM
411
-    /* The OS might guarantee only one guard page at the bottom of the stack,
412
-       and a page size can be as small as 4096 bytes.  So we cannot safely
413
-       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
414
-       to allow for a few compiler-allocated temporary stack slots.  */
415
-#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
416
-#  endif
417
-# else
418
-#  define YYSTACK_ALLOC YYMALLOC
419
-#  define YYSTACK_FREE YYFREE
420
-#  ifndef YYSTACK_ALLOC_MAXIMUM
421
-#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
422
-#  endif
423
-#  if (defined __cplusplus && ! defined EXIT_SUCCESS \
424
-       && ! ((defined YYMALLOC || defined malloc) \
425
-	     && (defined YYFREE || defined free)))
426
-#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
427
-#   ifndef EXIT_SUCCESS
428
-#    define EXIT_SUCCESS 0
429
-#   endif
430
-#  endif
431
-#  ifndef YYMALLOC
432
-#   define YYMALLOC malloc
433
-#   if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
434
-     || defined __cplusplus || defined _MSC_VER)
435
-void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
436
-#   endif
437
-#  endif
438
-#  ifndef YYFREE
439
-#   define YYFREE free
440
-#   if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
441
-     || defined __cplusplus || defined _MSC_VER)
442
-void free (void *); /* INFRINGES ON USER NAME SPACE */
443
-#   endif
444
-#  endif
445
-# endif
446
-#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
447
-
448
-
449
-#if (! defined yyoverflow \
450
-     && (! defined __cplusplus \
451
-	 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
452
-
453
-/* A type that is properly aligned for any stack member.  */
454
-union yyalloc
455
-{
456
-  yytype_int16 yyss_alloc;
457
-  YYSTYPE yyvs_alloc;
458
-};
459
-
460
-/* The size of the maximum gap between one aligned stack and the next.  */
461
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
462
-
463
-/* The size of an array large to enough to hold all stacks, each with
464
-   N elements.  */
465
-# define YYSTACK_BYTES(N) \
466
-     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
467
-      + YYSTACK_GAP_MAXIMUM)
468
-
469
-# define YYCOPY_NEEDED 1
470
-
471
-/* Relocate STACK from its old location to the new one.  The
472
-   local variables YYSIZE and YYSTACKSIZE give the old and new number of
473
-   elements in the stack, and YYPTR gives the new location of the
474
-   stack.  Advance YYPTR to a properly aligned location for the next
475
-   stack.  */
476
-# define YYSTACK_RELOCATE(Stack_alloc, Stack)				\
477
-    do									\
478
-      {									\
479
-	YYSIZE_T yynewbytes;						\
480
-	YYCOPY (&yyptr->Stack_alloc, Stack, yysize);			\
481
-	Stack = &yyptr->Stack_alloc;					\
482
-	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
483
-	yyptr += yynewbytes / sizeof (*yyptr);				\
484
-      }									\
485
-    while (YYID (0))
486
-
487
-#endif
488
-
489
-#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
490
-/* Copy COUNT objects from SRC to DST.  The source and destination do
491
-   not overlap.  */
492
-# ifndef YYCOPY
493
-#  if defined __GNUC__ && 1 < __GNUC__
494
-#   define YYCOPY(Dst, Src, Count) \
495
-      __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
496
-#  else
497
-#   define YYCOPY(Dst, Src, Count)              \
498
-      do                                        \
499
-        {                                       \
500
-          YYSIZE_T yyi;                         \
501
-          for (yyi = 0; yyi < (Count); yyi++)   \
502
-            (Dst)[yyi] = (Src)[yyi];            \
503
-        }                                       \
504
-      while (YYID (0))
505
-#  endif
506
-# endif
507
-#endif /* !YYCOPY_NEEDED */
508
-
509
-/* YYFINAL -- State number of the termination state.  */
510
-#define YYFINAL  2
511
-/* YYLAST -- Last index in YYTABLE.  */
512
-#define YYLAST   433
513
-
514
-/* YYNTOKENS -- Number of terminals.  */
515
-#define YYNTOKENS  74
516
-/* YYNNTS -- Number of nonterminals.  */
517
-#define YYNNTS  35
518
-/* YYNRULES -- Number of rules.  */
519
-#define YYNRULES  115
520
-/* YYNRULES -- Number of states.  */
521
-#define YYNSTATES  216
522
-
523
-/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
524
-#define YYUNDEFTOK  2
525
-#define YYMAXUTOK   308
526
-
527
-#define YYTRANSLATE(YYX)						\
528
-  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
529
-
530
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
531
-static const yytype_uint8 yytranslate[] =
532
-{
533
-       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
534
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
535
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
536
-       2,     2,     2,     2,     2,     2,     2,    60,    44,     2,
537
-      71,    72,    58,    56,    73,    57,    68,     2,     2,     2,
538
-       2,     2,     2,     2,     2,     2,     2,     2,    66,     2,
539
-       2,    67,     2,     2,     2,     2,     2,     2,     2,     2,
540
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
541
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
542
-       2,    69,    59,    70,    46,     2,     2,     2,     2,     2,
543
-       2,     2,     2,     2,     2,    63,     2,     2,     2,     2,
544
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
545
-       2,     2,     2,    64,    45,    65,    62,     2,     2,     2,
546
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
547
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
548
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
549
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
550
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
551
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
552
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
553
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
554
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
555
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
556
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
557
-       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
558
-       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
559
-       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
560
-      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
561
-      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
562
-      35,    36,    37,    38,    39,    40,    41,    42,    43,    47,
563
-      48,    49,    50,    51,    52,    53,    54,    55,    61
564
-};
565
-
566
-#if YYDEBUG
567
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
568
-   YYRHS.  */
569
-static const yytype_uint16 yyprhs[] =
570
-{
571
-       0,     0,     3,     4,     7,    10,    14,    18,    21,    31,
572
-      32,    36,    37,    41,    45,    46,    49,    51,    53,    54,
573
-      57,    59,    62,    64,    67,    71,    75,    79,    83,    85,
574
-      88,    93,    94,   100,   104,   105,   108,   110,   112,   114,
575
-     116,   118,   122,   127,   132,   133,   135,   139,   141,   143,
576
-     145,   147,   151,   155,   157,   161,   165,   166,   167,   179,
577
-     180,   190,   194,   197,   201,   205,   209,   213,   217,   221,
578
-     225,   229,   233,   235,   239,   243,   245,   252,   254,   258,
579
-     259,   264,   266,   268,   272,   274,   276,   278,   280,   282,
580
-     286,   288,   290,   295,   300,   305,   310,   315,   320,   322,
581
-     324,   326,   331,   333,   335,   339,   343,   347,   351,   355,
582
-     359,   363,   367,   370,   374,   378
583
-};
584
-
585
-/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
586
-static const yytype_int8 yyrhs[] =
587
-{
588
-      75,     0,    -1,    -1,    75,    77,    -1,    75,    76,    -1,
589
-      75,     1,    77,    -1,    75,     1,    63,    -1,    39,    15,
590
-      -1,    81,     3,     9,    83,    64,    78,    79,    80,    65,
591
-      -1,    -1,     6,    66,    85,    -1,    -1,     7,    66,    87,
592
-      -1,     8,    66,    95,    -1,    -1,    81,    82,    -1,     4,
593
-      -1,     5,    -1,    -1,    66,    84,    -1,     9,    -1,    84,
594
-       9,    -1,    86,    -1,    85,    86,    -1,     9,    67,    15,
595
-      -1,     9,    67,    14,    -1,     9,    67,    40,    -1,     9,
596
-      67,    41,    -1,    88,    -1,    87,    88,    -1,    10,    67,
597
-      15,    90,    -1,    -1,    10,    67,    89,    17,    90,    -1,
598
-      10,    67,    16,    -1,    -1,    90,    91,    -1,    19,    -1,
599
-      18,    -1,    20,    -1,    21,    -1,     9,    -1,    92,    68,
600
-       9,    -1,    92,    69,   108,    70,    -1,    92,    71,    93,
601
-      72,    -1,    -1,    96,    -1,    93,    73,    96,    -1,    17,
602
-      -1,    96,    -1,    40,    -1,    41,    -1,   108,    37,    94,
603
-      -1,   108,    38,   108,    -1,    10,    -1,    10,    22,   108,
604
-      -1,    10,    27,   101,    -1,    -1,    -1,    29,   107,     9,
605
-      27,    97,   100,    66,    98,    71,    95,    72,    -1,    -1,
606
-      29,   107,    28,   103,    66,    99,    71,    95,    72,    -1,
607
-     107,    28,   103,    -1,    61,    95,    -1,    95,    43,    95,
608
-      -1,    95,    42,    95,    -1,   108,    53,   108,    -1,   108,
609
-      51,   108,    -1,   108,    52,   108,    -1,   108,    50,   108,
610
-      -1,   108,    49,   108,    -1,   108,    47,   108,    -1,   108,
611
-      48,   108,    -1,   108,    -1,    71,    96,    72,    -1,    71,
612
-     102,    72,    -1,   101,    -1,    71,   108,    68,    68,   108,
613
-      72,    -1,   108,    -1,   102,    73,   108,    -1,    -1,    71,
614
-     104,   105,    72,    -1,    30,    -1,   106,    -1,   105,    73,
615
-     106,    -1,    10,    -1,    13,    -1,   108,    -1,    25,    -1,
616
-      26,    -1,    71,   108,    72,    -1,    23,    -1,    24,    -1,
617
-      31,    71,   108,    72,    -1,    32,    71,   108,    72,    -1,
618
-      33,    71,   108,    72,    -1,    34,    71,   108,    72,    -1,
619
-      35,    71,   108,    72,    -1,    36,    71,   108,    72,    -1,
620
-      14,    -1,    15,    -1,    11,    -1,    12,    69,   108,    70,
621
-      -1,    12,    -1,    92,    -1,   108,    56,   108,    -1,   108,
622
-      57,   108,    -1,   108,    58,   108,    -1,   108,    59,   108,
623
-      -1,   108,    60,   108,    -1,   108,    46,   108,    -1,   108,
624
-      44,   108,    -1,   108,    45,   108,    -1,    62,   108,    -1,
625
-     108,    55,   108,    -1,   108,    54,   108,    -1,    94,    -1
626
-};
627
-
628
-/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
629
-static const yytype_uint16 yyrline[] =
630
-{
631
-       0,   231,   231,   233,   234,   235,   236,   241,   253,   272,
632
-     275,   305,   309,   337,   342,   343,   348,   349,   355,   358,
633
-     378,   395,   434,   435,   440,   456,   469,   482,   499,   500,
634
-     505,   519,   518,   535,   552,   553,   558,   559,   560,   561,
635
-     566,   651,   701,   724,   764,   767,   789,   822,   869,   887,
636
-     896,   905,   920,   934,   947,   964,   980,  1014,   979,  1125,
637
-    1124,  1200,  1206,  1212,  1218,  1226,  1235,  1244,  1253,  1262,
638
-    1289,  1316,  1343,  1347,  1355,  1356,  1361,  1383,  1395,  1411,
639
-    1410,  1416,  1428,  1429,  1434,  1439,  1448,  1449,  1456,  1467,
640
-    1471,  1480,  1495,  1506,  1517,  1528,  1539,  1550,  1561,  1570,
641
-    1597,  1610,  1625,  1647,  1682,  1691,  1700,  1709,  1718,  1727,
642
-    1736,  1745,  1754,  1762,  1771,  1780
643
-};
644
-#endif
645
-
646
-#if YYDEBUG || YYERROR_VERBOSE || 0
647
-/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
648
-   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
649
-static const char *const yytname[] =
650
-{
651
-  "$end", "error", "$undefined", "_RULE_", "_PRIVATE_", "_GLOBAL_",
652
-  "_META_", "_STRINGS_", "_CONDITION_", "_IDENTIFIER_",
653
-  "_STRING_IDENTIFIER_", "_STRING_COUNT_", "_STRING_OFFSET_",
654
-  "_STRING_IDENTIFIER_WITH_WILDCARD_", "_NUMBER_", "_TEXT_STRING_",
655
-  "_HEX_STRING_", "_REGEXP_", "_ASCII_", "_WIDE_", "_NOCASE_",
656
-  "_FULLWORD_", "_AT_", "_FILESIZE_", "_ENTRYPOINT_", "_ALL_", "_ANY_",
657
-  "_IN_", "_OF_", "_FOR_", "_THEM_", "_INT8_", "_INT16_", "_INT32_",
658
-  "_UINT8_", "_UINT16_", "_UINT32_", "_MATCHES_", "_CONTAINS_", "_IMPORT_",
659
-  "_TRUE_", "_FALSE_", "_OR_", "_AND_", "'&'", "'|'", "'^'", "_IS_",
660
-  "_NEQ_", "_EQ_", "_GE_", "_GT_", "_LE_", "_LT_", "_SHIFT_RIGHT_",
661
-  "_SHIFT_LEFT_", "'+'", "'-'", "'*'", "'\\\\'", "'%'", "_NOT_", "'~'",
662
-  "'i'", "'{'", "'}'", "':'", "'='", "'.'", "'['", "']'", "'('", "')'",
663
-  "','", "$accept", "rules", "import", "rule", "meta", "strings",
664
-  "condition", "rule_modifiers", "rule_modifier", "tags", "tag_list",
665
-  "meta_declarations", "meta_declaration", "string_declarations",
666
-  "string_declaration", "$@1", "string_modifiers", "string_modifier",
667
-  "identifier", "arguments_list", "regexp", "boolean_expression",
668
-  "expression", "$@2", "$@3", "$@4", "integer_set", "range",
669
-  "integer_enumeration", "string_set", "$@5", "string_enumeration",
670
-  "string_enumeration_item", "for_expression", "primary_expression", YY_NULL
671
-};
672
-#endif
673
-
674
-# ifdef YYPRINT
675
-/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
676
-   token YYLEX-NUM.  */
677
-static const yytype_uint16 yytoknum[] =
678
-{
679
-       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
680
-     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
681
-     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
682
-     285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
683
-     295,   296,   297,   298,    38,   124,    94,   299,   300,   301,
684
-     302,   303,   304,   305,   306,   307,    43,    45,    42,    92,
685
-      37,   308,   126,   105,   123,   125,    58,    61,    46,    91,
686
-      93,    40,    41,    44
687
-};
688
-# endif
689
-
690
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
691
-static const yytype_uint8 yyr1[] =
692
-{
693
-       0,    74,    75,    75,    75,    75,    75,    76,    77,    78,
694
-      78,    79,    79,    80,    81,    81,    82,    82,    83,    83,
695
-      84,    84,    85,    85,    86,    86,    86,    86,    87,    87,
696
-      88,    89,    88,    88,    90,    90,    91,    91,    91,    91,
697
-      92,    92,    92,    92,    93,    93,    93,    94,    95,    96,
698
-      96,    96,    96,    96,    96,    96,    97,    98,    96,    99,
699
-      96,    96,    96,    96,    96,    96,    96,    96,    96,    96,
700
-      96,    96,    96,    96,   100,   100,   101,   102,   102,   104,
701
-     103,   103,   105,   105,   106,   106,   107,   107,   107,   108,
702
-     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
703
-     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
704
-     108,   108,   108,   108,   108,   108
705
-};
706
-
707
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
708
-static const yytype_uint8 yyr2[] =
709
-{
710
-       0,     2,     0,     2,     2,     3,     3,     2,     9,     0,
711
-       3,     0,     3,     3,     0,     2,     1,     1,     0,     2,
712
-       1,     2,     1,     2,     3,     3,     3,     3,     1,     2,
713
-       4,     0,     5,     3,     0,     2,     1,     1,     1,     1,
714
-       1,     3,     4,     4,     0,     1,     3,     1,     1,     1,
715
-       1,     3,     3,     1,     3,     3,     0,     0,    11,     0,
716
-       9,     3,     2,     3,     3,     3,     3,     3,     3,     3,
717
-       3,     3,     1,     3,     3,     1,     6,     1,     3,     0,
718
-       4,     1,     1,     3,     1,     1,     1,     1,     1,     3,
719
-       1,     1,     4,     4,     4,     4,     4,     4,     1,     1,
720
-       1,     4,     1,     1,     3,     3,     3,     3,     3,     3,
721
-       3,     3,     2,     3,     3,     1
722
-};
723
-
724
-/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
725
-   Performed when YYTABLE doesn't specify something else to do.  Zero
726
-   means the default is an error.  */
727
-static const yytype_uint8 yydefact[] =
728
-{
729
-       2,     0,     1,    14,     0,     4,     3,     0,     6,     5,
730
-       7,     0,    16,    17,    15,    18,     0,     0,    20,    19,
731
-       9,    21,     0,    11,     0,     0,     0,     0,    10,    22,
732
-       0,     0,     0,     0,    23,     0,    12,    28,     0,     8,
733
-      25,    24,    26,    27,    31,    29,    40,    53,   100,   102,
734
-      98,    99,    47,    90,    91,    87,    88,     0,     0,     0,
735
-       0,     0,     0,     0,    49,    50,     0,     0,     0,   103,
736
-     115,    13,    48,     0,    72,    34,    33,     0,     0,     0,
737
-       0,     0,     0,    86,     0,     0,     0,     0,     0,     0,
738
-      62,   112,     0,    48,    72,     0,     0,    44,     0,     0,
739
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
740
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
741
-      30,    34,    54,     0,    55,     0,     0,     0,     0,     0,
742
-       0,     0,     0,     0,     0,    73,    89,    41,     0,     0,
743
-      45,    64,    63,    81,    79,    61,    51,    52,   110,   111,
744
-     109,    70,    71,    69,    68,    66,    67,    65,   114,   113,
745
-     104,   105,   106,   107,   108,    37,    36,    38,    39,    35,
746
-      32,     0,   101,    56,     0,    92,    93,    94,    95,    96,
747
-      97,    42,    43,     0,     0,     0,     0,    59,    46,    84,
748
-      85,     0,    82,     0,     0,     0,    75,     0,    80,     0,
749
-       0,     0,    77,    57,     0,    83,    76,    74,     0,     0,
750
-       0,    78,     0,    60,     0,    58
751
-};
752
-
753
-/* YYDEFGOTO[NTERM-NUM].  */
754
-static const yytype_int16 yydefgoto[] =
755
-{
756
-      -1,     1,     5,     6,    23,    26,    32,     7,    14,    17,
757
-      19,    28,    29,    36,    37,    77,   120,   169,    69,   139,
758
-      70,    92,    72,   186,   209,   197,   195,   124,   201,   145,
759
-     184,   191,   192,    73,    74
760
-};
761
-
762
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
763
-   STATE-NUM.  */
764
-#define YYPACT_NINF -66
765
-static const yytype_int16 yypact[] =
766
-{
767
-     -66,     6,   -66,   -59,     0,   -66,   -66,    59,   -66,   -66,
768
-     -66,     9,   -66,   -66,   -66,   -44,    16,   -24,   -66,    49,
769
-      81,   -66,    26,    88,    92,    43,   115,    54,    92,   -66,
770
-     116,    63,    66,    -2,   -66,    75,   116,   -66,    79,   -66,
771
-     -66,   -66,   -66,   -66,    82,   -66,   -66,    -8,   -66,    83,
772
-     -66,   -66,   -66,   -66,   -66,   -66,   -66,   113,    72,    80,
773
-      84,    94,    96,    97,   -66,   -66,    79,   168,    79,   -42,
774
-     -66,    57,   -66,   125,   205,   -66,   -66,   137,   168,    98,
775
-     168,   168,    -7,   372,   168,   168,   168,   168,   168,   168,
776
-     -66,   -66,    57,   100,   169,   161,   168,    79,    79,    79,
777
-     -29,   156,   168,   168,   168,   168,   168,   168,   168,   168,
778
-     168,   168,   168,   168,   168,   168,   168,   168,   168,   168,
779
-      36,   -66,   372,   168,   -66,   338,   222,   149,   -29,   229,
780
-     251,   258,   280,   287,   309,   -66,   -66,   -66,   345,    34,
781
-      74,   135,   -66,   -66,   -66,   -66,   -66,   372,   104,   104,
782
-     104,   372,   372,   372,   372,   372,   372,   372,   -23,   -23,
783
-      25,    25,   -66,   -66,   -66,   -66,   -66,   -66,   -66,   -66,
784
-      36,   365,   -66,   -66,   120,   -66,   -66,   -66,   -66,   -66,
785
-     -66,   -66,   -66,    79,    -5,   119,   110,   -66,    74,   -66,
786
-     -66,    60,   -66,   168,   168,   122,   -66,   118,   -66,    -5,
787
-     316,    62,   365,   -66,    79,   -66,   -66,   -66,   168,   123,
788
-     -26,   372,    79,   -66,   -19,   -66
789
-};
790
-
791
-/* YYPGOTO[NTERM-NUM].  */
792
-static const yytype_int16 yypgoto[] =
793
-{
794
-     -66,   -66,   -66,   187,   -66,   -66,   -66,   -66,   -66,   -66,
795
-     -66,   -66,   165,   -66,   159,   -66,    77,   -66,   -66,   -66,
796
-      95,   -38,   -65,   -66,   -66,   -66,   -66,    19,   -66,   103,
797
-     -66,   -66,    10,   151,   -37
798
-};
799
-
800
-/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
801
-   positive, shift that token.  If negative, reduce the rule which
802
-   number is the opposite.  If YYTABLE_NINF, syntax error.  */
803
-#define YYTABLE_NINF -87
804
-static const yytype_int16 yytable[] =
805
-{
806
-      71,   143,   127,    93,     8,   189,     2,     3,   190,   -14,
807
-     -14,   -14,    40,    41,    78,    10,    98,    99,    15,    79,
808
-      83,   128,    16,    98,    99,    18,    95,    96,    90,    97,
809
-      91,    94,   140,   115,   116,   117,   118,   119,    42,    43,
810
-      20,   122,   144,   125,   126,     4,   213,   129,   130,   131,
811
-     132,   133,   134,   215,   165,   166,   167,   168,    21,   138,
812
-     141,   142,    11,    12,    13,   147,   148,   149,   150,   151,
813
-     152,   153,   154,   155,   156,   157,   158,   159,   160,   161,
814
-     162,   163,   164,   117,   118,   119,   171,    22,    46,    47,
815
-      48,    49,    24,    50,    51,    25,    52,    75,    76,    98,
816
-      99,    27,    53,    54,    55,    56,   182,   183,    57,    30,
817
-      58,    59,    60,    61,    62,    63,   -48,   -48,   188,    64,
818
-      65,    33,    46,    31,    48,    49,    35,    50,    51,    38,
819
-      52,    39,   198,   199,   207,   208,    53,    54,    55,    56,
820
-      66,    67,    44,    84,    58,    59,    60,    61,    62,    63,
821
-      68,    85,    80,   100,   121,    86,   200,   202,   113,   114,
822
-     115,   116,   117,   118,   119,    87,   210,    88,    89,   123,
823
-     137,   211,   135,    52,   214,    67,   173,    46,    99,    48,
824
-      49,   194,    50,    51,    81,    52,   187,   193,   203,   204,
825
-       9,    53,    54,    34,   212,    45,   146,   -86,   170,    58,
826
-      59,    60,    61,    62,    63,   196,   101,   102,    82,   205,
827
-       0,     0,     0,   103,   104,   105,   106,   107,   108,   109,
828
-     110,   111,   112,   113,   114,   115,   116,   117,   118,   119,
829
-      67,   174,     0,   -86,     0,     0,     0,     0,     0,    81,
830
-       0,   136,   101,   102,     0,     0,     0,     0,     0,   103,
831
-     104,   105,   106,   107,   108,   109,   110,   111,   112,   113,
832
-     114,   115,   116,   117,   118,   119,   103,   104,   105,     0,
833
-       0,     0,     0,   103,   104,   105,   113,   114,   115,   116,
834
-     117,   118,   119,   113,   114,   115,   116,   117,   118,   119,
835
-       0,     0,     0,     0,   136,   103,   104,   105,     0,     0,
836
-       0,   175,   103,   104,   105,   113,   114,   115,   116,   117,
837
-     118,   119,   113,   114,   115,   116,   117,   118,   119,     0,
838
-       0,     0,     0,   176,   103,   104,   105,     0,     0,     0,
839
-     177,   103,   104,   105,   113,   114,   115,   116,   117,   118,
840
-     119,   113,   114,   115,   116,   117,   118,   119,     0,     0,
841
-       0,     0,   178,   103,   104,   105,     0,     0,     0,   179,
842
-     103,   104,   105,   113,   114,   115,   116,   117,   118,   119,
843
-     113,   114,   115,   116,   117,   118,   119,     0,     0,     0,
844
-       0,   180,   103,   104,   105,     0,     0,     0,   206,   103,
845
-     104,   105,   113,   114,   115,   116,   117,   118,   119,   113,
846
-     114,   115,   116,   117,   118,   119,     0,     0,   172,   103,
847
-     104,   105,     0,     0,     0,   181,   103,   104,   105,   113,
848
-     114,   115,   116,   117,   118,   119,   113,   114,   115,   116,
849
-     117,   118,   119,   185
850
-};
851
-
852
-#define yypact_value_is_default(Yystate) \
853
-  (!!((Yystate) == (-66)))
854
-
855
-#define yytable_value_is_error(Yytable_value) \
856
-  YYID (0)
857
-
858
-static const yytype_int16 yycheck[] =
859
-{
860
-      38,    30,     9,    68,    63,    10,     0,     1,    13,     3,
861
-       4,     5,    14,    15,    22,    15,    42,    43,     9,    27,
862
-      57,    28,    66,    42,    43,     9,    68,    69,    66,    71,
863
-      67,    68,    97,    56,    57,    58,    59,    60,    40,    41,
864
-      64,    78,    71,    80,    81,    39,    72,    84,    85,    86,
865
-      87,    88,    89,    72,    18,    19,    20,    21,     9,    96,
866
-      98,    99,     3,     4,     5,   102,   103,   104,   105,   106,
867
-     107,   108,   109,   110,   111,   112,   113,   114,   115,   116,
868
-     117,   118,   119,    58,    59,    60,   123,     6,     9,    10,
869
-      11,    12,    66,    14,    15,     7,    17,    15,    16,    42,
870
-      43,     9,    23,    24,    25,    26,    72,    73,    29,    66,
871
-      31,    32,    33,    34,    35,    36,    42,    43,   183,    40,
872
-      41,    67,     9,     8,    11,    12,    10,    14,    15,    66,
873
-      17,    65,    72,    73,    72,    73,    23,    24,    25,    26,
874
-      61,    62,    67,    71,    31,    32,    33,    34,    35,    36,
875
-      71,    71,    69,    28,    17,    71,   193,   194,    54,    55,
876
-      56,    57,    58,    59,    60,    71,   204,    71,    71,    71,
877
-       9,   208,    72,    17,   212,    62,    27,     9,    43,    11,
878
-      12,    71,    14,    15,    71,    17,    66,    68,    66,    71,
879
-       3,    23,    24,    28,    71,    36,   101,    28,   121,    31,
880
-      32,    33,    34,    35,    36,   186,    37,    38,    57,   199,
881
-      -1,    -1,    -1,    44,    45,    46,    47,    48,    49,    50,
882
-      51,    52,    53,    54,    55,    56,    57,    58,    59,    60,
883
-      62,   128,    -1,    28,    -1,    -1,    -1,    -1,    -1,    71,
884
-      -1,    72,    37,    38,    -1,    -1,    -1,    -1,    -1,    44,
885
-      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
886
-      55,    56,    57,    58,    59,    60,    44,    45,    46,    -1,
887
-      -1,    -1,    -1,    44,    45,    46,    54,    55,    56,    57,
888
-      58,    59,    60,    54,    55,    56,    57,    58,    59,    60,
889
-      -1,    -1,    -1,    -1,    72,    44,    45,    46,    -1,    -1,
890
-      -1,    72,    44,    45,    46,    54,    55,    56,    57,    58,
891
-      59,    60,    54,    55,    56,    57,    58,    59,    60,    -1,
892
-      -1,    -1,    -1,    72,    44,    45,    46,    -1,    -1,    -1,
893
-      72,    44,    45,    46,    54,    55,    56,    57,    58,    59,
894
-      60,    54,    55,    56,    57,    58,    59,    60,    -1,    -1,
895
-      -1,    -1,    72,    44,    45,    46,    -1,    -1,    -1,    72,
896
-      44,    45,    46,    54,    55,    56,    57,    58,    59,    60,
897
-      54,    55,    56,    57,    58,    59,    60,    -1,    -1,    -1,
898
-      -1,    72,    44,    45,    46,    -1,    -1,    -1,    72,    44,
899
-      45,    46,    54,    55,    56,    57,    58,    59,    60,    54,
900
-      55,    56,    57,    58,    59,    60,    -1,    -1,    70,    44,
901
-      45,    46,    -1,    -1,    -1,    70,    44,    45,    46,    54,
902
-      55,    56,    57,    58,    59,    60,    54,    55,    56,    57,
903
-      58,    59,    60,    68
904
-};
905
-
906
-/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
907
-   symbol of state STATE-NUM.  */
908
-static const yytype_uint8 yystos[] =
909
-{
910
-       0,    75,     0,     1,    39,    76,    77,    81,    63,    77,
911
-      15,     3,     4,     5,    82,     9,    66,    83,     9,    84,
912
-      64,     9,     6,    78,    66,     7,    79,     9,    85,    86,
913
-      66,     8,    80,    67,    86,    10,    87,    88,    66,    65,
914
-      14,    15,    40,    41,    67,    88,     9,    10,    11,    12,
915
-      14,    15,    17,    23,    24,    25,    26,    29,    31,    32,
916
-      33,    34,    35,    36,    40,    41,    61,    62,    71,    92,
917
-      94,    95,    96,   107,   108,    15,    16,    89,    22,    27,
918
-      69,    71,   107,   108,    71,    71,    71,    71,    71,    71,
919
-      95,   108,    95,    96,   108,    68,    69,    71,    42,    43,
920
-      28,    37,    38,    44,    45,    46,    47,    48,    49,    50,
921
-      51,    52,    53,    54,    55,    56,    57,    58,    59,    60,
922
-      90,    17,   108,    71,   101,   108,   108,     9,    28,   108,
923
-     108,   108,   108,   108,   108,    72,    72,     9,   108,    93,
924
-      96,    95,    95,    30,    71,   103,    94,   108,   108,   108,
925
-     108,   108,   108,   108,   108,   108,   108,   108,   108,   108,
926
-     108,   108,   108,   108,   108,    18,    19,    20,    21,    91,
927
-      90,   108,    70,    27,   103,    72,    72,    72,    72,    72,
928
-      72,    70,    72,    73,   104,    68,    97,    66,    96,    10,
929
-      13,   105,   106,    68,    71,   100,   101,    99,    72,    73,
930
-     108,   102,   108,    66,    71,   106,    72,    72,    73,    98,
931
-      95,   108,    71,    72,    95,    72
932
-};
933
-
934
-#define yyerrok		(yyerrstatus = 0)
935
-#define yyclearin	(yychar = YYEMPTY)
936
-#define YYEMPTY		(-2)
937
-#define YYEOF		0
938
-
939
-#define YYACCEPT	goto yyacceptlab
940
-#define YYABORT		goto yyabortlab
941
-#define YYERROR		goto yyerrorlab
942
-
943
-
944
-/* Like YYERROR except do call yyerror.  This remains here temporarily
945
-   to ease the transition to the new meaning of YYERROR, for GCC.
946
-   Once GCC version 2 has supplanted version 1, this can go.  However,
947
-   YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
948
-   in Bison 2.4.2's NEWS entry, where a plan to phase it out is
949
-   discussed.  */
950
-
951
-#define YYFAIL		goto yyerrlab
952
-#if defined YYFAIL
953
-  /* This is here to suppress warnings from the GCC cpp's
954
-     -Wunused-macros.  Normally we don't worry about that warning, but
955
-     some users do, and we want to make it easy for users to remove
956
-     YYFAIL uses, which will produce warnings from Bison 2.5.  */
957
-#endif
958
-
959
-#define YYRECOVERING()  (!!yyerrstatus)
960
-
961
-#define YYBACKUP(Token, Value)                                  \
962
-do                                                              \
963
-  if (yychar == YYEMPTY)                                        \
964
-    {                                                           \
965
-      yychar = (Token);                                         \
966
-      yylval = (Value);                                         \
967
-      YYPOPSTACK (yylen);                                       \
968
-      yystate = *yyssp;                                         \
969
-      goto yybackup;                                            \
970
-    }                                                           \
971
-  else                                                          \
972
-    {                                                           \
973
-      yyerror (yyscanner, compiler, YY_("syntax error: cannot back up")); \
974
-      YYERROR;							\
975
-    }								\
976
-while (YYID (0))
977
-
978
-/* Error token number */
979
-#define YYTERROR	1
980
-#define YYERRCODE	256
981
-
982
-
983
-/* This macro is provided for backward compatibility. */
984
-#ifndef YY_LOCATION_PRINT
985
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
986
-#endif
987
-
988
-
989
-/* YYLEX -- calling `yylex' with the right arguments.  */
990
-#ifdef YYLEX_PARAM
991
-# define YYLEX yylex (&yylval, YYLEX_PARAM)
992
-#else
993
-# define YYLEX yylex (&yylval, yyscanner, compiler)
994
-#endif
995
-
996
-/* Enable debugging if requested.  */
997
-#if YYDEBUG
998
-
999
-# ifndef YYFPRINTF
1000
-#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1001
-#  define YYFPRINTF fprintf
1002
-# endif
1003
-
1004
-# define YYDPRINTF(Args)			\
1005
-do {						\
1006
-  if (yydebug)					\
1007
-    YYFPRINTF Args;				\
1008
-} while (YYID (0))
1009
-
1010
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
1011
-do {									  \
1012
-  if (yydebug)								  \
1013
-    {									  \
1014
-      YYFPRINTF (stderr, "%s ", Title);					  \
1015
-      yy_symbol_print (stderr,						  \
1016
-		  Type, Value, yyscanner, compiler); \
1017
-      YYFPRINTF (stderr, "\n");						  \
1018
-    }									  \
1019
-} while (YYID (0))
1020
-
1021
-
1022
-/*--------------------------------.
1023
-| Print this symbol on YYOUTPUT.  |
1024
-`--------------------------------*/
1025
-
1026
-/*ARGSUSED*/
1027
-#if (defined __STDC__ || defined __C99__FUNC__ \
1028
-     || defined __cplusplus || defined _MSC_VER)
1029
-static void
1030
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *yyscanner, YR_COMPILER* compiler)
1031
-#else
1032
-static void
1033
-yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, compiler)
1034
-    FILE *yyoutput;
1035
-    int yytype;
1036
-    YYSTYPE const * const yyvaluep;
1037
-    void *yyscanner;
1038
-    YR_COMPILER* compiler;
1039
-#endif
1040
-{
1041
-  FILE *yyo = yyoutput;
1042
-  YYUSE (yyo);
1043
-  if (!yyvaluep)
1044
-    return;
1045
-  YYUSE (yyscanner);
1046
-  YYUSE (compiler);
1047
-# ifdef YYPRINT
1048
-  if (yytype < YYNTOKENS)
1049
-    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1050
-# else
1051
-  YYUSE (yyoutput);
1052
-# endif
1053
-  switch (yytype)
1054
-    {
1055
-      default:
1056
-        break;
1057
-    }
1058
-}
1059
-
1060
-
1061
-/*--------------------------------.
1062
-| Print this symbol on YYOUTPUT.  |
1063
-`--------------------------------*/
1064
-
1065
-#if (defined __STDC__ || defined __C99__FUNC__ \
1066
-     || defined __cplusplus || defined _MSC_VER)
1067
-static void
1068
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *yyscanner, YR_COMPILER* compiler)
1069
-#else
1070
-static void
1071
-yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner, compiler)
1072
-    FILE *yyoutput;
1073
-    int yytype;
1074
-    YYSTYPE const * const yyvaluep;
1075
-    void *yyscanner;
1076
-    YR_COMPILER* compiler;
1077
-#endif
1078
-{
1079
-  if (yytype < YYNTOKENS)
1080
-    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1081
-  else
1082
-    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1083
-
1084
-  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, compiler);
1085
-  YYFPRINTF (yyoutput, ")");
1086
-}
1087
-
1088
-/*------------------------------------------------------------------.
1089
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1090
-| TOP (included).                                                   |
1091
-`------------------------------------------------------------------*/
1092
-
1093
-#if (defined __STDC__ || defined __C99__FUNC__ \
1094
-     || defined __cplusplus || defined _MSC_VER)
1095
-static void
1096
-yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1097
-#else
1098
-static void
1099
-yy_stack_print (yybottom, yytop)
1100
-    yytype_int16 *yybottom;
1101
-    yytype_int16 *yytop;
1102
-#endif
1103
-{
1104
-  YYFPRINTF (stderr, "Stack now");
1105
-  for (; yybottom <= yytop; yybottom++)
1106
-    {
1107
-      int yybot = *yybottom;
1108
-      YYFPRINTF (stderr, " %d", yybot);
1109
-    }
1110
-  YYFPRINTF (stderr, "\n");
1111
-}
1112
-
1113
-# define YY_STACK_PRINT(Bottom, Top)				\
1114
-do {								\
1115
-  if (yydebug)							\
1116
-    yy_stack_print ((Bottom), (Top));				\
1117
-} while (YYID (0))
1118
-
1119
-
1120
-/*------------------------------------------------.
1121
-| Report that the YYRULE is going to be reduced.  |
1122
-`------------------------------------------------*/
1123
-
1124
-#if (defined __STDC__ || defined __C99__FUNC__ \
1125
-     || defined __cplusplus || defined _MSC_VER)
1126
-static void
1127
-yy_reduce_print (YYSTYPE *yyvsp, int yyrule, void *yyscanner, YR_COMPILER* compiler)
1128
-#else
1129
-static void
1130
-yy_reduce_print (yyvsp, yyrule, yyscanner, compiler)
1131
-    YYSTYPE *yyvsp;
1132
-    int yyrule;
1133
-    void *yyscanner;
1134
-    YR_COMPILER* compiler;
1135
-#endif
1136
-{
1137
-  int yynrhs = yyr2[yyrule];
1138
-  int yyi;
1139
-  unsigned long int yylno = yyrline[yyrule];
1140
-  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1141
-	     yyrule - 1, yylno);
1142
-  /* The symbols being reduced.  */
1143
-  for (yyi = 0; yyi < yynrhs; yyi++)
1144
-    {
1145
-      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
1146
-      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1147
-		       &(yyvsp[(yyi + 1) - (yynrhs)])
1148
-		       		       , yyscanner, compiler);
1149
-      YYFPRINTF (stderr, "\n");
1150
-    }
1151
-}
1152
-
1153
-# define YY_REDUCE_PRINT(Rule)		\
1154
-do {					\
1155
-  if (yydebug)				\
1156
-    yy_reduce_print (yyvsp, Rule, yyscanner, compiler); \
1157
-} while (YYID (0))
1158
-
1159
-/* Nonzero means print parse trace.  It is left uninitialized so that
1160
-   multiple parsers can coexist.  */
1161
-int yydebug;
1162
-#else /* !YYDEBUG */
1163
-# define YYDPRINTF(Args)
1164
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1165
-# define YY_STACK_PRINT(Bottom, Top)
1166
-# define YY_REDUCE_PRINT(Rule)
1167
-#endif /* !YYDEBUG */
1168
-
1169
-
1170
-/* YYINITDEPTH -- initial size of the parser's stacks.  */
1171
-#ifndef	YYINITDEPTH
1172
-# define YYINITDEPTH 200
1173
-#endif
1174
-
1175
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1176
-   if the built-in stack extension method is used).
1177
-
1178
-   Do not make this value too large; the results are undefined if
1179
-   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1180
-   evaluated with infinite-precision integer arithmetic.  */
1181
-
1182
-#ifndef YYMAXDEPTH
1183
-# define YYMAXDEPTH 10000
1184
-#endif
1185
-
1186
-
1187
-#if YYERROR_VERBOSE
1188
-
1189
-# ifndef yystrlen
1190
-#  if defined __GLIBC__ && defined _STRING_H
1191
-#   define yystrlen strlen
1192
-#  else
1193
-/* Return the length of YYSTR.  */
1194
-#if (defined __STDC__ || defined __C99__FUNC__ \
1195
-     || defined __cplusplus || defined _MSC_VER)
1196
-static YYSIZE_T
1197
-yystrlen (const char *yystr)
1198
-#else
1199
-static YYSIZE_T
1200
-yystrlen (yystr)
1201
-    const char *yystr;
1202
-#endif
1203
-{
1204
-  YYSIZE_T yylen;
1205
-  for (yylen = 0; yystr[yylen]; yylen++)
1206
-    continue;
1207
-  return yylen;
1208
-}
1209
-#  endif
1210
-# endif
1211
-
1212
-# ifndef yystpcpy
1213
-#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1214
-#   define yystpcpy stpcpy
1215
-#  else
1216
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1217
-   YYDEST.  */
1218
-#if (defined __STDC__ || defined __C99__FUNC__ \
1219
-     || defined __cplusplus || defined _MSC_VER)
1220
-static char *
1221
-yystpcpy (char *yydest, const char *yysrc)
1222
-#else
1223
-static char *
1224
-yystpcpy (yydest, yysrc)
1225
-    char *yydest;
1226
-    const char *yysrc;
1227
-#endif
1228
-{
1229
-  char *yyd = yydest;
1230
-  const char *yys = yysrc;
1231
-
1232
-  while ((*yyd++ = *yys++) != '\0')
1233
-    continue;
1234
-
1235
-  return yyd - 1;
1236
-}
1237
-#  endif
1238
-# endif
1239
-
1240
-# ifndef yytnamerr
1241
-/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1242
-   quotes and backslashes, so that it's suitable for yyerror.  The
1243
-   heuristic is that double-quoting is unnecessary unless the string
1244
-   contains an apostrophe, a comma, or backslash (other than
1245
-   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1246
-   null, do not copy; instead, return the length of what the result
1247
-   would have been.  */
1248
-static YYSIZE_T
1249
-yytnamerr (char *yyres, const char *yystr)
1250
-{
1251
-  if (*yystr == '"')
1252
-    {
1253
-      YYSIZE_T yyn = 0;
1254
-      char const *yyp = yystr;
1255
-
1256
-      for (;;)
1257
-	switch (*++yyp)
1258
-	  {
1259
-	  case '\'':
1260
-	  case ',':
1261
-	    goto do_not_strip_quotes;
1262
-
1263
-	  case '\\':
1264
-	    if (*++yyp != '\\')
1265
-	      goto do_not_strip_quotes;
1266
-	    /* Fall through.  */
1267
-	  default:
1268
-	    if (yyres)
1269
-	      yyres[yyn] = *yyp;
1270
-	    yyn++;
1271
-	    break;
1272
-
1273
-	  case '"':
1274
-	    if (yyres)
1275
-	      yyres[yyn] = '\0';
1276
-	    return yyn;
1277
-	  }
1278
-    do_not_strip_quotes: ;
1279
-    }
1280
-
1281
-  if (! yyres)
1282
-    return yystrlen (yystr);
1283
-
1284
-  return yystpcpy (yyres, yystr) - yyres;
1285
-}
1286
-# endif
1287
-
1288
-/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1289
-   about the unexpected token YYTOKEN for the state stack whose top is
1290
-   YYSSP.
1291
-
1292
-   Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
1293
-   not large enough to hold the message.  In that case, also set
1294
-   *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
1295
-   required number of bytes is too large to store.  */
1296
-static int
1297
-yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1298
-                yytype_int16 *yyssp, int yytoken)
1299
-{
1300
-  YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
1301
-  YYSIZE_T yysize = yysize0;
1302
-  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1303
-  /* Internationalized format string. */
1304
-  const char *yyformat = YY_NULL;
1305
-  /* Arguments of yyformat. */
1306
-  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1307
-  /* Number of reported tokens (one for the "unexpected", one per
1308
-     "expected"). */
1309
-  int yycount = 0;
1310
-
1311
-  /* There are many possibilities here to consider:
1312
-     - Assume YYFAIL is not used.  It's too flawed to consider.  See
1313
-       <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1314
-       for details.  YYERROR is fine as it does not invoke this
1315
-       function.
1316
-     - If this state is a consistent state with a default action, then
1317
-       the only way this function was invoked is if the default action
1318
-       is an error action.  In that case, don't check for expected
1319
-       tokens because there are none.
1320
-     - The only way there can be no lookahead present (in yychar) is if
1321
-       this state is a consistent state with a default action.  Thus,
1322
-       detecting the absence of a lookahead is sufficient to determine
1323
-       that there is no unexpected or expected token to report.  In that
1324
-       case, just report a simple "syntax error".
1325
-     - Don't assume there isn't a lookahead just because this state is a
1326
-       consistent state with a default action.  There might have been a
1327
-       previous inconsistent state, consistent state with a non-default
1328
-       action, or user semantic action that manipulated yychar.
1329
-     - Of course, the expected token list depends on states to have
1330
-       correct lookahead information, and it depends on the parser not
1331
-       to perform extra reductions after fetching a lookahead from the
1332
-       scanner and before detecting a syntax error.  Thus, state merging
1333
-       (from LALR or IELR) and default reductions corrupt the expected
1334
-       token list.  However, the list is correct for canonical LR with
1335
-       one exception: it will still contain any token that will not be
1336
-       accepted due to an error action in a later state.
1337
-  */
1338
-  if (yytoken != YYEMPTY)
1339
-    {
1340
-      int yyn = yypact[*yyssp];
1341
-      yyarg[yycount++] = yytname[yytoken];
1342
-      if (!yypact_value_is_default (yyn))
1343
-        {
1344
-          /* Start YYX at -YYN if negative to avoid negative indexes in
1345
-             YYCHECK.  In other words, skip the first -YYN actions for
1346
-             this state because they are default actions.  */
1347
-          int yyxbegin = yyn < 0 ? -yyn : 0;
1348
-          /* Stay within bounds of both yycheck and yytname.  */
1349
-          int yychecklim = YYLAST - yyn + 1;
1350
-          int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1351
-          int yyx;
1352
-
1353
-          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1354
-            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1355
-                && !yytable_value_is_error (yytable[yyx + yyn]))
1356
-              {
1357
-                if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1358
-                  {
1359
-                    yycount = 1;
1360
-                    yysize = yysize0;
1361
-                    break;
1362
-                  }
1363
-                yyarg[yycount++] = yytname[yyx];
1364
-                {
1365
-                  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1366
-                  if (! (yysize <= yysize1
1367
-                         && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1368
-                    return 2;
1369
-                  yysize = yysize1;
1370
-                }
1371
-              }
1372
-        }
1373
-    }
1374
-
1375
-  switch (yycount)
1376
-    {
1377
-# define YYCASE_(N, S)                      \
1378
-      case N:                               \
1379
-        yyformat = S;                       \
1380
-      break
1381
-      YYCASE_(0, YY_("syntax error"));
1382
-      YYCASE_(1, YY_("syntax error, unexpected %s"));
1383
-      YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1384
-      YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1385
-      YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1386
-      YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1387
-# undef YYCASE_
1388
-    }
1389
-
1390
-  {
1391
-    YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1392
-    if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1393
-      return 2;
1394
-    yysize = yysize1;
1395
-  }
1396
-
1397
-  if (*yymsg_alloc < yysize)
1398
-    {
1399
-      *yymsg_alloc = 2 * yysize;
1400
-      if (! (yysize <= *yymsg_alloc
1401
-             && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1402
-        *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1403
-      return 1;
1404
-    }
1405
-
1406
-  /* Avoid sprintf, as that infringes on the user's name space.
1407
-     Don't have undefined behavior even if the translation
1408
-     produced a string with the wrong number of "%s"s.  */
1409
-  {
1410
-    char *yyp = *yymsg;
1411
-    int yyi = 0;
1412
-    while ((*yyp = *yyformat) != '\0')
1413
-      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1414
-        {
1415
-          yyp += yytnamerr (yyp, yyarg[yyi++]);
1416
-          yyformat += 2;
1417
-        }
1418
-      else
1419
-        {
1420
-          yyp++;
1421
-          yyformat++;
1422
-        }
1423
-  }
1424
-  return 0;
1425
-}
1426
-#endif /* YYERROR_VERBOSE */
1427
-
1428
-/*-----------------------------------------------.
1429
-| Release the memory associated to this symbol.  |
1430
-`-----------------------------------------------*/
1431
-
1432
-/*ARGSUSED*/
1433
-#if (defined __STDC__ || defined __C99__FUNC__ \
1434
-     || defined __cplusplus || defined _MSC_VER)
1435
-static void
1436
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *yyscanner, YR_COMPILER* compiler)
1437
-#else
1438
-static void
1439
-yydestruct (yymsg, yytype, yyvaluep, yyscanner, compiler)
1440
-    const char *yymsg;
1441
-    int yytype;
1442
-    YYSTYPE *yyvaluep;
1443
-    void *yyscanner;
1444
-    YR_COMPILER* compiler;
1445
-#endif
1446
-{
1447
-  YYUSE (yyvaluep);
1448
-  YYUSE (yyscanner);
1449
-  YYUSE (compiler);
1450
-
1451
-  if (!yymsg)
1452
-    yymsg = "Deleting";
1453
-  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1454
-
1455
-  switch (yytype)
1456
-    {
1457
-      case 9: /* _IDENTIFIER_ */
1458
-/* Line 1398 of yacc.c  */
1459
-#line 209 "yara_grammar.y"
1460
-        { yr_free(((*yyvaluep).c_string)); };
1461
-/* Line 1398 of yacc.c  */
1462
-#line 1463 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.c"
1463
-        break;
1464
-      case 10: /* _STRING_IDENTIFIER_ */
1465
-/* Line 1398 of yacc.c  */
1466
-#line 210 "yara_grammar.y"
1467
-        { yr_free(((*yyvaluep).c_string)); };
1468
-/* Line 1398 of yacc.c  */
1469
-#line 1470 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.c"
1470
-        break;
1471
-      case 11: /* _STRING_COUNT_ */
1472
-/* Line 1398 of yacc.c  */
1473
-#line 211 "yara_grammar.y"
1474
-        { yr_free(((*yyvaluep).c_string)); };
1475
-/* Line 1398 of yacc.c  */
1476
-#line 1477 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.c"
1477
-        break;
1478
-      case 12: /* _STRING_OFFSET_ */
1479
-/* Line 1398 of yacc.c  */
1480
-#line 212 "yara_grammar.y"
1481
-        { yr_free(((*yyvaluep).c_string)); };
1482
-/* Line 1398 of yacc.c  */
1483
-#line 1484 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.c"
1484
-        break;
1485
-      case 13: /* _STRING_IDENTIFIER_WITH_WILDCARD_ */
1486
-/* Line 1398 of yacc.c  */
1487
-#line 213 "yara_grammar.y"
1488
-        { yr_free(((*yyvaluep).c_string)); };
1489
-/* Line 1398 of yacc.c  */
1490
-#line 1491 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.c"
1491
-        break;
1492
-      case 15: /* _TEXT_STRING_ */
1493
-/* Line 1398 of yacc.c  */
1494
-#line 214 "yara_grammar.y"
1495
-        { yr_free(((*yyvaluep).sized_string)); };
1496
-/* Line 1398 of yacc.c  */
1497
-#line 1498 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.c"
1498
-        break;
1499
-      case 16: /* _HEX_STRING_ */
1500
-/* Line 1398 of yacc.c  */
1501
-#line 215 "yara_grammar.y"
1502
-        { yr_free(((*yyvaluep).sized_string)); };
1503
-/* Line 1398 of yacc.c  */
1504
-#line 1505 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.c"
1505
-        break;
1506
-      case 17: /* _REGEXP_ */
1507
-/* Line 1398 of yacc.c  */
1508
-#line 216 "yara_grammar.y"
1509
-        { yr_free(((*yyvaluep).sized_string)); };
1510
-/* Line 1398 of yacc.c  */
1511
-#line 1512 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.c"
1512
-        break;
1513
-
1514
-      default:
1515
-        break;
1516
-    }
1517
-}
1518
-
1519
-
1520
-
1521
-
1522
-/*----------.
1523
-| yyparse.  |
1524
-`----------*/
1525
-
1526
-#ifdef YYPARSE_PARAM
1527
-#if (defined __STDC__ || defined __C99__FUNC__ \
1528
-     || defined __cplusplus || defined _MSC_VER)
1529
-int
1530
-yyparse (void *YYPARSE_PARAM)
1531
-#else
1532
-int
1533
-yyparse (YYPARSE_PARAM)
1534
-    void *YYPARSE_PARAM;
1535
-#endif
1536
-#else /* ! YYPARSE_PARAM */
1537
-#if (defined __STDC__ || defined __C99__FUNC__ \
1538
-     || defined __cplusplus || defined _MSC_VER)
1539
-int
1540
-yyparse (void *yyscanner, YR_COMPILER* compiler)
1541
-#else
1542
-int
1543
-yyparse (yyscanner, compiler)
1544
-    void *yyscanner;
1545
-    YR_COMPILER* compiler;
1546
-#endif
1547
-#endif
1548
-{
1549
-/* The lookahead symbol.  */
1550
-int yychar;
1551
-
1552
-
1553
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
1554
-/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
1555
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
1556
-    _Pragma ("GCC diagnostic push") \
1557
-    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
1558
-    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
1559
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
1560
-    _Pragma ("GCC diagnostic pop")
1561
-#else
1562
-/* Default value used for initialization, for pacifying older GCCs
1563
-   or non-GCC compilers.  */
1564
-static YYSTYPE yyval_default;
1565
-# define YY_INITIAL_VALUE(Value) = Value
1566
-#endif
1567
-#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1568
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1569
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END
1570
-#endif
1571
-#ifndef YY_INITIAL_VALUE
1572
-# define YY_INITIAL_VALUE(Value) /* Nothing. */
1573
-#endif
1574
-
1575
-/* The semantic value of the lookahead symbol.  */
1576
-YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
1577
-
1578
-    /* Number of syntax errors so far.  */
1579
-    int yynerrs;
1580
-
1581
-    int yystate;
1582
-    /* Number of tokens to shift before error messages enabled.  */
1583
-    int yyerrstatus;
1584
-
1585
-    /* The stacks and their tools:
1586
-       `yyss': related to states.
1587
-       `yyvs': related to semantic values.
1588
-
1589
-       Refer to the stacks through separate pointers, to allow yyoverflow
1590
-       to reallocate them elsewhere.  */
1591
-
1592
-    /* The state stack.  */
1593
-    yytype_int16 yyssa[YYINITDEPTH];
1594
-    yytype_int16 *yyss;
1595
-    yytype_int16 *yyssp;
1596
-
1597
-    /* The semantic value stack.  */
1598
-    YYSTYPE yyvsa[YYINITDEPTH];
1599
-    YYSTYPE *yyvs;
1600
-    YYSTYPE *yyvsp;
1601
-
1602
-    YYSIZE_T yystacksize;
1603
-
1604
-  int yyn;
1605
-  int yyresult;
1606
-  /* Lookahead token as an internal (translated) token number.  */
1607
-  int yytoken = 0;
1608
-  /* The variables used to return semantic value and location from the
1609
-     action routines.  */
1610
-  YYSTYPE yyval;
1611
-
1612
-#if YYERROR_VERBOSE
1613
-  /* Buffer for error messages, and its allocated size.  */
1614
-  char yymsgbuf[128];
1615
-  char *yymsg = yymsgbuf;
1616
-  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1617
-#endif
1618
-
1619
-#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1620
-
1621
-  /* The number of symbols on the RHS of the reduced rule.
1622
-     Keep to zero when no symbol should be popped.  */
1623
-  int yylen = 0;
1624
-
1625
-  yyssp = yyss = yyssa;
1626
-  yyvsp = yyvs = yyvsa;
1627
-  yystacksize = YYINITDEPTH;
1628
-
1629
-  YYDPRINTF ((stderr, "Starting parse\n"));
1630
-
1631
-  yystate = 0;
1632
-  yyerrstatus = 0;
1633
-  yynerrs = 0;
1634
-  yychar = YYEMPTY; /* Cause a token to be read.  */
1635
-  goto yysetstate;
1636
-
1637
-/*------------------------------------------------------------.
1638
-| yynewstate -- Push a new state, which is found in yystate.  |
1639
-`------------------------------------------------------------*/
1640
- yynewstate:
1641
-  /* In all cases, when you get here, the value and location stacks
1642
-     have just been pushed.  So pushing a state here evens the stacks.  */
1643
-  yyssp++;
1644
-
1645
- yysetstate:
1646
-  *yyssp = yystate;
1647
-
1648
-  if (yyss + yystacksize - 1 <= yyssp)
1649
-    {
1650
-      /* Get the current used size of the three stacks, in elements.  */
1651
-      YYSIZE_T yysize = yyssp - yyss + 1;
1652
-
1653
-#ifdef yyoverflow
1654
-      {
1655
-	/* Give user a chance to reallocate the stack.  Use copies of
1656
-	   these so that the &'s don't force the real ones into
1657
-	   memory.  */
1658
-	YYSTYPE *yyvs1 = yyvs;
1659
-	yytype_int16 *yyss1 = yyss;
1660
-
1661
-	/* Each stack pointer address is followed by the size of the
1662
-	   data in use in that stack, in bytes.  This used to be a
1663
-	   conditional around just the two extra args, but that might
1664
-	   be undefined if yyoverflow is a macro.  */
1665
-	yyoverflow (YY_("memory exhausted"),
1666
-		    &yyss1, yysize * sizeof (*yyssp),
1667
-		    &yyvs1, yysize * sizeof (*yyvsp),
1668
-		    &yystacksize);
1669
-
1670
-	yyss = yyss1;
1671
-	yyvs = yyvs1;
1672
-      }
1673
-#else /* no yyoverflow */
1674
-# ifndef YYSTACK_RELOCATE
1675
-      goto yyexhaustedlab;
1676
-# else
1677
-      /* Extend the stack our own way.  */
1678
-      if (YYMAXDEPTH <= yystacksize)
1679
-	goto yyexhaustedlab;
1680
-      yystacksize *= 2;
1681
-      if (YYMAXDEPTH < yystacksize)
1682
-	yystacksize = YYMAXDEPTH;
1683
-
1684
-      {
1685
-	yytype_int16 *yyss1 = yyss;
1686
-	union yyalloc *yyptr =
1687
-	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1688
-	if (! yyptr)
1689
-	  goto yyexhaustedlab;
1690
-	YYSTACK_RELOCATE (yyss_alloc, yyss);
1691
-	YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1692
-#  undef YYSTACK_RELOCATE
1693
-	if (yyss1 != yyssa)
1694
-	  YYSTACK_FREE (yyss1);
1695
-      }
1696
-# endif
1697
-#endif /* no yyoverflow */
1698
-
1699
-      yyssp = yyss + yysize - 1;
1700
-      yyvsp = yyvs + yysize - 1;
1701
-
1702
-      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1703
-		  (unsigned long int) yystacksize));
1704
-
1705
-      if (yyss + yystacksize - 1 <= yyssp)
1706
-	YYABORT;
1707
-    }
1708
-
1709
-  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1710
-
1711
-  if (yystate == YYFINAL)
1712
-    YYACCEPT;
1713
-
1714
-  goto yybackup;
1715
-
1716
-/*-----------.
1717
-| yybackup.  |
1718
-`-----------*/
1719
-yybackup:
1720
-
1721
-  /* Do appropriate processing given the current state.  Read a
1722
-     lookahead token if we need one and don't already have one.  */
1723
-
1724
-  /* First try to decide what to do without reference to lookahead token.  */
1725
-  yyn = yypact[yystate];
1726
-  if (yypact_value_is_default (yyn))
1727
-    goto yydefault;
1728
-
1729
-  /* Not known => get a lookahead token if don't already have one.  */
1730
-
1731
-  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1732
-  if (yychar == YYEMPTY)
1733
-    {
1734
-      YYDPRINTF ((stderr, "Reading a token: "));
1735
-      yychar = YYLEX;
1736
-    }
1737
-
1738
-  if (yychar <= YYEOF)
1739
-    {
1740
-      yychar = yytoken = YYEOF;
1741
-      YYDPRINTF ((stderr, "Now at end of input.\n"));
1742
-    }
1743
-  else
1744
-    {
1745
-      yytoken = YYTRANSLATE (yychar);
1746
-      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1747
-    }
1748
-
1749
-  /* If the proper action on seeing token YYTOKEN is to reduce or to
1750
-     detect an error, take that action.  */
1751
-  yyn += yytoken;
1752
-  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1753
-    goto yydefault;
1754
-  yyn = yytable[yyn];
1755
-  if (yyn <= 0)
1756
-    {
1757
-      if (yytable_value_is_error (yyn))
1758
-        goto yyerrlab;
1759
-      yyn = -yyn;
1760
-      goto yyreduce;
1761
-    }
1762
-
1763
-  /* Count tokens shifted since error; after three, turn off error
1764
-     status.  */
1765
-  if (yyerrstatus)
1766
-    yyerrstatus--;
1767
-
1768
-  /* Shift the lookahead token.  */
1769
-  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1770
-
1771
-  /* Discard the shifted token.  */
1772
-  yychar = YYEMPTY;
1773
-
1774
-  yystate = yyn;
1775
-  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1776
-  *++yyvsp = yylval;
1777
-  YY_IGNORE_MAYBE_UNINITIALIZED_END
1778
-
1779
-  goto yynewstate;
1780
-
1781
-
1782
-/*-----------------------------------------------------------.
1783
-| yydefault -- do the default action for the current state.  |
1784
-`-----------------------------------------------------------*/
1785
-yydefault:
1786
-  yyn = yydefact[yystate];
1787
-  if (yyn == 0)
1788
-    goto yyerrlab;
1789
-  goto yyreduce;
1790
-
1791
-
1792
-/*-----------------------------.
1793
-| yyreduce -- Do a reduction.  |
1794
-`-----------------------------*/
1795
-yyreduce:
1796
-  /* yyn is the number of a rule to reduce with.  */
1797
-  yylen = yyr2[yyn];
1798
-
1799
-  /* If YYLEN is nonzero, implement the default value of the action:
1800
-     `$$ = $1'.
1801
-
1802
-     Otherwise, the following line sets YYVAL to garbage.
1803
-     This behavior is undocumented and Bison
1804
-     users should not rely upon it.  Assigning to YYVAL
1805
-     unconditionally makes the parser a bit smaller, and it avoids a
1806
-     GCC warning that YYVAL may be used uninitialized.  */
1807
-  yyval = yyvsp[1-yylen];
1808
-
1809
-
1810
-  YY_REDUCE_PRINT (yyn);
1811
-  switch (yyn)
1812
-    {
1813
-        case 7:
1814
-/* Line 1792 of yacc.c  */
1815
-#line 242 "yara_grammar.y"
1816
-    {
1817
-        int result = yr_parser_reduce_import(yyscanner, (yyvsp[(2) - (2)].sized_string));
1818
-
1819
-        yr_free((yyvsp[(2) - (2)].sized_string));
1820
-
1821
-        ERROR_IF(result != ERROR_SUCCESS);
1822
-      }
1823
-    break;
1824
-
1825
-  case 8:
1826
-/* Line 1792 of yacc.c  */
1827
-#line 254 "yara_grammar.y"
1828
-    {
1829
-        int result = yr_parser_reduce_rule_declaration(
1830
-            yyscanner,
1831
-            (yyvsp[(1) - (9)].integer),
1832
-            (yyvsp[(3) - (9)].c_string),
1833
-            (yyvsp[(4) - (9)].c_string),
1834
-            (yyvsp[(7) - (9)].string),
1835
-            (yyvsp[(6) - (9)].meta));
1836
-
1837
-        yr_free((yyvsp[(3) - (9)].c_string));
1838
-
1839
-        ERROR_IF(result != ERROR_SUCCESS);
1840
-      }
1841
-    break;
1842
-
1843
-  case 9:
1844
-/* Line 1792 of yacc.c  */
1845
-#line 272 "yara_grammar.y"
1846
-    {
1847
-        (yyval.meta) = NULL;
1848
-      }
1849
-    break;
1850
-
1851
-  case 10:
1852
-/* Line 1792 of yacc.c  */
1853
-#line 276 "yara_grammar.y"
1854
-    {
1855
-#if REAL_YARA //Meta not supported
1856
-        // Each rule have a list of meta-data info, consisting in a
1857
-        // sequence of YR_META structures. The last YR_META structure does
1858
-        // not represent a real meta-data, it's just a end-of-list marker
1859
-        // identified by a specific type (META_TYPE_NULL). Here we
1860
-        // write the end-of-list marker.
1861
-
1862
-        YR_META null_meta;
1863
-
1864
-        memset(&null_meta, 0xFF, sizeof(YR_META));
1865
-        null_meta.type = META_TYPE_NULL;
1866
-
1867
-        compiler->last_result = yr_arena_write_data(
1868
-            compiler->metas_arena,
1869
-            &null_meta,
1870
-            sizeof(YR_META),
1871
-            NULL);
1872
-
1873
-#endif
1874
-        (yyval.meta) = (yyvsp[(3) - (3)].meta);
1875
-
1876
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
1877
-      }
1878
-    break;
1879
-
1880
-  case 11:
1881
-/* Line 1792 of yacc.c  */
1882
-#line 305 "yara_grammar.y"
1883
-    {
1884
-        (yyval.string) = NULL;
1885
-        compiler->current_rule_strings = (yyval.string);
1886
-      }
1887
-    break;
1888
-
1889
-  case 12:
1890
-/* Line 1792 of yacc.c  */
1891
-#line 310 "yara_grammar.y"
1892
-    {
1893
-        // Each rule have a list of strings, consisting in a sequence
1894
-        // of YR_STRING structures. The last YR_STRING structure does not
1895
-        // represent a real string, it's just a end-of-list marker
1896
-        // identified by a specific flag (STRING_FLAGS_NULL). Here we
1897
-        // write the end-of-list marker.
1898
-
1899
-        YR_STRING null_string;
1900
-
1901
-        memset(&null_string, 0xFF, sizeof(YR_STRING));
1902
-        null_string.g_flags = STRING_GFLAGS_NULL;
1903
-
1904
-        compiler->last_result = yr_arena_write_data(
1905
-            compiler->strings_arena,
1906
-            &null_string,
1907
-            sizeof(YR_STRING),
1908
-            NULL);
1909
-
1910
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
1911
-
1912
-        compiler->current_rule_strings = (yyvsp[(3) - (3)].string);
1913
-        (yyval.string) = (yyvsp[(3) - (3)].string);
1914
-      }
1915
-    break;
1916
-
1917
-  case 14:
1918
-/* Line 1792 of yacc.c  */
1919
-#line 342 "yara_grammar.y"
1920
-    { (yyval.integer) = 0;  }
1921
-    break;
1922
-
1923
-  case 15:
1924
-/* Line 1792 of yacc.c  */
1925
-#line 343 "yara_grammar.y"
1926
-    { (yyval.integer) = (yyvsp[(1) - (2)].integer) | (yyvsp[(2) - (2)].integer); }
1927
-    break;
1928
-
1929
-  case 16:
1930
-/* Line 1792 of yacc.c  */
1931
-#line 348 "yara_grammar.y"
1932
-    { (yyval.integer) = RULE_GFLAGS_PRIVATE; }
1933
-    break;
1934
-
1935
-  case 17:
1936
-/* Line 1792 of yacc.c  */
1937
-#line 349 "yara_grammar.y"
1938
-    { (yyval.integer) = RULE_GFLAGS_GLOBAL; }
1939
-    break;
1940
-
1941
-  case 18:
1942
-/* Line 1792 of yacc.c  */
1943
-#line 355 "yara_grammar.y"
1944
-    {
1945
-        (yyval.c_string) = NULL;
1946
-      }
1947
-    break;
1948
-
1949
-  case 19:
1950
-/* Line 1792 of yacc.c  */
1951
-#line 359 "yara_grammar.y"
1952
-    {
1953
-#if REAL_YARA //tags not supported
1954
-        // Tags list is represented in the arena as a sequence
1955
-        // of null-terminated strings, the sequence ends with an
1956
-        // additional null character. Here we write the ending null
1957
-        //character. Example: tag1\0tag2\0tag3\0\0
1958
-
1959
-        compiler->last_result = yr_arena_write_string(
1960
-            yyget_extra(yyscanner)->sz_arena, "", NULL);
1961
-
1962
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
1963
-#endif
1964
-
1965
-        (yyval.c_string) = (yyvsp[(2) - (2)].c_string);
1966
-      }
1967
-    break;
1968
-
1969
-  case 20:
1970
-/* Line 1792 of yacc.c  */
1971
-#line 379 "yara_grammar.y"
1972
-    {
1973
-#if REAL_YARA //tags not supported
1974
-        char* identifier;
1975
-
1976
-        compiler->last_result = yr_arena_write_string(
1977
-            yyget_extra(yyscanner)->sz_arena, (yyvsp[(1) - (1)].c_string), &identifier);
1978
-
1979
-#endif
1980
-        yr_free((yyvsp[(1) - (1)].c_string));
1981
-
1982
-#if REAL_YARA //tags not supported
1983
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
1984
-
1985
-        (yyval.c_string) = identifier;
1986
-#endif
1987
-      }
1988
-    break;
1989
-
1990
-  case 21:
1991
-/* Line 1792 of yacc.c  */
1992
-#line 396 "yara_grammar.y"
1993
-    {
1994
-#if REAL_YARA //tags not supported
1995
-        char* tag_name = (yyvsp[(1) - (2)].c_string);
1996
-        size_t tag_length = tag_name != NULL ? strlen(tag_name) : 0;
1997
-
1998
-        while (tag_length > 0)
1999
-        {
2000
-          if (strcmp(tag_name, (yyvsp[(2) - (2)].c_string)) == 0)
2001
-          {
2002
-            yr_compiler_set_error_extra_info(compiler, tag_name);
2003
-            compiler->last_result = ERROR_DUPLICATE_TAG_IDENTIFIER;
2004
-            break;
2005
-          }
2006
-
2007
-          tag_name = yr_arena_next_address(
2008
-              yyget_extra(yyscanner)->sz_arena,
2009
-              tag_name,
2010
-              tag_length + 1);
2011
-
2012
-          tag_length = tag_name != NULL ? strlen(tag_name) : 0;
2013
-        }
2014
-
2015
-        if (compiler->last_result == ERROR_SUCCESS)
2016
-          compiler->last_result = yr_arena_write_string(
2017
-              yyget_extra(yyscanner)->sz_arena, (yyvsp[(2) - (2)].c_string), NULL);
2018
-
2019
-#endif
2020
-        yr_free((yyvsp[(2) - (2)].c_string));
2021
-
2022
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2023
-
2024
-        (yyval.c_string) = (yyvsp[(1) - (2)].c_string);
2025
-      }
2026
-    break;
2027
-
2028
-  case 22:
2029
-/* Line 1792 of yacc.c  */
2030
-#line 434 "yara_grammar.y"
2031
-    {  (yyval.meta) = (yyvsp[(1) - (1)].meta); }
2032
-    break;
2033
-
2034
-  case 23:
2035
-/* Line 1792 of yacc.c  */
2036
-#line 435 "yara_grammar.y"
2037
-    {  (yyval.meta) = (yyvsp[(1) - (2)].meta); }
2038
-    break;
2039
-
2040
-  case 24:
2041
-/* Line 1792 of yacc.c  */
2042
-#line 441 "yara_grammar.y"
2043
-    {
2044
-        SIZED_STRING* sized_string = (yyvsp[(3) - (3)].sized_string);
2045
-
2046
-        (yyval.meta) = yr_parser_reduce_meta_declaration(
2047
-            yyscanner,
2048
-            META_TYPE_STRING,
2049
-            (yyvsp[(1) - (3)].c_string),
2050
-            sized_string->c_string,
2051
-            0);
2052
-
2053
-        yr_free((yyvsp[(1) - (3)].c_string));
2054
-        yr_free((yyvsp[(3) - (3)].sized_string));
2055
-
2056
-        ERROR_IF((yyval.meta) == NULL);
2057
-      }
2058
-    break;
2059
-
2060
-  case 25:
2061
-/* Line 1792 of yacc.c  */
2062
-#line 457 "yara_grammar.y"
2063
-    {
2064
-        (yyval.meta) = yr_parser_reduce_meta_declaration(
2065
-            yyscanner,
2066
-            META_TYPE_INTEGER,
2067
-            (yyvsp[(1) - (3)].c_string),
2068
-            NULL,
2069
-            (yyvsp[(3) - (3)].integer));
2070
-
2071
-        yr_free((yyvsp[(1) - (3)].c_string));
2072
-
2073
-        ERROR_IF((yyval.meta) == NULL);
2074
-      }
2075
-    break;
2076
-
2077
-  case 26:
2078
-/* Line 1792 of yacc.c  */
2079
-#line 470 "yara_grammar.y"
2080
-    {
2081
-        (yyval.meta) = yr_parser_reduce_meta_declaration(
2082
-            yyscanner,
2083
-            META_TYPE_BOOLEAN,
2084
-            (yyvsp[(1) - (3)].c_string),
2085
-            NULL,
2086
-            TRUE);
2087
-
2088
-        yr_free((yyvsp[(1) - (3)].c_string));
2089
-
2090
-        ERROR_IF((yyval.meta) == NULL);
2091
-      }
2092
-    break;
2093
-
2094
-  case 27:
2095
-/* Line 1792 of yacc.c  */
2096
-#line 483 "yara_grammar.y"
2097
-    {
2098
-        (yyval.meta) = yr_parser_reduce_meta_declaration(
2099
-            yyscanner,
2100
-            META_TYPE_BOOLEAN,
2101
-            (yyvsp[(1) - (3)].c_string),
2102
-            NULL,
2103
-            FALSE);
2104
-
2105
-        yr_free((yyvsp[(1) - (3)].c_string));
2106
-
2107
-        ERROR_IF((yyval.meta) == NULL);
2108
-      }
2109
-    break;
2110
-
2111
-  case 28:
2112
-/* Line 1792 of yacc.c  */
2113
-#line 499 "yara_grammar.y"
2114
-    { (yyval.string) = (yyvsp[(1) - (1)].string); }
2115
-    break;
2116
-
2117
-  case 29:
2118
-/* Line 1792 of yacc.c  */
2119
-#line 500 "yara_grammar.y"
2120
-    { (yyval.string) = (yyvsp[(1) - (2)].string); }
2121
-    break;
2122
-
2123
-  case 30:
2124
-/* Line 1792 of yacc.c  */
2125
-#line 506 "yara_grammar.y"
2126
-    {
2127
-        (yyval.string) = yr_parser_reduce_string_declaration(
2128
-            yyscanner,
2129
-            (yyvsp[(4) - (4)].integer),
2130
-            (yyvsp[(1) - (4)].c_string),
2131
-            (yyvsp[(3) - (4)].sized_string));
2132
-
2133
-        yr_free((yyvsp[(1) - (4)].c_string));
2134
-        yr_free((yyvsp[(3) - (4)].sized_string));
2135
-
2136
-        ERROR_IF((yyval.string) == NULL);
2137
-      }
2138
-    break;
2139
-
2140
-  case 31:
2141
-/* Line 1792 of yacc.c  */
2142
-#line 519 "yara_grammar.y"
2143
-    {
2144
-        compiler->error_line = yyget_lineno(yyscanner);
2145
-      }
2146
-    break;
2147
-
2148
-  case 32:
2149
-/* Line 1792 of yacc.c  */
2150
-#line 523 "yara_grammar.y"
2151
-    {
2152
-        (yyval.string) = yr_parser_reduce_string_declaration(
2153
-            yyscanner,
2154
-            (yyvsp[(5) - (5)].integer) | STRING_GFLAGS_REGEXP,
2155
-            (yyvsp[(1) - (5)].c_string),
2156
-            (yyvsp[(4) - (5)].sized_string));
2157
-
2158
-        yr_free((yyvsp[(1) - (5)].c_string));
2159
-        yr_free((yyvsp[(4) - (5)].sized_string));
2160
-
2161
-        ERROR_IF((yyval.string) == NULL);
2162
-      }
2163
-    break;
2164
-
2165
-  case 33:
2166
-/* Line 1792 of yacc.c  */
2167
-#line 536 "yara_grammar.y"
2168
-    {
2169
-        (yyval.string) = yr_parser_reduce_string_declaration(
2170
-            yyscanner,
2171
-            STRING_GFLAGS_HEXADECIMAL,
2172
-            (yyvsp[(1) - (3)].c_string),
2173
-            (yyvsp[(3) - (3)].sized_string));
2174
-
2175
-        yr_free((yyvsp[(1) - (3)].c_string));
2176
-        yr_free((yyvsp[(3) - (3)].sized_string));
2177
-
2178
-        ERROR_IF((yyval.string) == NULL);
2179
-      }
2180
-    break;
2181
-
2182
-  case 34:
2183
-/* Line 1792 of yacc.c  */
2184
-#line 552 "yara_grammar.y"
2185
-    { (yyval.integer) = 0; }
2186
-    break;
2187
-
2188
-  case 35:
2189
-/* Line 1792 of yacc.c  */
2190
-#line 553 "yara_grammar.y"
2191
-    { (yyval.integer) = (yyvsp[(1) - (2)].integer) | (yyvsp[(2) - (2)].integer); }
2192
-    break;
2193
-
2194
-  case 36:
2195
-/* Line 1792 of yacc.c  */
2196
-#line 558 "yara_grammar.y"
2197
-    { (yyval.integer) = STRING_GFLAGS_WIDE; }
2198
-    break;
2199
-
2200
-  case 37:
2201
-/* Line 1792 of yacc.c  */
2202
-#line 559 "yara_grammar.y"
2203
-    { (yyval.integer) = STRING_GFLAGS_ASCII; }
2204
-    break;
2205
-
2206
-  case 38:
2207
-/* Line 1792 of yacc.c  */
2208
-#line 560 "yara_grammar.y"
2209
-    { (yyval.integer) = STRING_GFLAGS_NO_CASE; }
2210
-    break;
2211
-
2212
-  case 39:
2213
-/* Line 1792 of yacc.c  */
2214
-#line 561 "yara_grammar.y"
2215
-    { (yyval.integer) = STRING_GFLAGS_FULL_WORD; }
2216
-    break;
2217
-
2218
-  case 40:
2219
-/* Line 1792 of yacc.c  */
2220
-#line 567 "yara_grammar.y"
2221
-    {
2222
-        YR_OBJECT* object = NULL;
2223
-        YR_RULE* rule;
2224
-
2225
-        char* id;
2226
-        char* ns = NULL;
2227
-
2228
-        int var_index;
2229
-
2230
-        var_index = yr_parser_lookup_loop_variable(yyscanner, (yyvsp[(1) - (1)].c_string));
2231
-
2232
-        if (var_index >= 0)
2233
-        {
2234
-         compiler->last_result = yr_parser_emit_with_arg(
2235
-            yyscanner,
2236
-            OP_PUSH_M,
2237
-            LOOP_LOCAL_VARS * var_index,
2238
-            NULL);
2239
-
2240
-          (yyval.object) = (YR_OBJECT*) -1;
2241
-        }
2242
-        else
2243
-        {
2244
-          // Search for identifier within the global namespace, where the
2245
-          // externals variables reside.
2246
-          object = (YR_OBJECT*) yr_hash_table_lookup(
2247
-                compiler->objects_table,
2248
-                (yyvsp[(1) - (1)].c_string),
2249
-                NULL);
2250
-          if (object == NULL)
2251
-          {
2252
-            // If not found, search within the current namespace.
2253
-
2254
-            ns = compiler->current_namespace->name;
2255
-            object = (YR_OBJECT*) yr_hash_table_lookup(
2256
-                compiler->objects_table,
2257
-                (yyvsp[(1) - (1)].c_string),
2258
-                ns);
2259
-          }
2260
-
2261
-          if (object != NULL)
2262
-          {
2263
-            compiler->last_result = yr_arena_write_string(
2264
-                compiler->sz_arena,
2265
-                (yyvsp[(1) - (1)].c_string),
2266
-                &id);
2267
-
2268
-            if (compiler->last_result == ERROR_SUCCESS)
2269
-              compiler->last_result = yr_parser_emit_with_arg_reloc(
2270
-                  yyscanner,
2271
-                  OP_OBJ_LOAD,
2272
-                  PTR_TO_UINT64(id),
2273
-                  NULL);
2274
-
2275
-            (yyval.object) = object;
2276
-          }
2277
-          else
2278
-          {
2279
-           rule = (YR_RULE*) yr_hash_table_lookup(
2280
-                compiler->rules_table,
2281
-                (yyvsp[(1) - (1)].c_string),
2282
-                compiler->current_namespace->name);
2283
-            if (rule != NULL)
2284
-            {
2285
-              compiler->last_result = yr_parser_emit_with_arg_reloc(
2286
-                  yyscanner,
2287
-                  OP_PUSH_RULE,
2288
-                  PTR_TO_UINT64(rule),
2289
-                  NULL);
2290
-            }
2291
-            else
2292
-            {
2293
-              yr_compiler_set_error_extra_info(compiler, (yyvsp[(1) - (1)].c_string));
2294
-              compiler->last_result = ERROR_UNDEFINED_IDENTIFIER;
2295
-            }
2296
-
2297
-            (yyval.object) = (YR_OBJECT*) -2;
2298
-          }
2299
-        }
2300
-
2301
-        yr_free((yyvsp[(1) - (1)].c_string));
2302
-
2303
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2304
-      }
2305
-    break;
2306
-
2307
-  case 41:
2308
-/* Line 1792 of yacc.c  */
2309
-#line 652 "yara_grammar.y"
2310
-    {
2311
-        YR_OBJECT* object = (yyvsp[(1) - (3)].object);
2312
-        YR_OBJECT* field = NULL;
2313
-
2314
-        char* ident;
2315
-
2316
-        if (object != NULL &&
2317
-            object != (YR_OBJECT*) -1 &&    // not a loop variable identifier
2318
-            object != (YR_OBJECT*) -2 &&    // not a rule identifier
2319
-            object->type == OBJECT_TYPE_STRUCTURE)
2320
-        {
2321
-#if REAL_YARA
2322
-         field = yr_object_lookup_field(object, (yyvsp[(3) - (3)].c_string));
2323
-#endif
2324
-          if (field != NULL)
2325
-          {
2326
-            compiler->last_result = yr_arena_write_string(
2327
-              compiler->sz_arena,
2328
-              (yyvsp[(3) - (3)].c_string),
2329
-              &ident);
2330
-
2331
-            if (compiler->last_result == ERROR_SUCCESS)
2332
-              compiler->last_result = yr_parser_emit_with_arg_reloc(
2333
-                  yyscanner,
2334
-                  OP_OBJ_FIELD,
2335
-                  PTR_TO_UINT64(ident),
2336
-                  NULL);
2337
-          }
2338
-          else
2339
-          {
2340
-            yr_compiler_set_error_extra_info(compiler, (yyvsp[(3) - (3)].c_string));
2341
-            compiler->last_result = ERROR_INVALID_FIELD_NAME;
2342
-          }
2343
-        }
2344
-        else
2345
-        {
2346
-          yr_compiler_set_error_extra_info(
2347
-              compiler,
2348
-              object->identifier);
2349
-
2350
-          compiler->last_result = ERROR_NOT_A_STRUCTURE;
2351
-        }
2352
-
2353
-        (yyval.object) = field;
2354
-
2355
-        yr_free((yyvsp[(3) - (3)].c_string));
2356
-
2357
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2358
-      }
2359
-    break;
2360
-
2361
-  case 42:
2362
-/* Line 1792 of yacc.c  */
2363
-#line 702 "yara_grammar.y"
2364
-    {
2365
-        if ((yyvsp[(1) - (4)].object) != NULL && (yyvsp[(1) - (4)].object)->type == OBJECT_TYPE_ARRAY)
2366
-        {
2367
-          compiler->last_result = yr_parser_emit(
2368
-              yyscanner,
2369
-              OP_INDEX_ARRAY,
2370
-              NULL);
2371
-
2372
-          (yyval.object) = ((YR_OBJECT_ARRAY*) (yyvsp[(1) - (4)].object))->items->objects[0];
2373
-        }
2374
-        else
2375
-        {
2376
-          yr_compiler_set_error_extra_info(
2377
-              compiler,
2378
-              (yyvsp[(1) - (4)].object)->identifier);
2379
-
2380
-          compiler->last_result = ERROR_NOT_AN_ARRAY;
2381
-        }
2382
-
2383
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2384
-      }
2385
-    break;
2386
-
2387
-  case 43:
2388
-/* Line 1792 of yacc.c  */
2389
-#line 725 "yara_grammar.y"
2390
-    {
2391
-        int args_count;
2392
-
2393
-        if ((yyvsp[(1) - (4)].object) != NULL && (yyvsp[(1) - (4)].object)->type == OBJECT_TYPE_FUNCTION)
2394
-        {
2395
-          compiler->last_result = yr_parser_check_types(
2396
-              compiler, (YR_OBJECT_FUNCTION*) (yyvsp[(1) - (4)].object), (yyvsp[(3) - (4)].c_string));
2397
-
2398
-          if (compiler->last_result == ERROR_SUCCESS)
2399
-          {
2400
-            args_count = strlen((yyvsp[(3) - (4)].c_string));
2401
-
2402
-            compiler->last_result = yr_parser_emit_with_arg(
2403
-                yyscanner,
2404
-                OP_CALL,
2405
-                args_count,
2406
-                NULL);
2407
-          }
2408
-
2409
-          (yyval.object) = ((YR_OBJECT_FUNCTION*) (yyvsp[(1) - (4)].object))->return_obj;
2410
-        }
2411
-        else
2412
-        {
2413
-          yr_compiler_set_error_extra_info(
2414
-              compiler,
2415
-              (yyvsp[(1) - (4)].object)->identifier);
2416
-
2417
-          compiler->last_result = ERROR_NOT_A_FUNCTION;
2418
-        }
2419
-
2420
-        yr_free((yyvsp[(3) - (4)].c_string));
2421
-
2422
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2423
-      }
2424
-    break;
2425
-
2426
-  case 44:
2427
-/* Line 1792 of yacc.c  */
2428
-#line 764 "yara_grammar.y"
2429
-    {
2430
-        (yyval.c_string) = yr_strdup("");
2431
-      }
2432
-    break;
2433
-
2434
-  case 45:
2435
-/* Line 1792 of yacc.c  */
2436
-#line 768 "yara_grammar.y"
2437
-    {
2438
-        (yyval.c_string) = yr_malloc(MAX_FUNCTION_ARGS + 1);
2439
-
2440
-        switch((yyvsp[(1) - (1)].expression_type))
2441
-        {
2442
-          case EXPRESSION_TYPE_INTEGER:
2443
-            strlcpy((yyval.c_string), "i", MAX_FUNCTION_ARGS);
2444
-            break;
2445
-          case EXPRESSION_TYPE_BOOLEAN:
2446
-            strlcpy((yyval.c_string), "b", MAX_FUNCTION_ARGS);
2447
-            break;
2448
-          case EXPRESSION_TYPE_STRING:
2449
-            strlcpy((yyval.c_string), "s", MAX_FUNCTION_ARGS);
2450
-            break;
2451
-          case EXPRESSION_TYPE_REGEXP:
2452
-            strlcpy((yyval.c_string), "r", MAX_FUNCTION_ARGS);
2453
-            break;
2454
-        }
2455
-
2456
-        ERROR_IF((yyval.c_string) == NULL);
2457
-      }
2458
-    break;
2459
-
2460
-  case 46:
2461
-/* Line 1792 of yacc.c  */
2462
-#line 790 "yara_grammar.y"
2463
-    {
2464
-        if (strlen((yyvsp[(1) - (3)].c_string)) == MAX_FUNCTION_ARGS)
2465
-        {
2466
-          compiler->last_result = ERROR_TOO_MANY_ARGUMENTS;
2467
-        }
2468
-        else
2469
-        {
2470
-          switch((yyvsp[(3) - (3)].expression_type))
2471
-          {
2472
-            case EXPRESSION_TYPE_INTEGER:
2473
-              strlcat((yyvsp[(1) - (3)].c_string), "i", MAX_FUNCTION_ARGS);
2474
-              break;
2475
-            case EXPRESSION_TYPE_BOOLEAN:
2476
-              strlcat((yyvsp[(1) - (3)].c_string), "b", MAX_FUNCTION_ARGS);
2477
-              break;
2478
-            case EXPRESSION_TYPE_STRING:
2479
-              strlcat((yyvsp[(1) - (3)].c_string), "s", MAX_FUNCTION_ARGS);
2480
-              break;
2481
-            case EXPRESSION_TYPE_REGEXP:
2482
-              strlcat((yyvsp[(1) - (3)].c_string), "r", MAX_FUNCTION_ARGS);
2483
-              break;
2484
-          }
2485
-        }
2486
-
2487
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2488
-
2489
-        (yyval.c_string) = (yyvsp[(1) - (3)].c_string);
2490
-      }
2491
-    break;
2492
-
2493
-  case 47:
2494
-/* Line 1792 of yacc.c  */
2495
-#line 823 "yara_grammar.y"
2496
-    {
2497
-#ifdef REAL_YARA
2498
-        SIZED_STRING* sized_string = (yyvsp[(1) - (1)].sized_string);
2499
-        RE* re;
2500
-        RE_ERROR error;
2501
-
2502
-        int re_flags = 0;
2503
-
2504
-        if (sized_string->flags & SIZED_STRING_FLAGS_NO_CASE)
2505
-          re_flags |= RE_FLAGS_NO_CASE;
2506
-
2507
-        if (sized_string->flags & SIZED_STRING_FLAGS_DOT_ALL)
2508
-          re_flags |= RE_FLAGS_DOT_ALL;
2509
-
2510
-        compiler->last_result = yr_re_compile(
2511
-            sized_string->c_string,
2512
-            re_flags,
2513
-            compiler->re_code_arena,
2514
-            &re,
2515
-            &error);
2516
-
2517
-        yr_free((yyvsp[(1) - (1)].sized_string));
2518
-
2519
-        if (compiler->last_result == ERROR_INVALID_REGULAR_EXPRESSION)
2520
-          yr_compiler_set_error_extra_info(compiler, error.message);
2521
-
2522
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2523
-
2524
-        if (compiler->last_result == ERROR_SUCCESS)
2525
-          compiler->last_result = yr_parser_emit_with_arg_reloc(
2526
-              yyscanner,
2527
-              OP_PUSH,
2528
-              PTR_TO_UINT64(re->root_node->forward_code),
2529
-              NULL);
2530
-
2531
-        yr_re_destroy(re);
2532
-
2533
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2534
-#endif
2535
-
2536
-        (yyval.expression_type) = EXPRESSION_TYPE_REGEXP;
2537
-      }
2538
-    break;
2539
-
2540
-  case 48:
2541
-/* Line 1792 of yacc.c  */
2542
-#line 870 "yara_grammar.y"
2543
-    {
2544
-        if ((yyvsp[(1) - (1)].expression_type) == EXPRESSION_TYPE_STRING)
2545
-        {
2546
-          compiler->last_result = yr_parser_emit(
2547
-              yyscanner,
2548
-              OP_SZ_TO_BOOL,
2549
-              NULL);
2550
-
2551
-          ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2552
-        }
2553
-
2554
-
2555
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2556
-      }
2557
-    break;
2558
-
2559
-  case 49:
2560
-/* Line 1792 of yacc.c  */
2561
-#line 888 "yara_grammar.y"
2562
-    {
2563
-        compiler->last_result = yr_parser_emit_with_arg(
2564
-            yyscanner, OP_PUSH, 1, NULL);
2565
-
2566
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2567
-
2568
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2569
-      }
2570
-    break;
2571
-
2572
-  case 50:
2573
-/* Line 1792 of yacc.c  */
2574
-#line 897 "yara_grammar.y"
2575
-    {
2576
-        compiler->last_result = yr_parser_emit_with_arg(
2577
-            yyscanner, OP_PUSH, 0, NULL);
2578
-
2579
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2580
-
2581
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2582
-      }
2583
-    break;
2584
-
2585
-  case 51:
2586
-/* Line 1792 of yacc.c  */
2587
-#line 906 "yara_grammar.y"
2588
-    {
2589
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_STRING, "matches");
2590
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_REGEXP, "matches");
2591
-
2592
-        if (compiler->last_result == ERROR_SUCCESS)
2593
-          compiler->last_result = yr_parser_emit(
2594
-              yyscanner,
2595
-              OP_MATCHES,
2596
-              NULL);
2597
-
2598
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2599
-
2600
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2601
-      }
2602
-    break;
2603
-
2604
-  case 52:
2605
-/* Line 1792 of yacc.c  */
2606
-#line 921 "yara_grammar.y"
2607
-    {
2608
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_STRING, "contains");
2609
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_STRING, "contains");
2610
-
2611
-        compiler->last_result = yr_parser_emit(
2612
-            yyscanner,
2613
-            OP_CONTAINS,
2614
-            NULL);
2615
-
2616
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2617
-
2618
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2619
-      }
2620
-    break;
2621
-
2622
-  case 53:
2623
-/* Line 1792 of yacc.c  */
2624
-#line 935 "yara_grammar.y"
2625
-    {
2626
-        int result = yr_parser_reduce_string_identifier(
2627
-            yyscanner,
2628
-            (yyvsp[(1) - (1)].c_string),
2629
-            OP_STR_FOUND);
2630
-
2631
-        yr_free((yyvsp[(1) - (1)].c_string));
2632
-
2633
-        ERROR_IF(result != ERROR_SUCCESS);
2634
-
2635
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2636
-      }
2637
-    break;
2638
-
2639
-  case 54:
2640
-/* Line 1792 of yacc.c  */
2641
-#line 948 "yara_grammar.y"
2642
-    {
2643
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "at");
2644
-
2645
-        compiler->last_result = yr_parser_reduce_string_identifier(
2646
-            yyscanner,
2647
-            (yyvsp[(1) - (3)].c_string),
2648
-            OP_STR_FOUND_AT);
2649
-
2650
-        yr_free((yyvsp[(1) - (3)].c_string));
2651
-
2652
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2653
-
2654
-        compiler->current_rule_clflags |= RULE_OFFSETS;
2655
-
2656
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2657
-      }
2658
-    break;
2659
-
2660
-  case 55:
2661
-/* Line 1792 of yacc.c  */
2662
-#line 965 "yara_grammar.y"
2663
-    {
2664
-        compiler->last_result = yr_parser_reduce_string_identifier(
2665
-            yyscanner,
2666
-            (yyvsp[(1) - (3)].c_string),
2667
-            OP_STR_FOUND_IN);
2668
-
2669
-        yr_free((yyvsp[(1) - (3)].c_string));
2670
-
2671
-        ERROR_IF(compiler->last_result!= ERROR_SUCCESS);
2672
-
2673
-        compiler->current_rule_clflags |= RULE_OFFSETS;
2674
-
2675
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2676
-      }
2677
-    break;
2678
-
2679
-  case 56:
2680
-/* Line 1792 of yacc.c  */
2681
-#line 980 "yara_grammar.y"
2682
-    {
2683
-        int var_index;
2684
-
2685
-        if (compiler->loop_depth == MAX_LOOP_NESTING)
2686
-          compiler->last_result = \
2687
-              ERROR_LOOP_NESTING_LIMIT_EXCEEDED;
2688
-
2689
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2690
-
2691
-        var_index = yr_parser_lookup_loop_variable(
2692
-            yyscanner,
2693
-            (yyvsp[(3) - (4)].c_string));
2694
-
2695
-        if (var_index >= 0)
2696
-        {
2697
-          yr_compiler_set_error_extra_info(
2698
-              compiler,
2699
-              (yyvsp[(3) - (4)].c_string));
2700
-
2701
-          compiler->last_result = \
2702
-              ERROR_DUPLICATE_LOOP_IDENTIFIER;
2703
-        }
2704
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2705
-
2706
-        // Push end-of-list marker
2707
-        compiler->last_result = yr_parser_emit_with_arg(
2708
-            yyscanner,
2709
-            OP_PUSH,
2710
-            UNDEFINED,
2711
-            NULL);
2712
-
2713
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2714
-      }
2715
-    break;
2716
-
2717
-  case 57:
2718
-/* Line 1792 of yacc.c  */
2719
-#line 1014 "yara_grammar.y"
2720
-    {
2721
-        int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
2722
-
2723
-        int8_t* addr;
2724
-
2725
-        // Clear counter for number of expressions evaluating
2726
-        // to TRUE.
2727
-        yr_parser_emit_with_arg(
2728
-            yyscanner, OP_CLEAR_M, mem_offset + 1, NULL);
2729
-
2730
-        // Clear iterations counter
2731
-        yr_parser_emit_with_arg(
2732
-            yyscanner, OP_CLEAR_M, mem_offset + 2, NULL);
2733
-
2734
-        if ((yyvsp[(6) - (7)].integer) == INTEGER_SET_ENUMERATION)
2735
-        {
2736
-          // Pop the first integer
2737
-          yr_parser_emit_with_arg(
2738
-              yyscanner, OP_POP_M, mem_offset, &addr);
2739
-        }
2740
-        else // INTEGER_SET_RANGE
2741
-        {
2742
-          // Pop higher bound of set range
2743
-          yr_parser_emit_with_arg(
2744
-              yyscanner, OP_POP_M, mem_offset + 3, &addr);
2745
-
2746
-          // Pop lower bound of set range
2747
-          yr_parser_emit_with_arg(
2748
-              yyscanner, OP_POP_M, mem_offset, NULL);
2749
-        }
2750
-        compiler->loop_address[compiler->loop_depth] = addr;
2751
-        compiler->loop_identifier[compiler->loop_depth] = (yyvsp[(3) - (7)].c_string);
2752
-        compiler->loop_depth++;
2753
-      }
2754
-    break;
2755
-
2756
-  case 58:
2757
-/* Line 1792 of yacc.c  */
2758
-#line 1049 "yara_grammar.y"
2759
-    {
2760
-        int mem_offset;
2761
-
2762
-        compiler->loop_depth--;
2763
-        mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
2764
-
2765
-        // The value at the top of the stack is 1 if latest
2766
-        // expression was true or 0 otherwise. Add this value
2767
-        // to the counter for number of expressions evaluating
2768
-        // to true.
2769
-        yr_parser_emit_with_arg(
2770
-            yyscanner, OP_ADD_M, mem_offset + 1, NULL);
2771
-
2772
-        // Increment iterations counter
2773
-        yr_parser_emit_with_arg(
2774
-            yyscanner, OP_INCR_M, mem_offset + 2, NULL);
2775
-
2776
-        if ((yyvsp[(6) - (11)].integer) == INTEGER_SET_ENUMERATION)
2777
-        {
2778
-          yr_parser_emit_with_arg_reloc(
2779
-              yyscanner,
2780
-              OP_JNUNDEF,
2781
-              PTR_TO_UINT64(
2782
-                  compiler->loop_address[compiler->loop_depth]),
2783
-              NULL);
2784
-        }
2785
-        else // INTEGER_SET_RANGE
2786
-        {
2787
-          // Increment lower bound of integer set
2788
-          yr_parser_emit_with_arg(
2789
-              yyscanner, OP_INCR_M, mem_offset, NULL);
2790
-
2791
-          // Push lower bound of integer set
2792
-          yr_parser_emit_with_arg(
2793
-              yyscanner, OP_PUSH_M, mem_offset, NULL);
2794
-
2795
-          // Push higher bound of integer set
2796
-          yr_parser_emit_with_arg(
2797
-              yyscanner, OP_PUSH_M, mem_offset + 3, NULL);
2798
-
2799
-          // Compare higher bound with lower bound, do loop again
2800
-          // if lower bound is still lower or equal than higher bound
2801
-          yr_parser_emit_with_arg_reloc(
2802
-              yyscanner,
2803
-              OP_JLE,
2804
-              PTR_TO_UINT64(
2805
-                compiler->loop_address[compiler->loop_depth]),
2806
-              NULL);
2807
-
2808
-          yr_parser_emit(yyscanner, OP_POP, NULL);
2809
-          yr_parser_emit(yyscanner, OP_POP, NULL);
2810
-        }
2811
-
2812
-        // Pop end-of-list marker.
2813
-        yr_parser_emit(yyscanner, OP_POP, NULL);
2814
-
2815
-        // At this point the loop quantifier (any, all, 1, 2,..)
2816
-        // is at the top of the stack. Check if the quantifier
2817
-        // is undefined (meaning "all") and replace it with the
2818
-        // iterations counter in that case.
2819
-        yr_parser_emit_with_arg(
2820
-            yyscanner, OP_SWAPUNDEF, mem_offset + 2, NULL);
2821
-
2822
-        // Compare the loop quantifier with the number of
2823
-        // expressions evaluating to TRUE.
2824
-        yr_parser_emit_with_arg(
2825
-            yyscanner, OP_PUSH_M, mem_offset + 1, NULL);
2826
-
2827
-        yr_parser_emit(yyscanner, OP_LE, NULL);
2828
-
2829
-        compiler->loop_identifier[compiler->loop_depth] = NULL;
2830
-        yr_free((yyvsp[(3) - (11)].c_string));
2831
-
2832
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2833
-      }
2834
-    break;
2835
-
2836
-  case 59:
2837
-/* Line 1792 of yacc.c  */
2838
-#line 1125 "yara_grammar.y"
2839
-    {
2840
-        int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
2841
-        int8_t* addr;
2842
-
2843
-        if (compiler->loop_depth == MAX_LOOP_NESTING)
2844
-          compiler->last_result = \
2845
-            ERROR_LOOP_NESTING_LIMIT_EXCEEDED;
2846
-
2847
-        if (compiler->loop_for_of_mem_offset != -1)
2848
-          compiler->last_result = \
2849
-            ERROR_NESTED_FOR_OF_LOOP;
2850
-
2851
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
2852
-
2853
-        yr_parser_emit_with_arg(
2854
-            yyscanner, OP_CLEAR_M, mem_offset + 1, NULL);
2855
-
2856
-        yr_parser_emit_with_arg(
2857
-            yyscanner, OP_CLEAR_M, mem_offset + 2, NULL);
2858
-
2859
-        // Pop the first string.
2860
-        yr_parser_emit_with_arg(
2861
-            yyscanner, OP_POP_M, mem_offset, &addr);
2862
-
2863
-        compiler->loop_for_of_mem_offset = mem_offset;
2864
-        compiler->loop_address[compiler->loop_depth] = addr;
2865
-        compiler->loop_identifier[compiler->loop_depth] = NULL;
2866
-        compiler->loop_depth++;
2867
-      }
2868
-    break;
2869
-
2870
-  case 60:
2871
-/* Line 1792 of yacc.c  */
2872
-#line 1155 "yara_grammar.y"
2873
-    {
2874
-        int mem_offset;
2875
-
2876
-        compiler->loop_depth--;
2877
-        compiler->loop_for_of_mem_offset = -1;
2878
-
2879
-        mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
2880
-
2881
-        // Increment counter by the value returned by the
2882
-        // boolean expression (0 or 1).
2883
-        yr_parser_emit_with_arg(
2884
-            yyscanner, OP_ADD_M, mem_offset + 1, NULL);
2885
-
2886
-        // Increment iterations counter.
2887
-        yr_parser_emit_with_arg(
2888
-            yyscanner, OP_INCR_M, mem_offset + 2, NULL);
2889
-
2890
-        // If next string is not undefined, go back to the
2891
-        // beginning of the loop.
2892
-        yr_parser_emit_with_arg_reloc(
2893
-            yyscanner,
2894
-            OP_JNUNDEF,
2895
-            PTR_TO_UINT64(
2896
-                compiler->loop_address[compiler->loop_depth]),
2897
-            NULL);
2898
-
2899
-        // Pop end-of-list marker.
2900
-        yr_parser_emit(yyscanner, OP_POP, NULL);
2901
-
2902
-        // At this point the loop quantifier (any, all, 1, 2,..)
2903
-        // is at top of the stack. Check if the quantifier is
2904
-        // undefined (meaning "all") and replace it with the
2905
-        // iterations counter in that case.
2906
-        yr_parser_emit_with_arg(
2907
-            yyscanner, OP_SWAPUNDEF, mem_offset + 2, NULL);
2908
-
2909
-        // Compare the loop quantifier with the number of
2910
-        // expressions evaluating to TRUE.
2911
-        yr_parser_emit_with_arg(
2912
-            yyscanner, OP_PUSH_M, mem_offset + 1, NULL);
2913
-
2914
-        yr_parser_emit(yyscanner, OP_LE, NULL);
2915
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2916
-
2917
-      }
2918
-    break;
2919
-
2920
-  case 61:
2921
-/* Line 1792 of yacc.c  */
2922
-#line 1201 "yara_grammar.y"
2923
-    {
2924
-        yr_parser_emit(yyscanner, OP_OF, NULL);
2925
-
2926
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2927
-      }
2928
-    break;
2929
-
2930
-  case 62:
2931
-/* Line 1792 of yacc.c  */
2932
-#line 1207 "yara_grammar.y"
2933
-    {
2934
-        yr_parser_emit(yyscanner, OP_NOT, NULL);
2935
-
2936
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2937
-      }
2938
-    break;
2939
-
2940
-  case 63:
2941
-/* Line 1792 of yacc.c  */
2942
-#line 1213 "yara_grammar.y"
2943
-    {
2944
-        yr_parser_emit(yyscanner, OP_AND, NULL);
2945
-
2946
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2947
-      }
2948
-    break;
2949
-
2950
-  case 64:
2951
-/* Line 1792 of yacc.c  */
2952
-#line 1219 "yara_grammar.y"
2953
-    {
2954
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_BOOLEAN, "or");
2955
-
2956
-        yr_parser_emit(yyscanner, OP_OR, NULL);
2957
-
2958
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2959
-      }
2960
-    break;
2961
-
2962
-  case 65:
2963
-/* Line 1792 of yacc.c  */
2964
-#line 1227 "yara_grammar.y"
2965
-    {
2966
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<");
2967
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<");
2968
-
2969
-        yr_parser_emit(yyscanner, OP_LT, NULL);
2970
-
2971
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2972
-      }
2973
-    break;
2974
-
2975
-  case 66:
2976
-/* Line 1792 of yacc.c  */
2977
-#line 1236 "yara_grammar.y"
2978
-    {
2979
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">");
2980
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">");
2981
-
2982
-        yr_parser_emit(yyscanner, OP_GT, NULL);
2983
-
2984
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2985
-      }
2986
-    break;
2987
-
2988
-  case 67:
2989
-/* Line 1792 of yacc.c  */
2990
-#line 1245 "yara_grammar.y"
2991
-    {
2992
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<=");
2993
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<=");
2994
-
2995
-        yr_parser_emit(yyscanner, OP_LE, NULL);
2996
-
2997
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
2998
-      }
2999
-    break;
3000
-
3001
-  case 68:
3002
-/* Line 1792 of yacc.c  */
3003
-#line 1254 "yara_grammar.y"
3004
-    {
3005
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">=");
3006
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">=");
3007
-
3008
-        yr_parser_emit(yyscanner, OP_GE, NULL);
3009
-
3010
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
3011
-      }
3012
-    break;
3013
-
3014
-  case 69:
3015
-/* Line 1792 of yacc.c  */
3016
-#line 1263 "yara_grammar.y"
3017
-    {
3018
-        if ((yyvsp[(1) - (3)].expression_type) != (yyvsp[(3) - (3)].expression_type))
3019
-        {
3020
-          yr_compiler_set_error_extra_info(
3021
-              compiler, "mismatching types for == operator");
3022
-          compiler->last_result = ERROR_WRONG_TYPE;
3023
-        }
3024
-        else if ((yyvsp[(1) - (3)].expression_type) == EXPRESSION_TYPE_STRING)
3025
-        {
3026
-          compiler->last_result = yr_parser_emit(
3027
-              yyscanner,
3028
-              OP_SZ_EQ,
3029
-              NULL);
3030
-        }
3031
-        else
3032
-        {
3033
-          compiler->last_result = yr_parser_emit(
3034
-              yyscanner,
3035
-              OP_EQ,
3036
-              NULL);
3037
-        }
3038
-
3039
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3040
-
3041
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
3042
-      }
3043
-    break;
3044
-
3045
-  case 70:
3046
-/* Line 1792 of yacc.c  */
3047
-#line 1290 "yara_grammar.y"
3048
-    {
3049
-        if ((yyvsp[(1) - (3)].expression_type) != (yyvsp[(3) - (3)].expression_type))
3050
-        {
3051
-          yr_compiler_set_error_extra_info(
3052
-              compiler, "mismatching types for == operator");
3053
-          compiler->last_result = ERROR_WRONG_TYPE;
3054
-        }
3055
-        else if ((yyvsp[(1) - (3)].expression_type) == EXPRESSION_TYPE_STRING)
3056
-        {
3057
-          compiler->last_result = yr_parser_emit(
3058
-              yyscanner,
3059
-              OP_SZ_EQ,
3060
-              NULL);
3061
-        }
3062
-        else
3063
-        {
3064
-          compiler->last_result = yr_parser_emit(
3065
-              yyscanner,
3066
-              OP_EQ,
3067
-              NULL);
3068
-        }
3069
-
3070
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3071
-
3072
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
3073
-      }
3074
-    break;
3075
-
3076
-  case 71:
3077
-/* Line 1792 of yacc.c  */
3078
-#line 1317 "yara_grammar.y"
3079
-    {
3080
-        if ((yyvsp[(1) - (3)].expression_type) != (yyvsp[(3) - (3)].expression_type))
3081
-        {
3082
-          yr_compiler_set_error_extra_info(
3083
-              compiler, "mismatching types for != operator");
3084
-          compiler->last_result = ERROR_WRONG_TYPE;
3085
-        }
3086
-        else if ((yyvsp[(1) - (3)].expression_type) == EXPRESSION_TYPE_STRING)
3087
-        {
3088
-          compiler->last_result = yr_parser_emit(
3089
-              yyscanner,
3090
-              OP_SZ_NEQ,
3091
-              NULL);
3092
-        }
3093
-        else
3094
-        {
3095
-          compiler->last_result = yr_parser_emit(
3096
-              yyscanner,
3097
-              OP_NEQ,
3098
-              NULL);
3099
-        }
3100
-
3101
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3102
-
3103
-        (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
3104
-      }
3105
-    break;
3106
-
3107
-  case 72:
3108
-/* Line 1792 of yacc.c  */
3109
-#line 1344 "yara_grammar.y"
3110
-    {
3111
-        (yyval.expression_type) = (yyvsp[(1) - (1)].expression_type);
3112
-      }
3113
-    break;
3114
-
3115
-  case 73:
3116
-/* Line 1792 of yacc.c  */
3117
-#line 1348 "yara_grammar.y"
3118
-    {
3119
-        (yyval.expression_type) = (yyvsp[(2) - (3)].expression_type);
3120
-      }
3121
-    break;
3122
-
3123
-  case 74:
3124
-/* Line 1792 of yacc.c  */
3125
-#line 1355 "yara_grammar.y"
3126
-    { (yyval.integer) = INTEGER_SET_ENUMERATION; }
3127
-    break;
3128
-
3129
-  case 75:
3130
-/* Line 1792 of yacc.c  */
3131
-#line 1356 "yara_grammar.y"
3132
-    { (yyval.integer) = INTEGER_SET_RANGE; }
3133
-    break;
3134
-
3135
-  case 76:
3136
-/* Line 1792 of yacc.c  */
3137
-#line 1362 "yara_grammar.y"
3138
-    {
3139
-        if ((yyvsp[(2) - (6)].expression_type) != EXPRESSION_TYPE_INTEGER)
3140
-        {
3141
-          yr_compiler_set_error_extra_info(
3142
-              compiler, "wrong type for range's lower bound");
3143
-          compiler->last_result = ERROR_WRONG_TYPE;
3144
-        }
3145
-
3146
-        if ((yyvsp[(5) - (6)].expression_type) != EXPRESSION_TYPE_INTEGER)
3147
-        {
3148
-          yr_compiler_set_error_extra_info(
3149
-              compiler, "wrong type for range's upper bound");
3150
-          compiler->last_result = ERROR_WRONG_TYPE;
3151
-        }
3152
-
3153
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3154
-      }
3155
-    break;
3156
-
3157
-  case 77:
3158
-/* Line 1792 of yacc.c  */
3159
-#line 1384 "yara_grammar.y"
3160
-    {
3161
-        if ((yyvsp[(1) - (1)].expression_type) != EXPRESSION_TYPE_INTEGER)
3162
-        {
3163
-          yr_compiler_set_error_extra_info(
3164
-              compiler, "wrong type for enumeration item");
3165
-          compiler->last_result = ERROR_WRONG_TYPE;
3166
-
3167
-        }
3168
-
3169
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3170
-      }
3171
-    break;
3172
-
3173
-  case 78:
3174
-/* Line 1792 of yacc.c  */
3175
-#line 1396 "yara_grammar.y"
3176
-    {
3177
-        if ((yyvsp[(3) - (3)].expression_type) != EXPRESSION_TYPE_INTEGER)
3178
-        {
3179
-          yr_compiler_set_error_extra_info(
3180
-              compiler, "wrong type for enumeration item");
3181
-          compiler->last_result = ERROR_WRONG_TYPE;
3182
-        }
3183
-
3184
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3185
-      }
3186
-    break;
3187
-
3188
-  case 79:
3189
-/* Line 1792 of yacc.c  */
3190
-#line 1411 "yara_grammar.y"
3191
-    {
3192
-        // Push end-of-list marker
3193
-        yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
3194
-      }
3195
-    break;
3196
-
3197
-  case 81:
3198
-/* Line 1792 of yacc.c  */
3199
-#line 1417 "yara_grammar.y"
3200
-    {
3201
-        yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
3202
-        yr_parser_emit_pushes_for_strings(yyscanner, "$*");
3203
-#ifdef YARA_PROTO
3204
-        compiler->current_rule_clflags |= RULE_THEM;
3205
-#endif
3206
-      }
3207
-    break;
3208
-
3209
-  case 84:
3210
-/* Line 1792 of yacc.c  */
3211
-#line 1435 "yara_grammar.y"
3212
-    {
3213
-        yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[(1) - (1)].c_string));
3214
-        yr_free((yyvsp[(1) - (1)].c_string));
3215
-      }
3216
-    break;
3217
-
3218
-  case 85:
3219
-/* Line 1792 of yacc.c  */
3220
-#line 1440 "yara_grammar.y"
3221
-    {
3222
-        yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[(1) - (1)].c_string));
3223
-        yr_free((yyvsp[(1) - (1)].c_string));
3224
-      }
3225
-    break;
3226
-
3227
-  case 87:
3228
-/* Line 1792 of yacc.c  */
3229
-#line 1450 "yara_grammar.y"
3230
-    {
3231
-        yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL);
3232
-#ifdef YARA_PROTO
3233
-        compiler->current_rule_clflags |= RULE_ALL;
3234
-#endif
3235
-      }
3236
-    break;
3237
-
3238
-  case 88:
3239
-/* Line 1792 of yacc.c  */
3240
-#line 1457 "yara_grammar.y"
3241
-    {
3242
-        yr_parser_emit_with_arg(yyscanner, OP_PUSH, 1, NULL);
3243
-#ifdef YARA_PROTO
3244
-        compiler->current_rule_clflags |= RULE_ANY;
3245
-#endif
3246
-      }
3247
-    break;
3248
-
3249
-  case 89:
3250
-/* Line 1792 of yacc.c  */
3251
-#line 1468 "yara_grammar.y"
3252
-    {
3253
-        (yyval.expression_type) = (yyvsp[(2) - (3)].expression_type);
3254
-      }
3255
-    break;
3256
-
3257
-  case 90:
3258
-/* Line 1792 of yacc.c  */
3259
-#line 1472 "yara_grammar.y"
3260
-    {
3261
-        compiler->last_result = yr_parser_emit(
3262
-            yyscanner, OP_FILESIZE, NULL);
3263
-
3264
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3265
-
3266
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3267
-      }
3268
-    break;
3269
-
3270
-  case 91:
3271
-/* Line 1792 of yacc.c  */
3272
-#line 1481 "yara_grammar.y"
3273
-    {
3274
-#ifndef YARA_PROTO
3275
-        yywarning(yyscanner,
3276
-            "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " "function from PE module instead.");
3277
-#else
3278
-        compiler->current_rule_clflags |= RULE_EP;
3279
-#endif
3280
-        compiler->last_result = yr_parser_emit(
3281
-            yyscanner, OP_ENTRYPOINT, NULL);
3282
-
3283
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3284
-
3285
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3286
-      }
3287
-    break;
3288
-
3289
-  case 92:
3290
-/* Line 1792 of yacc.c  */
3291
-#line 1496 "yara_grammar.y"
3292
-    {
3293
-        CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "int8");
3294
-
3295
-        compiler->last_result = yr_parser_emit(
3296
-            yyscanner, OP_INT8, NULL);
3297
-
3298
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3299
-
3300
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3301
-      }
3302
-    break;
3303
-
3304
-  case 93:
3305
-/* Line 1792 of yacc.c  */
3306
-#line 1507 "yara_grammar.y"
3307
-    {
3308
-        CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "int16");
3309
-
3310
-        compiler->last_result = yr_parser_emit(
3311
-            yyscanner, OP_INT16, NULL);
3312
-
3313
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3314
-
3315
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3316
-      }
3317
-    break;
3318
-
3319
-  case 94:
3320
-/* Line 1792 of yacc.c  */
3321
-#line 1518 "yara_grammar.y"
3322
-    {
3323
-        CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "int32");
3324
-
3325
-        compiler->last_result = yr_parser_emit(
3326
-            yyscanner, OP_INT32, NULL);
3327
-
3328
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3329
-
3330
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3331
-      }
3332
-    break;
3333
-
3334
-  case 95:
3335
-/* Line 1792 of yacc.c  */
3336
-#line 1529 "yara_grammar.y"
3337
-    {
3338
-        CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "uint8");
3339
-
3340
-        compiler->last_result = yr_parser_emit(
3341
-            yyscanner, OP_UINT8, NULL);
3342
-
3343
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3344
-
3345
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3346
-      }
3347
-    break;
3348
-
3349
-  case 96:
3350
-/* Line 1792 of yacc.c  */
3351
-#line 1540 "yara_grammar.y"
3352
-    {
3353
-        CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "uint16");
3354
-
3355
-        compiler->last_result = yr_parser_emit(
3356
-            yyscanner, OP_UINT16, NULL);
3357
-
3358
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3359
-
3360
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3361
-      }
3362
-    break;
3363
-
3364
-  case 97:
3365
-/* Line 1792 of yacc.c  */
3366
-#line 1551 "yara_grammar.y"
3367
-    {
3368
-        CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "uint32");
3369
-
3370
-        compiler->last_result = yr_parser_emit(
3371
-            yyscanner, OP_UINT32, NULL);
3372
-
3373
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3374
-
3375
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3376
-      }
3377
-    break;
3378
-
3379
-  case 98:
3380
-/* Line 1792 of yacc.c  */
3381
-#line 1562 "yara_grammar.y"
3382
-    {
3383
-        compiler->last_result = yr_parser_emit_with_arg(
3384
-            yyscanner, OP_PUSH, (yyvsp[(1) - (1)].integer), NULL);
3385
-
3386
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3387
-
3388
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3389
-      }
3390
-    break;
3391
-
3392
-  case 99:
3393
-/* Line 1792 of yacc.c  */
3394
-#line 1571 "yara_grammar.y"
3395
-    {
3396
-#if REAL_YARA
3397
-        SIZED_STRING* sized_string = (yyvsp[(1) - (1)].sized_string);
3398
-#endif
3399
-        char* string = NULL;
3400
-
3401
-#if REAL_YARA
3402
-        compiler->last_result = yr_arena_write_string(
3403
-            compiler->sz_arena,
3404
-            sized_string->c_string,
3405
-            &string);
3406
-#endif
3407
-
3408
-        yr_free((yyvsp[(1) - (1)].sized_string));
3409
-
3410
-        if (compiler->last_result == ERROR_SUCCESS)
3411
-          compiler->last_result = yr_parser_emit_with_arg_reloc(
3412
-              yyscanner,
3413
-              OP_PUSH,
3414
-              PTR_TO_UINT64(string),
3415
-              NULL);
3416
-
3417
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3418
-
3419
-        (yyval.expression_type) = EXPRESSION_TYPE_STRING;
3420
-      }
3421
-    break;
3422
-
3423
-  case 100:
3424
-/* Line 1792 of yacc.c  */
3425
-#line 1598 "yara_grammar.y"
3426
-    {
3427
-        compiler->last_result = yr_parser_reduce_string_identifier(
3428
-            yyscanner,
3429
-            (yyvsp[(1) - (1)].c_string),
3430
-            OP_STR_COUNT);
3431
-
3432
-        yr_free((yyvsp[(1) - (1)].c_string));
3433
-
3434
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3435
-
3436
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3437
-      }
3438
-    break;
3439
-
3440
-  case 101:
3441
-/* Line 1792 of yacc.c  */
3442
-#line 1611 "yara_grammar.y"
3443
-    {
3444
-        compiler->last_result = yr_parser_reduce_string_identifier(
3445
-            yyscanner,
3446
-            (yyvsp[(1) - (4)].c_string),
3447
-            OP_STR_OFFSET);
3448
-
3449
-        yr_free((yyvsp[(1) - (4)].c_string));
3450
-
3451
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3452
-
3453
-        compiler->current_rule_clflags |= RULE_OFFSETS;
3454
-
3455
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3456
-      }
3457
-    break;
3458
-
3459
-  case 102:
3460
-/* Line 1792 of yacc.c  */
3461
-#line 1626 "yara_grammar.y"
3462
-    {
3463
-        compiler->last_result = yr_parser_emit_with_arg(
3464
-            yyscanner,
3465
-            OP_PUSH,
3466
-            1,
3467
-            NULL);
3468
-
3469
-        if (compiler->last_result == ERROR_SUCCESS)
3470
-          compiler->last_result = yr_parser_reduce_string_identifier(
3471
-              yyscanner,
3472
-              (yyvsp[(1) - (1)].c_string),
3473
-              OP_STR_OFFSET);
3474
-
3475
-        yr_free((yyvsp[(1) - (1)].c_string));
3476
-
3477
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3478
-
3479
-        compiler->current_rule_clflags |= RULE_OFFSETS;
3480
-
3481
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3482
-      }
3483
-    break;
3484
-
3485
-  case 103:
3486
-/* Line 1792 of yacc.c  */
3487
-#line 1648 "yara_grammar.y"
3488
-    {
3489
-        if ((yyvsp[(1) - (1)].object) == (YR_OBJECT*) -1)  // loop identifier
3490
-        {
3491
-          (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3492
-        }
3493
-        else if ((yyvsp[(1) - (1)].object) == (YR_OBJECT*) -2)  // rule identifier
3494
-        {
3495
-          (yyval.expression_type) = EXPRESSION_TYPE_BOOLEAN;
3496
-        }
3497
-        else if ((yyvsp[(1) - (1)].object) != NULL)
3498
-        {
3499
-          compiler->last_result = yr_parser_emit(
3500
-              yyscanner, OP_OBJ_VALUE, NULL);
3501
-
3502
-          switch((yyvsp[(1) - (1)].object)->type)
3503
-          {
3504
-            case OBJECT_TYPE_INTEGER:
3505
-              (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3506
-              break;
3507
-            case OBJECT_TYPE_STRING:
3508
-              (yyval.expression_type) = EXPRESSION_TYPE_STRING;
3509
-              break;
3510
-            default:
3511
-              assert(FALSE);
3512
-          }
3513
-        }
3514
-        else
3515
-        {
3516
-          yr_compiler_set_error_extra_info(compiler, (yyvsp[(1) - (1)].object)->identifier);
3517
-          compiler->last_result = ERROR_WRONG_TYPE;
3518
-        }
3519
-
3520
-        ERROR_IF(compiler->last_result != ERROR_SUCCESS);
3521
-      }
3522
-    break;
3523
-
3524
-  case 104:
3525
-/* Line 1792 of yacc.c  */
3526
-#line 1683 "yara_grammar.y"
3527
-    {
3528
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "+");
3529
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "+");
3530
-
3531
-        yr_parser_emit(yyscanner, OP_ADD, NULL);
3532
-
3533
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3534
-      }
3535
-    break;
3536
-
3537
-  case 105:
3538
-/* Line 1792 of yacc.c  */
3539
-#line 1692 "yara_grammar.y"
3540
-    {
3541
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "-");
3542
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "-");
3543
-
3544
-        yr_parser_emit(yyscanner, OP_SUB, NULL);
3545
-
3546
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3547
-      }
3548
-    break;
3549
-
3550
-  case 106:
3551
-/* Line 1792 of yacc.c  */
3552
-#line 1701 "yara_grammar.y"
3553
-    {
3554
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "*");
3555
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "*");
3556
-
3557
-        yr_parser_emit(yyscanner, OP_MUL, NULL);
3558
-
3559
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3560
-      }
3561
-    break;
3562
-
3563
-  case 107:
3564
-/* Line 1792 of yacc.c  */
3565
-#line 1710 "yara_grammar.y"
3566
-    {
3567
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "\\");
3568
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "\\");
3569
-
3570
-        yr_parser_emit(yyscanner, OP_DIV, NULL);
3571
-
3572
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3573
-      }
3574
-    break;
3575
-
3576
-  case 108:
3577
-/* Line 1792 of yacc.c  */
3578
-#line 1719 "yara_grammar.y"
3579
-    {
3580
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "%");
3581
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "%");
3582
-
3583
-        yr_parser_emit(yyscanner, OP_MOD, NULL);
3584
-
3585
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3586
-      }
3587
-    break;
3588
-
3589
-  case 109:
3590
-/* Line 1792 of yacc.c  */
3591
-#line 1728 "yara_grammar.y"
3592
-    {
3593
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^");
3594
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^");
3595
-
3596
-        yr_parser_emit(yyscanner, OP_XOR, NULL);
3597
-
3598
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3599
-      }
3600
-    break;
3601
-
3602
-  case 110:
3603
-/* Line 1792 of yacc.c  */
3604
-#line 1737 "yara_grammar.y"
3605
-    {
3606
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^");
3607
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^");
3608
-
3609
-        yr_parser_emit(yyscanner, OP_AND, NULL);
3610
-
3611
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3612
-      }
3613
-    break;
3614
-
3615
-  case 111:
3616
-/* Line 1792 of yacc.c  */
3617
-#line 1746 "yara_grammar.y"
3618
-    {
3619
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "|");
3620
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "|");
3621
-
3622
-        yr_parser_emit(yyscanner, OP_OR, NULL);
3623
-
3624
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3625
-      }
3626
-    break;
3627
-
3628
-  case 112:
3629
-/* Line 1792 of yacc.c  */
3630
-#line 1755 "yara_grammar.y"
3631
-    {
3632
-        CHECK_TYPE((yyvsp[(2) - (2)].expression_type), EXPRESSION_TYPE_INTEGER, "~");
3633
-
3634
-        yr_parser_emit(yyscanner, OP_NEG, NULL);
3635
-
3636
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3637
-      }
3638
-    break;
3639
-
3640
-  case 113:
3641
-/* Line 1792 of yacc.c  */
3642
-#line 1763 "yara_grammar.y"
3643
-    {
3644
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<<");
3645
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<<");
3646
-
3647
-        yr_parser_emit(yyscanner, OP_SHL, NULL);
3648
-
3649
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3650
-      }
3651
-    break;
3652
-
3653
-  case 114:
3654
-/* Line 1792 of yacc.c  */
3655
-#line 1772 "yara_grammar.y"
3656
-    {
3657
-        CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">>");
3658
-        CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">>");
3659
-
3660
-        yr_parser_emit(yyscanner, OP_SHR, NULL);
3661
-
3662
-        (yyval.expression_type) = EXPRESSION_TYPE_INTEGER;
3663
-      }
3664
-    break;
3665
-
3666
-  case 115:
3667
-/* Line 1792 of yacc.c  */
3668
-#line 1781 "yara_grammar.y"
3669
-    {
3670
-        (yyval.expression_type) = (yyvsp[(1) - (1)].expression_type);
3671
-      }
3672
-    break;
3673
-
3674
-
3675
-/* Line 1792 of yacc.c  */
3676
-#line 3677 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.c"
3677
-      default: break;
3678
-    }
3679
-  /* User semantic actions sometimes alter yychar, and that requires
3680
-     that yytoken be updated with the new translation.  We take the
3681
-     approach of translating immediately before every use of yytoken.
3682
-     One alternative is translating here after every semantic action,
3683
-     but that translation would be missed if the semantic action invokes
3684
-     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
3685
-     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
3686
-     incorrect destructor might then be invoked immediately.  In the
3687
-     case of YYERROR or YYBACKUP, subsequent parser actions might lead
3688
-     to an incorrect destructor call or verbose syntax error message
3689
-     before the lookahead is translated.  */
3690
-  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
3691
-
3692
-  YYPOPSTACK (yylen);
3693
-  yylen = 0;
3694
-  YY_STACK_PRINT (yyss, yyssp);
3695
-
3696
-  *++yyvsp = yyval;
3697
-
3698
-  /* Now `shift' the result of the reduction.  Determine what state
3699
-     that goes to, based on the state we popped back to and the rule
3700
-     number reduced by.  */
3701
-
3702
-  yyn = yyr1[yyn];
3703
-
3704
-  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
3705
-  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
3706
-    yystate = yytable[yystate];
3707
-  else
3708
-    yystate = yydefgoto[yyn - YYNTOKENS];
3709
-
3710
-  goto yynewstate;
3711
-
3712
-
3713
-/*------------------------------------.
3714
-| yyerrlab -- here on detecting error |
3715
-`------------------------------------*/
3716
-yyerrlab:
3717
-  /* Make sure we have latest lookahead translation.  See comments at
3718
-     user semantic actions for why this is necessary.  */
3719
-  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
3720
-
3721
-  /* If not already recovering from an error, report this error.  */
3722
-  if (!yyerrstatus)
3723
-    {
3724
-      ++yynerrs;
3725
-#if ! YYERROR_VERBOSE
3726
-      yyerror (yyscanner, compiler, YY_("syntax error"));
3727
-#else
3728
-# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
3729
-                                        yyssp, yytoken)
3730
-      {
3731
-        char const *yymsgp = YY_("syntax error");
3732
-        int yysyntax_error_status;
3733
-        yysyntax_error_status = YYSYNTAX_ERROR;
3734
-        if (yysyntax_error_status == 0)
3735
-          yymsgp = yymsg;
3736
-        else if (yysyntax_error_status == 1)
3737
-          {
3738
-            if (yymsg != yymsgbuf)
3739
-              YYSTACK_FREE (yymsg);
3740
-            yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
3741
-            if (!yymsg)
3742
-              {
3743
-                yymsg = yymsgbuf;
3744
-                yymsg_alloc = sizeof yymsgbuf;
3745
-                yysyntax_error_status = 2;
3746
-              }
3747
-            else
3748
-              {
3749
-                yysyntax_error_status = YYSYNTAX_ERROR;
3750
-                yymsgp = yymsg;
3751
-              }
3752
-          }
3753
-        yyerror (yyscanner, compiler, yymsgp);
3754
-        if (yysyntax_error_status == 2)
3755
-          goto yyexhaustedlab;
3756
-      }
3757
-# undef YYSYNTAX_ERROR
3758
-#endif
3759
-    }
3760
-
3761
-
3762
-
3763
-  if (yyerrstatus == 3)
3764
-    {
3765
-      /* If just tried and failed to reuse lookahead token after an
3766
-	 error, discard it.  */
3767
-
3768
-      if (yychar <= YYEOF)
3769
-	{
3770
-	  /* Return failure if at end of input.  */
3771
-	  if (yychar == YYEOF)
3772
-	    YYABORT;
3773
-	}
3774
-      else
3775
-	{
3776
-	  yydestruct ("Error: discarding",
3777
-		      yytoken, &yylval, yyscanner, compiler);
3778
-	  yychar = YYEMPTY;
3779
-	}
3780
-    }
3781
-
3782
-  /* Else will try to reuse lookahead token after shifting the error
3783
-     token.  */
3784
-  goto yyerrlab1;
3785
-
3786
-
3787
-/*---------------------------------------------------.
3788
-| yyerrorlab -- error raised explicitly by YYERROR.  |
3789
-`---------------------------------------------------*/
3790
-yyerrorlab:
3791
-
3792
-  /* Pacify compilers like GCC when the user code never invokes
3793
-     YYERROR and the label yyerrorlab therefore never appears in user
3794
-     code.  */
3795
-  if (/*CONSTCOND*/ 0)
3796
-     goto yyerrorlab;
3797
-
3798
-  /* Do not reclaim the symbols of the rule which action triggered
3799
-     this YYERROR.  */
3800
-  YYPOPSTACK (yylen);
3801
-  yylen = 0;
3802
-  YY_STACK_PRINT (yyss, yyssp);
3803
-  yystate = *yyssp;
3804
-  goto yyerrlab1;
3805
-
3806
-
3807
-/*-------------------------------------------------------------.
3808
-| yyerrlab1 -- common code for both syntax error and YYERROR.  |
3809
-`-------------------------------------------------------------*/
3810
-yyerrlab1:
3811
-  yyerrstatus = 3;	/* Each real token shifted decrements this.  */
3812
-
3813
-  for (;;)
3814
-    {
3815
-      yyn = yypact[yystate];
3816
-      if (!yypact_value_is_default (yyn))
3817
-	{
3818
-	  yyn += YYTERROR;
3819
-	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
3820
-	    {
3821
-	      yyn = yytable[yyn];
3822
-	      if (0 < yyn)
3823
-		break;
3824
-	    }
3825
-	}
3826
-
3827
-      /* Pop the current state because it cannot handle the error token.  */
3828
-      if (yyssp == yyss)
3829
-	YYABORT;
3830
-
3831
-
3832
-      yydestruct ("Error: popping",
3833
-		  yystos[yystate], yyvsp, yyscanner, compiler);
3834
-      YYPOPSTACK (1);
3835
-      yystate = *yyssp;
3836
-      YY_STACK_PRINT (yyss, yyssp);
3837
-    }
3838
-
3839
-  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
3840
-  *++yyvsp = yylval;
3841
-  YY_IGNORE_MAYBE_UNINITIALIZED_END
3842
-
3843
-
3844
-  /* Shift the error token.  */
3845
-  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
3846
-
3847
-  yystate = yyn;
3848
-  goto yynewstate;
3849
-
3850
-
3851
-/*-------------------------------------.
3852
-| yyacceptlab -- YYACCEPT comes here.  |
3853
-`-------------------------------------*/
3854
-yyacceptlab:
3855
-  yyresult = 0;
3856
-  goto yyreturn;
3857
-
3858
-/*-----------------------------------.
3859
-| yyabortlab -- YYABORT comes here.  |
3860
-`-----------------------------------*/
3861
-yyabortlab:
3862
-  yyresult = 1;
3863
-  goto yyreturn;
3864
-
3865
-#if !defined yyoverflow || YYERROR_VERBOSE
3866
-/*-------------------------------------------------.
3867
-| yyexhaustedlab -- memory exhaustion comes here.  |
3868
-`-------------------------------------------------*/
3869
-yyexhaustedlab:
3870
-  yyerror (yyscanner, compiler, YY_("memory exhausted"));
3871
-  yyresult = 2;
3872
-  /* Fall through.  */
3873
-#endif
3874
-
3875
-yyreturn:
3876
-  if (yychar != YYEMPTY)
3877
-    {
3878
-      /* Make sure we have latest lookahead translation.  See comments at
3879
-         user semantic actions for why this is necessary.  */
3880
-      yytoken = YYTRANSLATE (yychar);
3881
-      yydestruct ("Cleanup: discarding lookahead",
3882
-                  yytoken, &yylval, yyscanner, compiler);
3883
-    }
3884
-  /* Do not reclaim the symbols of the rule which action triggered
3885
-     this YYABORT or YYACCEPT.  */
3886
-  YYPOPSTACK (yylen);
3887
-  YY_STACK_PRINT (yyss, yyssp);
3888
-  while (yyssp != yyss)
3889
-    {
3890
-      yydestruct ("Cleanup: popping",
3891
-		  yystos[*yyssp], yyvsp, yyscanner, compiler);
3892
-      YYPOPSTACK (1);
3893
-    }
3894
-#ifndef yyoverflow
3895
-  if (yyss != yyssa)
3896
-    YYSTACK_FREE (yyss);
3897
-#endif
3898
-#if YYERROR_VERBOSE
3899
-  if (yymsg != yymsgbuf)
3900
-    YYSTACK_FREE (yymsg);
3901
-#endif
3902
-  /* Make sure YYID is used.  */
3903
-  return YYID (yyresult);
3904
-}
3905
-
3906
-
3907
-/* Line 2055 of yacc.c  */
3908
-#line 1786 "yara_grammar.y"
3909
-
3910 1
deleted file mode 100644
... ...
@@ -1,151 +0,0 @@
1
-/* A Bison parser, made by GNU Bison 2.7.  */
2
-
3
-/* Bison interface for Yacc-like parsers in C
4
-   
5
-      Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
6
-   
7
-   This program is free software: you can redistribute it and/or modify
8
-   it under the terms of the GNU General Public License as published by
9
-   the Free Software Foundation, either version 3 of the License, or
10
-   (at your option) any later version.
11
-   
12
-   This program is distributed in the hope that it will be useful,
13
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
-   GNU General Public License for more details.
16
-   
17
-   You should have received a copy of the GNU General Public License
18
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
-
20
-/* As a special exception, you may create a larger work that contains
21
-   part or all of the Bison parser skeleton and distribute that work
22
-   under terms of your choice, so long as that work isn't itself a
23
-   parser generator using the skeleton or a modified version thereof
24
-   as a parser skeleton.  Alternatively, if you modify or redistribute
25
-   the parser skeleton itself, you may (at your option) remove this
26
-   special exception, which will cause the skeleton and the resulting
27
-   Bison output files to be licensed under the GNU General Public
28
-   License without this special exception.
29
-   
30
-   This special exception was added by the Free Software Foundation in
31
-   version 2.2 of Bison.  */
32
-
33
-#ifndef YY_YARA_YY_C_USERS_MICASNYD_WORKSPACE_CLAMAV_MICASNYD_BUILD_LIBCLAMAV_YARA_GRAMMAR_H_INCLUDED
34
-# define YY_YARA_YY_C_USERS_MICASNYD_WORKSPACE_CLAMAV_MICASNYD_BUILD_LIBCLAMAV_YARA_GRAMMAR_H_INCLUDED
35
-/* Enabling traces.  */
36
-#ifndef YYDEBUG
37
-# define YYDEBUG 0
38
-#endif
39
-#if YYDEBUG
40
-extern int yara_yydebug;
41
-#endif
42
-/* "%code requires" blocks.  */
43
-/* Line 2058 of yacc.c  */
44
-#line 39 "yara_grammar.y"
45
-
46
-#include "yara_compiler.h"
47
-
48
-
49
-/* Line 2058 of yacc.c  */
50
-#line 51 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.h"
51
-
52
-/* Tokens.  */
53
-#ifndef YYTOKENTYPE
54
-# define YYTOKENTYPE
55
-   /* Put the tokens into the symbol table, so that GDB and other debuggers
56
-      know about them.  */
57
-   enum yytokentype {
58
-     _RULE_ = 258,
59
-     _PRIVATE_ = 259,
60
-     _GLOBAL_ = 260,
61
-     _META_ = 261,
62
-     _STRINGS_ = 262,
63
-     _CONDITION_ = 263,
64
-     _IDENTIFIER_ = 264,
65
-     _STRING_IDENTIFIER_ = 265,
66
-     _STRING_COUNT_ = 266,
67
-     _STRING_OFFSET_ = 267,
68
-     _STRING_IDENTIFIER_WITH_WILDCARD_ = 268,
69
-     _NUMBER_ = 269,
70
-     _TEXT_STRING_ = 270,
71
-     _HEX_STRING_ = 271,
72
-     _REGEXP_ = 272,
73
-     _ASCII_ = 273,
74
-     _WIDE_ = 274,
75
-     _NOCASE_ = 275,
76
-     _FULLWORD_ = 276,
77
-     _AT_ = 277,
78
-     _FILESIZE_ = 278,
79
-     _ENTRYPOINT_ = 279,
80
-     _ALL_ = 280,
81
-     _ANY_ = 281,
82
-     _IN_ = 282,
83
-     _OF_ = 283,
84
-     _FOR_ = 284,
85
-     _THEM_ = 285,
86
-     _INT8_ = 286,
87
-     _INT16_ = 287,
88
-     _INT32_ = 288,
89
-     _UINT8_ = 289,
90
-     _UINT16_ = 290,
91
-     _UINT32_ = 291,
92
-     _MATCHES_ = 292,
93
-     _CONTAINS_ = 293,
94
-     _IMPORT_ = 294,
95
-     _TRUE_ = 295,
96
-     _FALSE_ = 296,
97
-     _OR_ = 297,
98
-     _AND_ = 298,
99
-     _IS_ = 299,
100
-     _NEQ_ = 300,
101
-     _EQ_ = 301,
102
-     _GE_ = 302,
103
-     _GT_ = 303,
104
-     _LE_ = 304,
105
-     _LT_ = 305,
106
-     _SHIFT_RIGHT_ = 306,
107
-     _SHIFT_LEFT_ = 307,
108
-     _NOT_ = 308
109
-   };
110
-#endif
111
-
112
-
113
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
114
-typedef union YYSTYPE
115
-{
116
-/* Line 2058 of yacc.c  */
117
-#line 218 "yara_grammar.y"
118
-
119
-  SIZED_STRING*   sized_string;
120
-  char*           c_string;
121
-  int8_t          expression_type;
122
-  int64_t         integer;
123
-  YR_STRING*      string;
124
-  YR_META*        meta;
125
-  YR_OBJECT*      object;
126
-
127
-
128
-/* Line 2058 of yacc.c  */
129
-#line 130 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_grammar.h"
130
-} YYSTYPE;
131
-# define YYSTYPE_IS_TRIVIAL 1
132
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
133
-# define YYSTYPE_IS_DECLARED 1
134
-#endif
135
-
136
-
137
-#ifdef YYPARSE_PARAM
138
-#if defined __STDC__ || defined __cplusplus
139
-int yara_yyparse (void *YYPARSE_PARAM);
140
-#else
141
-int yara_yyparse ();
142
-#endif
143
-#else /* ! YYPARSE_PARAM */
144
-#if defined __STDC__ || defined __cplusplus
145
-int yara_yyparse (void *yyscanner, YR_COMPILER* compiler);
146
-#else
147
-int yara_yyparse ();
148
-#endif
149
-#endif /* ! YYPARSE_PARAM */
150
-
151
-#endif /* !YY_YARA_YY_C_USERS_MICASNYD_WORKSPACE_CLAMAV_MICASNYD_BUILD_LIBCLAMAV_YARA_GRAMMAR_H_INCLUDED  */
152 1
deleted file mode 100644
... ...
@@ -1,3163 +0,0 @@
1
-#line 1 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_lexer.c"
2
-
3
-#line 3 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_lexer.c"
4
-
5
-#define  YY_INT_ALIGNED short int
6
-
7
-/* A lexical scanner generated by flex */
8
-
9
-#define FLEX_SCANNER
10
-#define YY_FLEX_MAJOR_VERSION 2
11
-#define YY_FLEX_MINOR_VERSION 6
12
-#define YY_FLEX_SUBMINOR_VERSION 3
13
-#if YY_FLEX_SUBMINOR_VERSION > 0
14
-#define FLEX_BETA
15
-#endif
16
-
17
-    #define yy_create_buffer yy_create_buffer
18
-
19
-    #define yy_delete_buffer yy_delete_buffer
20
-
21
-    #define yy_scan_buffer yy_scan_buffer
22
-
23
-    #define yy_scan_string yy_scan_string
24
-
25
-    #define yy_scan_bytes yy_scan_bytes
26
-
27
-    #define yy_init_buffer yy_init_buffer
28
-
29
-    #define yy_flush_buffer yy_flush_buffer
30
-
31
-    #define yy_load_buffer_state yy_load_buffer_state
32
-
33
-    #define yy_switch_to_buffer yy_switch_to_buffer
34
-
35
-    #define yypush_buffer_state yypush_buffer_state
36
-
37
-    #define yypop_buffer_state yypop_buffer_state
38
-
39
-    #define yyensure_buffer_stack yyensure_buffer_stack
40
-
41
-    #define yylex yylex
42
-
43
-    #define yyrestart yyrestart
44
-
45
-    #define yylex_init yylex_init
46
-
47
-    #define yylex_init_extra yylex_init_extra
48
-
49
-    #define yylex_destroy yylex_destroy
50
-
51
-    #define yyget_debug yyget_debug
52
-
53
-    #define yyset_debug yyset_debug
54
-
55
-    #define yyget_extra yyget_extra
56
-
57
-    #define yyset_extra yyset_extra
58
-
59
-    #define yyget_in yyget_in
60
-
61
-    #define yyset_in yyset_in
62
-
63
-    #define yyget_out yyget_out
64
-
65
-    #define yyset_out yyset_out
66
-
67
-    #define yyget_leng yyget_leng
68
-
69
-    #define yyget_text yyget_text
70
-
71
-    #define yyget_lineno yyget_lineno
72
-
73
-    #define yyset_lineno yyset_lineno
74
-
75
-        #define yyget_column yyget_column
76
-
77
-        #define yyset_column yyset_column
78
-
79
-    #define yywrap yywrap
80
-
81
-    #define yyget_lval yyget_lval
82
-
83
-    #define yyset_lval yyset_lval
84
-
85
-    #define yyalloc yyalloc
86
-
87
-    #define yyrealloc yyrealloc
88
-
89
-    #define yyfree yyfree
90
-
91
-/* First, we deal with  platform-specific or compiler-specific issues. */
92
-
93
-/* begin standard C headers. */
94
-#include <stdio.h>
95
-#include <string.h>
96
-#include <errno.h>
97
-#include <stdlib.h>
98
-
99
-/* end standard C headers. */
100
-
101
-/* flex integer type definitions */
102
-
103
-#ifndef FLEXINT_H
104
-#define FLEXINT_H
105
-
106
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
107
-
108
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
109
-
110
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
111
- * if you want the limit (max/min) macros for int types. 
112
- */
113
-#ifndef __STDC_LIMIT_MACROS
114
-#define __STDC_LIMIT_MACROS 1
115
-#endif
116
-
117
-#include <inttypes.h>
118
-typedef int8_t flex_int8_t;
119
-typedef uint8_t flex_uint8_t;
120
-typedef int16_t flex_int16_t;
121
-typedef uint16_t flex_uint16_t;
122
-typedef int32_t flex_int32_t;
123
-typedef uint32_t flex_uint32_t;
124
-#else
125
-typedef signed char flex_int8_t;
126
-typedef short int flex_int16_t;
127
-typedef int flex_int32_t;
128
-typedef unsigned char flex_uint8_t; 
129
-typedef unsigned short int flex_uint16_t;
130
-typedef unsigned int flex_uint32_t;
131
-
132
-/* Limits of integral types. */
133
-#ifndef INT8_MIN
134
-#define INT8_MIN               (-128)
135
-#endif
136
-#ifndef INT16_MIN
137
-#define INT16_MIN              (-32767-1)
138
-#endif
139
-#ifndef INT32_MIN
140
-#define INT32_MIN              (-2147483647-1)
141
-#endif
142
-#ifndef INT8_MAX
143
-#define INT8_MAX               (127)
144
-#endif
145
-#ifndef INT16_MAX
146
-#define INT16_MAX              (32767)
147
-#endif
148
-#ifndef INT32_MAX
149
-#define INT32_MAX              (2147483647)
150
-#endif
151
-#ifndef UINT8_MAX
152
-#define UINT8_MAX              (255U)
153
-#endif
154
-#ifndef UINT16_MAX
155
-#define UINT16_MAX             (65535U)
156
-#endif
157
-#ifndef UINT32_MAX
158
-#define UINT32_MAX             (4294967295U)
159
-#endif
160
-
161
-#endif /* ! C99 */
162
-
163
-#endif /* ! FLEXINT_H */
164
-
165
-/* TODO: this is always defined, so inline it */
166
-#define yyconst const
167
-
168
-#if defined(__GNUC__) && __GNUC__ >= 3
169
-#define yynoreturn __attribute__((__noreturn__))
170
-#else
171
-#define yynoreturn
172
-#endif
173
-
174
-/* Returned upon end-of-file. */
175
-#define YY_NULL 0
176
-
177
-/* Promotes a possibly negative, possibly signed char to an
178
- *   integer in range [0..255] for use as an array index.
179
- */
180
-#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
181
-
182
-/* An opaque pointer. */
183
-#ifndef YY_TYPEDEF_YY_SCANNER_T
184
-#define YY_TYPEDEF_YY_SCANNER_T
185
-typedef void* yyscan_t;
186
-#endif
187
-
188
-/* For convenience, these vars (plus the bison vars far below)
189
-   are macros in the reentrant scanner. */
190
-#define yyin yyg->yyin_r
191
-#define yyout yyg->yyout_r
192
-#define yyextra yyg->yyextra_r
193
-#define yyleng yyg->yyleng_r
194
-#define yytext yyg->yytext_r
195
-#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
196
-#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
197
-#define yy_flex_debug yyg->yy_flex_debug_r
198
-
199
-/* Enter a start condition.  This macro really ought to take a parameter,
200
- * but we do it the disgusting crufty way forced on us by the ()-less
201
- * definition of BEGIN.
202
- */
203
-#define BEGIN yyg->yy_start = 1 + 2 *
204
-/* Translate the current start state into a value that can be later handed
205
- * to BEGIN to return to the state.  The YYSTATE alias is for lex
206
- * compatibility.
207
- */
208
-#define YY_START ((yyg->yy_start - 1) / 2)
209
-#define YYSTATE YY_START
210
-/* Action number for EOF rule of a given start state. */
211
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
212
-/* Special action meaning "start processing a new file". */
213
-#define YY_NEW_FILE yyrestart(yyin ,yyscanner )
214
-#define YY_END_OF_BUFFER_CHAR 0
215
-
216
-/* Size of default input buffer. */
217
-#ifndef YY_BUF_SIZE
218
-#ifdef __ia64__
219
-/* On IA-64, the buffer size is 16k, not 8k.
220
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
221
- * Ditto for the __ia64__ case accordingly.
222
- */
223
-#define YY_BUF_SIZE 32768
224
-#else
225
-#define YY_BUF_SIZE 16384
226
-#endif /* __ia64__ */
227
-#endif
228
-
229
-/* The state buf must be large enough to hold one state per character in the main buffer.
230
- */
231
-#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
232
-
233
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
234
-#define YY_TYPEDEF_YY_BUFFER_STATE
235
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
236
-#endif
237
-
238
-#ifndef YY_TYPEDEF_YY_SIZE_T
239
-#define YY_TYPEDEF_YY_SIZE_T
240
-typedef size_t yy_size_t;
241
-#endif
242
-
243
-#define EOB_ACT_CONTINUE_SCAN 0
244
-#define EOB_ACT_END_OF_FILE 1
245
-#define EOB_ACT_LAST_MATCH 2
246
-    
247
-    /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
248
-     *       access to the local variable yy_act. Since yyless() is a macro, it would break
249
-     *       existing scanners that call yyless() from OUTSIDE yylex.
250
-     *       One obvious solution it to make yy_act a global. I tried that, and saw
251
-     *       a 5% performance hit in a non-yylineno scanner, because yy_act is
252
-     *       normally declared as a register variable-- so it is not worth it.
253
-     */
254
-    #define  YY_LESS_LINENO(n) \
255
-            do { \
256
-                int yyl;\
257
-                for ( yyl = n; yyl < yyleng; ++yyl )\
258
-                    if ( yytext[yyl] == '\n' )\
259
-                        --yylineno;\
260
-            }while(0)
261
-    #define YY_LINENO_REWIND_TO(dst) \
262
-            do {\
263
-                const char *p;\
264
-                for ( p = yy_cp-1; p >= (dst); --p)\
265
-                    if ( *p == '\n' )\
266
-                        --yylineno;\
267
-            }while(0)
268
-    
269
-/* Return all but the first "n" matched characters back to the input stream. */
270
-#define yyless(n) \
271
-	do \
272
-		{ \
273
-		/* Undo effects of setting up yytext. */ \
274
-        int yyless_macro_arg = (n); \
275
-        YY_LESS_LINENO(yyless_macro_arg);\
276
-		*yy_cp = yyg->yy_hold_char; \
277
-		YY_RESTORE_YY_MORE_OFFSET \
278
-		yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
279
-		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
280
-		} \
281
-	while ( 0 )
282
-#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
283
-
284
-#ifndef YY_STRUCT_YY_BUFFER_STATE
285
-#define YY_STRUCT_YY_BUFFER_STATE
286
-struct yy_buffer_state
287
-	{
288
-	FILE *yy_input_file;
289
-
290
-	char *yy_ch_buf;		/* input buffer */
291
-	char *yy_buf_pos;		/* current position in input buffer */
292
-
293
-	/* Size of input buffer in bytes, not including room for EOB
294
-	 * characters.
295
-	 */
296
-	int yy_buf_size;
297
-
298
-	/* Number of characters read into yy_ch_buf, not including EOB
299
-	 * characters.
300
-	 */
301
-	int yy_n_chars;
302
-
303
-	/* Whether we "own" the buffer - i.e., we know we created it,
304
-	 * and can realloc() it to grow it, and should free() it to
305
-	 * delete it.
306
-	 */
307
-	int yy_is_our_buffer;
308
-
309
-	/* Whether this is an "interactive" input source; if so, and
310
-	 * if we're using stdio for input, then we want to use getc()
311
-	 * instead of fread(), to make sure we stop fetching input after
312
-	 * each newline.
313
-	 */
314
-	int yy_is_interactive;
315
-
316
-	/* Whether we're considered to be at the beginning of a line.
317
-	 * If so, '^' rules will be active on the next match, otherwise
318
-	 * not.
319
-	 */
320
-	int yy_at_bol;
321
-
322
-    int yy_bs_lineno; /**< The line count. */
323
-    int yy_bs_column; /**< The column count. */
324
-
325
-	/* Whether to try to fill the input buffer when we reach the
326
-	 * end of it.
327
-	 */
328
-	int yy_fill_buffer;
329
-
330
-	int yy_buffer_status;
331
-
332
-#define YY_BUFFER_NEW 0
333
-#define YY_BUFFER_NORMAL 1
334
-	/* When an EOF's been seen but there's still some text to process
335
-	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
336
-	 * shouldn't try reading from the input source any more.  We might
337
-	 * still have a bunch of tokens to match, though, because of
338
-	 * possible backing-up.
339
-	 *
340
-	 * When we actually see the EOF, we change the status to "new"
341
-	 * (via yyrestart()), so that the user can continue scanning by
342
-	 * just pointing yyin at a new input file.
343
-	 */
344
-#define YY_BUFFER_EOF_PENDING 2
345
-
346
-	};
347
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
348
-
349
-/* We provide macros for accessing buffer states in case in the
350
- * future we want to put the buffer states in a more general
351
- * "scanner state".
352
- *
353
- * Returns the top of the stack, or NULL.
354
- */
355
-#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
356
-                          ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
357
-                          : NULL)
358
-/* Same as previous macro, but useful when we know that the buffer stack is not
359
- * NULL or when we need an lvalue. For internal use only.
360
- */
361
-#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
362
-
363
-void yyrestart ( FILE *input_file , yyscan_t yyscanner );
364
-void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
365
-YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
366
-void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
367
-void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
368
-void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
369
-void yypop_buffer_state ( yyscan_t yyscanner );
370
-
371
-static void yyensure_buffer_stack ( yyscan_t yyscanner );
372
-static void yy_load_buffer_state ( yyscan_t yyscanner );
373
-static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
374
-#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
375
-
376
-YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
377
-YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
378
-YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
379
-
380
-void *yyalloc ( yy_size_t , yyscan_t yyscanner );
381
-void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
382
-void yyfree ( void * , yyscan_t yyscanner );
383
-
384
-#define yy_new_buffer yy_create_buffer
385
-#define yy_set_interactive(is_interactive) \
386
-	{ \
387
-	if ( ! YY_CURRENT_BUFFER ){ \
388
-        yyensure_buffer_stack (yyscanner); \
389
-		YY_CURRENT_BUFFER_LVALUE =    \
390
-            yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
391
-	} \
392
-	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
393
-	}
394
-#define yy_set_bol(at_bol) \
395
-	{ \
396
-	if ( ! YY_CURRENT_BUFFER ){\
397
-        yyensure_buffer_stack (yyscanner); \
398
-		YY_CURRENT_BUFFER_LVALUE =    \
399
-            yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
400
-	} \
401
-	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
402
-	}
403
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
404
-
405
-/* Begin user sect3 */
406
-
407
-#define yywrap(yyscanner) (/*CONSTCOND*/1)
408
-#define YY_SKIP_YYWRAP
409
-typedef flex_uint8_t YY_CHAR;
410
-
411
-typedef int yy_state_type;
412
-
413
-#define yytext_ptr yytext_r
414
-
415
-static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
416
-static yy_state_type yy_try_NUL_trans ( yy_state_type current_state  , yyscan_t yyscanner);
417
-static int yy_get_next_buffer ( yyscan_t yyscanner );
418
-static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
419
-
420
-/* Done after the current pattern has been matched and before the
421
- * corresponding action - sets up yytext.
422
- */
423
-#define YY_DO_BEFORE_ACTION \
424
-	yyg->yytext_ptr = yy_bp; \
425
-	yyleng = (int) (yy_cp - yy_bp); \
426
-	yyg->yy_hold_char = *yy_cp; \
427
-	*yy_cp = '\0'; \
428
-	yyg->yy_c_buf_p = yy_cp;
429
-#define YY_NUM_RULES 75
430
-#define YY_END_OF_BUFFER 76
431
-/* This struct is not used in this scanner,
432
-   but its presence is necessary. */
433
-struct yy_trans_info
434
-	{
435
-	flex_int32_t yy_verify;
436
-	flex_int32_t yy_nxt;
437
-	};
438
-static const flex_int16_t yy_accept[219] =
439
-    {   0,
440
-        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
441
-       76,   74,   73,   73,   74,   70,   51,   50,   71,   54,
442
-       54,    1,   74,    2,   52,   53,   53,   53,   53,   53,
443
-       53,   53,   53,   53,   53,   53,   53,   53,   53,   53,
444
-       53,   74,   62,   63,   56,   75,   68,   69,   65,   75,
445
-       47,   48,   44,   44,    6,   51,   49,   50,   42,   45,
446
-       54,    0,    0,    0,    7,    3,    5,    4,    8,   52,
447
-       53,   53,   53,   53,   24,   53,   53,   53,   53,   53,
448
-       53,   53,   53,   25,   53,   53,   53,   26,   23,   53,
449
-       53,   53,   53,   53,   53,   53,    0,   62,   64,   59,
450
-
451
-       60,   58,   57,   64,   68,   65,   65,   67,   66,   47,
452
-       43,   45,   54,   55,   29,   22,   30,   53,   53,   53,
453
-       53,   53,   28,   53,   53,   53,   53,   53,   53,   53,
454
-       53,   21,   53,   53,   53,   53,   53,   53,   53,   72,
455
-        0,   53,   53,   53,   53,   53,   53,   53,   53,   53,
456
-       53,   53,   53,   36,   53,   12,   53,   53,   11,   53,
457
-       27,   19,   53,   15,   61,   14,   53,   53,   53,   20,
458
-       53,   53,   53,   53,   53,   37,   38,   53,   53,   53,
459
-       53,   53,   53,   33,   53,   53,   53,   53,   53,   10,
460
-       41,   53,   53,   17,   53,   53,   34,   35,   53,   53,
461
-
462
-       53,   53,   53,   53,   39,    9,   13,   53,   40,   53,
463
-       32,   16,    0,   18,   53,   46,   31,    0
464
-    } ;
465
-
466
-static const YY_CHAR yy_ec[256] =
467
-    {   0,
468
-        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
469
-        1,    1,    4,    1,    1,    1,    1,    1,    1,    1,
470
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
471
-        1,    2,    5,    6,    7,    8,    1,    1,    1,    9,
472
-        9,   10,    1,    1,    9,    1,   11,   12,   13,   14,
473
-       15,   16,   16,   17,   16,   18,   16,    1,    1,   19,
474
-       20,   21,    9,   22,   23,   24,   23,   23,   23,   23,
475
-       25,   25,   25,   25,   26,   25,   27,   25,   25,   25,
476
-       25,   25,   25,   25,   25,   25,   25,   25,   25,   25,
477
-        9,   28,    9,    1,   29,    1,   30,   31,   32,   33,
478
-
479
-       34,   35,   36,   37,   38,   25,   25,   39,   40,   41,
480
-       42,   43,   25,   44,   45,   46,   47,   48,   49,   50,
481
-       51,   52,   53,    9,   54,    1,    1,    1,    1,    1,
482
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
483
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
484
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
485
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
486
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
487
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
488
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
489
-
490
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
491
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
492
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
493
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
494
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
495
-        1,    1,    1,    1,    1
496
-    } ;
497
-
498
-static const YY_CHAR yy_meta[55] =
499
-    {   0,
500
-        1,    2,    3,    1,    1,    4,    1,    1,    2,    5,
501
-        6,    7,    7,    7,    7,    7,    7,    7,    1,    1,
502
-        1,    1,    8,    8,    9,   10,   10,   11,    9,    8,
503
-        8,    8,    8,    8,    8,    9,    9,    9,    9,    9,
504
-        9,    9,    9,    9,    9,    9,    9,    9,    9,   10,
505
-        9,    9,    1,    1
506
-    } ;
507
-
508
-static const flex_int16_t yy_base[238] =
509
-    {   0,
510
-        0,    0,   52,   53,   54,   57,  350,  349,  344,  343,
511
-      352,  357,  357,  357,  331,  357,    0,  340,   51,   37,
512
-       40,   50,  329,   51,    0,    0,   38,  306,  306,   56,
513
-      307,   33,   58,  303,   56,  300,  296,  296,   52,  303,
514
-      302,    0,    0,  357,  357,   69,    0,  357,   57,  328,
515
-        0,  357,  357,  327,  357,    0,  357,  327,  357,    0,
516
-        0,  312,  311,    0,  357,  357,  357,  357,  357,    0,
517
-        0,  295,   60,  301,    0,  291,  285,  291,  290,  284,
518
-      288,  284,  282,   67,  278,  277,   72,    0,    0,  284,
519
-      282,  276,  285,  271,  276,  283,  261,    0,  357,  357,
520
-
521
-      357,  357,  357,    0,    0,  269,  357,  357,  357,    0,
522
-      357,    0,  357,    0,    0,    0,    0,  275,   68,  268,
523
-      266,  276,    0,  270,  277,  265,  267,   94,  273,  274,
524
-      273,    0,  254,  267,  262,  259,  264,  251,  262,  357,
525
-        0,  257,  256,  263,  241,  257,  245,  240,  258,  243,
526
-      239,  268,  270,    0,  246,    0,  237,  251,    0,  239,
527
-        0,    0,  107,    0,  357,    0,  233,  240,  234,    0,
528
-      238,  233,  235,  227,  239,    0,    0,  237,  236,  223,
529
-      218,  227,  218,    0,  187,  181,  160,  149,  152,    0,
530
-        0,  161,  149,    0,  148,  136,    0,    0,  133,   79,
531
-
532
-       85,   82,   75,  104,    0,    0,    0,   64,    0,   37,
533
-        0,    0,  115,    0,   30,  357,    0,  357,  125,  136,
534
-      147,  158,  163,  169,  173,  177,  181,  190,  198,  208,
535
-      219,  229,  240,  251,  256,  258,  260
536
-    } ;
537
-
538
-static const flex_int16_t yy_def[238] =
539
-    {   0,
540
-      218,    1,  219,  219,  220,  220,  221,  221,  222,  222,
541
-      218,  218,  218,  218,  218,  218,  223,  224,  218,  225,
542
-      225,  218,  218,  218,  226,  227,  227,  227,  227,  227,
543
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
544
-      227,  228,  229,  218,  218,  230,  231,  218,  218,  232,
545
-      233,  218,  218,  218,  218,  223,  218,  224,  218,  234,
546
-       21,  218,  218,  235,  218,  218,  218,  218,  218,  226,
547
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
548
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
549
-      227,  227,  227,  227,  227,  227,  228,  229,  218,  218,
550
-
551
-      218,  218,  218,  236,  231,  218,  218,  218,  218,  233,
552
-      218,  234,  218,  235,  227,  227,  227,  227,  227,  227,
553
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
554
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  218,
555
-      237,  227,  227,  227,  227,  227,  227,  227,  227,  227,
556
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
557
-      227,  227,  227,  227,  218,  227,  227,  227,  227,  227,
558
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
559
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
560
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
561
-
562
-      227,  227,  227,  227,  227,  227,  227,  227,  227,  227,
563
-      227,  227,  218,  227,  227,  218,  227,    0,  218,  218,
564
-      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
565
-      218,  218,  218,  218,  218,  218,  218
566
-    } ;
567
-
568
-static const flex_int16_t yy_nxt[412] =
569
-    {   0,
570
-       12,   13,   14,   13,   15,   16,   17,   18,   12,   12,
571
-       19,   20,   21,   21,   21,   21,   21,   21,   22,   23,
572
-       24,   25,   26,   26,   26,   26,   26,   12,   26,   27,
573
-       26,   28,   26,   29,   30,   31,   26,   32,   26,   33,
574
-       34,   35,   36,   37,   38,   39,   40,   26,   41,   26,
575
-       26,   26,   42,   12,   44,   44,   48,   45,   45,   48,
576
-       59,   60,   62,   63,   49,   62,   63,   49,   65,   66,
577
-       68,   69,   83,   84,  100,  217,   72,  215,   73,   46,
578
-       46,   50,   74,   75,   50,   78,   64,   85,   93,  218,
579
-       88,   86,  116,   79,  106,   94,  101,   80,  127,   89,
580
-
581
-      143,  107,   81,  131,  214,  213,  152,  212,  153,  102,
582
-      117,  154,  128,  144,  103,  211,  213,  132,  104,  182,
583
-      216,  183,  210,  209,  184,   43,   43,   43,   43,   43,
584
-       43,   43,   43,   43,   43,   43,   47,   47,   47,   47,
585
-       47,   47,   47,   47,   47,   47,   47,   51,   51,   51,
586
-       51,   51,   51,   51,   51,   51,   51,   51,   53,   53,
587
-       53,   53,   53,   53,   53,   53,   53,   53,   53,   56,
588
-       56,   56,   56,   58,  208,   58,   58,   58,   58,   61,
589
-      207,  206,   61,   70,   70,   70,   70,   71,   71,   71,
590
-       71,   97,   97,  205,  204,  203,   97,   97,   98,   98,
591
-
592
-      202,  201,   98,   98,   98,   98,   98,   98,   99,   99,
593
-       99,   99,   99,   99,   99,   99,   99,   99,   99,  105,
594
-      105,  200,  105,  105,  199,  105,  105,  105,  105,  108,
595
-      108,  198,  108,  108,  108,  108,  108,  108,  108,  108,
596
-      110,  110,  110,  197,  110,  110,  110,  110,  110,  110,
597
-      110,  112,  112,  196,  112,  112,  112,  112,  112,  112,
598
-      112,  112,  114,  114,  141,  141,  165,  165,  195,  194,
599
-      193,  192,  191,  190,  189,  188,  187,  186,  185,  181,
600
-      180,  179,  178,  177,  176,  175,  174,  173,  172,  171,
601
-      170,  169,  168,  167,  166,  164,  163,  162,  161,  160,
602
-
603
-      159,  158,  157,  156,  155,  151,  150,  149,  148,  147,
604
-      146,  145,  142,  107,  140,  139,  138,  137,  136,  135,
605
-      134,  133,  130,  129,  126,  125,  124,  123,  122,  121,
606
-      120,  119,  118,  115,  113,  113,   57,  111,  109,   96,
607
-       95,   92,   91,   90,   87,   82,   77,   76,   67,   57,
608
-       55,  218,   54,   54,   52,   52,   11,  218,  218,  218,
609
-      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
610
-      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
611
-      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
612
-      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
613
-
614
-      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
615
-      218
616
-    } ;
617
-
618
-static const flex_int16_t yy_chk[412] =
619
-    {   0,
620
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
621
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
622
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
623
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
624
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
625
-        1,    1,    1,    1,    3,    4,    5,    3,    4,    6,
626
-       19,   19,   20,   20,    5,   21,   21,    6,   22,   22,
627
-       24,   24,   32,   32,   46,  215,   27,  210,   27,    3,
628
-        4,    5,   27,   27,    6,   30,   20,   33,   39,   21,
629
-       35,   33,   73,   30,   49,   39,   46,   30,   84,   35,
630
-
631
-      119,   49,   30,   87,  208,  204,  128,  203,  128,   46,
632
-       73,  128,   84,  119,   46,  202,  213,   87,   46,  163,
633
-      213,  163,  201,  200,  163,  219,  219,  219,  219,  219,
634
-      219,  219,  219,  219,  219,  219,  220,  220,  220,  220,
635
-      220,  220,  220,  220,  220,  220,  220,  221,  221,  221,
636
-      221,  221,  221,  221,  221,  221,  221,  221,  222,  222,
637
-      222,  222,  222,  222,  222,  222,  222,  222,  222,  223,
638
-      223,  223,  223,  224,  199,  224,  224,  224,  224,  225,
639
-      196,  195,  225,  226,  226,  226,  226,  227,  227,  227,
640
-      227,  228,  228,  193,  192,  189,  228,  228,  229,  229,
641
-
642
-      188,  187,  229,  229,  229,  229,  229,  229,  230,  230,
643
-      230,  230,  230,  230,  230,  230,  230,  230,  230,  231,
644
-      231,  186,  231,  231,  185,  231,  231,  231,  231,  232,
645
-      232,  183,  232,  232,  232,  232,  232,  232,  232,  232,
646
-      233,  233,  233,  182,  233,  233,  233,  233,  233,  233,
647
-      233,  234,  234,  181,  234,  234,  234,  234,  234,  234,
648
-      234,  234,  235,  235,  236,  236,  237,  237,  180,  179,
649
-      178,  175,  174,  173,  172,  171,  169,  168,  167,  160,
650
-      158,  157,  155,  153,  152,  151,  150,  149,  148,  147,
651
-      146,  145,  144,  143,  142,  139,  138,  137,  136,  135,
652
-
653
-      134,  133,  131,  130,  129,  127,  126,  125,  124,  122,
654
-      121,  120,  118,  106,   97,   96,   95,   94,   93,   92,
655
-       91,   90,   86,   85,   83,   82,   81,   80,   79,   78,
656
-       77,   76,   74,   72,   63,   62,   58,   54,   50,   41,
657
-       40,   38,   37,   36,   34,   31,   29,   28,   23,   18,
658
-       15,   11,   10,    9,    8,    7,  218,  218,  218,  218,
659
-      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
660
-      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
661
-      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
662
-      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
663
-
664
-      218,  218,  218,  218,  218,  218,  218,  218,  218,  218,
665
-      218
666
-    } ;
667
-
668
-/* Table of booleans, true if rule could match eol. */
669
-static const flex_int32_t yy_rule_can_match_eol[76] =
670
-    {   0,
671
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
672
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
673
-    0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
674
-    0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0,     };
675
-
676
-/* The intent behind this definition is that it'll catch
677
- * any uses of REJECT which flex missed.
678
- */
679
-#define REJECT reject_used_but_not_detected
680
-#define yymore() yymore_used_but_not_detected
681
-#define YY_MORE_ADJ 0
682
-#define YY_RESTORE_YY_MORE_OFFSET
683
-#line 1 "yara_lexer.l"
684
-/*
685
- * YARA rule lexer for ClamAV
686
- *
687
- * Copyright (C) 2014-2020 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
688
- *
689
- * Authors: Steven Morgan
690
- *
691
- * This program is free software; you can redistribute it and/or modify it under
692
- * the terms of the GNU General Public License version 2 as published by the
693
- * Free Software Foundation.
694
- *
695
- * This program is distributed in the hope that it will be useful, but WITHOUT
696
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
697
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
698
- * more details.
699
- *
700
- * You should have received a copy of the GNU General Public License along with
701
- * this program; if not, write to the Free Software Foundation, Inc., 51
702
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
703
- */
704
-/* This file was originally derived from yara 3.1.0 libyara/lexer.l and is
705
-   revised for running YARA rules in ClamAV. Following is the YARA copyright. */
706
-/*
707
-Copyright (c) 2007-2013. The YARA Authors. All Rights Reserved.
708
-
709
-Licensed under the Apache License, Version 2.0 (the "License");
710
-you may not use this file except in compliance with the License.
711
-You may obtain a copy of the License at
712
-
713
-   http://www.apache.org/licenses/LICENSE-2.0
714
-
715
-Unless required by applicable law or agreed to in writing, software
716
-distributed under the License is distributed on an "AS IS" BASIS,
717
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
718
-See the License for the specific language governing permissions and
719
-limitations under the License.
720
-*/
721
-/* Lexical analyzer for YARA */
722
-#line 42 "yara_lexer.l"
723
-
724
-#include <math.h>
725
-#include <stdio.h>
726
-#ifdef REAL_YARA
727
-#include <stdint.h>
728
-#endif
729
-#include <string.h>
730
-#include <setjmp.h>
731
-
732
-#ifdef REAL_YARA
733
-#include <yara/lexer.h>
734
-#include <yara/rules.h>
735
-#include <yara/sizedstr.h>
736
-#include <yara/error.h>
737
-#include <yara/mem.h>
738
-#include <yara/utils.h>
739
-
740
-#include "grammar.h"
741
-#else
742
-#include "others.h"
743
-#include "yara_clam.h"
744
-#include "yara_grammar.h"
745
-#include "yara_lexer.h"
746
-#endif
747
-
748
-#define LEX_CHECK_SPACE_OK(data, current_size, max_length) \
749
-    if (strlen(data) + current_size >= max_length - 1) \
750
-    { \
751
-      yyerror(yyscanner, compiler, "out of space in lex_buf"); \
752
-      yyterminate(); \
753
-    }
754
-
755
-#define YYTEXT_TO_BUFFER \
756
-    { \
757
-      char *yptr = yytext; \
758
-      LEX_CHECK_SPACE_OK(yptr, yyextra->lex_buf_len, LEX_BUF_SIZE); \
759
-      while(*yptr) \
760
-      { \
761
-        *yyextra->lex_buf_ptr++ = *yptr++; \
762
-        yyextra->lex_buf_len++; \
763
-      } \
764
-    }
765
-
766
-#ifdef _WIN32
767
-#define snprintf _snprintf
768
-#endif
769
-
770
-#line 770 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_lexer.c"
771
-#define YY_NO_UNISTD_H 1
772
-#define YY_NO_INPUT 1
773
-/* %option prefix="yara_yy" */
774
-
775
-#line 775 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_lexer.c"
776
-
777
-#define INITIAL 0
778
-#define str 1
779
-#define regexp 2
780
-#define include 3
781
-#define comment 4
782
-
783
-#ifndef YY_NO_UNISTD_H
784
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
785
- * down here because we want the user's section 1 to have been scanned first.
786
- * The user has a chance to override it with an option.
787
- */
788
-#include <unistd.h>
789
-#endif
790
-    
791
-#ifndef YY_EXTRA_TYPE
792
-#define YY_EXTRA_TYPE void *
793
-#endif
794
-
795
-/* Holds the entire state of the reentrant scanner. */
796
-struct yyguts_t
797
-    {
798
-
799
-    /* User-defined. Not touched by flex. */
800
-    YY_EXTRA_TYPE yyextra_r;
801
-
802
-    /* The rest are the same as the globals declared in the non-reentrant scanner. */
803
-    FILE *yyin_r, *yyout_r;
804
-    size_t yy_buffer_stack_top; /**< index of top of stack. */
805
-    size_t yy_buffer_stack_max; /**< capacity of stack. */
806
-    YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
807
-    char yy_hold_char;
808
-    int yy_n_chars;
809
-    int yyleng_r;
810
-    char *yy_c_buf_p;
811
-    int yy_init;
812
-    int yy_start;
813
-    int yy_did_buffer_switch_on_eof;
814
-    int yy_start_stack_ptr;
815
-    int yy_start_stack_depth;
816
-    int *yy_start_stack;
817
-    yy_state_type yy_last_accepting_state;
818
-    char* yy_last_accepting_cpos;
819
-
820
-    int yylineno_r;
821
-    int yy_flex_debug_r;
822
-
823
-    char *yytext_r;
824
-    int yy_more_flag;
825
-    int yy_more_len;
826
-
827
-    YYSTYPE * yylval_r;
828
-
829
-    }; /* end struct yyguts_t */
830
-
831
-static int yy_init_globals ( yyscan_t yyscanner );
832
-
833
-    /* This must go here because YYSTYPE and YYLTYPE are included
834
-     * from bison output in section 1.*/
835
-    #    define yylval yyg->yylval_r
836
-    
837
-int yylex_init (yyscan_t* scanner);
838
-
839
-int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
840
-
841
-/* Accessor methods to globals.
842
-   These are made visible to non-reentrant scanners for convenience. */
843
-
844
-int yylex_destroy ( yyscan_t yyscanner );
845
-
846
-int yyget_debug ( yyscan_t yyscanner );
847
-
848
-void yyset_debug ( int debug_flag , yyscan_t yyscanner );
849
-
850
-YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
851
-
852
-void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
853
-
854
-FILE *yyget_in ( yyscan_t yyscanner );
855
-
856
-void yyset_in  ( FILE * _in_str , yyscan_t yyscanner );
857
-
858
-FILE *yyget_out ( yyscan_t yyscanner );
859
-
860
-void yyset_out  ( FILE * _out_str , yyscan_t yyscanner );
861
-
862
-			int yyget_leng ( yyscan_t yyscanner );
863
-
864
-char *yyget_text ( yyscan_t yyscanner );
865
-
866
-int yyget_lineno ( yyscan_t yyscanner );
867
-
868
-void yyset_lineno ( int _line_number , yyscan_t yyscanner );
869
-
870
-int yyget_column  ( yyscan_t yyscanner );
871
-
872
-void yyset_column ( int _column_no , yyscan_t yyscanner );
873
-
874
-YYSTYPE * yyget_lval ( yyscan_t yyscanner );
875
-
876
-void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );
877
-
878
-/* Macros after this point can all be overridden by user definitions in
879
- * section 1.
880
- */
881
-
882
-#ifndef YY_SKIP_YYWRAP
883
-#ifdef __cplusplus
884
-extern "C" int yywrap ( yyscan_t yyscanner );
885
-#else
886
-extern int yywrap ( yyscan_t yyscanner );
887
-#endif
888
-#endif
889
-
890
-#ifndef YY_NO_UNPUT
891
-    
892
-#endif
893
-
894
-#ifndef yytext_ptr
895
-static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
896
-#endif
897
-
898
-#ifdef YY_NEED_STRLEN
899
-static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
900
-#endif
901
-
902
-#ifndef YY_NO_INPUT
903
-#ifdef __cplusplus
904
-static int yyinput ( yyscan_t yyscanner );
905
-#else
906
-static int input ( yyscan_t yyscanner );
907
-#endif
908
-
909
-#endif
910
-
911
-/* Amount of stuff to slurp up with each read. */
912
-#ifndef YY_READ_BUF_SIZE
913
-#ifdef __ia64__
914
-/* On IA-64, the buffer size is 16k, not 8k */
915
-#define YY_READ_BUF_SIZE 16384
916
-#else
917
-#define YY_READ_BUF_SIZE 8192
918
-#endif /* __ia64__ */
919
-#endif
920
-
921
-/* Copy whatever the last rule matched to the standard output. */
922
-#ifndef ECHO
923
-/* This used to be an fputs(), but since the string might contain NUL's,
924
- * we now use fwrite().
925
- */
926
-#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
927
-#endif
928
-
929
-/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
930
- * is returned in "result".
931
- */
932
-#ifndef YY_INPUT
933
-#define YY_INPUT(buf,result,max_size) \
934
-	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
935
-		{ \
936
-		int c = '*'; \
937
-		int n; \
938
-		for ( n = 0; n < max_size && \
939
-			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
940
-			buf[n] = (char) c; \
941
-		if ( c == '\n' ) \
942
-			buf[n++] = (char) c; \
943
-		if ( c == EOF && ferror( yyin ) ) \
944
-			YY_FATAL_ERROR( "input in flex scanner failed" ); \
945
-		result = n; \
946
-		} \
947
-	else \
948
-		{ \
949
-		errno=0; \
950
-		while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
951
-			{ \
952
-			if( errno != EINTR) \
953
-				{ \
954
-				YY_FATAL_ERROR( "input in flex scanner failed" ); \
955
-				break; \
956
-				} \
957
-			errno=0; \
958
-			clearerr(yyin); \
959
-			} \
960
-		}\
961
-\
962
-
963
-#endif
964
-
965
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
966
- * we don't want an extra ';' after the "return" because that will cause
967
- * some compilers to complain about unreachable statements.
968
- */
969
-#ifndef yyterminate
970
-#define yyterminate() return YY_NULL
971
-#endif
972
-
973
-/* Number of entries by which start-condition stack grows. */
974
-#ifndef YY_START_STACK_INCR
975
-#define YY_START_STACK_INCR 25
976
-#endif
977
-
978
-/* Report a fatal error. */
979
-#ifndef YY_FATAL_ERROR
980
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
981
-#endif
982
-
983
-/* end tables serialization structures and prototypes */
984
-
985
-/* Default declaration of generated scanner - a define so the user can
986
- * easily add parameters.
987
- */
988
-#ifndef YY_DECL
989
-#define YY_DECL_IS_OURS 1
990
-
991
-extern int yylex \
992
-               (YYSTYPE * yylval_param , yyscan_t yyscanner);
993
-
994
-#define YY_DECL int yylex \
995
-               (YYSTYPE * yylval_param , yyscan_t yyscanner)
996
-#endif /* !YY_DECL */
997
-
998
-/* Code executed at the beginning of each rule, after yytext and yyleng
999
- * have been set up.
1000
- */
1001
-#ifndef YY_USER_ACTION
1002
-#define YY_USER_ACTION
1003
-#endif
1004
-
1005
-/* Code executed at the end of each rule. */
1006
-#ifndef YY_BREAK
1007
-#define YY_BREAK /*LINTED*/break;
1008
-#endif
1009
-
1010
-#define YY_RULE_SETUP \
1011
-	YY_USER_ACTION
1012
-
1013
-/** The main scanner function which does all the work.
1014
- */
1015
-YY_DECL
1016
-{
1017
-	yy_state_type yy_current_state;
1018
-	char *yy_cp, *yy_bp;
1019
-	int yy_act;
1020
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1021
-
1022
-    yylval = yylval_param;
1023
-
1024
-	if ( !yyg->yy_init )
1025
-		{
1026
-		yyg->yy_init = 1;
1027
-
1028
-#ifdef YY_USER_INIT
1029
-		YY_USER_INIT;
1030
-#endif
1031
-
1032
-		if ( ! yyg->yy_start )
1033
-			yyg->yy_start = 1;	/* first start state */
1034
-
1035
-		if ( ! yyin )
1036
-			yyin = stdin;
1037
-
1038
-		if ( ! yyout )
1039
-			yyout = stdout;
1040
-
1041
-		if ( ! YY_CURRENT_BUFFER ) {
1042
-			yyensure_buffer_stack (yyscanner);
1043
-			YY_CURRENT_BUFFER_LVALUE =
1044
-				yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
1045
-		}
1046
-
1047
-		yy_load_buffer_state(yyscanner );
1048
-		}
1049
-
1050
-	{
1051
-#line 111 "yara_lexer.l"
1052
-
1053
-
1054
-#line 1054 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_lexer.c"
1055
-
1056
-	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
1057
-		{
1058
-		yy_cp = yyg->yy_c_buf_p;
1059
-
1060
-		/* Support of yytext. */
1061
-		*yy_cp = yyg->yy_hold_char;
1062
-
1063
-		/* yy_bp points to the position in yy_ch_buf of the start of
1064
-		 * the current run.
1065
-		 */
1066
-		yy_bp = yy_cp;
1067
-
1068
-		yy_current_state = yyg->yy_start;
1069
-yy_match:
1070
-		do
1071
-			{
1072
-			YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
1073
-			if ( yy_accept[yy_current_state] )
1074
-				{
1075
-				yyg->yy_last_accepting_state = yy_current_state;
1076
-				yyg->yy_last_accepting_cpos = yy_cp;
1077
-				}
1078
-			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1079
-				{
1080
-				yy_current_state = (int) yy_def[yy_current_state];
1081
-				if ( yy_current_state >= 219 )
1082
-					yy_c = yy_meta[yy_c];
1083
-				}
1084
-			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1085
-			++yy_cp;
1086
-			}
1087
-		while ( yy_base[yy_current_state] != 357 );
1088
-
1089
-yy_find_action:
1090
-		yy_act = yy_accept[yy_current_state];
1091
-		if ( yy_act == 0 )
1092
-			{ /* have to back up */
1093
-			yy_cp = yyg->yy_last_accepting_cpos;
1094
-			yy_current_state = yyg->yy_last_accepting_state;
1095
-			yy_act = yy_accept[yy_current_state];
1096
-			}
1097
-
1098
-		YY_DO_BEFORE_ACTION;
1099
-
1100
-		if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
1101
-			{
1102
-			int yyl;
1103
-			for ( yyl = 0; yyl < yyleng; ++yyl )
1104
-				if ( yytext[yyl] == '\n' )
1105
-					
1106
-    do{ yylineno++;
1107
-        yycolumn=0;
1108
-    }while(0)
1109
-;
1110
-			}
1111
-
1112
-do_action:	/* This label is used only to access EOF actions. */
1113
-
1114
-		switch ( yy_act )
1115
-	{ /* beginning of action switch */
1116
-			case 0: /* must back up */
1117
-			/* undo the effects of YY_DO_BEFORE_ACTION */
1118
-			*yy_cp = yyg->yy_hold_char;
1119
-			yy_cp = yyg->yy_last_accepting_cpos;
1120
-			yy_current_state = yyg->yy_last_accepting_state;
1121
-			goto yy_find_action;
1122
-
1123
-case 1:
1124
-YY_RULE_SETUP
1125
-#line 113 "yara_lexer.l"
1126
-{ return _LT_;          }
1127
-	YY_BREAK
1128
-case 2:
1129
-YY_RULE_SETUP
1130
-#line 114 "yara_lexer.l"
1131
-{ return _GT_;          }
1132
-	YY_BREAK
1133
-case 3:
1134
-YY_RULE_SETUP
1135
-#line 115 "yara_lexer.l"
1136
-{ return _LE_;          }
1137
-	YY_BREAK
1138
-case 4:
1139
-YY_RULE_SETUP
1140
-#line 116 "yara_lexer.l"
1141
-{ return _GE_;          }
1142
-	YY_BREAK
1143
-case 5:
1144
-YY_RULE_SETUP
1145
-#line 117 "yara_lexer.l"
1146
-{ return _EQ_;          }
1147
-	YY_BREAK
1148
-case 6:
1149
-YY_RULE_SETUP
1150
-#line 118 "yara_lexer.l"
1151
-{ return _NEQ_;         }
1152
-	YY_BREAK
1153
-case 7:
1154
-YY_RULE_SETUP
1155
-#line 119 "yara_lexer.l"
1156
-{ return _SHIFT_LEFT_;  }
1157
-	YY_BREAK
1158
-case 8:
1159
-YY_RULE_SETUP
1160
-#line 120 "yara_lexer.l"
1161
-{ return _SHIFT_RIGHT_; }
1162
-	YY_BREAK
1163
-case 9:
1164
-YY_RULE_SETUP
1165
-#line 121 "yara_lexer.l"
1166
-{ return _PRIVATE_;     }
1167
-	YY_BREAK
1168
-case 10:
1169
-YY_RULE_SETUP
1170
-#line 122 "yara_lexer.l"
1171
-{ return _GLOBAL_;      }
1172
-	YY_BREAK
1173
-case 11:
1174
-YY_RULE_SETUP
1175
-#line 123 "yara_lexer.l"
1176
-{ return _RULE_;        }
1177
-	YY_BREAK
1178
-case 12:
1179
-YY_RULE_SETUP
1180
-#line 124 "yara_lexer.l"
1181
-{ return _META_;        }
1182
-	YY_BREAK
1183
-case 13:
1184
-YY_RULE_SETUP
1185
-#line 125 "yara_lexer.l"
1186
-{ return _STRINGS_;     }
1187
-	YY_BREAK
1188
-case 14:
1189
-YY_RULE_SETUP
1190
-#line 126 "yara_lexer.l"
1191
-{ return _ASCII_;       }
1192
-	YY_BREAK
1193
-case 15:
1194
-YY_RULE_SETUP
1195
-#line 127 "yara_lexer.l"
1196
-{ return _WIDE_;        }
1197
-	YY_BREAK
1198
-case 16:
1199
-YY_RULE_SETUP
1200
-#line 128 "yara_lexer.l"
1201
-{ return _FULLWORD_;    }
1202
-	YY_BREAK
1203
-case 17:
1204
-YY_RULE_SETUP
1205
-#line 129 "yara_lexer.l"
1206
-{ return _NOCASE_;      }
1207
-	YY_BREAK
1208
-case 18:
1209
-YY_RULE_SETUP
1210
-#line 130 "yara_lexer.l"
1211
-{ return _CONDITION_;   }
1212
-	YY_BREAK
1213
-case 19:
1214
-YY_RULE_SETUP
1215
-#line 131 "yara_lexer.l"
1216
-{ return _TRUE_;        }
1217
-	YY_BREAK
1218
-case 20:
1219
-YY_RULE_SETUP
1220
-#line 132 "yara_lexer.l"
1221
-{ return _FALSE_;       }
1222
-	YY_BREAK
1223
-case 21:
1224
-YY_RULE_SETUP
1225
-#line 133 "yara_lexer.l"
1226
-{ return _NOT_;         }
1227
-	YY_BREAK
1228
-case 22:
1229
-YY_RULE_SETUP
1230
-#line 134 "yara_lexer.l"
1231
-{ return _AND_;         }
1232
-	YY_BREAK
1233
-case 23:
1234
-YY_RULE_SETUP
1235
-#line 135 "yara_lexer.l"
1236
-{ return _OR_;          }
1237
-	YY_BREAK
1238
-case 24:
1239
-YY_RULE_SETUP
1240
-#line 136 "yara_lexer.l"
1241
-{ return _AT_;          }
1242
-	YY_BREAK
1243
-case 25:
1244
-YY_RULE_SETUP
1245
-#line 137 "yara_lexer.l"
1246
-{ return _IN_;          }
1247
-	YY_BREAK
1248
-case 26:
1249
-YY_RULE_SETUP
1250
-#line 138 "yara_lexer.l"
1251
-{ return _OF_;          }
1252
-	YY_BREAK
1253
-case 27:
1254
-YY_RULE_SETUP
1255
-#line 139 "yara_lexer.l"
1256
-{ return _THEM_;        }
1257
-	YY_BREAK
1258
-case 28:
1259
-YY_RULE_SETUP
1260
-#line 140 "yara_lexer.l"
1261
-{ return _FOR_;         }
1262
-	YY_BREAK
1263
-case 29:
1264
-YY_RULE_SETUP
1265
-#line 141 "yara_lexer.l"
1266
-{ return _ALL_;         }
1267
-	YY_BREAK
1268
-case 30:
1269
-YY_RULE_SETUP
1270
-#line 142 "yara_lexer.l"
1271
-{ return _ANY_;         }
1272
-	YY_BREAK
1273
-case 31:
1274
-YY_RULE_SETUP
1275
-#line 143 "yara_lexer.l"
1276
-{ return _ENTRYPOINT_;  }
1277
-	YY_BREAK
1278
-case 32:
1279
-YY_RULE_SETUP
1280
-#line 144 "yara_lexer.l"
1281
-{ return _FILESIZE_;    }
1282
-	YY_BREAK
1283
-case 33:
1284
-YY_RULE_SETUP
1285
-#line 145 "yara_lexer.l"
1286
-{ return _UINT8_;       }
1287
-	YY_BREAK
1288
-case 34:
1289
-YY_RULE_SETUP
1290
-#line 146 "yara_lexer.l"
1291
-{ return _UINT16_;      }
1292
-	YY_BREAK
1293
-case 35:
1294
-YY_RULE_SETUP
1295
-#line 147 "yara_lexer.l"
1296
-{ return _UINT32_;      }
1297
-	YY_BREAK
1298
-case 36:
1299
-YY_RULE_SETUP
1300
-#line 148 "yara_lexer.l"
1301
-{ return _INT8_;        }
1302
-	YY_BREAK
1303
-case 37:
1304
-YY_RULE_SETUP
1305
-#line 149 "yara_lexer.l"
1306
-{ return _INT16_;       }
1307
-	YY_BREAK
1308
-case 38:
1309
-YY_RULE_SETUP
1310
-#line 150 "yara_lexer.l"
1311
-{ return _INT32_;       }
1312
-	YY_BREAK
1313
-case 39:
1314
-YY_RULE_SETUP
1315
-#line 151 "yara_lexer.l"
1316
-{ return _MATCHES_;     }
1317
-	YY_BREAK
1318
-case 40:
1319
-YY_RULE_SETUP
1320
-#line 152 "yara_lexer.l"
1321
-{ return _CONTAINS_;    }
1322
-	YY_BREAK
1323
-case 41:
1324
-YY_RULE_SETUP
1325
-#line 153 "yara_lexer.l"
1326
-{ return _IMPORT_;      }
1327
-	YY_BREAK
1328
-case 42:
1329
-YY_RULE_SETUP
1330
-#line 156 "yara_lexer.l"
1331
-{ BEGIN(comment);       }
1332
-	YY_BREAK
1333
-case 43:
1334
-YY_RULE_SETUP
1335
-#line 157 "yara_lexer.l"
1336
-{ BEGIN(INITIAL);       }
1337
-	YY_BREAK
1338
-case 44:
1339
-/* rule 44 can match eol */
1340
-YY_RULE_SETUP
1341
-#line 158 "yara_lexer.l"
1342
-{ /* skip comments */   }
1343
-	YY_BREAK
1344
-case 45:
1345
-YY_RULE_SETUP
1346
-#line 161 "yara_lexer.l"
1347
-{ /* skip single-line comments */ }
1348
-	YY_BREAK
1349
-case 46:
1350
-YY_RULE_SETUP
1351
-#line 164 "yara_lexer.l"
1352
-{
1353
-                          yyextra->lex_buf_ptr = yyextra->lex_buf;
1354
-                          yyextra->lex_buf_len = 0;
1355
-                          BEGIN(include);
1356
-                        }
1357
-	YY_BREAK
1358
-case 47:
1359
-/* rule 47 can match eol */
1360
-YY_RULE_SETUP
1361
-#line 171 "yara_lexer.l"
1362
-{ YYTEXT_TO_BUFFER; }
1363
-	YY_BREAK
1364
-case 48:
1365
-YY_RULE_SETUP
1366
-#line 174 "yara_lexer.l"
1367
-{
1368
-
1369
-  char            buffer[1024];
1370
-  char            *current_file_name;
1371
-  char            *s = NULL;
1372
-  char            *b = NULL;
1373
-  char            *f;
1374
-  FILE*           fh;
1375
-
1376
-  if (compiler->allow_includes)
1377
-  {
1378
-    *yyextra->lex_buf_ptr = '\0'; // null-terminate included file path
1379
-
1380
-    // move path of current source file into buffer
1381
-    current_file_name = yr_compiler_get_current_file_name(compiler);
1382
-
1383
-    if (current_file_name != NULL)
1384
-    {
1385
-      strlcpy(buffer, current_file_name, sizeof(buffer));
1386
-    }
1387
-    else
1388
-    {
1389
-      buffer[0] = '\0';
1390
-    }
1391
-
1392
-    // make included file path relative to current source file
1393
-    s = strrchr(buffer, '/');
1394
-
1395
-    #ifdef _WIN32
1396
-    b = strrchr(buffer, '\\'); // in Windows both path delimiters are accepted
1397
-    #endif
1398
-
1399
-    if (s != NULL || b != NULL)
1400
-    {
1401
-      f = (b > s)? (b + 1): (s + 1);
1402
-
1403
-      strlcpy(f, yyextra->lex_buf, sizeof(buffer) - (f - buffer));
1404
-
1405
-      f = buffer;
1406
-
1407
-      // SECURITY: Potential for directory traversal here.
1408
-      fh = fopen(buffer, "r");
1409
-
1410
-      // if include file was not found relative to current source file,
1411
-      // try to open it with path as specified by user (maybe user wrote
1412
-      // a full path)
1413
-
1414
-      if (fh == NULL)
1415
-      {
1416
-        f = yyextra->lex_buf;
1417
-
1418
-        // SECURITY: Potential for directory traversal here.
1419
-        fh = fopen(yyextra->lex_buf, "r");
1420
-      }
1421
-    }
1422
-    else
1423
-    {
1424
-      f = yyextra->lex_buf;
1425
-
1426
-      // SECURITY: Potential for directory traversal here.
1427
-      fh = fopen(yyextra->lex_buf, "r");
1428
-    }
1429
-
1430
-    if (fh != NULL)
1431
-    {
1432
-      int error_code = _yr_compiler_push_file_name(compiler, f);
1433
-
1434
-      if (error_code != ERROR_SUCCESS)
1435
-      {
1436
-        if (error_code == ERROR_INCLUDES_CIRCULAR_REFERENCE)
1437
-        {
1438
-          yyerror(yyscanner, compiler, "includes circular reference");
1439
-        }
1440
-        else if (error_code == ERROR_INCLUDE_DEPTH_EXCEEDED)
1441
-        {
1442
-          yyerror(yyscanner, compiler, "includes depth exceeded");
1443
-        }
1444
-
1445
-        yyterminate();
1446
-      }
1447
-
1448
-      _yr_compiler_push_file(compiler, fh);
1449
-      yypush_buffer_state(
1450
-          yy_create_buffer(fh, YY_BUF_SIZE, yyscanner), yyscanner);
1451
-    }
1452
-    else
1453
-    {
1454
-      snprintf(buffer, sizeof(buffer),
1455
-               "can't open include file: %s", yyextra->lex_buf);
1456
-      yyerror(yyscanner, compiler, buffer);
1457
-    }
1458
-  }
1459
-  else // not allowing includes
1460
-  {
1461
-    yyerror(yyscanner, compiler, "includes are disabled");
1462
-    yyterminate();
1463
-  }
1464
-
1465
-  BEGIN(INITIAL);
1466
-}
1467
-	YY_BREAK
1468
-case YY_STATE_EOF(INITIAL):
1469
-case YY_STATE_EOF(str):
1470
-case YY_STATE_EOF(regexp):
1471
-case YY_STATE_EOF(include):
1472
-case YY_STATE_EOF(comment):
1473
-#line 276 "yara_lexer.l"
1474
-{
1475
-
1476
-  YR_COMPILER* compiler = yyget_extra(yyscanner);
1477
-  FILE* file = _yr_compiler_pop_file(compiler);
1478
-
1479
-  if (file != NULL)
1480
-  {
1481
-    fclose(file);
1482
-  }
1483
-
1484
-  _yr_compiler_pop_file_name(compiler);
1485
-  yypop_buffer_state(yyscanner);
1486
-
1487
-  if (!YY_CURRENT_BUFFER)
1488
-  {
1489
-    yyterminate();
1490
-  }
1491
-}
1492
-	YY_BREAK
1493
-case 49:
1494
-YY_RULE_SETUP
1495
-#line 296 "yara_lexer.l"
1496
-{
1497
-
1498
-  yylval->c_string = yr_strdup(yytext);
1499
-
1500
-  if (yylval->c_string == NULL)
1501
-  {
1502
-    yyerror(yyscanner, compiler, "not enough memory");
1503
-    yyterminate();
1504
-  }
1505
-
1506
-  return _STRING_IDENTIFIER_WITH_WILDCARD_;
1507
-}
1508
-	YY_BREAK
1509
-case 50:
1510
-YY_RULE_SETUP
1511
-#line 310 "yara_lexer.l"
1512
-{
1513
-
1514
-  yylval->c_string = yr_strdup(yytext);
1515
-
1516
-  if (yylval->c_string == NULL)
1517
-  {
1518
-    yyerror(yyscanner, compiler, "not enough memory");
1519
-    yyterminate();
1520
-  }
1521
-
1522
-  return _STRING_IDENTIFIER_;
1523
-}
1524
-	YY_BREAK
1525
-case 51:
1526
-YY_RULE_SETUP
1527
-#line 324 "yara_lexer.l"
1528
-{
1529
-
1530
-  yylval->c_string = yr_strdup(yytext);
1531
-
1532
-  if (yylval->c_string == NULL)
1533
-  {
1534
-    yyerror(yyscanner, compiler, "not enough memory");
1535
-    yyterminate();
1536
-  }
1537
-
1538
-  yylval->c_string[0] = '$'; /* replace # by $*/
1539
-  return _STRING_COUNT_;
1540
-}
1541
-	YY_BREAK
1542
-case 52:
1543
-YY_RULE_SETUP
1544
-#line 339 "yara_lexer.l"
1545
-{
1546
-
1547
-  yylval->c_string = yr_strdup(yytext);
1548
-
1549
-  if (yylval->c_string == NULL)
1550
-  {
1551
-    yyerror(yyscanner, compiler, "not enough memory");
1552
-    yyterminate();
1553
-  }
1554
-
1555
-  yylval->c_string[0] = '$'; /* replace @ by $*/
1556
-  return _STRING_OFFSET_;
1557
-}
1558
-	YY_BREAK
1559
-case 53:
1560
-YY_RULE_SETUP
1561
-#line 354 "yara_lexer.l"
1562
-{
1563
-
1564
-  if (strlen(yytext) > 128)
1565
-  {
1566
-    yyerror(yyscanner, compiler, "indentifier too long");
1567
-  }
1568
-
1569
-  yylval->c_string = yr_strdup(yytext);
1570
-
1571
-  if (yylval->c_string == NULL)
1572
-  {
1573
-    yyerror(yyscanner, compiler, "not enough memory");
1574
-    yyterminate();
1575
-  }
1576
-  return _IDENTIFIER_;
1577
-}
1578
-	YY_BREAK
1579
-case 54:
1580
-YY_RULE_SETUP
1581
-#line 372 "yara_lexer.l"
1582
-{
1583
-
1584
-  yylval->integer = (size_t) atol(yytext);
1585
-
1586
-  if (strstr(yytext, "KB") != NULL)
1587
-  {
1588
-     yylval->integer *= 1024;
1589
-  }
1590
-  else if (strstr(yytext, "MB") != NULL)
1591
-  {
1592
-     yylval->integer *= 1048576;
1593
-  }
1594
-  return _NUMBER_;
1595
-}
1596
-	YY_BREAK
1597
-case 55:
1598
-YY_RULE_SETUP
1599
-#line 388 "yara_lexer.l"
1600
-{
1601
-
1602
-  yylval->integer = xtoi(yytext + 2);
1603
-  return _NUMBER_;
1604
-}
1605
-	YY_BREAK
1606
-case 56:
1607
-YY_RULE_SETUP
1608
-#line 395 "yara_lexer.l"
1609
-{     /* saw closing quote - all done */
1610
-
1611
-  SIZED_STRING* s;
1612
-
1613
-  if (yyextra->lex_buf_len == 0)
1614
-  {
1615
-    yyerror(yyscanner, compiler, "empty string");
1616
-  }
1617
-
1618
-  *yyextra->lex_buf_ptr = '\0';
1619
-
1620
-  BEGIN(INITIAL);
1621
-
1622
-  s = (SIZED_STRING*) yr_malloc(yyextra->lex_buf_len + sizeof(SIZED_STRING));
1623
-  s->length = yyextra->lex_buf_len;
1624
-  s->flags = 0;
1625
-
1626
-  memcpy(s->c_string, yyextra->lex_buf, yyextra->lex_buf_len + 1);
1627
-  yylval->sized_string = s;
1628
-
1629
-  return _TEXT_STRING_;
1630
-}
1631
-	YY_BREAK
1632
-case 57:
1633
-YY_RULE_SETUP
1634
-#line 419 "yara_lexer.l"
1635
-{
1636
-
1637
-  LEX_CHECK_SPACE_OK("\t", yyextra->lex_buf_len, LEX_BUF_SIZE);
1638
-  *yyextra->lex_buf_ptr++ = '\t';
1639
-  yyextra->lex_buf_len++;
1640
-}
1641
-	YY_BREAK
1642
-case 58:
1643
-YY_RULE_SETUP
1644
-#line 427 "yara_lexer.l"
1645
-{
1646
-
1647
-  LEX_CHECK_SPACE_OK("\n", yyextra->lex_buf_len, LEX_BUF_SIZE);
1648
-  *yyextra->lex_buf_ptr++ = '\n';
1649
-  yyextra->lex_buf_len++;
1650
-}
1651
-	YY_BREAK
1652
-case 59:
1653
-YY_RULE_SETUP
1654
-#line 435 "yara_lexer.l"
1655
-{
1656
-
1657
-  LEX_CHECK_SPACE_OK("\"", yyextra->lex_buf_len, LEX_BUF_SIZE);
1658
-  *yyextra->lex_buf_ptr++ = '\"';
1659
-  yyextra->lex_buf_len++;
1660
-}
1661
-	YY_BREAK
1662
-case 60:
1663
-YY_RULE_SETUP
1664
-#line 443 "yara_lexer.l"
1665
-{
1666
-
1667
-  LEX_CHECK_SPACE_OK("\\", yyextra->lex_buf_len, LEX_BUF_SIZE);
1668
-  *yyextra->lex_buf_ptr++ = '\\';
1669
-  yyextra->lex_buf_len++;
1670
-}
1671
-	YY_BREAK
1672
-case 61:
1673
-YY_RULE_SETUP
1674
-#line 451 "yara_lexer.l"
1675
-{
1676
-
1677
-   int result;
1678
-
1679
-   sscanf( yytext + 2, "%x", &result );
1680
-   LEX_CHECK_SPACE_OK("X", yyextra->lex_buf_len, LEX_BUF_SIZE);
1681
-   *yyextra->lex_buf_ptr++ = result;
1682
-   yyextra->lex_buf_len++;
1683
-}
1684
-	YY_BREAK
1685
-case 62:
1686
-YY_RULE_SETUP
1687
-#line 462 "yara_lexer.l"
1688
-{ YYTEXT_TO_BUFFER; }
1689
-	YY_BREAK
1690
-case 63:
1691
-/* rule 63 can match eol */
1692
-YY_RULE_SETUP
1693
-#line 465 "yara_lexer.l"
1694
-{
1695
-
1696
-  yyerror(yyscanner, compiler, "unterminated string");
1697
-  yyterminate();
1698
-}
1699
-	YY_BREAK
1700
-case 64:
1701
-/* rule 64 can match eol */
1702
-YY_RULE_SETUP
1703
-#line 471 "yara_lexer.l"
1704
-{
1705
-
1706
-  yyerror(yyscanner, compiler, "illegal escape sequence");
1707
-}
1708
-	YY_BREAK
1709
-case 65:
1710
-YY_RULE_SETUP
1711
-#line 477 "yara_lexer.l"
1712
-{
1713
-
1714
-  SIZED_STRING* s;
1715
-
1716
-  if (yyextra->lex_buf_len == 0)
1717
-  {
1718
-    yyerror(yyscanner, compiler, "empty regular expression");
1719
-  }
1720
-
1721
-  *yyextra->lex_buf_ptr = '\0';
1722
-
1723
-  BEGIN(INITIAL);
1724
-
1725
-  s = (SIZED_STRING*) yr_malloc(yyextra->lex_buf_len + sizeof(SIZED_STRING));
1726
-  s->flags = 0;
1727
-
1728
-  if (yytext[1] == 'i')
1729
-    s->flags |= SIZED_STRING_FLAGS_NO_CASE;
1730
-
1731
-  if (yytext[1] == 's' || yytext[2] == 's')
1732
-    s->flags |= SIZED_STRING_FLAGS_DOT_ALL;
1733
-
1734
-  s->length = yyextra->lex_buf_len;
1735
-  strlcpy(s->c_string, yyextra->lex_buf, s->length + 1);
1736
-
1737
-  yylval->sized_string = s;
1738
-
1739
-  return _REGEXP_;
1740
-}
1741
-	YY_BREAK
1742
-case 66:
1743
-YY_RULE_SETUP
1744
-#line 508 "yara_lexer.l"
1745
-{
1746
-
1747
-  LEX_CHECK_SPACE_OK("/", yyextra->lex_buf_len, LEX_BUF_SIZE);
1748
-  *yyextra->lex_buf_ptr++ = '/';
1749
-  yyextra->lex_buf_len++ ;
1750
-}
1751
-	YY_BREAK
1752
-case 67:
1753
-YY_RULE_SETUP
1754
-#line 516 "yara_lexer.l"
1755
-{
1756
-
1757
-  LEX_CHECK_SPACE_OK("\\.", yyextra->lex_buf_len, LEX_BUF_SIZE);
1758
-  *yyextra->lex_buf_ptr++ = yytext[0];
1759
-  *yyextra->lex_buf_ptr++ = yytext[1];
1760
-  yyextra->lex_buf_len += 2;
1761
-}
1762
-	YY_BREAK
1763
-case 68:
1764
-YY_RULE_SETUP
1765
-#line 525 "yara_lexer.l"
1766
-{ YYTEXT_TO_BUFFER; }
1767
-	YY_BREAK
1768
-case 69:
1769
-/* rule 69 can match eol */
1770
-YY_RULE_SETUP
1771
-#line 528 "yara_lexer.l"
1772
-{
1773
-
1774
-  yyerror(yyscanner, compiler, "unterminated regular expression");
1775
-  yyterminate();
1776
-}
1777
-	YY_BREAK
1778
-case 70:
1779
-YY_RULE_SETUP
1780
-#line 535 "yara_lexer.l"
1781
-{
1782
-
1783
-  yyextra->lex_buf_ptr = yyextra->lex_buf;
1784
-  yyextra->lex_buf_len = 0;
1785
-  BEGIN(str);
1786
-}
1787
-	YY_BREAK
1788
-case 71:
1789
-YY_RULE_SETUP
1790
-#line 543 "yara_lexer.l"
1791
-{
1792
-
1793
-  yyextra->lex_buf_ptr = yyextra->lex_buf;
1794
-  yyextra->lex_buf_len = 0;
1795
-  BEGIN(regexp);
1796
-}
1797
-	YY_BREAK
1798
-case 72:
1799
-/* rule 72 can match eol */
1800
-YY_RULE_SETUP
1801
-#line 551 "yara_lexer.l"
1802
-{
1803
-
1804
-  int len = strlen(yytext);
1805
-  SIZED_STRING* s = (SIZED_STRING*) yr_malloc(len + sizeof(SIZED_STRING));
1806
-
1807
-  s->length = len;
1808
-  s->flags = 0;
1809
-
1810
-  strlcpy(s->c_string, yytext, s->length + 1);
1811
-  yylval->sized_string = s;
1812
-
1813
-  return _HEX_STRING_;
1814
-}
1815
-	YY_BREAK
1816
-case 73:
1817
-/* rule 73 can match eol */
1818
-YY_RULE_SETUP
1819
-#line 566 "yara_lexer.l"
1820
-/* skip whitespace */
1821
-	YY_BREAK
1822
-case 74:
1823
-YY_RULE_SETUP
1824
-#line 568 "yara_lexer.l"
1825
-{
1826
-
1827
-  if (yytext[0] >= 32 && yytext[0] < 127)
1828
-  {
1829
-    return yytext[0];
1830
-  }
1831
-  else
1832
-  {
1833
-    yyerror(yyscanner, compiler, "non-ascii character");
1834
-    yyterminate();
1835
-  }
1836
-}
1837
-	YY_BREAK
1838
-case 75:
1839
-YY_RULE_SETUP
1840
-#line 581 "yara_lexer.l"
1841
-ECHO;
1842
-	YY_BREAK
1843
-#line 1843 "C:/Users/micasnyd/workspace/clamav-micasnyd/build/libclamav/yara_lexer.c"
1844
-
1845
-	case YY_END_OF_BUFFER:
1846
-		{
1847
-		/* Amount of text matched not including the EOB char. */
1848
-		int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1849
-
1850
-		/* Undo the effects of YY_DO_BEFORE_ACTION. */
1851
-		*yy_cp = yyg->yy_hold_char;
1852
-		YY_RESTORE_YY_MORE_OFFSET
1853
-
1854
-		if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1855
-			{
1856
-			/* We're scanning a new file or input source.  It's
1857
-			 * possible that this happened because the user
1858
-			 * just pointed yyin at a new source and called
1859
-			 * yylex().  If so, then we have to assure
1860
-			 * consistency between YY_CURRENT_BUFFER and our
1861
-			 * globals.  Here is the right place to do so, because
1862
-			 * this is the first action (other than possibly a
1863
-			 * back-up) that will match for the new input source.
1864
-			 */
1865
-			yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1866
-			YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1867
-			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1868
-			}
1869
-
1870
-		/* Note that here we test for yy_c_buf_p "<=" to the position
1871
-		 * of the first EOB in the buffer, since yy_c_buf_p will
1872
-		 * already have been incremented past the NUL character
1873
-		 * (since all states make transitions on EOB to the
1874
-		 * end-of-buffer state).  Contrast this with the test
1875
-		 * in input().
1876
-		 */
1877
-		if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1878
-			{ /* This was really a NUL. */
1879
-			yy_state_type yy_next_state;
1880
-
1881
-			yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1882
-
1883
-			yy_current_state = yy_get_previous_state( yyscanner );
1884
-
1885
-			/* Okay, we're now positioned to make the NUL
1886
-			 * transition.  We couldn't have
1887
-			 * yy_get_previous_state() go ahead and do it
1888
-			 * for us because it doesn't know how to deal
1889
-			 * with the possibility of jamming (and we don't
1890
-			 * want to build jamming into it because then it
1891
-			 * will run more slowly).
1892
-			 */
1893
-
1894
-			yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1895
-
1896
-			yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1897
-
1898
-			if ( yy_next_state )
1899
-				{
1900
-				/* Consume the NUL. */
1901
-				yy_cp = ++yyg->yy_c_buf_p;
1902
-				yy_current_state = yy_next_state;
1903
-				goto yy_match;
1904
-				}
1905
-
1906
-			else
1907
-				{
1908
-				yy_cp = yyg->yy_c_buf_p;
1909
-				goto yy_find_action;
1910
-				}
1911
-			}
1912
-
1913
-		else switch ( yy_get_next_buffer( yyscanner ) )
1914
-			{
1915
-			case EOB_ACT_END_OF_FILE:
1916
-				{
1917
-				yyg->yy_did_buffer_switch_on_eof = 0;
1918
-
1919
-				if ( yywrap(yyscanner ) )
1920
-					{
1921
-					/* Note: because we've taken care in
1922
-					 * yy_get_next_buffer() to have set up
1923
-					 * yytext, we can now set up
1924
-					 * yy_c_buf_p so that if some total
1925
-					 * hoser (like flex itself) wants to
1926
-					 * call the scanner after we return the
1927
-					 * YY_NULL, it'll still work - another
1928
-					 * YY_NULL will get returned.
1929
-					 */
1930
-					yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1931
-
1932
-					yy_act = YY_STATE_EOF(YY_START);
1933
-					goto do_action;
1934
-					}
1935
-
1936
-				else
1937
-					{
1938
-					if ( ! yyg->yy_did_buffer_switch_on_eof )
1939
-						YY_NEW_FILE;
1940
-					}
1941
-				break;
1942
-				}
1943
-
1944
-			case EOB_ACT_CONTINUE_SCAN:
1945
-				yyg->yy_c_buf_p =
1946
-					yyg->yytext_ptr + yy_amount_of_matched_text;
1947
-
1948
-				yy_current_state = yy_get_previous_state( yyscanner );
1949
-
1950
-				yy_cp = yyg->yy_c_buf_p;
1951
-				yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1952
-				goto yy_match;
1953
-
1954
-			case EOB_ACT_LAST_MATCH:
1955
-				yyg->yy_c_buf_p =
1956
-				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1957
-
1958
-				yy_current_state = yy_get_previous_state( yyscanner );
1959
-
1960
-				yy_cp = yyg->yy_c_buf_p;
1961
-				yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1962
-				goto yy_find_action;
1963
-			}
1964
-		break;
1965
-		}
1966
-
1967
-	default:
1968
-		YY_FATAL_ERROR(
1969
-			"fatal flex scanner internal error--no action found" );
1970
-	} /* end of action switch */
1971
-		} /* end of scanning one token */
1972
-	} /* end of user's declarations */
1973
-} /* end of yylex */
1974
-
1975
-/* yy_get_next_buffer - try to read in a new buffer
1976
- *
1977
- * Returns a code representing an action:
1978
- *	EOB_ACT_LAST_MATCH -
1979
- *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1980
- *	EOB_ACT_END_OF_FILE - end of file
1981
- */
1982
-static int yy_get_next_buffer (yyscan_t yyscanner)
1983
-{
1984
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1985
-	char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1986
-	char *source = yyg->yytext_ptr;
1987
-	int number_to_move, i;
1988
-	int ret_val;
1989
-
1990
-	if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1991
-		YY_FATAL_ERROR(
1992
-		"fatal flex scanner internal error--end of buffer missed" );
1993
-
1994
-	if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1995
-		{ /* Don't try to fill the buffer, so this is an EOF. */
1996
-		if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1997
-			{
1998
-			/* We matched a single character, the EOB, so
1999
-			 * treat this as a final EOF.
2000
-			 */
2001
-			return EOB_ACT_END_OF_FILE;
2002
-			}
2003
-
2004
-		else
2005
-			{
2006
-			/* We matched some text prior to the EOB, first
2007
-			 * process it.
2008
-			 */
2009
-			return EOB_ACT_LAST_MATCH;
2010
-			}
2011
-		}
2012
-
2013
-	/* Try to read more data. */
2014
-
2015
-	/* First move last chars to start of buffer. */
2016
-	number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
2017
-
2018
-	for ( i = 0; i < number_to_move; ++i )
2019
-		*(dest++) = *(source++);
2020
-
2021
-	if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
2022
-		/* don't do the read, it's not guaranteed to return an EOF,
2023
-		 * just force an EOF
2024
-		 */
2025
-		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
2026
-
2027
-	else
2028
-		{
2029
-			int num_to_read =
2030
-			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
2031
-
2032
-		while ( num_to_read <= 0 )
2033
-			{ /* Not enough room in the buffer - grow it. */
2034
-
2035
-			/* just a shorter name for the current buffer */
2036
-			YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
2037
-
2038
-			int yy_c_buf_p_offset =
2039
-				(int) (yyg->yy_c_buf_p - b->yy_ch_buf);
2040
-
2041
-			if ( b->yy_is_our_buffer )
2042
-				{
2043
-				int new_size = b->yy_buf_size * 2;
2044
-
2045
-				if ( new_size <= 0 )
2046
-					b->yy_buf_size += b->yy_buf_size / 8;
2047
-				else
2048
-					b->yy_buf_size *= 2;
2049
-
2050
-				b->yy_ch_buf = (char *)
2051
-					/* Include room in for 2 EOB chars. */
2052
-					yyrealloc((void *) b->yy_ch_buf,(yy_size_t) (b->yy_buf_size + 2) ,yyscanner );
2053
-				}
2054
-			else
2055
-				/* Can't grow it, we don't own it. */
2056
-				b->yy_ch_buf = NULL;
2057
-
2058
-			if ( ! b->yy_ch_buf )
2059
-				YY_FATAL_ERROR(
2060
-				"fatal error - scanner input buffer overflow" );
2061
-
2062
-			yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
2063
-
2064
-			num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
2065
-						number_to_move - 1;
2066
-
2067
-			}
2068
-
2069
-		if ( num_to_read > YY_READ_BUF_SIZE )
2070
-			num_to_read = YY_READ_BUF_SIZE;
2071
-
2072
-		/* Read in more data. */
2073
-		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
2074
-			yyg->yy_n_chars, num_to_read );
2075
-
2076
-		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2077
-		}
2078
-
2079
-	if ( yyg->yy_n_chars == 0 )
2080
-		{
2081
-		if ( number_to_move == YY_MORE_ADJ )
2082
-			{
2083
-			ret_val = EOB_ACT_END_OF_FILE;
2084
-			yyrestart(yyin  ,yyscanner);
2085
-			}
2086
-
2087
-		else
2088
-			{
2089
-			ret_val = EOB_ACT_LAST_MATCH;
2090
-			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
2091
-				YY_BUFFER_EOF_PENDING;
2092
-			}
2093
-		}
2094
-
2095
-	else
2096
-		ret_val = EOB_ACT_CONTINUE_SCAN;
2097
-
2098
-	if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
2099
-		/* Extend the array by 50%, plus the number we really need. */
2100
-		int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
2101
-		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,(yy_size_t) new_size ,yyscanner );
2102
-		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
2103
-			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
2104
-	}
2105
-
2106
-	yyg->yy_n_chars += number_to_move;
2107
-	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
2108
-	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
2109
-
2110
-	yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
2111
-
2112
-	return ret_val;
2113
-}
2114
-
2115
-/* yy_get_previous_state - get the state just before the EOB char was reached */
2116
-
2117
-    static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
2118
-{
2119
-	yy_state_type yy_current_state;
2120
-	char *yy_cp;
2121
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2122
-
2123
-	yy_current_state = yyg->yy_start;
2124
-
2125
-	for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
2126
-		{
2127
-		YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
2128
-		if ( yy_accept[yy_current_state] )
2129
-			{
2130
-			yyg->yy_last_accepting_state = yy_current_state;
2131
-			yyg->yy_last_accepting_cpos = yy_cp;
2132
-			}
2133
-		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
2134
-			{
2135
-			yy_current_state = (int) yy_def[yy_current_state];
2136
-			if ( yy_current_state >= 219 )
2137
-				yy_c = yy_meta[yy_c];
2138
-			}
2139
-		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
2140
-		}
2141
-
2142
-	return yy_current_state;
2143
-}
2144
-
2145
-/* yy_try_NUL_trans - try to make a transition on the NUL character
2146
- *
2147
- * synopsis
2148
- *	next_state = yy_try_NUL_trans( current_state );
2149
- */
2150
-    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
2151
-{
2152
-	int yy_is_jam;
2153
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
2154
-	char *yy_cp = yyg->yy_c_buf_p;
2155
-
2156
-	YY_CHAR yy_c = 1;
2157
-	if ( yy_accept[yy_current_state] )
2158
-		{
2159
-		yyg->yy_last_accepting_state = yy_current_state;
2160
-		yyg->yy_last_accepting_cpos = yy_cp;
2161
-		}
2162
-	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
2163
-		{
2164
-		yy_current_state = (int) yy_def[yy_current_state];
2165
-		if ( yy_current_state >= 219 )
2166
-			yy_c = yy_meta[yy_c];
2167
-		}
2168
-	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
2169
-	yy_is_jam = (yy_current_state == 218);
2170
-
2171
-	(void)yyg;
2172
-	return yy_is_jam ? 0 : yy_current_state;
2173
-}
2174
-
2175
-#ifndef YY_NO_UNPUT
2176
-
2177
-#endif
2178
-
2179
-#ifndef YY_NO_INPUT
2180
-#ifdef __cplusplus
2181
-    static int yyinput (yyscan_t yyscanner)
2182
-#else
2183
-    static int input  (yyscan_t yyscanner)
2184
-#endif
2185
-
2186
-{
2187
-	int c;
2188
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2189
-
2190
-	*yyg->yy_c_buf_p = yyg->yy_hold_char;
2191
-
2192
-	if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
2193
-		{
2194
-		/* yy_c_buf_p now points to the character we want to return.
2195
-		 * If this occurs *before* the EOB characters, then it's a
2196
-		 * valid NUL; if not, then we've hit the end of the buffer.
2197
-		 */
2198
-		if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
2199
-			/* This was really a NUL. */
2200
-			*yyg->yy_c_buf_p = '\0';
2201
-
2202
-		else
2203
-			{ /* need more input */
2204
-			int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
2205
-			++yyg->yy_c_buf_p;
2206
-
2207
-			switch ( yy_get_next_buffer( yyscanner ) )
2208
-				{
2209
-				case EOB_ACT_LAST_MATCH:
2210
-					/* This happens because yy_g_n_b()
2211
-					 * sees that we've accumulated a
2212
-					 * token and flags that we need to
2213
-					 * try matching the token before
2214
-					 * proceeding.  But for input(),
2215
-					 * there's no matching to consider.
2216
-					 * So convert the EOB_ACT_LAST_MATCH
2217
-					 * to EOB_ACT_END_OF_FILE.
2218
-					 */
2219
-
2220
-					/* Reset buffer status. */
2221
-					yyrestart(yyin ,yyscanner);
2222
-
2223
-					/*FALLTHROUGH*/
2224
-
2225
-				case EOB_ACT_END_OF_FILE:
2226
-					{
2227
-					if ( yywrap(yyscanner ) )
2228
-						return 0;
2229
-
2230
-					if ( ! yyg->yy_did_buffer_switch_on_eof )
2231
-						YY_NEW_FILE;
2232
-#ifdef __cplusplus
2233
-					return yyinput(yyscanner);
2234
-#else
2235
-					return input(yyscanner);
2236
-#endif
2237
-					}
2238
-
2239
-				case EOB_ACT_CONTINUE_SCAN:
2240
-					yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
2241
-					break;
2242
-				}
2243
-			}
2244
-		}
2245
-
2246
-	c = *(unsigned char *) yyg->yy_c_buf_p;	/* cast for 8-bit char's */
2247
-	*yyg->yy_c_buf_p = '\0';	/* preserve yytext */
2248
-	yyg->yy_hold_char = *++yyg->yy_c_buf_p;
2249
-
2250
-	if ( c == '\n' )
2251
-		
2252
-    do{ yylineno++;
2253
-        yycolumn=0;
2254
-    }while(0)
2255
-;
2256
-
2257
-	return c;
2258
-}
2259
-#endif	/* ifndef YY_NO_INPUT */
2260
-
2261
-/** Immediately switch to a different input stream.
2262
- * @param input_file A readable stream.
2263
- * @param yyscanner The scanner object.
2264
- * @note This function does not reset the start condition to @c INITIAL .
2265
- */
2266
-    void yyrestart  (FILE * input_file , yyscan_t yyscanner)
2267
-{
2268
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2269
-
2270
-	if ( ! YY_CURRENT_BUFFER ){
2271
-        yyensure_buffer_stack (yyscanner);
2272
-		YY_CURRENT_BUFFER_LVALUE =
2273
-            yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
2274
-	}
2275
-
2276
-	yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
2277
-	yy_load_buffer_state(yyscanner );
2278
-}
2279
-
2280
-/** Switch to a different input buffer.
2281
- * @param new_buffer The new input buffer.
2282
- * @param yyscanner The scanner object.
2283
- */
2284
-    void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
2285
-{
2286
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2287
-
2288
-	/* TODO. We should be able to replace this entire function body
2289
-	 * with
2290
-	 *		yypop_buffer_state();
2291
-	 *		yypush_buffer_state(new_buffer);
2292
-     */
2293
-	yyensure_buffer_stack (yyscanner);
2294
-	if ( YY_CURRENT_BUFFER == new_buffer )
2295
-		return;
2296
-
2297
-	if ( YY_CURRENT_BUFFER )
2298
-		{
2299
-		/* Flush out information for old buffer. */
2300
-		*yyg->yy_c_buf_p = yyg->yy_hold_char;
2301
-		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2302
-		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2303
-		}
2304
-
2305
-	YY_CURRENT_BUFFER_LVALUE = new_buffer;
2306
-	yy_load_buffer_state(yyscanner );
2307
-
2308
-	/* We don't actually know whether we did this switch during
2309
-	 * EOF (yywrap()) processing, but the only time this flag
2310
-	 * is looked at is after yywrap() is called, so it's safe
2311
-	 * to go ahead and always set it.
2312
-	 */
2313
-	yyg->yy_did_buffer_switch_on_eof = 1;
2314
-}
2315
-
2316
-static void yy_load_buffer_state  (yyscan_t yyscanner)
2317
-{
2318
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2319
-	yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2320
-	yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
2321
-	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
2322
-	yyg->yy_hold_char = *yyg->yy_c_buf_p;
2323
-}
2324
-
2325
-/** Allocate and initialize an input buffer state.
2326
- * @param file A readable stream.
2327
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
2328
- * @param yyscanner The scanner object.
2329
- * @return the allocated buffer state.
2330
- */
2331
-    YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
2332
-{
2333
-	YY_BUFFER_STATE b;
2334
-    
2335
-	b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
2336
-	if ( ! b )
2337
-		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
2338
-
2339
-	b->yy_buf_size = size;
2340
-
2341
-	/* yy_ch_buf has to be 2 characters longer than the size given because
2342
-	 * we need to put in 2 end-of-buffer characters.
2343
-	 */
2344
-	b->yy_ch_buf = (char *) yyalloc((yy_size_t) (b->yy_buf_size + 2) ,yyscanner );
2345
-	if ( ! b->yy_ch_buf )
2346
-		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
2347
-
2348
-	b->yy_is_our_buffer = 1;
2349
-
2350
-	yy_init_buffer(b,file ,yyscanner);
2351
-
2352
-	return b;
2353
-}
2354
-
2355
-/** Destroy the buffer.
2356
- * @param b a buffer created with yy_create_buffer()
2357
- * @param yyscanner The scanner object.
2358
- */
2359
-    void yy_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
2360
-{
2361
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2362
-
2363
-	if ( ! b )
2364
-		return;
2365
-
2366
-	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
2367
-		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
2368
-
2369
-	if ( b->yy_is_our_buffer )
2370
-		yyfree((void *) b->yy_ch_buf ,yyscanner );
2371
-
2372
-	yyfree((void *) b ,yyscanner );
2373
-}
2374
-
2375
-/* Initializes or reinitializes a buffer.
2376
- * This function is sometimes called more than once on the same buffer,
2377
- * such as during a yyrestart() or at EOF.
2378
- */
2379
-    static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
2380
-
2381
-{
2382
-	int oerrno = errno;
2383
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2384
-
2385
-	yy_flush_buffer(b ,yyscanner);
2386
-
2387
-	b->yy_input_file = file;
2388
-	b->yy_fill_buffer = 1;
2389
-
2390
-    /* If b is the current buffer, then yy_init_buffer was _probably_
2391
-     * called from yyrestart() or through yy_get_next_buffer.
2392
-     * In that case, we don't want to reset the lineno or column.
2393
-     */
2394
-    if (b != YY_CURRENT_BUFFER){
2395
-        b->yy_bs_lineno = 1;
2396
-        b->yy_bs_column = 0;
2397
-    }
2398
-
2399
-        b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
2400
-    
2401
-	errno = oerrno;
2402
-}
2403
-
2404
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2405
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2406
- * @param yyscanner The scanner object.
2407
- */
2408
-    void yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
2409
-{
2410
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2411
-	if ( ! b )
2412
-		return;
2413
-
2414
-	b->yy_n_chars = 0;
2415
-
2416
-	/* We always need two end-of-buffer characters.  The first causes
2417
-	 * a transition to the end-of-buffer state.  The second causes
2418
-	 * a jam in that state.
2419
-	 */
2420
-	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2421
-	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2422
-
2423
-	b->yy_buf_pos = &b->yy_ch_buf[0];
2424
-
2425
-	b->yy_at_bol = 1;
2426
-	b->yy_buffer_status = YY_BUFFER_NEW;
2427
-
2428
-	if ( b == YY_CURRENT_BUFFER )
2429
-		yy_load_buffer_state(yyscanner );
2430
-}
2431
-
2432
-/** Pushes the new state onto the stack. The new state becomes
2433
- *  the current state. This function will allocate the stack
2434
- *  if necessary.
2435
- *  @param new_buffer The new state.
2436
- *  @param yyscanner The scanner object.
2437
- */
2438
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
2439
-{
2440
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2441
-	if (new_buffer == NULL)
2442
-		return;
2443
-
2444
-	yyensure_buffer_stack(yyscanner);
2445
-
2446
-	/* This block is copied from yy_switch_to_buffer. */
2447
-	if ( YY_CURRENT_BUFFER )
2448
-		{
2449
-		/* Flush out information for old buffer. */
2450
-		*yyg->yy_c_buf_p = yyg->yy_hold_char;
2451
-		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
2452
-		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
2453
-		}
2454
-
2455
-	/* Only push if top exists. Otherwise, replace top. */
2456
-	if (YY_CURRENT_BUFFER)
2457
-		yyg->yy_buffer_stack_top++;
2458
-	YY_CURRENT_BUFFER_LVALUE = new_buffer;
2459
-
2460
-	/* copied from yy_switch_to_buffer. */
2461
-	yy_load_buffer_state(yyscanner );
2462
-	yyg->yy_did_buffer_switch_on_eof = 1;
2463
-}
2464
-
2465
-/** Removes and deletes the top of the stack, if present.
2466
- *  The next element becomes the new top.
2467
- *  @param yyscanner The scanner object.
2468
- */
2469
-void yypop_buffer_state (yyscan_t yyscanner)
2470
-{
2471
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2472
-	if (!YY_CURRENT_BUFFER)
2473
-		return;
2474
-
2475
-	yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
2476
-	YY_CURRENT_BUFFER_LVALUE = NULL;
2477
-	if (yyg->yy_buffer_stack_top > 0)
2478
-		--yyg->yy_buffer_stack_top;
2479
-
2480
-	if (YY_CURRENT_BUFFER) {
2481
-		yy_load_buffer_state(yyscanner );
2482
-		yyg->yy_did_buffer_switch_on_eof = 1;
2483
-	}
2484
-}
2485
-
2486
-/* Allocates the stack if it does not exist.
2487
- *  Guarantees space for at least one push.
2488
- */
2489
-static void yyensure_buffer_stack (yyscan_t yyscanner)
2490
-{
2491
-	yy_size_t num_to_alloc;
2492
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2493
-
2494
-	if (!yyg->yy_buffer_stack) {
2495
-
2496
-		/* First allocation is just for 2 elements, since we don't know if this
2497
-		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2498
-		 * immediate realloc on the next call.
2499
-         */
2500
-      num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
2501
-		yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
2502
-								(num_to_alloc * sizeof(struct yy_buffer_state*)
2503
-								, yyscanner);
2504
-		if ( ! yyg->yy_buffer_stack )
2505
-			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2506
-
2507
-		memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2508
-
2509
-		yyg->yy_buffer_stack_max = num_to_alloc;
2510
-		yyg->yy_buffer_stack_top = 0;
2511
-		return;
2512
-	}
2513
-
2514
-	if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
2515
-
2516
-		/* Increase the buffer to prepare for a possible push. */
2517
-		yy_size_t grow_size = 8 /* arbitrary grow size */;
2518
-
2519
-		num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
2520
-		yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
2521
-								(yyg->yy_buffer_stack,
2522
-								num_to_alloc * sizeof(struct yy_buffer_state*)
2523
-								, yyscanner);
2524
-		if ( ! yyg->yy_buffer_stack )
2525
-			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2526
-
2527
-		/* zero only the new slots.*/
2528
-		memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
2529
-		yyg->yy_buffer_stack_max = num_to_alloc;
2530
-	}
2531
-}
2532
-
2533
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
2534
- * @param base the character buffer
2535
- * @param size the size in bytes of the character buffer
2536
- * @param yyscanner The scanner object.
2537
- * @return the newly allocated buffer state object.
2538
- */
2539
-YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
2540
-{
2541
-	YY_BUFFER_STATE b;
2542
-    
2543
-	if ( size < 2 ||
2544
-	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
2545
-	     base[size-1] != YY_END_OF_BUFFER_CHAR )
2546
-		/* They forgot to leave room for the EOB's. */
2547
-		return NULL;
2548
-
2549
-	b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
2550
-	if ( ! b )
2551
-		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
2552
-
2553
-	b->yy_buf_size = (int) (size - 2);	/* "- 2" to take care of EOB's */
2554
-	b->yy_buf_pos = b->yy_ch_buf = base;
2555
-	b->yy_is_our_buffer = 0;
2556
-	b->yy_input_file = NULL;
2557
-	b->yy_n_chars = b->yy_buf_size;
2558
-	b->yy_is_interactive = 0;
2559
-	b->yy_at_bol = 1;
2560
-	b->yy_fill_buffer = 0;
2561
-	b->yy_buffer_status = YY_BUFFER_NEW;
2562
-
2563
-	yy_switch_to_buffer(b ,yyscanner );
2564
-
2565
-	return b;
2566
-}
2567
-
2568
-/** Setup the input buffer state to scan a string. The next call to yylex() will
2569
- * scan from a @e copy of @a str.
2570
- * @param yystr a NUL-terminated string to scan
2571
- * @param yyscanner The scanner object.
2572
- * @return the newly allocated buffer state object.
2573
- * @note If you want to scan bytes that may contain NUL values, then use
2574
- *       yy_scan_bytes() instead.
2575
- */
2576
-YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
2577
-{
2578
-    
2579
-	return yy_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner);
2580
-}
2581
-
2582
-/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
2583
- * scan from a @e copy of @a bytes.
2584
- * @param yybytes the byte buffer to scan
2585
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2586
- * @param yyscanner The scanner object.
2587
- * @return the newly allocated buffer state object.
2588
- */
2589
-YY_BUFFER_STATE yy_scan_bytes  (const char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
2590
-{
2591
-	YY_BUFFER_STATE b;
2592
-	char *buf;
2593
-	yy_size_t n;
2594
-	int i;
2595
-    
2596
-	/* Get memory for full buffer, including space for trailing EOB's. */
2597
-	n = (yy_size_t) (_yybytes_len + 2);
2598
-	buf = (char *) yyalloc(n ,yyscanner );
2599
-	if ( ! buf )
2600
-		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
2601
-
2602
-	for ( i = 0; i < _yybytes_len; ++i )
2603
-		buf[i] = yybytes[i];
2604
-
2605
-	buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2606
-
2607
-	b = yy_scan_buffer(buf,n ,yyscanner);
2608
-	if ( ! b )
2609
-		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
2610
-
2611
-	/* It's okay to grow etc. this buffer, and we should throw it
2612
-	 * away when we're done.
2613
-	 */
2614
-	b->yy_is_our_buffer = 1;
2615
-
2616
-	return b;
2617
-}
2618
-
2619
-#ifndef YY_EXIT_FAILURE
2620
-#define YY_EXIT_FAILURE 2
2621
-#endif
2622
-
2623
-static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
2624
-{
2625
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2626
-	(void)yyg;
2627
-	(void) fprintf( stderr, "%s\n", msg );
2628
-	exit( YY_EXIT_FAILURE );
2629
-}
2630
-
2631
-/* Redefine yyless() so it works in section 3 code. */
2632
-
2633
-#undef yyless
2634
-#define yyless(n) \
2635
-	do \
2636
-		{ \
2637
-		/* Undo effects of setting up yytext. */ \
2638
-        int yyless_macro_arg = (n); \
2639
-        YY_LESS_LINENO(yyless_macro_arg);\
2640
-		yytext[yyleng] = yyg->yy_hold_char; \
2641
-		yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
2642
-		yyg->yy_hold_char = *yyg->yy_c_buf_p; \
2643
-		*yyg->yy_c_buf_p = '\0'; \
2644
-		yyleng = yyless_macro_arg; \
2645
-		} \
2646
-	while ( 0 )
2647
-
2648
-/* Accessor  methods (get/set functions) to struct members. */
2649
-
2650
-/** Get the user-defined data for this scanner.
2651
- * @param yyscanner The scanner object.
2652
- */
2653
-YY_EXTRA_TYPE yyget_extra  (yyscan_t yyscanner)
2654
-{
2655
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2656
-    return yyextra;
2657
-}
2658
-
2659
-/** Get the current line number.
2660
- * @param yyscanner The scanner object.
2661
- */
2662
-int yyget_lineno  (yyscan_t yyscanner)
2663
-{
2664
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2665
-
2666
-        if (! YY_CURRENT_BUFFER)
2667
-            return 0;
2668
-    
2669
-    return yylineno;
2670
-}
2671
-
2672
-/** Get the current column number.
2673
- * @param yyscanner The scanner object.
2674
- */
2675
-int yyget_column  (yyscan_t yyscanner)
2676
-{
2677
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2678
-
2679
-        if (! YY_CURRENT_BUFFER)
2680
-            return 0;
2681
-    
2682
-    return yycolumn;
2683
-}
2684
-
2685
-/** Get the input stream.
2686
- * @param yyscanner The scanner object.
2687
- */
2688
-FILE *yyget_in  (yyscan_t yyscanner)
2689
-{
2690
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2691
-    return yyin;
2692
-}
2693
-
2694
-/** Get the output stream.
2695
- * @param yyscanner The scanner object.
2696
- */
2697
-FILE *yyget_out  (yyscan_t yyscanner)
2698
-{
2699
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2700
-    return yyout;
2701
-}
2702
-
2703
-/** Get the length of the current token.
2704
- * @param yyscanner The scanner object.
2705
- */
2706
-int yyget_leng  (yyscan_t yyscanner)
2707
-{
2708
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2709
-    return yyleng;
2710
-}
2711
-
2712
-/** Get the current token.
2713
- * @param yyscanner The scanner object.
2714
- */
2715
-
2716
-char *yyget_text  (yyscan_t yyscanner)
2717
-{
2718
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2719
-    return yytext;
2720
-}
2721
-
2722
-/** Set the user-defined data. This data is never touched by the scanner.
2723
- * @param user_defined The data to be associated with this scanner.
2724
- * @param yyscanner The scanner object.
2725
- */
2726
-void yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
2727
-{
2728
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2729
-    yyextra = user_defined ;
2730
-}
2731
-
2732
-/** Set the current line number.
2733
- * @param _line_number line number
2734
- * @param yyscanner The scanner object.
2735
- */
2736
-void yyset_lineno (int  _line_number , yyscan_t yyscanner)
2737
-{
2738
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2739
-
2740
-        /* lineno is only valid if an input buffer exists. */
2741
-        if (! YY_CURRENT_BUFFER )
2742
-           YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
2743
-    
2744
-    yylineno = _line_number;
2745
-}
2746
-
2747
-/** Set the current column.
2748
- * @param _column_no column number
2749
- * @param yyscanner The scanner object.
2750
- */
2751
-void yyset_column (int  _column_no , yyscan_t yyscanner)
2752
-{
2753
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2754
-
2755
-        /* column is only valid if an input buffer exists. */
2756
-        if (! YY_CURRENT_BUFFER )
2757
-           YY_FATAL_ERROR( "yyset_column called with no buffer" );
2758
-    
2759
-    yycolumn = _column_no;
2760
-}
2761
-
2762
-/** Set the input stream. This does not discard the current
2763
- * input buffer.
2764
- * @param _in_str A readable stream.
2765
- * @param yyscanner The scanner object.
2766
- * @see yy_switch_to_buffer
2767
- */
2768
-void yyset_in (FILE *  _in_str , yyscan_t yyscanner)
2769
-{
2770
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2771
-    yyin = _in_str ;
2772
-}
2773
-
2774
-void yyset_out (FILE *  _out_str , yyscan_t yyscanner)
2775
-{
2776
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2777
-    yyout = _out_str ;
2778
-}
2779
-
2780
-int yyget_debug  (yyscan_t yyscanner)
2781
-{
2782
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2783
-    return yy_flex_debug;
2784
-}
2785
-
2786
-void yyset_debug (int  _bdebug , yyscan_t yyscanner)
2787
-{
2788
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2789
-    yy_flex_debug = _bdebug ;
2790
-}
2791
-
2792
-/* Accessor methods for yylval and yylloc */
2793
-
2794
-YYSTYPE * yyget_lval  (yyscan_t yyscanner)
2795
-{
2796
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2797
-    return yylval;
2798
-}
2799
-
2800
-void yyset_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)
2801
-{
2802
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2803
-    yylval = yylval_param;
2804
-}
2805
-
2806
-/* User-visible API */
2807
-
2808
-/* yylex_init is special because it creates the scanner itself, so it is
2809
- * the ONLY reentrant function that doesn't take the scanner as the last argument.
2810
- * That's why we explicitly handle the declaration, instead of using our macros.
2811
- */
2812
-int yylex_init(yyscan_t* ptr_yy_globals)
2813
-{
2814
-    if (ptr_yy_globals == NULL){
2815
-        errno = EINVAL;
2816
-        return 1;
2817
-    }
2818
-
2819
-    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
2820
-
2821
-    if (*ptr_yy_globals == NULL){
2822
-        errno = ENOMEM;
2823
-        return 1;
2824
-    }
2825
-
2826
-    /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2827
-    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2828
-
2829
-    return yy_init_globals ( *ptr_yy_globals );
2830
-}
2831
-
2832
-/* yylex_init_extra has the same functionality as yylex_init, but follows the
2833
- * convention of taking the scanner as the last argument. Note however, that
2834
- * this is a *pointer* to a scanner, as it will be allocated by this call (and
2835
- * is the reason, too, why this function also must handle its own declaration).
2836
- * The user defined value in the first argument will be available to yyalloc in
2837
- * the yyextra field.
2838
- */
2839
-int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
2840
-{
2841
-    struct yyguts_t dummy_yyguts;
2842
-
2843
-    yyset_extra (yy_user_defined, &dummy_yyguts);
2844
-
2845
-    if (ptr_yy_globals == NULL){
2846
-        errno = EINVAL;
2847
-        return 1;
2848
-    }
2849
-
2850
-    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2851
-
2852
-    if (*ptr_yy_globals == NULL){
2853
-        errno = ENOMEM;
2854
-        return 1;
2855
-    }
2856
-
2857
-    /* By setting to 0xAA, we expose bugs in
2858
-    yy_init_globals. Leave at 0x00 for releases. */
2859
-    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2860
-
2861
-    yyset_extra (yy_user_defined, *ptr_yy_globals);
2862
-
2863
-    return yy_init_globals ( *ptr_yy_globals );
2864
-}
2865
-
2866
-static int yy_init_globals (yyscan_t yyscanner)
2867
-{
2868
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2869
-    /* Initialization is the same as for the non-reentrant scanner.
2870
-     * This function is called from yylex_destroy(), so don't allocate here.
2871
-     */
2872
-
2873
-    yyg->yy_buffer_stack = NULL;
2874
-    yyg->yy_buffer_stack_top = 0;
2875
-    yyg->yy_buffer_stack_max = 0;
2876
-    yyg->yy_c_buf_p = NULL;
2877
-    yyg->yy_init = 0;
2878
-    yyg->yy_start = 0;
2879
-
2880
-    yyg->yy_start_stack_ptr = 0;
2881
-    yyg->yy_start_stack_depth = 0;
2882
-    yyg->yy_start_stack =  NULL;
2883
-
2884
-/* Defined in main.c */
2885
-#ifdef YY_STDINIT
2886
-    yyin = stdin;
2887
-    yyout = stdout;
2888
-#else
2889
-    yyin = NULL;
2890
-    yyout = NULL;
2891
-#endif
2892
-
2893
-    /* For future reference: Set errno on error, since we are called by
2894
-     * yylex_init()
2895
-     */
2896
-    return 0;
2897
-}
2898
-
2899
-/* yylex_destroy is for both reentrant and non-reentrant scanners. */
2900
-int yylex_destroy  (yyscan_t yyscanner)
2901
-{
2902
-    struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2903
-
2904
-    /* Pop the buffer stack, destroying each element. */
2905
-	while(YY_CURRENT_BUFFER){
2906
-		yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
2907
-		YY_CURRENT_BUFFER_LVALUE = NULL;
2908
-		yypop_buffer_state(yyscanner);
2909
-	}
2910
-
2911
-	/* Destroy the stack itself. */
2912
-	yyfree(yyg->yy_buffer_stack ,yyscanner);
2913
-	yyg->yy_buffer_stack = NULL;
2914
-
2915
-    /* Destroy the start condition stack. */
2916
-        yyfree(yyg->yy_start_stack ,yyscanner );
2917
-        yyg->yy_start_stack = NULL;
2918
-
2919
-    /* Reset the globals. This is important in a non-reentrant scanner so the next time
2920
-     * yylex() is called, initialization will occur. */
2921
-    yy_init_globals( yyscanner);
2922
-
2923
-    /* Destroy the main struct (reentrant only). */
2924
-    yyfree ( yyscanner , yyscanner );
2925
-    yyscanner = NULL;
2926
-    return 0;
2927
-}
2928
-
2929
-/*
2930
- * Internal utility routines.
2931
- */
2932
-
2933
-#ifndef yytext_ptr
2934
-static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
2935
-{
2936
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2937
-	(void)yyg;
2938
-
2939
-	int i;
2940
-	for ( i = 0; i < n; ++i )
2941
-		s1[i] = s2[i];
2942
-}
2943
-#endif
2944
-
2945
-#ifdef YY_NEED_STRLEN
2946
-static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
2947
-{
2948
-	int n;
2949
-	for ( n = 0; s[n]; ++n )
2950
-		;
2951
-
2952
-	return n;
2953
-}
2954
-#endif
2955
-
2956
-void *yyalloc (yy_size_t  size , yyscan_t yyscanner)
2957
-{
2958
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2959
-	(void)yyg;
2960
-	return malloc(size);
2961
-}
2962
-
2963
-void *yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
2964
-{
2965
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2966
-	(void)yyg;
2967
-
2968
-	/* The cast to (char *) in the following accommodates both
2969
-	 * implementations that use char* generic pointers, and those
2970
-	 * that use void* generic pointers.  It works with the latter
2971
-	 * because both ANSI C and C++ allow castless assignment from
2972
-	 * any pointer type to void*, and deal with argument conversions
2973
-	 * as though doing an assignment.
2974
-	 */
2975
-	return realloc(ptr, size);
2976
-}
2977
-
2978
-void yyfree (void * ptr , yyscan_t yyscanner)
2979
-{
2980
-	struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2981
-	(void)yyg;
2982
-	free( (char *) ptr );	/* see yyrealloc() for (char *) cast */
2983
-}
2984
-
2985
-#define YYTABLES_NAME "yytables"
2986
-
2987
-#line 581 "yara_lexer.l"
2988
-
2989
-
2990
-
2991
-void yywarning(
2992
-    yyscan_t yyscanner,
2993
-    const char *warning_message)
2994
-{
2995
-  YR_COMPILER* compiler = yyget_extra(yyscanner);
2996
-  char* file_name;
2997
-
2998
-  if (compiler->file_name_stack_ptr > 0)
2999
-    file_name = compiler->file_name_stack[compiler->file_name_stack_ptr - 1];
3000
-  else
3001
-    file_name = NULL;
3002
-
3003
-#ifdef REAL_YARA
3004
-  compiler->callback(
3005
-      YARA_ERROR_LEVEL_WARNING,
3006
-      file_name,
3007
-      yyget_lineno(yyscanner),
3008
-      warning_message);
3009
-#else
3010
-    cli_warnmsg("yywarning(): %s line %d %s\n", file_name?file_name:"(file name missing)", compiler->last_error_line, warning_message);
3011
-#endif
3012
-}
3013
-
3014
-
3015
-void yyfatal(
3016
-    yyscan_t yyscanner,
3017
-    const char *error_message)
3018
-{
3019
-  YR_COMPILER* compiler = yyget_extra(yyscanner);
3020
-  int last_result = compiler->last_result;
3021
-
3022
-  yyerror(yyscanner, compiler, error_message);
3023
-  compiler->last_result = last_result;
3024
-  longjmp(compiler->error_recovery, 1);
3025
-}
3026
-
3027
-
3028
-void yyerror(
3029
-    yyscan_t yyscanner,
3030
-    YR_COMPILER* compiler,
3031
-    const char *error_message)
3032
-{
3033
-  char message[512] = {'\0'};
3034
-  char* file_name = NULL;
3035
-
3036
-  /*
3037
-    if error_message != NULL the error comes from yyparse internal code
3038
-    else the error comes from my code and the error code is set in
3039
-    compiler->last_result
3040
-  */
3041
-
3042
-  compiler->errors++;
3043
-
3044
-  if (compiler->error_line != 0)
3045
-    compiler->last_error_line = compiler->error_line;
3046
-  else
3047
-    compiler->last_error_line = yyget_lineno(yyscanner);
3048
-
3049
-  compiler->error_line = 0;
3050
-
3051
-  if (compiler->file_name_stack_ptr > 0)
3052
-  {
3053
-    file_name = compiler->file_name_stack[compiler->file_name_stack_ptr - 1];
3054
-  }
3055
-  else
3056
-  {
3057
-    file_name = NULL;
3058
-  }
3059
-
3060
-  if (error_message != NULL)
3061
-  {
3062
-    yr_compiler_set_error_extra_info(compiler, error_message);
3063
-    compiler->last_error = ERROR_SYNTAX_ERROR;
3064
-
3065
-#ifdef REAL_YARA
3066
-    if (compiler->callback != NULL)
3067
-    {
3068
-      compiler->callback(
3069
-          YARA_ERROR_LEVEL_ERROR,
3070
-          file_name,
3071
-          compiler->last_error_line,
3072
-          error_message);
3073
-    }
3074
-#else
3075
-    cli_errmsg("yyerror(): %s line %d %s\n", file_name?file_name:"(file name missing)", compiler->last_error_line, error_message);
3076
-#endif
3077
-  }
3078
-  else
3079
-  {
3080
-    compiler->last_error = compiler->last_result;
3081
-
3082
-#ifdef REAL_YARA
3083
-    if (compiler->callback != NULL)
3084
-    {
3085
-      yr_compiler_get_error_message(compiler, message, sizeof(message));
3086
-
3087
-      compiler->callback(
3088
-        YARA_ERROR_LEVEL_ERROR,
3089
-        file_name,
3090
-        compiler->last_error_line,
3091
-        message);
3092
-    }
3093
-#else
3094
-    yr_compiler_get_error_message(compiler, message, sizeof(message));
3095
-    cli_errmsg("yyerror(): %s line %d %s\n", file_name?file_name:"NULL filename", compiler->last_error_line, message);
3096
-#endif
3097
-  }
3098
-
3099
-  compiler->last_result = ERROR_SUCCESS;
3100
-}
3101
-
3102
-
3103
-int yr_lex_parse_rules_string(
3104
-  const char* rules_string,
3105
-  YR_COMPILER* compiler)
3106
-{
3107
-#ifdef REAL_YARA
3108
-  yyscan_t yyscanner;
3109
-
3110
-  compiler->errors = 0;
3111
-
3112
-  if (setjmp(compiler->error_recovery) != 0)
3113
-    return compiler->errors;
3114
-
3115
-  yylex_init(&yyscanner);
3116
-
3117
-  yyset_debug(1, yyscanner);
3118
-
3119
-  yyset_extra(compiler, yyscanner);
3120
-
3121
-  yy_scan_string(rules_string, yyscanner);
3122
-
3123
-  yyset_lineno(1, yyscanner);
3124
-  yyparse(yyscanner, compiler);
3125
-  yylex_destroy(yyscanner);
3126
-
3127
-  return compiler->errors;
3128
-#else
3129
-  (void)rules_string;
3130
-  (void)compiler;
3131
-  cli_errmsg("yara_lexer:yr_lex_parse_rules_string() disabled\n");
3132
-  return 0;
3133
-#endif
3134
-}
3135
-
3136
-
3137
-int yr_lex_parse_rules_file(
3138
-  FILE* rules_file,
3139
-  YR_COMPILER* compiler)
3140
-{
3141
-  yyscan_t yyscanner;
3142
-
3143
-  compiler->errors = 0;
3144
-
3145
-  if (setjmp(compiler->error_recovery) != 0)
3146
-    return compiler->errors;
3147
-
3148
-  yylex_init(&yyscanner);
3149
-
3150
-  #if YYDEBUG
3151
-  printf("debug enabled");
3152
-  #endif
3153
-
3154
-  yyset_debug(1, yyscanner);
3155
-
3156
-  yyset_in(rules_file, yyscanner);
3157
-  yyset_extra(compiler, yyscanner);
3158
-  yyparse(yyscanner, compiler);
3159
-  yylex_destroy(yyscanner);
3160
-
3161
-  return compiler->errors;
3162
-}
3163
-
... ...
@@ -419,9 +419,9 @@
419 419
     <ClCompile Include="..\libclamav\yara_arena.c" />
420 420
     <ClCompile Include="..\libclamav\yara_compiler.c" />
421 421
     <ClCompile Include="..\libclamav\yara_exec.c" />
422
-    <ClCompile Include="compat\yara_grammar.c" />
422
+    <ClCompile Include="..\libclamav\yara_grammar.c" />
423 423
     <ClCompile Include="..\libclamav\yara_hash.c" />
424
-    <ClCompile Include="compat\yara_lexer.c" />
424
+    <ClCompile Include="..\libclamav\yara_lexer.c" />
425 425
     <ClCompile Include="..\libclamav\yara_parser.c" />
426 426
     <ClCompile Include="..\libclamav\yc.c" />
427 427
     <ClCompile Include="..\libclamav\libclamav_main.c" />