[Forensics-changes] [yara] 218/415: Compile in C99 mode and remove warnings

Hilko Bengen bengen at moszumanska.debian.org
Thu Apr 3 05:43:07 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch debian
in repository yara.

commit 70e7db6b70938af7de267a77b50f4b877e0828e9
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Tue Nov 12 12:20:33 2013 +0000

    Compile in C99 mode and remove warnings
---
 libyara/Makefile.am |   2 +-
 libyara/grammar.c   | 254 ++++++++++++++++++++++++++--------------------------
 libyara/grammar.h   |   2 +-
 libyara/grammar.y   |   4 +-
 libyara/hex_lexer.c |  35 ++++----
 libyara/hex_lexer.h |  22 +++--
 libyara/hex_lexer.l |   3 +-
 libyara/lexer.c     | 169 +++++++++++++++++-----------------
 libyara/lexer.h     |  12 ++-
 libyara/lexer.l     |   1 +
 libyara/parser.c    |   4 +-
 libyara/parser.h    |   6 ++
 libyara/re.h        |  10 +++
 libyara/re_lexer.c  |  78 ++++++++--------
 libyara/re_lexer.h  |  17 +++-
 libyara/re_lexer.l  |   6 --
 libyara/rules.c     |   6 +-
 libyara/yara.h      |   3 +
 18 files changed, 336 insertions(+), 298 deletions(-)

diff --git a/libyara/Makefile.am b/libyara/Makefile.am
index f727481..09eefbc 100644
--- a/libyara/Makefile.am
+++ b/libyara/Makefile.am
@@ -1,6 +1,6 @@
 AM_YFLAGS=-d
 
-AM_CFLAGS=-g -O4
+AM_CFLAGS=-g -O4 -std=gnu99
 
 ACLOCAL_AMFLAGS=-I m4
 
diff --git a/libyara/grammar.c b/libyara/grammar.c
index 1950ea2..40d5f2a 100644
--- a/libyara/grammar.c
+++ b/libyara/grammar.c
@@ -228,8 +228,6 @@
 #define INTEGER_SET_ENUMERATION 1
 #define INTEGER_SET_RANGE 2
 
-
-
 #define ERROR_IF(x) \
     if (x) \
     { \
@@ -259,7 +257,7 @@
 
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 typedef union YYSTYPE
-#line 150 "grammar.y"
+#line 148 "grammar.y"
 {
   SIZED_STRING*   sized_string;
   char*           c_string;
@@ -268,7 +266,7 @@ typedef union YYSTYPE
   META*           meta;
 }
 /* Line 193 of yacc.c.  */
-#line 272 "grammar.c"
+#line 270 "grammar.c"
 	YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
@@ -281,7 +279,7 @@ typedef union YYSTYPE
 
 
 /* Line 216 of yacc.c.  */
-#line 285 "grammar.c"
+#line 283 "grammar.c"
 
 #ifdef short
 # undef short
@@ -614,17 +612,17 @@ static const yytype_int8 yyrhs[] =
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   161,   161,   162,   163,   164,   168,   185,   186,   214,
-     218,   246,   250,   251,   255,   256,   260,   261,   276,   286,
-     320,   321,   325,   341,   354,   367,   383,   384,   388,   401,
-     414,   430,   431,   435,   436,   437,   438,   442,   443,   447,
-     451,   481,   510,   514,   525,   536,   540,   551,   557,   594,
-     556,   693,   692,   761,   765,   768,   772,   776,   780,   784,
-     788,   792,   796,   800,   804,   811,   830,   844,   845,   849,
-     853,   854,   858,   857,   862,   869,   870,   873,   878,   885,
-     886,   890,   897,   898,   902,   906,   910,   914,   918,   922,
-     926,   930,   934,   945,   956,   970,   997,  1001,  1005,  1009,
-    1013,  1017,  1021,  1025,  1029,  1033,  1037,  1043,  1044,  1045
+       0,   159,   159,   160,   161,   162,   166,   183,   184,   212,
+     216,   244,   248,   249,   253,   254,   258,   259,   274,   284,
+     318,   319,   323,   339,   352,   365,   381,   382,   386,   399,
+     412,   428,   429,   433,   434,   435,   436,   440,   441,   445,
+     449,   479,   508,   512,   523,   534,   538,   549,   555,   592,
+     554,   691,   690,   759,   763,   766,   770,   774,   778,   782,
+     786,   790,   794,   798,   802,   809,   828,   842,   843,   847,
+     851,   852,   856,   855,   860,   867,   868,   871,   876,   883,
+     884,   888,   895,   896,   900,   904,   908,   912,   916,   920,
+     924,   928,   932,   943,   954,   968,   995,   999,  1003,  1007,
+    1011,  1015,  1019,  1023,  1027,  1031,  1035,  1041,  1042,  1043
 };
 #endif
 
@@ -1421,49 +1419,49 @@ yydestruct (yymsg, yytype, yyvaluep, yyscanner)
   switch (yytype)
     {
       case 10: /* "_IDENTIFIER_" */
-#line 140 "grammar.y"
+#line 138 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1427 "grammar.c"
+#line 1425 "grammar.c"
 	break;
       case 11: /* "_STRING_IDENTIFIER_" */
-#line 141 "grammar.y"
+#line 139 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1432 "grammar.c"
+#line 1430 "grammar.c"
 	break;
       case 12: /* "_STRING_COUNT_" */
-#line 142 "grammar.y"
+#line 140 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1437 "grammar.c"
+#line 1435 "grammar.c"
 	break;
       case 13: /* "_STRING_OFFSET_" */
-#line 143 "grammar.y"
+#line 141 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1442 "grammar.c"
+#line 1440 "grammar.c"
 	break;
       case 14: /* "_STRING_IDENTIFIER_WITH_WILDCARD_" */
-#line 144 "grammar.y"
+#line 142 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1447 "grammar.c"
+#line 1445 "grammar.c"
 	break;
       case 15: /* "_ANONYMOUS_STRING_" */
-#line 145 "grammar.y"
+#line 143 "grammar.y"
 	{ yr_free((yyvaluep->c_string)); };
-#line 1452 "grammar.c"
+#line 1450 "grammar.c"
 	break;
       case 18: /* "_TEXTSTRING_" */
-#line 146 "grammar.y"
+#line 144 "grammar.y"
 	{ yr_free((yyvaluep->sized_string)); };
-#line 1457 "grammar.c"
+#line 1455 "grammar.c"
 	break;
       case 19: /* "_HEXSTRING_" */
-#line 147 "grammar.y"
+#line 145 "grammar.y"
 	{ yr_free((yyvaluep->sized_string)); };
-#line 1462 "grammar.c"
+#line 1460 "grammar.c"
 	break;
       case 20: /* "_REGEXP_" */
-#line 148 "grammar.y"
+#line 146 "grammar.y"
 	{ yr_free((yyvaluep->sized_string)); };
-#line 1467 "grammar.c"
+#line 1465 "grammar.c"
 	break;
 
       default:
@@ -1772,7 +1770,7 @@ yyreduce:
   switch (yyn)
     {
         case 6:
-#line 169 "grammar.y"
+#line 167 "grammar.y"
     {
           int result = yr_parser_reduce_rule_declaration(
               yyscanner,
@@ -1789,12 +1787,12 @@ yyreduce:
     break;
 
   case 7:
-#line 185 "grammar.y"
+#line 183 "grammar.y"
     {  (yyval.meta) = NULL; }
     break;
 
   case 8:
-#line 187 "grammar.y"
+#line 185 "grammar.y"
     {
           // Each rule have a list of meta-data info, consisting in a
           // sequence of META structures. The last META structure does
@@ -1821,7 +1819,7 @@ yyreduce:
     break;
 
   case 9:
-#line 214 "grammar.y"
+#line 212 "grammar.y"
     {
           (yyval.string) = NULL;
           yyget_extra(yyscanner)->current_rule_strings = (yyval.string);
@@ -1829,7 +1827,7 @@ yyreduce:
     break;
 
   case 10:
-#line 219 "grammar.y"
+#line 217 "grammar.y"
     {
           // Each rule have a list of strings, consisting in a sequence
           // of STRING structures. The last STRING structure does not
@@ -1857,32 +1855,32 @@ yyreduce:
     break;
 
   case 12:
-#line 250 "grammar.y"
+#line 248 "grammar.y"
     { (yyval.integer) = 0;  }
     break;
 
   case 13:
-#line 251 "grammar.y"
+#line 249 "grammar.y"
     { (yyval.integer) = (yyvsp[(1) - (2)].integer) | (yyvsp[(2) - (2)].integer); }
     break;
 
   case 14:
-#line 255 "grammar.y"
+#line 253 "grammar.y"
     { (yyval.integer) = RULE_GFLAGS_PRIVATE; }
     break;
 
   case 15:
-#line 256 "grammar.y"
+#line 254 "grammar.y"
     { (yyval.integer) = RULE_GFLAGS_GLOBAL; }
     break;
 
   case 16:
-#line 260 "grammar.y"
+#line 258 "grammar.y"
     { (yyval.c_string) = NULL; }
     break;
 
   case 17:
-#line 262 "grammar.y"
+#line 260 "grammar.y"
     {
           // Tags list is represented in the arena as a sequence
           // of null-terminated strings, the sequence ends with an
@@ -1897,7 +1895,7 @@ yyreduce:
     break;
 
   case 18:
-#line 277 "grammar.y"
+#line 275 "grammar.y"
     {
               char* identifier;
 
@@ -1910,7 +1908,7 @@ yyreduce:
     break;
 
   case 19:
-#line 287 "grammar.y"
+#line 285 "grammar.y"
     {
               YARA_COMPILER* compiler = yyget_extra(yyscanner);
               char* tag_name = (yyvsp[(1) - (2)].c_string);
@@ -1945,17 +1943,17 @@ yyreduce:
     break;
 
   case 20:
-#line 320 "grammar.y"
+#line 318 "grammar.y"
     {  (yyval.meta) = (yyvsp[(1) - (1)].meta); }
     break;
 
   case 21:
-#line 321 "grammar.y"
+#line 319 "grammar.y"
     {  (yyval.meta) = (yyvsp[(1) - (2)].meta); }
     break;
 
   case 22:
-#line 326 "grammar.y"
+#line 324 "grammar.y"
     {
                       SIZED_STRING* sized_string = (yyvsp[(3) - (3)].sized_string);
 
@@ -1974,7 +1972,7 @@ yyreduce:
     break;
 
   case 23:
-#line 342 "grammar.y"
+#line 340 "grammar.y"
     {
                       (yyval.meta) = yr_parser_reduce_meta_declaration(
                           yyscanner,
@@ -1990,7 +1988,7 @@ yyreduce:
     break;
 
   case 24:
-#line 355 "grammar.y"
+#line 353 "grammar.y"
     {
                       (yyval.meta) = yr_parser_reduce_meta_declaration(
                           yyscanner,
@@ -2006,7 +2004,7 @@ yyreduce:
     break;
 
   case 25:
-#line 368 "grammar.y"
+#line 366 "grammar.y"
     {
                       (yyval.meta) = yr_parser_reduce_meta_declaration(
                           yyscanner,
@@ -2022,17 +2020,17 @@ yyreduce:
     break;
 
   case 26:
-#line 383 "grammar.y"
+#line 381 "grammar.y"
     { (yyval.string) = (yyvsp[(1) - (1)].string); }
     break;
 
   case 27:
-#line 384 "grammar.y"
+#line 382 "grammar.y"
     { (yyval.string) = (yyvsp[(1) - (2)].string); }
     break;
 
   case 28:
-#line 389 "grammar.y"
+#line 387 "grammar.y"
     {
                         (yyval.string) = yr_parser_reduce_string_declaration(
                             yyscanner,
@@ -2048,7 +2046,7 @@ yyreduce:
     break;
 
   case 29:
-#line 402 "grammar.y"
+#line 400 "grammar.y"
     {
                         (yyval.string) = yr_parser_reduce_string_declaration(
                             yyscanner,
@@ -2064,7 +2062,7 @@ yyreduce:
     break;
 
   case 30:
-#line 415 "grammar.y"
+#line 413 "grammar.y"
     {
                         (yyval.string) = yr_parser_reduce_string_declaration(
                             yyscanner,
@@ -2080,51 +2078,51 @@ yyreduce:
     break;
 
   case 31:
-#line 430 "grammar.y"
+#line 428 "grammar.y"
     { (yyval.integer) = 0;  }
     break;
 
   case 32:
-#line 431 "grammar.y"
+#line 429 "grammar.y"
     { (yyval.integer) = (yyvsp[(1) - (2)].integer) | (yyvsp[(2) - (2)].integer); }
     break;
 
   case 33:
-#line 435 "grammar.y"
+#line 433 "grammar.y"
     { (yyval.integer) = STRING_GFLAGS_WIDE; }
     break;
 
   case 34:
-#line 436 "grammar.y"
+#line 434 "grammar.y"
     { (yyval.integer) = STRING_GFLAGS_ASCII; }
     break;
 
   case 35:
-#line 437 "grammar.y"
+#line 435 "grammar.y"
     { (yyval.integer) = STRING_GFLAGS_NO_CASE; }
     break;
 
   case 36:
-#line 438 "grammar.y"
+#line 436 "grammar.y"
     { (yyval.integer) = STRING_GFLAGS_FULL_WORD; }
     break;
 
   case 38:
-#line 444 "grammar.y"
+#line 442 "grammar.y"
     {
                         yr_parser_emit_with_arg(yyscanner, PUSH, 1, NULL);
                       }
     break;
 
   case 39:
-#line 448 "grammar.y"
+#line 446 "grammar.y"
     {
                         yr_parser_emit_with_arg(yyscanner, PUSH, 0, NULL);
                       }
     break;
 
   case 40:
-#line 452 "grammar.y"
+#line 450 "grammar.y"
     {
                         YARA_COMPILER* compiler = yyget_extra(yyscanner);
                         RULE* rule;
@@ -2157,13 +2155,13 @@ yyreduce:
     break;
 
   case 41:
-#line 482 "grammar.y"
+#line 480 "grammar.y"
     {
                         YARA_COMPILER* compiler = yyget_extra(yyscanner);
                         SIZED_STRING* sized_string = (yyvsp[(3) - (3)].sized_string);
                         RE* re;
 
-                        compiler->last_result = yr_parse_re_string(
+                        compiler->last_result = yr_re_compile(
                             sized_string->c_string, &re);
 
                         ERROR_IF(compiler->last_result != ERROR_SUCCESS);
@@ -2189,14 +2187,14 @@ yyreduce:
     break;
 
   case 42:
-#line 511 "grammar.y"
+#line 509 "grammar.y"
     {
                         yr_parser_emit(yyscanner, CONTAINS, NULL);
                       }
     break;
 
   case 43:
-#line 515 "grammar.y"
+#line 513 "grammar.y"
     {
                         int result = yr_parser_reduce_string_identifier(
                             yyscanner,
@@ -2210,7 +2208,7 @@ yyreduce:
     break;
 
   case 44:
-#line 526 "grammar.y"
+#line 524 "grammar.y"
     {
                         int result = yr_parser_reduce_string_identifier(
                             yyscanner,
@@ -2224,14 +2222,14 @@ yyreduce:
     break;
 
   case 45:
-#line 537 "grammar.y"
+#line 535 "grammar.y"
     {
                         yr_free((yyvsp[(1) - (4)].c_string));
                       }
     break;
 
   case 46:
-#line 541 "grammar.y"
+#line 539 "grammar.y"
     {
                         int result = yr_parser_reduce_string_identifier(
                             yyscanner,
@@ -2245,7 +2243,7 @@ yyreduce:
     break;
 
   case 47:
-#line 552 "grammar.y"
+#line 550 "grammar.y"
     {
                         yr_free((yyvsp[(1) - (6)].c_string));
                         yr_free((yyvsp[(5) - (6)].sized_string));
@@ -2253,7 +2251,7 @@ yyreduce:
     break;
 
   case 48:
-#line 557 "grammar.y"
+#line 555 "grammar.y"
     {
                         YARA_COMPILER* compiler = yyget_extra(yyscanner);
                         int result = ERROR_SUCCESS;
@@ -2293,7 +2291,7 @@ yyreduce:
     break;
 
   case 49:
-#line 594 "grammar.y"
+#line 592 "grammar.y"
     {
                         YARA_COMPILER* compiler = yyget_extra(yyscanner);
                         int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
@@ -2330,7 +2328,7 @@ yyreduce:
     break;
 
   case 50:
-#line 628 "grammar.y"
+#line 626 "grammar.y"
     {
                         YARA_COMPILER* compiler = yyget_extra(yyscanner);
                         int mem_offset;
@@ -2398,7 +2396,7 @@ yyreduce:
     break;
 
   case 51:
-#line 693 "grammar.y"
+#line 691 "grammar.y"
     {
                         YARA_COMPILER* compiler = yyget_extra(yyscanner);
                         int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
@@ -2426,7 +2424,7 @@ yyreduce:
     break;
 
   case 52:
-#line 718 "grammar.y"
+#line 716 "grammar.y"
     {
                         YARA_COMPILER* compiler = yyget_extra(yyscanner);
                         int mem_offset;
@@ -2473,90 +2471,90 @@ yyreduce:
     break;
 
   case 53:
-#line 762 "grammar.y"
+#line 760 "grammar.y"
     {
                         yr_parser_emit(yyscanner, OF, NULL);
                       }
     break;
 
   case 54:
-#line 766 "grammar.y"
+#line 764 "grammar.y"
     {
                       }
     break;
 
   case 55:
-#line 769 "grammar.y"
+#line 767 "grammar.y"
     {
                         yr_parser_emit(yyscanner, NOT, NULL);
                       }
     break;
 
   case 56:
-#line 773 "grammar.y"
+#line 771 "grammar.y"
     {
                         yr_parser_emit(yyscanner, AND, NULL);
                       }
     break;
 
   case 57:
-#line 777 "grammar.y"
+#line 775 "grammar.y"
     {
                         yr_parser_emit(yyscanner, OR, NULL);
                       }
     break;
 
   case 58:
-#line 781 "grammar.y"
+#line 779 "grammar.y"
     {
                         yr_parser_emit(yyscanner, LT, NULL);
                       }
     break;
 
   case 59:
-#line 785 "grammar.y"
+#line 783 "grammar.y"
     {
                         yr_parser_emit(yyscanner, GT, NULL);
                       }
     break;
 
   case 60:
-#line 789 "grammar.y"
+#line 787 "grammar.y"
     {
                         yr_parser_emit(yyscanner, LE, NULL);
                       }
     break;
 
   case 61:
-#line 793 "grammar.y"
+#line 791 "grammar.y"
     {
                         yr_parser_emit(yyscanner, GE, NULL);
                       }
     break;
 
   case 62:
-#line 797 "grammar.y"
+#line 795 "grammar.y"
     {
                         yr_parser_emit(yyscanner, EQ, NULL);
                       }
     break;
 
   case 63:
-#line 801 "grammar.y"
+#line 799 "grammar.y"
     {
                         yr_parser_emit(yyscanner, EQ, NULL);
                       }
     break;
 
   case 64:
-#line 805 "grammar.y"
+#line 803 "grammar.y"
     {
                         yr_parser_emit(yyscanner, NEQ, NULL);
                       }
     break;
 
   case 65:
-#line 812 "grammar.y"
+#line 810 "grammar.y"
     {
           YARA_COMPILER* compiler = yyget_extra(yyscanner);
           SIZED_STRING* sized_string = (yyvsp[(1) - (1)].sized_string);
@@ -2578,7 +2576,7 @@ yyreduce:
     break;
 
   case 66:
-#line 831 "grammar.y"
+#line 829 "grammar.y"
     {
           int result = yr_parser_reduce_external(
               yyscanner,
@@ -2592,24 +2590,24 @@ yyreduce:
     break;
 
   case 67:
-#line 844 "grammar.y"
+#line 842 "grammar.y"
     { (yyval.integer) = INTEGER_SET_ENUMERATION; }
     break;
 
   case 68:
-#line 845 "grammar.y"
+#line 843 "grammar.y"
     { (yyval.integer) = INTEGER_SET_RANGE; }
     break;
 
   case 72:
-#line 858 "grammar.y"
+#line 856 "grammar.y"
     {
                 yr_parser_emit_with_arg(yyscanner, PUSH, UNDEFINED, NULL);
               }
     break;
 
   case 74:
-#line 863 "grammar.y"
+#line 861 "grammar.y"
     {
                 yr_parser_emit_with_arg(yyscanner, PUSH, UNDEFINED, NULL);
                 yr_parser_emit_pushes_for_strings(yyscanner, "$*");
@@ -2617,7 +2615,7 @@ yyreduce:
     break;
 
   case 77:
-#line 874 "grammar.y"
+#line 872 "grammar.y"
     {
                             yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[(1) - (1)].c_string));
                             yr_free((yyvsp[(1) - (1)].c_string));
@@ -2625,7 +2623,7 @@ yyreduce:
     break;
 
   case 78:
-#line 879 "grammar.y"
+#line 877 "grammar.y"
     {
                             yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[(1) - (1)].c_string));
                             yr_free((yyvsp[(1) - (1)].c_string));
@@ -2633,84 +2631,84 @@ yyreduce:
     break;
 
   case 80:
-#line 887 "grammar.y"
+#line 885 "grammar.y"
     {
                     yr_parser_emit_with_arg(yyscanner, PUSH, UNDEFINED, NULL);
                   }
     break;
 
   case 81:
-#line 891 "grammar.y"
+#line 889 "grammar.y"
     {
                     yr_parser_emit_with_arg(yyscanner, PUSH, 1, NULL);
                   }
     break;
 
   case 83:
-#line 899 "grammar.y"
+#line 897 "grammar.y"
     {
                 yr_parser_emit(yyscanner, SIZE, NULL);
               }
     break;
 
   case 84:
-#line 903 "grammar.y"
+#line 901 "grammar.y"
     {
                 yr_parser_emit(yyscanner, ENTRYPOINT, NULL);
               }
     break;
 
   case 85:
-#line 907 "grammar.y"
+#line 905 "grammar.y"
     {
                 yr_parser_emit(yyscanner, INT8, NULL);
               }
     break;
 
   case 86:
-#line 911 "grammar.y"
+#line 909 "grammar.y"
     {
                 yr_parser_emit(yyscanner, INT16, NULL);
               }
     break;
 
   case 87:
-#line 915 "grammar.y"
+#line 913 "grammar.y"
     {
                 yr_parser_emit(yyscanner, INT32, NULL);
               }
     break;
 
   case 88:
-#line 919 "grammar.y"
+#line 917 "grammar.y"
     {
                 yr_parser_emit(yyscanner, UINT8, NULL);
               }
     break;
 
   case 89:
-#line 923 "grammar.y"
+#line 921 "grammar.y"
     {
                 yr_parser_emit(yyscanner, UINT16, NULL);
               }
     break;
 
   case 90:
-#line 927 "grammar.y"
+#line 925 "grammar.y"
     {
                 yr_parser_emit(yyscanner, UINT32, NULL);
               }
     break;
 
   case 91:
-#line 931 "grammar.y"
+#line 929 "grammar.y"
     {
                 yr_parser_emit_with_arg(yyscanner, PUSH, (yyvsp[(1) - (1)].integer), NULL);
               }
     break;
 
   case 92:
-#line 935 "grammar.y"
+#line 933 "grammar.y"
     {
                 int result = yr_parser_reduce_string_identifier(
                     yyscanner,
@@ -2724,7 +2722,7 @@ yyreduce:
     break;
 
   case 93:
-#line 946 "grammar.y"
+#line 944 "grammar.y"
     {
                 int result = yr_parser_reduce_string_identifier(
                     yyscanner,
@@ -2738,7 +2736,7 @@ yyreduce:
     break;
 
   case 94:
-#line 957 "grammar.y"
+#line 955 "grammar.y"
     {
                 int result = yr_parser_emit_with_arg(yyscanner, PUSH, 1, NULL);
 
@@ -2755,7 +2753,7 @@ yyreduce:
     break;
 
   case 95:
-#line 971 "grammar.y"
+#line 969 "grammar.y"
     {
                 YARA_COMPILER* compiler = yyget_extra(yyscanner);
                 int var_index;
@@ -2785,77 +2783,77 @@ yyreduce:
     break;
 
   case 96:
-#line 998 "grammar.y"
+#line 996 "grammar.y"
     {
                 yr_parser_emit(yyscanner, ADD, NULL);
               }
     break;
 
   case 97:
-#line 1002 "grammar.y"
+#line 1000 "grammar.y"
     {
                 yr_parser_emit(yyscanner, SUB, NULL);
               }
     break;
 
   case 98:
-#line 1006 "grammar.y"
+#line 1004 "grammar.y"
     {
                 yr_parser_emit(yyscanner, MUL, NULL);
               }
     break;
 
   case 99:
-#line 1010 "grammar.y"
+#line 1008 "grammar.y"
     {
                 yr_parser_emit(yyscanner, DIV, NULL);
               }
     break;
 
   case 100:
-#line 1014 "grammar.y"
+#line 1012 "grammar.y"
     {
                 yr_parser_emit(yyscanner, MOD, NULL);
               }
     break;
 
   case 101:
-#line 1018 "grammar.y"
+#line 1016 "grammar.y"
     {
                 yr_parser_emit(yyscanner, XOR, NULL);
               }
     break;
 
   case 102:
-#line 1022 "grammar.y"
+#line 1020 "grammar.y"
     {
                 yr_parser_emit(yyscanner, AND, NULL);
               }
     break;
 
   case 103:
-#line 1026 "grammar.y"
+#line 1024 "grammar.y"
     {
                 yr_parser_emit(yyscanner, OR, NULL);
               }
     break;
 
   case 104:
-#line 1030 "grammar.y"
+#line 1028 "grammar.y"
     {
                 yr_parser_emit(yyscanner, NEG, NULL);
               }
     break;
 
   case 105:
-#line 1034 "grammar.y"
+#line 1032 "grammar.y"
     {
                 yr_parser_emit(yyscanner, SHL, NULL);
               }
     break;
 
   case 106:
-#line 1038 "grammar.y"
+#line 1036 "grammar.y"
     {
                 yr_parser_emit(yyscanner, SHR, NULL);
               }
@@ -2863,7 +2861,7 @@ yyreduce:
 
 
 /* Line 1267 of yacc.c.  */
-#line 2867 "grammar.c"
+#line 2865 "grammar.c"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -3077,7 +3075,7 @@ yyreturn:
 }
 
 
-#line 1048 "grammar.y"
+#line 1046 "grammar.y"
 
 
 
diff --git a/libyara/grammar.h b/libyara/grammar.h
index d83cb6f..8aadb2b 100644
--- a/libyara/grammar.h
+++ b/libyara/grammar.h
@@ -170,7 +170,7 @@
 
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 typedef union YYSTYPE
-#line 150 "grammar.y"
+#line 148 "grammar.y"
 {
   SIZED_STRING*   sized_string;
   char*           c_string;
diff --git a/libyara/grammar.y b/libyara/grammar.y
index d0f3261..3bb5c88 100644
--- a/libyara/grammar.y
+++ b/libyara/grammar.y
@@ -37,8 +37,6 @@ limitations under the License.
 #define INTEGER_SET_ENUMERATION 1
 #define INTEGER_SET_RANGE 2
 
-
-
 #define ERROR_IF(x) \
     if (x) \
     { \
@@ -484,7 +482,7 @@ boolean_expression  : '(' boolean_expression ')'
                         SIZED_STRING* sized_string = $3;
                         RE* re;
 
-                        compiler->last_result = yr_parse_re_string(
+                        compiler->last_result = yr_re_compile(
                             sized_string->c_string, &re);
 
                         ERROR_IF(compiler->last_result != ERROR_SUCCESS);
diff --git a/libyara/hex_lexer.c b/libyara/hex_lexer.c
index 1320661..3f0432a 100644
--- a/libyara/hex_lexer.c
+++ b/libyara/hex_lexer.c
@@ -490,8 +490,7 @@ limitations under the License.
 #endif
 
 
-#define YY_DECL int hex_yylex \
-    (YYSTYPE * yylval_param , yyscan_t yyscanner, LEX_ENVIRONMENT* lex_env)
+
 
 #define LEX_ENV  ((LEX_ENVIRONMENT*) lex_env)
 
@@ -505,7 +504,7 @@ limitations under the License.
 
 #define YY_NO_UNISTD_H 1
 
-#line 509 "hex_lexer.c"
+#line 508 "hex_lexer.c"
 
 #define INITIAL 0
 #define range 1
@@ -739,11 +738,11 @@ YY_DECL
 	register int yy_act;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-#line 67 "hex_lexer.l"
+#line 66 "hex_lexer.l"
 
 
 
-#line 747 "hex_lexer.c"
+#line 746 "hex_lexer.c"
 
     yylval = yylval_param;
 
@@ -842,7 +841,7 @@ do_action:	/* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 70 "hex_lexer.l"
+#line 69 "hex_lexer.l"
 {
 
   yylval->integer = xtoi(yytext);
@@ -851,7 +850,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 76 "hex_lexer.l"
+#line 75 "hex_lexer.l"
 {
 
   yytext[1] = '0'; // replace ? by 0
@@ -861,7 +860,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 83 "hex_lexer.l"
+#line 82 "hex_lexer.l"
 {
 
   yytext[0] = '0'; // replace ? by 0
@@ -871,7 +870,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 90 "hex_lexer.l"
+#line 89 "hex_lexer.l"
 {
 
   yylval->integer = 0x0000;
@@ -880,7 +879,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 96 "hex_lexer.l"
+#line 95 "hex_lexer.l"
 {
 
   BEGIN(range);
@@ -889,14 +888,14 @@ YY_RULE_SETUP
 	YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 102 "hex_lexer.l"
+#line 101 "hex_lexer.l"
 {
   return yytext[0];
 }
 	YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 106 "hex_lexer.l"
+#line 105 "hex_lexer.l"
 {
 
   yylval->integer = atoi(yytext);
@@ -912,7 +911,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 119 "hex_lexer.l"
+#line 118 "hex_lexer.l"
 {
 
   BEGIN(INITIAL);
@@ -922,12 +921,12 @@ YY_RULE_SETUP
 case 9:
 /* rule 9 can match eol */
 YY_RULE_SETUP
-#line 126 "hex_lexer.l"
+#line 125 "hex_lexer.l"
 // skip whitespace
 	YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 129 "hex_lexer.l"
+#line 128 "hex_lexer.l"
 {
 
   if (yytext[0] >= 32 && yytext[0] < 127)
@@ -943,10 +942,10 @@ YY_RULE_SETUP
 	YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 142 "hex_lexer.l"
+#line 141 "hex_lexer.l"
 ECHO;
 	YY_BREAK
-#line 950 "hex_lexer.c"
+#line 949 "hex_lexer.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(range):
 	yyterminate();
@@ -2124,7 +2123,7 @@ void hex_yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 142 "hex_lexer.l"
+#line 141 "hex_lexer.l"
 
 
 
diff --git a/libyara/hex_lexer.h b/libyara/hex_lexer.h
index 412b7bb..aba470f 100644
--- a/libyara/hex_lexer.h
+++ b/libyara/hex_lexer.h
@@ -14,8 +14,9 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-
 #include "re.h"
+#include "hex_grammar.h"
+
 
 #define yyparse         hex_yyparse
 #define yylex           hex_yylex
@@ -43,15 +44,26 @@ typedef struct _LEX_ENVIRONMENT
 } LEX_ENVIRONMENT;
 
 
+#define LEX_ENV  ((LEX_ENVIRONMENT*) lex_env)
+
+#define YY_DECL int hex_yylex \
+    (YYSTYPE * yylval_param , yyscan_t yyscanner, LEX_ENVIRONMENT* lex_env)
+
+
 YY_EXTRA_TYPE yyget_extra(
     yyscan_t yyscanner);
 
+int yylex(
+    YYSTYPE* yylval_param,
+    yyscan_t yyscanner, 
+    LEX_ENVIRONMENT* lex_env);
+
+int yyparse(
+    void *yyscanner, 
+    LEX_ENVIRONMENT *lex_env);
+
 void yyerror(
     yyscan_t yyscanner,
     LEX_ENVIRONMENT* lex_env,
     const char *error_message);
 
-int yr_parse_hex_string(
-  const char* hex_string,
-  RE** re);
-
diff --git a/libyara/hex_lexer.l b/libyara/hex_lexer.l
index e10c81d..2ad0731 100644
--- a/libyara/hex_lexer.l
+++ b/libyara/hex_lexer.l
@@ -32,8 +32,7 @@ limitations under the License.
 #endif
 
 
-#define YY_DECL int hex_yylex \
-    (YYSTYPE * yylval_param , yyscan_t yyscanner, LEX_ENVIRONMENT* lex_env)
+
 
 #define LEX_ENV  ((LEX_ENVIRONMENT*) lex_env)
 
diff --git a/libyara/lexer.c b/libyara/lexer.c
index fbc0dd3..7b4f78d 100644
--- a/libyara/lexer.c
+++ b/libyara/lexer.c
@@ -648,6 +648,7 @@ limitations under the License.
 #include "grammar.h"
 #include "mem.h"
 #include "lexer.h"
+#include "utils.h"
 
 
 #define LEX_CHECK_SPACE_OK(data, current_size, max_length) \
@@ -677,7 +678,7 @@ limitations under the License.
 
 
 
-#line 681 "lexer.c"
+#line 682 "lexer.c"
 
 #define INITIAL 0
 #define str 1
@@ -914,10 +915,10 @@ YY_DECL
 	register int yy_act;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-#line 76 "lexer.l"
+#line 77 "lexer.l"
 
 
-#line 921 "lexer.c"
+#line 922 "lexer.c"
 
     yylval = yylval_param;
 
@@ -1016,253 +1017,253 @@ do_action:	/* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 78 "lexer.l"
+#line 79 "lexer.l"
 { return _LT_;          }
 	YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 79 "lexer.l"
+#line 80 "lexer.l"
 { return _GT_;          }
 	YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 80 "lexer.l"
+#line 81 "lexer.l"
 { return _LE_;          }
 	YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 81 "lexer.l"
+#line 82 "lexer.l"
 { return _GE_;          }
 	YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 82 "lexer.l"
+#line 83 "lexer.l"
 { return _EQ_;          }
 	YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 83 "lexer.l"
+#line 84 "lexer.l"
 { return _NEQ_;         }
 	YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 84 "lexer.l"
+#line 85 "lexer.l"
 { return _SHIFT_LEFT_;  }
 	YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 85 "lexer.l"
+#line 86 "lexer.l"
 { return _SHIFT_RIGHT_; }
 	YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 86 "lexer.l"
+#line 87 "lexer.l"
 { return _PRIVATE_;     }
 	YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 87 "lexer.l"
+#line 88 "lexer.l"
 { return _GLOBAL_;      }
 	YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 88 "lexer.l"
+#line 89 "lexer.l"
 { return _RULE_;        }
 	YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 89 "lexer.l"
+#line 90 "lexer.l"
 { return _META_;        }
 	YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 90 "lexer.l"
+#line 91 "lexer.l"
 { return _STRINGS_;     }
 	YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 91 "lexer.l"
+#line 92 "lexer.l"
 { return _ASCII_;       }
 	YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 92 "lexer.l"
+#line 93 "lexer.l"
 { return _WIDE_;        }
 	YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 93 "lexer.l"
+#line 94 "lexer.l"
 { return _FULLWORD_;    }
 	YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 94 "lexer.l"
+#line 95 "lexer.l"
 { return _NOCASE_;      }
 	YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 95 "lexer.l"
+#line 96 "lexer.l"
 { return _CONDITION_;   }
 	YY_BREAK
 case 19:
 YY_RULE_SETUP
-#line 96 "lexer.l"
+#line 97 "lexer.l"
 { return _TRUE_;        }
 	YY_BREAK
 case 20:
 YY_RULE_SETUP
-#line 97 "lexer.l"
+#line 98 "lexer.l"
 { return _FALSE_;       }
 	YY_BREAK
 case 21:
 YY_RULE_SETUP
-#line 98 "lexer.l"
+#line 99 "lexer.l"
 { return _NOT_;         }
 	YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 99 "lexer.l"
+#line 100 "lexer.l"
 { return _AND_;         }
 	YY_BREAK
 case 23:
 YY_RULE_SETUP
-#line 100 "lexer.l"
+#line 101 "lexer.l"
 { return _OR_;          }
 	YY_BREAK
 case 24:
 YY_RULE_SETUP
-#line 101 "lexer.l"
+#line 102 "lexer.l"
 { return _AT_;          }
 	YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 102 "lexer.l"
+#line 103 "lexer.l"
 { return _IN_;          }
 	YY_BREAK
 case 26:
 YY_RULE_SETUP
-#line 103 "lexer.l"
+#line 104 "lexer.l"
 { return _OF_;          }
 	YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 104 "lexer.l"
+#line 105 "lexer.l"
 { return _THEM_;        }
 	YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 105 "lexer.l"
+#line 106 "lexer.l"
 { return _FOR_;         }
 	YY_BREAK
 case 29:
 YY_RULE_SETUP
-#line 106 "lexer.l"
+#line 107 "lexer.l"
 { return _ALL_;         }
 	YY_BREAK
 case 30:
 YY_RULE_SETUP
-#line 107 "lexer.l"
+#line 108 "lexer.l"
 { return _ANY_;         }
 	YY_BREAK
 case 31:
 YY_RULE_SETUP
-#line 108 "lexer.l"
+#line 109 "lexer.l"
 { return _ENTRYPOINT_;  }
 	YY_BREAK
 case 32:
 YY_RULE_SETUP
-#line 109 "lexer.l"
+#line 110 "lexer.l"
 { return _SIZE_;        }
 	YY_BREAK
 case 33:
 YY_RULE_SETUP
-#line 110 "lexer.l"
+#line 111 "lexer.l"
 { return _RVA_;         }
 	YY_BREAK
 case 34:
 YY_RULE_SETUP
-#line 111 "lexer.l"
+#line 112 "lexer.l"
 { return _OFFSET_;      }
 	YY_BREAK
 case 35:
 YY_RULE_SETUP
-#line 112 "lexer.l"
+#line 113 "lexer.l"
 { return _FILE_;        }
 	YY_BREAK
 case 36:
 YY_RULE_SETUP
-#line 113 "lexer.l"
+#line 114 "lexer.l"
 { return _SECTION_;     }
 	YY_BREAK
 case 37:
 YY_RULE_SETUP
-#line 114 "lexer.l"
+#line 115 "lexer.l"
 { return _UINT8_;       }
 	YY_BREAK
 case 38:
 YY_RULE_SETUP
-#line 115 "lexer.l"
+#line 116 "lexer.l"
 { return _UINT16_;      }
 	YY_BREAK
 case 39:
 YY_RULE_SETUP
-#line 116 "lexer.l"
+#line 117 "lexer.l"
 { return _UINT32_;      }
 	YY_BREAK
 case 40:
 YY_RULE_SETUP
-#line 117 "lexer.l"
+#line 118 "lexer.l"
 { return _INT8_;        }
 	YY_BREAK
 case 41:
 YY_RULE_SETUP
-#line 118 "lexer.l"
+#line 119 "lexer.l"
 { return _INT16_;       }
 	YY_BREAK
 case 42:
 YY_RULE_SETUP
-#line 119 "lexer.l"
+#line 120 "lexer.l"
 { return _INT32_;       }
 	YY_BREAK
 case 43:
 YY_RULE_SETUP
-#line 120 "lexer.l"
+#line 121 "lexer.l"
 { return _MATCHES_;     }
 	YY_BREAK
 case 44:
 YY_RULE_SETUP
-#line 121 "lexer.l"
+#line 122 "lexer.l"
 { return _CONTAINS_;    }
 	YY_BREAK
 case 45:
 YY_RULE_SETUP
-#line 122 "lexer.l"
+#line 123 "lexer.l"
 { return _INDEX_;       }
 	YY_BREAK
 case 46:
 YY_RULE_SETUP
-#line 125 "lexer.l"
+#line 126 "lexer.l"
 { BEGIN(comment);       }
 	YY_BREAK
 case 47:
 YY_RULE_SETUP
-#line 126 "lexer.l"
+#line 127 "lexer.l"
 { BEGIN(INITIAL);       }
 	YY_BREAK
 case 48:
 /* rule 48 can match eol */
 YY_RULE_SETUP
-#line 127 "lexer.l"
+#line 128 "lexer.l"
 { /* skip comments */   }
 	YY_BREAK
 case 49:
 YY_RULE_SETUP
-#line 130 "lexer.l"
+#line 131 "lexer.l"
 { /* skip single-line comments */ }
 	YY_BREAK
 case 50:
 YY_RULE_SETUP
-#line 133 "lexer.l"
+#line 134 "lexer.l"
 {
                           yyextra->lex_buf_ptr = yyextra->lex_buf;
                           yyextra->lex_buf_len = 0;
@@ -1272,12 +1273,12 @@ YY_RULE_SETUP
 case 51:
 /* rule 51 can match eol */
 YY_RULE_SETUP
-#line 140 "lexer.l"
+#line 141 "lexer.l"
 { YYTEXT_TO_BUFFER; }
 	YY_BREAK
 case 52:
 YY_RULE_SETUP
-#line 143 "lexer.l"
+#line 144 "lexer.l"
 {
 
   char            buffer[1024];
@@ -1379,7 +1380,7 @@ case YY_STATE_EOF(str):
 case YY_STATE_EOF(regexp):
 case YY_STATE_EOF(include):
 case YY_STATE_EOF(comment):
-#line 241 "lexer.l"
+#line 242 "lexer.l"
 {
 
   YARA_COMPILER* compiler = yara_yyget_extra(yyscanner);
@@ -1401,7 +1402,7 @@ case YY_STATE_EOF(comment):
 	YY_BREAK
 case 53:
 YY_RULE_SETUP
-#line 261 "lexer.l"
+#line 262 "lexer.l"
 {
 
   yylval->c_string = yr_strdup(yytext);
@@ -1410,7 +1411,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 54:
 YY_RULE_SETUP
-#line 268 "lexer.l"
+#line 269 "lexer.l"
 {
 
   yylval->c_string = yr_strdup(yytext);
@@ -1419,7 +1420,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 55:
 YY_RULE_SETUP
-#line 275 "lexer.l"
+#line 276 "lexer.l"
 {
 
   yylval->c_string = yr_strdup(yytext);
@@ -1429,7 +1430,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 56:
 YY_RULE_SETUP
-#line 283 "lexer.l"
+#line 284 "lexer.l"
 {
 
   yylval->c_string = yr_strdup(yytext);
@@ -1439,7 +1440,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 57:
 YY_RULE_SETUP
-#line 291 "lexer.l"
+#line 292 "lexer.l"
 {
 
   if (strlen(yytext) > 128)
@@ -1453,7 +1454,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 58:
 YY_RULE_SETUP
-#line 303 "lexer.l"
+#line 304 "lexer.l"
 {
 
   yylval->integer = (size_t) atol(yytext);
@@ -1471,7 +1472,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 59:
 YY_RULE_SETUP
-#line 319 "lexer.l"
+#line 320 "lexer.l"
 {
 
   yylval->integer = xtoi(yytext + 2);
@@ -1480,7 +1481,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 60:
 YY_RULE_SETUP
-#line 326 "lexer.l"
+#line 327 "lexer.l"
 {     /* saw closing quote - all done */
 
   SIZED_STRING* s;
@@ -1504,7 +1505,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 61:
 YY_RULE_SETUP
-#line 348 "lexer.l"
+#line 349 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("\t", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1514,7 +1515,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 62:
 YY_RULE_SETUP
-#line 356 "lexer.l"
+#line 357 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("\"", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1524,7 +1525,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 63:
 YY_RULE_SETUP
-#line 364 "lexer.l"
+#line 365 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("\\", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1534,7 +1535,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 64:
 YY_RULE_SETUP
-#line 372 "lexer.l"
+#line 373 "lexer.l"
 {
 
    int result;
@@ -1547,13 +1548,13 @@ YY_RULE_SETUP
 	YY_BREAK
 case 65:
 YY_RULE_SETUP
-#line 383 "lexer.l"
+#line 384 "lexer.l"
 { YYTEXT_TO_BUFFER; }
 	YY_BREAK
 case 66:
 /* rule 66 can match eol */
 YY_RULE_SETUP
-#line 386 "lexer.l"
+#line 387 "lexer.l"
 {
 
   yyerror(yyscanner, "unterminated string");
@@ -1563,7 +1564,7 @@ YY_RULE_SETUP
 case 67:
 /* rule 67 can match eol */
 YY_RULE_SETUP
-#line 392 "lexer.l"
+#line 393 "lexer.l"
 {
 
   yyerror(yyscanner, "illegal escape sequence");
@@ -1571,7 +1572,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 68:
 YY_RULE_SETUP
-#line 398 "lexer.l"
+#line 399 "lexer.l"
 {
 
   SIZED_STRING* s;
@@ -1597,7 +1598,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 69:
 YY_RULE_SETUP
-#line 422 "lexer.l"
+#line 423 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("/", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1607,7 +1608,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 70:
 YY_RULE_SETUP
-#line 430 "lexer.l"
+#line 431 "lexer.l"
 {
 
   LEX_CHECK_SPACE_OK("\\.", yyextra->lex_buf_len, LEX_BUF_SIZE);
@@ -1618,13 +1619,13 @@ YY_RULE_SETUP
 	YY_BREAK
 case 71:
 YY_RULE_SETUP
-#line 439 "lexer.l"
+#line 440 "lexer.l"
 { YYTEXT_TO_BUFFER; }
 	YY_BREAK
 case 72:
 /* rule 72 can match eol */
 YY_RULE_SETUP
-#line 442 "lexer.l"
+#line 443 "lexer.l"
 {
 
   yyerror(yyscanner, "unterminated regular expression");
@@ -1633,7 +1634,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 73:
 YY_RULE_SETUP
-#line 449 "lexer.l"
+#line 450 "lexer.l"
 {
 
   yyextra->lex_buf_ptr = yyextra->lex_buf;
@@ -1643,7 +1644,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 74:
 YY_RULE_SETUP
-#line 457 "lexer.l"
+#line 458 "lexer.l"
 {
 
   yyextra->lex_buf_ptr = yyextra->lex_buf;
@@ -1654,7 +1655,7 @@ YY_RULE_SETUP
 case 75:
 /* rule 75 can match eol */
 YY_RULE_SETUP
-#line 465 "lexer.l"
+#line 466 "lexer.l"
 {
 
   int len = strlen(yytext);
@@ -1670,12 +1671,12 @@ YY_RULE_SETUP
 case 76:
 /* rule 76 can match eol */
 YY_RULE_SETUP
-#line 478 "lexer.l"
+#line 479 "lexer.l"
 /* skip whitespace */
 	YY_BREAK
 case 77:
 YY_RULE_SETUP
-#line 480 "lexer.l"
+#line 481 "lexer.l"
 {
 
   if (yytext[0] >= 32 && yytext[0] < 127)
@@ -1691,10 +1692,10 @@ YY_RULE_SETUP
 	YY_BREAK
 case 78:
 YY_RULE_SETUP
-#line 493 "lexer.l"
+#line 494 "lexer.l"
 ECHO;
 	YY_BREAK
-#line 1698 "lexer.c"
+#line 1699 "lexer.c"
 
 	case YY_END_OF_BUFFER:
 		{
@@ -2869,7 +2870,7 @@ void yara_yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 493 "lexer.l"
+#line 494 "lexer.l"
 
 
 
diff --git a/libyara/lexer.h b/libyara/lexer.h
index 702412c..b311cc0 100644
--- a/libyara/lexer.h
+++ b/libyara/lexer.h
@@ -14,9 +14,10 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
+#include "sizedstr.h"
+#include "grammar.h"
 #include "compiler.h"
 
-
 #define yyparse       yara_yyparse
 #define yylex         yara_yylex
 #define yyerror       yara_yyerror
@@ -35,6 +36,15 @@ typedef void* yyscan_t;
 #define YY_EXTRA_TYPE YARA_COMPILER*
 #define YY_USE_CONST
 
+int yyget_lineno(yyscan_t yyscanner);
+
+int yylex(
+    YYSTYPE* yylval_param,
+    yyscan_t yyscanner);
+
+int yyparse(
+    void *yyscanner);
+
 void yyerror(
     yyscan_t yyscanner,
     const char *error_message);
diff --git a/libyara/lexer.l b/libyara/lexer.l
index b4a74fb..c605c84 100644
--- a/libyara/lexer.l
+++ b/libyara/lexer.l
@@ -28,6 +28,7 @@ limitations under the License.
 #include "grammar.h"
 #include "mem.h"
 #include "lexer.h"
+#include "utils.h"
 
 
 #define LEX_CHECK_SPACE_OK(data, current_size, max_length) \
diff --git a/libyara/parser.c b/libyara/parser.c
index e086374..37fa348 100644
--- a/libyara/parser.c
+++ b/libyara/parser.c
@@ -268,10 +268,10 @@ STRING* yr_parser_reduce_string_declaration(
       flags & STRING_GFLAGS_REGEXP)
   {
     if (flags & STRING_GFLAGS_HEXADECIMAL)
-      compiler->last_result = yr_parse_hex_string(
+      compiler->last_result = yr_re_compile_hex(
           str->c_string, &re);
     else
-      compiler->last_result = yr_parse_re_string(
+      compiler->last_result = yr_re_compile(
           str->c_string, &re);
 
     if (compiler->last_result != ERROR_SUCCESS)
diff --git a/libyara/parser.h b/libyara/parser.h
index 5c4f19f..9611ac2 100644
--- a/libyara/parser.h
+++ b/libyara/parser.h
@@ -88,11 +88,17 @@ int yr_parser_reduce_string_identifier(
     int8_t instruction);
 
 
+void yr_parser_emit_pushes_for_strings(
+    yyscan_t yyscanner,
+    const char* identifier);
+
+
 int yr_parser_reduce_external(
     yyscan_t yyscanner,
     const char* identifier,
     int8_t intruction);
 
+
 int yr_parser_lookup_loop_variable(
     yyscan_t yyscanner,
     const char* identifier);
diff --git a/libyara/re.h b/libyara/re.h
index 42ac1e2..a06d6a1 100644
--- a/libyara/re.h
+++ b/libyara/re.h
@@ -127,6 +127,16 @@ int yr_re_create(
     RE** re);
 
 
+int yr_re_compile(
+    const char* re_string,
+    RE** re);
+
+
+int yr_re_compile_hex(
+    const char* hex_string,
+    RE** re);
+
+
 RE_NODE* yr_re_node_create(
     int type, 
     RE_NODE* left, 
diff --git a/libyara/re_lexer.c b/libyara/re_lexer.c
index 736cfe9..44f5239 100644
--- a/libyara/re_lexer.c
+++ b/libyara/re_lexer.c
@@ -511,17 +511,11 @@ limitations under the License.
 #endif
 
 
-#define YY_DECL int re_yylex \
-    (YYSTYPE * yylval_param , yyscan_t yyscanner, LEX_ENVIRONMENT* lex_env)
-
-#define LEX_ENV  ((LEX_ENVIRONMENT*) lex_env)
-
-
 uint8_t read_escaped_char(yyscan_t yyscanner);
 
 #define YY_NO_UNISTD_H 1
 
-#line 525 "re_lexer.c"
+#line 519 "re_lexer.c"
 
 #define INITIAL 0
 #define char_class 1
@@ -758,10 +752,10 @@ YY_DECL
 	register int yy_act;
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
 
-#line 61 "re_lexer.l"
+#line 55 "re_lexer.l"
 
 
-#line 765 "re_lexer.c"
+#line 759 "re_lexer.c"
 
     yylval = yylval_param;
 
@@ -861,7 +855,7 @@ do_action:	/* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 63 "re_lexer.l"
+#line 57 "re_lexer.l"
 {
 
   // If ^ was found just at the beginning of the regexp
@@ -873,7 +867,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 2:
 YY_RULE_SETUP
-#line 73 "re_lexer.l"
+#line 67 "re_lexer.l"
 {
   
   // In a perfect world we would be able to detect a trailing $
@@ -888,7 +882,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 3:
 YY_RULE_SETUP
-#line 86 "re_lexer.l"
+#line 80 "re_lexer.l"
 {
 
   // Examples: {3,8} {0,5} {,5} {7,}
@@ -924,7 +918,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 120 "re_lexer.l"
+#line 114 "re_lexer.l"
 {
 
   // Example: {10}
@@ -944,7 +938,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 5:
 YY_RULE_SETUP
-#line 138 "re_lexer.l"
+#line 132 "re_lexer.l"
 {
 
   // Start of a negated character class. Example: [^abcd] 
@@ -956,7 +950,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 6:
 YY_RULE_SETUP
-#line 147 "re_lexer.l"
+#line 141 "re_lexer.l"
 {
 
   // Start of character negated class containing a ]. 
@@ -971,7 +965,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 160 "re_lexer.l"
+#line 154 "re_lexer.l"
 {
 
   // Start of character class containing a ]. 
@@ -986,7 +980,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 173 "re_lexer.l"
+#line 167 "re_lexer.l"
 {
 
   // Start of character class. Example: [abcd]
@@ -999,7 +993,7 @@ YY_RULE_SETUP
 case 9:
 /* rule 9 can match eol */
 YY_RULE_SETUP
-#line 183 "re_lexer.l"
+#line 177 "re_lexer.l"
 {
 
   // Any non-special character is passed as a CHAR token to the scanner.
@@ -1010,49 +1004,49 @@ YY_RULE_SETUP
 	YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 192 "re_lexer.l"
+#line 186 "re_lexer.l"
 {
   return _WORD_CHAR_;
 }
 	YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 197 "re_lexer.l"
+#line 191 "re_lexer.l"
 {
   return _NON_WORD_CHAR_;
 }
 	YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 202 "re_lexer.l"
+#line 196 "re_lexer.l"
 {
   return _SPACE_;
 }
 	YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 207 "re_lexer.l"
+#line 201 "re_lexer.l"
 {
   return _NON_SPACE_;
 }
 	YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 212 "re_lexer.l"
+#line 206 "re_lexer.l"
 {
   return _DIGIT_;
 }
 	YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 217 "re_lexer.l"
+#line 211 "re_lexer.l"
 {
   return _NON_DIGIT_;
 }
 	YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 222 "re_lexer.l"
+#line 216 "re_lexer.l"
 {
   yylval->integer = read_escaped_char(yyscanner);
   return _CHAR_;
@@ -1060,7 +1054,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 228 "re_lexer.l"
+#line 222 "re_lexer.l"
 {
 
   // End of character class.
@@ -1083,7 +1077,7 @@ YY_RULE_SETUP
 case 18:
 /* rule 18 can match eol */
 YY_RULE_SETUP
-#line 248 "re_lexer.l"
+#line 242 "re_lexer.l"
 {
 
   // A range inside a character class.
@@ -1112,7 +1106,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 19:
 YY_RULE_SETUP
-#line 275 "re_lexer.l"
+#line 269 "re_lexer.l"
 {
 
   LEX_ENV->class_vector[']' / 8] |= 1 << ']' % 8;
@@ -1120,7 +1114,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 20:
 YY_RULE_SETUP
-#line 281 "re_lexer.l"
+#line 275 "re_lexer.l"
 {
 
   int i;
@@ -1135,7 +1129,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 21:
 YY_RULE_SETUP
-#line 294 "re_lexer.l"
+#line 288 "re_lexer.l"
 {
 
   int i;
@@ -1150,7 +1144,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 307 "re_lexer.l"
+#line 301 "re_lexer.l"
 {
 
   LEX_ENV->class_vector[' ' / 8] |= 1 << ' ' % 8;
@@ -1159,7 +1153,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 23:
 YY_RULE_SETUP
-#line 314 "re_lexer.l"
+#line 308 "re_lexer.l"
 {
 
   int i;
@@ -1173,7 +1167,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 24:
 YY_RULE_SETUP
-#line 326 "re_lexer.l"
+#line 320 "re_lexer.l"
 {
  
   char c;
@@ -1184,7 +1178,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 335 "re_lexer.l"
+#line 329 "re_lexer.l"
 {
 
   int i;
@@ -1199,7 +1193,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 26:
 YY_RULE_SETUP
-#line 348 "re_lexer.l"
+#line 342 "re_lexer.l"
 {
   
   uint8_t c = read_escaped_char(yyscanner);
@@ -1209,7 +1203,7 @@ YY_RULE_SETUP
 case 27:
 /* rule 27 can match eol */
 YY_RULE_SETUP
-#line 355 "re_lexer.l"
+#line 349 "re_lexer.l"
 {
 
   // A character class (i.e: [0-9a-f]) is represented by a 256-bits vector,
@@ -1219,7 +1213,7 @@ YY_RULE_SETUP
 }
 	YY_BREAK
 case YY_STATE_EOF(char_class):
-#line 364 "re_lexer.l"
+#line 358 "re_lexer.l"
 {
 
   // End of regexp reached while scanning a character class.
@@ -1230,7 +1224,7 @@ case YY_STATE_EOF(char_class):
 	YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 373 "re_lexer.l"
+#line 367 "re_lexer.l"
 {
 
   if (yytext[0] >= 32 && yytext[0] < 127)
@@ -1245,7 +1239,7 @@ YY_RULE_SETUP
 }
 	YY_BREAK
 case YY_STATE_EOF(INITIAL):
-#line 387 "re_lexer.l"
+#line 381 "re_lexer.l"
 {
 
   // If $ was found just before the end of the regexp
@@ -1262,10 +1256,10 @@ case YY_STATE_EOF(INITIAL):
 	YY_BREAK
 case 29:
 YY_RULE_SETUP
-#line 401 "re_lexer.l"
+#line 395 "re_lexer.l"
 ECHO;
 	YY_BREAK
-#line 1269 "re_lexer.c"
+#line 1263 "re_lexer.c"
 
 	case YY_END_OF_BUFFER:
 		{
@@ -2442,7 +2436,7 @@ void re_yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 401 "re_lexer.l"
+#line 395 "re_lexer.l"
 
 
 
diff --git a/libyara/re_lexer.h b/libyara/re_lexer.h
index 4238f80..81f1d67 100644
--- a/libyara/re_lexer.h
+++ b/libyara/re_lexer.h
@@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-
 #include "re.h"
+#include "re_grammar.h"
 
 #define yyparse         re_yyparse
 #define yylex           re_yylex
@@ -46,9 +46,24 @@ typedef struct _LEX_ENVIRONMENT
 } LEX_ENVIRONMENT;
 
 
+#define LEX_ENV  ((LEX_ENVIRONMENT*) lex_env)
+
+#define YY_DECL int re_yylex \
+    (YYSTYPE * yylval_param , yyscan_t yyscanner, LEX_ENVIRONMENT* lex_env)
+
+
 YY_EXTRA_TYPE yyget_extra(
     yyscan_t yyscanner);
 
+int yylex(
+    YYSTYPE* yylval_param,
+    yyscan_t yyscanner, 
+    LEX_ENVIRONMENT* lex_env);
+
+int yyparse(
+    void *yyscanner, 
+    LEX_ENVIRONMENT *lex_env);
+
 void yyerror(
     yyscan_t yyscanner,
     LEX_ENVIRONMENT* lex_env,
diff --git a/libyara/re_lexer.l b/libyara/re_lexer.l
index eeeaabf..880d6de 100644
--- a/libyara/re_lexer.l
+++ b/libyara/re_lexer.l
@@ -32,12 +32,6 @@ limitations under the License.
 #endif
 
 
-#define YY_DECL int re_yylex \
-    (YYSTYPE * yylval_param , yyscan_t yyscanner, LEX_ENVIRONMENT* lex_env)
-
-#define LEX_ENV  ((LEX_ENVIRONMENT*) lex_env)
-
-
 uint8_t read_escaped_char(yyscan_t yyscanner);
 
 %}
diff --git a/libyara/rules.c b/libyara/rules.c
index 49ee5f6..702e576 100644
--- a/libyara/rules.c
+++ b/libyara/rules.c
@@ -17,20 +17,18 @@ limitations under the License.
 #include <assert.h>
 #include <string.h>
 #include <time.h>
+#include <ctype.h>
 
 #include "arena.h"
 #include "exec.h"
 #include "exefiles.h"
 #include "filemap.h"
 #include "mem.h"
+#include "proc.h"
 #include "re.h"
 #include "utils.h"
 #include "yara.h"
 
-#ifdef WIN32
-#define inline __inline
-#endif
-
 
 typedef struct _CALLBACK_ARGS
 {
diff --git a/libyara/yara.h b/libyara/yara.h
index 5945e98..904adc9 100644
--- a/libyara/yara.h
+++ b/libyara/yara.h
@@ -567,6 +567,9 @@ void yr_finalize(void);
 int yr_get_tidx(void);
 
 
+void yr_set_tidx(int);
+
+
 int yr_compiler_create(
     YARA_COMPILER** compiler);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git



More information about the forensics-changes mailing list