diff --git a/libyara/grammar.c b/libyara/grammar.c index bfa4a0addf..089dd8c840 100644 --- a/libyara/grammar.c +++ b/libyara/grammar.c @@ -260,51 +260,62 @@ extern int yara_yydebug; _STRING_IDENTIFIER_WITH_WILDCARD_ = 271, /* "string identifier with wildcard" */ _NUMBER_ = 272, /* "integer number" */ _DOUBLE_ = 273, /* "floating point number" */ - _INTEGER_FUNCTION_ = 274, /* "integer function" */ - _TEXT_STRING_ = 275, /* "text string" */ - _HEX_STRING_ = 276, /* "hex string" */ - _REGEXP_ = 277, /* "regular expression" */ - _ASCII_ = 278, /* "" */ - _WIDE_ = 279, /* "" */ - _XOR_ = 280, /* "" */ - _BASE64_ = 281, /* "" */ - _BASE64_WIDE_ = 282, /* "" */ - _NOCASE_ = 283, /* "" */ - _FULLWORD_ = 284, /* "" */ - _AT_ = 285, /* "" */ - _FILESIZE_ = 286, /* "" */ - _ENTRYPOINT_ = 287, /* "" */ - _ALL_ = 288, /* "" */ - _ANY_ = 289, /* "" */ - _NONE_ = 290, /* "" */ - _IN_ = 291, /* "" */ - _OF_ = 292, /* "" */ - _FOR_ = 293, /* "" */ - _THEM_ = 294, /* "" */ - _MATCHES_ = 295, /* "" */ - _CONTAINS_ = 296, /* "" */ - _STARTSWITH_ = 297, /* "" */ - _ENDSWITH_ = 298, /* "" */ - _ICONTAINS_ = 299, /* "" */ - _ISTARTSWITH_ = 300, /* "" */ - _IENDSWITH_ = 301, /* "" */ - _IEQUALS_ = 302, /* "" */ - _IMPORT_ = 303, /* "" */ - _TRUE_ = 304, /* "" */ - _FALSE_ = 305, /* "" */ - _OR_ = 306, /* "" */ - _AND_ = 307, /* "" */ - _NOT_ = 308, /* "" */ - _DEFINED_ = 309, /* "" */ - _EQ_ = 310, /* "==" */ - _NEQ_ = 311, /* "!=" */ - _LT_ = 312, /* "<" */ - _LE_ = 313, /* "<=" */ - _GT_ = 314, /* ">" */ - _GE_ = 315, /* ">=" */ - _SHIFT_LEFT_ = 316, /* "<<" */ - _SHIFT_RIGHT_ = 317, /* ">>" */ - UNARY_MINUS = 318 /* UNARY_MINUS */ + _TEXT_STRING_ = 274, /* "text string" */ + _HEX_STRING_ = 275, /* "hex string" */ + _REGEXP_ = 276, /* "regular expression" */ + _INT8_FUNCTION_ = 277, /* "" */ + _UINT8_FUNCTION_ = 278, /* "" */ + _INT16_FUNCTION_ = 279, /* "" */ + _UINT16_FUNCTION_ = 280, /* "" */ + _INT32_FUNCTION_ = 281, /* "" */ + _UINT32_FUNCTION_ = 282, /* "" */ + _INT8BE_FUNCTION_ = 283, /* "" */ + _UINT8BE_FUNCTION_ = 284, /* "" */ + _INT16BE_FUNCTION_ = 285, /* "" */ + _UINT16BE_FUNCTION_ = 286, /* "" */ + _INT32BE_FUNCTION_ = 287, /* "" */ + _UINT32BE_FUNCTION_ = 288, /* "" */ + _ASCII_ = 289, /* "" */ + _WIDE_ = 290, /* "" */ + _XOR_ = 291, /* "" */ + _BASE64_ = 292, /* "" */ + _BASE64_WIDE_ = 293, /* "" */ + _NOCASE_ = 294, /* "" */ + _FULLWORD_ = 295, /* "" */ + _AT_ = 296, /* "" */ + _FILESIZE_ = 297, /* "" */ + _ENTRYPOINT_ = 298, /* "" */ + _ALL_ = 299, /* "" */ + _ANY_ = 300, /* "" */ + _NONE_ = 301, /* "" */ + _IN_ = 302, /* "" */ + _OF_ = 303, /* "" */ + _FOR_ = 304, /* "" */ + _THEM_ = 305, /* "" */ + _MATCHES_ = 306, /* "" */ + _CONTAINS_ = 307, /* "" */ + _STARTSWITH_ = 308, /* "" */ + _ENDSWITH_ = 309, /* "" */ + _ICONTAINS_ = 310, /* "" */ + _ISTARTSWITH_ = 311, /* "" */ + _IENDSWITH_ = 312, /* "" */ + _IEQUALS_ = 313, /* "" */ + _IMPORT_ = 314, /* "" */ + _TRUE_ = 315, /* "" */ + _FALSE_ = 316, /* "" */ + _OR_ = 317, /* "" */ + _AND_ = 318, /* "" */ + _NOT_ = 319, /* "" */ + _DEFINED_ = 320, /* "" */ + _EQ_ = 321, /* "==" */ + _NEQ_ = 322, /* "!=" */ + _LT_ = 323, /* "<" */ + _LE_ = 324, /* "<=" */ + _GT_ = 325, /* ">" */ + _GE_ = 326, /* ">=" */ + _SHIFT_LEFT_ = 327, /* "<<" */ + _SHIFT_RIGHT_ = 328, /* ">>" */ + UNARY_MINUS = 329 /* UNARY_MINUS */ }; typedef enum yytokentype yytoken_kind_t; #endif @@ -329,57 +340,68 @@ extern int yara_yydebug; #define _STRING_IDENTIFIER_WITH_WILDCARD_ 271 #define _NUMBER_ 272 #define _DOUBLE_ 273 -#define _INTEGER_FUNCTION_ 274 -#define _TEXT_STRING_ 275 -#define _HEX_STRING_ 276 -#define _REGEXP_ 277 -#define _ASCII_ 278 -#define _WIDE_ 279 -#define _XOR_ 280 -#define _BASE64_ 281 -#define _BASE64_WIDE_ 282 -#define _NOCASE_ 283 -#define _FULLWORD_ 284 -#define _AT_ 285 -#define _FILESIZE_ 286 -#define _ENTRYPOINT_ 287 -#define _ALL_ 288 -#define _ANY_ 289 -#define _NONE_ 290 -#define _IN_ 291 -#define _OF_ 292 -#define _FOR_ 293 -#define _THEM_ 294 -#define _MATCHES_ 295 -#define _CONTAINS_ 296 -#define _STARTSWITH_ 297 -#define _ENDSWITH_ 298 -#define _ICONTAINS_ 299 -#define _ISTARTSWITH_ 300 -#define _IENDSWITH_ 301 -#define _IEQUALS_ 302 -#define _IMPORT_ 303 -#define _TRUE_ 304 -#define _FALSE_ 305 -#define _OR_ 306 -#define _AND_ 307 -#define _NOT_ 308 -#define _DEFINED_ 309 -#define _EQ_ 310 -#define _NEQ_ 311 -#define _LT_ 312 -#define _LE_ 313 -#define _GT_ 314 -#define _GE_ 315 -#define _SHIFT_LEFT_ 316 -#define _SHIFT_RIGHT_ 317 -#define UNARY_MINUS 318 +#define _TEXT_STRING_ 274 +#define _HEX_STRING_ 275 +#define _REGEXP_ 276 +#define _INT8_FUNCTION_ 277 +#define _UINT8_FUNCTION_ 278 +#define _INT16_FUNCTION_ 279 +#define _UINT16_FUNCTION_ 280 +#define _INT32_FUNCTION_ 281 +#define _UINT32_FUNCTION_ 282 +#define _INT8BE_FUNCTION_ 283 +#define _UINT8BE_FUNCTION_ 284 +#define _INT16BE_FUNCTION_ 285 +#define _UINT16BE_FUNCTION_ 286 +#define _INT32BE_FUNCTION_ 287 +#define _UINT32BE_FUNCTION_ 288 +#define _ASCII_ 289 +#define _WIDE_ 290 +#define _XOR_ 291 +#define _BASE64_ 292 +#define _BASE64_WIDE_ 293 +#define _NOCASE_ 294 +#define _FULLWORD_ 295 +#define _AT_ 296 +#define _FILESIZE_ 297 +#define _ENTRYPOINT_ 298 +#define _ALL_ 299 +#define _ANY_ 300 +#define _NONE_ 301 +#define _IN_ 302 +#define _OF_ 303 +#define _FOR_ 304 +#define _THEM_ 305 +#define _MATCHES_ 306 +#define _CONTAINS_ 307 +#define _STARTSWITH_ 308 +#define _ENDSWITH_ 309 +#define _ICONTAINS_ 310 +#define _ISTARTSWITH_ 311 +#define _IENDSWITH_ 312 +#define _IEQUALS_ 313 +#define _IMPORT_ 314 +#define _TRUE_ 315 +#define _FALSE_ 316 +#define _OR_ 317 +#define _AND_ 318 +#define _NOT_ 319 +#define _DEFINED_ 320 +#define _EQ_ 321 +#define _NEQ_ 322 +#define _LT_ 323 +#define _LE_ 324 +#define _GT_ 325 +#define _GE_ 326 +#define _SHIFT_LEFT_ 327 +#define _SHIFT_RIGHT_ 328 +#define UNARY_MINUS 329 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { -#line 342 "libyara/grammar.y" +#line 354 "libyara/grammar.y" YR_EXPRESSION expression; SIZED_STRING* sized_string; @@ -394,7 +416,7 @@ union YYSTYPE YR_ARENA_REF meta; YR_ARENA_REF string; -#line 398 "libyara/grammar.c" +#line 420 "libyara/grammar.c" }; typedef union YYSTYPE YYSTYPE; @@ -432,125 +454,137 @@ enum yysymbol_kind_t YYSYMBOL__STRING_IDENTIFIER_WITH_WILDCARD_ = 16, /* "string identifier with wildcard" */ YYSYMBOL__NUMBER_ = 17, /* "integer number" */ YYSYMBOL__DOUBLE_ = 18, /* "floating point number" */ - YYSYMBOL__INTEGER_FUNCTION_ = 19, /* "integer function" */ - YYSYMBOL__TEXT_STRING_ = 20, /* "text string" */ - YYSYMBOL__HEX_STRING_ = 21, /* "hex string" */ - YYSYMBOL__REGEXP_ = 22, /* "regular expression" */ - YYSYMBOL__ASCII_ = 23, /* "" */ - YYSYMBOL__WIDE_ = 24, /* "" */ - YYSYMBOL__XOR_ = 25, /* "" */ - YYSYMBOL__BASE64_ = 26, /* "" */ - YYSYMBOL__BASE64_WIDE_ = 27, /* "" */ - YYSYMBOL__NOCASE_ = 28, /* "" */ - YYSYMBOL__FULLWORD_ = 29, /* "" */ - YYSYMBOL__AT_ = 30, /* "" */ - YYSYMBOL__FILESIZE_ = 31, /* "" */ - YYSYMBOL__ENTRYPOINT_ = 32, /* "" */ - YYSYMBOL__ALL_ = 33, /* "" */ - YYSYMBOL__ANY_ = 34, /* "" */ - YYSYMBOL__NONE_ = 35, /* "" */ - YYSYMBOL__IN_ = 36, /* "" */ - YYSYMBOL__OF_ = 37, /* "" */ - YYSYMBOL__FOR_ = 38, /* "" */ - YYSYMBOL__THEM_ = 39, /* "" */ - YYSYMBOL__MATCHES_ = 40, /* "" */ - YYSYMBOL__CONTAINS_ = 41, /* "" */ - YYSYMBOL__STARTSWITH_ = 42, /* "" */ - YYSYMBOL__ENDSWITH_ = 43, /* "" */ - YYSYMBOL__ICONTAINS_ = 44, /* "" */ - YYSYMBOL__ISTARTSWITH_ = 45, /* "" */ - YYSYMBOL__IENDSWITH_ = 46, /* "" */ - YYSYMBOL__IEQUALS_ = 47, /* "" */ - YYSYMBOL__IMPORT_ = 48, /* "" */ - YYSYMBOL__TRUE_ = 49, /* "" */ - YYSYMBOL__FALSE_ = 50, /* "" */ - YYSYMBOL__OR_ = 51, /* "" */ - YYSYMBOL__AND_ = 52, /* "" */ - YYSYMBOL__NOT_ = 53, /* "" */ - YYSYMBOL__DEFINED_ = 54, /* "" */ - YYSYMBOL__EQ_ = 55, /* "==" */ - YYSYMBOL__NEQ_ = 56, /* "!=" */ - YYSYMBOL__LT_ = 57, /* "<" */ - YYSYMBOL__LE_ = 58, /* "<=" */ - YYSYMBOL__GT_ = 59, /* ">" */ - YYSYMBOL__GE_ = 60, /* ">=" */ - YYSYMBOL__SHIFT_LEFT_ = 61, /* "<<" */ - YYSYMBOL__SHIFT_RIGHT_ = 62, /* ">>" */ - YYSYMBOL_63_ = 63, /* '|' */ - YYSYMBOL_64_ = 64, /* '^' */ - YYSYMBOL_65_ = 65, /* '&' */ - YYSYMBOL_66_ = 66, /* '+' */ - YYSYMBOL_67_ = 67, /* '-' */ - YYSYMBOL_68_ = 68, /* '*' */ - YYSYMBOL_69_ = 69, /* '\\' */ - YYSYMBOL_70_ = 70, /* '%' */ - YYSYMBOL_71_ = 71, /* '~' */ - YYSYMBOL_UNARY_MINUS = 72, /* UNARY_MINUS */ - YYSYMBOL_73_include_ = 73, /* "include" */ - YYSYMBOL_74_ = 74, /* '{' */ - YYSYMBOL_75_ = 75, /* '}' */ - YYSYMBOL_76_ = 76, /* ':' */ - YYSYMBOL_77_ = 77, /* '=' */ - YYSYMBOL_78_ = 78, /* '(' */ - YYSYMBOL_79_ = 79, /* ')' */ - YYSYMBOL_80_ = 80, /* '.' */ - YYSYMBOL_81_ = 81, /* '[' */ - YYSYMBOL_82_ = 82, /* ']' */ - YYSYMBOL_83_ = 83, /* ',' */ - YYSYMBOL_YYACCEPT = 84, /* $accept */ - YYSYMBOL_rules = 85, /* rules */ - YYSYMBOL_import = 86, /* import */ - YYSYMBOL_rule = 87, /* rule */ - YYSYMBOL_88_1 = 88, /* @1 */ - YYSYMBOL_89_2 = 89, /* $@2 */ - YYSYMBOL_meta = 90, /* meta */ - YYSYMBOL_strings = 91, /* strings */ - YYSYMBOL_condition = 92, /* condition */ - YYSYMBOL_rule_modifiers = 93, /* rule_modifiers */ - YYSYMBOL_rule_modifier = 94, /* rule_modifier */ - YYSYMBOL_tags = 95, /* tags */ - YYSYMBOL_tag_list = 96, /* tag_list */ - YYSYMBOL_meta_declarations = 97, /* meta_declarations */ - YYSYMBOL_meta_declaration = 98, /* meta_declaration */ - YYSYMBOL_string_declarations = 99, /* string_declarations */ - YYSYMBOL_string_declaration = 100, /* string_declaration */ - YYSYMBOL_101_3 = 101, /* $@3 */ - YYSYMBOL_102_4 = 102, /* $@4 */ - YYSYMBOL_103_5 = 103, /* $@5 */ - YYSYMBOL_string_modifiers = 104, /* string_modifiers */ - YYSYMBOL_string_modifier = 105, /* string_modifier */ - YYSYMBOL_regexp_modifiers = 106, /* regexp_modifiers */ - YYSYMBOL_regexp_modifier = 107, /* regexp_modifier */ - YYSYMBOL_hex_modifiers = 108, /* hex_modifiers */ - YYSYMBOL_hex_modifier = 109, /* hex_modifier */ - YYSYMBOL_identifier = 110, /* identifier */ - YYSYMBOL_arguments = 111, /* arguments */ - YYSYMBOL_arguments_list = 112, /* arguments_list */ - YYSYMBOL_regexp = 113, /* regexp */ - YYSYMBOL_boolean_expression = 114, /* boolean_expression */ - YYSYMBOL_expression = 115, /* expression */ - YYSYMBOL_116_6 = 116, /* $@6 */ - YYSYMBOL_117_7 = 117, /* $@7 */ - YYSYMBOL_118_8 = 118, /* $@8 */ - YYSYMBOL_119_9 = 119, /* $@9 */ - YYSYMBOL_for_iteration = 120, /* for_iteration */ - YYSYMBOL_for_variables = 121, /* for_variables */ - YYSYMBOL_iterator = 122, /* iterator */ - YYSYMBOL_set = 123, /* set */ - YYSYMBOL_range = 124, /* range */ - YYSYMBOL_enumeration = 125, /* enumeration */ - YYSYMBOL_string_iterator = 126, /* string_iterator */ - YYSYMBOL_string_set = 127, /* string_set */ - YYSYMBOL_128_10 = 128, /* $@10 */ - YYSYMBOL_string_enumeration = 129, /* string_enumeration */ - YYSYMBOL_string_enumeration_item = 130, /* string_enumeration_item */ - YYSYMBOL_rule_set = 131, /* rule_set */ - YYSYMBOL_132_11 = 132, /* $@11 */ - YYSYMBOL_rule_enumeration = 133, /* rule_enumeration */ - YYSYMBOL_rule_enumeration_item = 134, /* rule_enumeration_item */ - YYSYMBOL_for_expression = 135, /* for_expression */ - YYSYMBOL_for_quantifier = 136, /* for_quantifier */ - YYSYMBOL_primary_expression = 137 /* primary_expression */ + YYSYMBOL__TEXT_STRING_ = 19, /* "text string" */ + YYSYMBOL__HEX_STRING_ = 20, /* "hex string" */ + YYSYMBOL__REGEXP_ = 21, /* "regular expression" */ + YYSYMBOL__INT8_FUNCTION_ = 22, /* "" */ + YYSYMBOL__UINT8_FUNCTION_ = 23, /* "" */ + YYSYMBOL__INT16_FUNCTION_ = 24, /* "" */ + YYSYMBOL__UINT16_FUNCTION_ = 25, /* "" */ + YYSYMBOL__INT32_FUNCTION_ = 26, /* "" */ + YYSYMBOL__UINT32_FUNCTION_ = 27, /* "" */ + YYSYMBOL__INT8BE_FUNCTION_ = 28, /* "" */ + YYSYMBOL__UINT8BE_FUNCTION_ = 29, /* "" */ + YYSYMBOL__INT16BE_FUNCTION_ = 30, /* "" */ + YYSYMBOL__UINT16BE_FUNCTION_ = 31, /* "" */ + YYSYMBOL__INT32BE_FUNCTION_ = 32, /* "" */ + YYSYMBOL__UINT32BE_FUNCTION_ = 33, /* "" */ + YYSYMBOL__ASCII_ = 34, /* "" */ + YYSYMBOL__WIDE_ = 35, /* "" */ + YYSYMBOL__XOR_ = 36, /* "" */ + YYSYMBOL__BASE64_ = 37, /* "" */ + YYSYMBOL__BASE64_WIDE_ = 38, /* "" */ + YYSYMBOL__NOCASE_ = 39, /* "" */ + YYSYMBOL__FULLWORD_ = 40, /* "" */ + YYSYMBOL__AT_ = 41, /* "" */ + YYSYMBOL__FILESIZE_ = 42, /* "" */ + YYSYMBOL__ENTRYPOINT_ = 43, /* "" */ + YYSYMBOL__ALL_ = 44, /* "" */ + YYSYMBOL__ANY_ = 45, /* "" */ + YYSYMBOL__NONE_ = 46, /* "" */ + YYSYMBOL__IN_ = 47, /* "" */ + YYSYMBOL__OF_ = 48, /* "" */ + YYSYMBOL__FOR_ = 49, /* "" */ + YYSYMBOL__THEM_ = 50, /* "" */ + YYSYMBOL__MATCHES_ = 51, /* "" */ + YYSYMBOL__CONTAINS_ = 52, /* "" */ + YYSYMBOL__STARTSWITH_ = 53, /* "" */ + YYSYMBOL__ENDSWITH_ = 54, /* "" */ + YYSYMBOL__ICONTAINS_ = 55, /* "" */ + YYSYMBOL__ISTARTSWITH_ = 56, /* "" */ + YYSYMBOL__IENDSWITH_ = 57, /* "" */ + YYSYMBOL__IEQUALS_ = 58, /* "" */ + YYSYMBOL__IMPORT_ = 59, /* "" */ + YYSYMBOL__TRUE_ = 60, /* "" */ + YYSYMBOL__FALSE_ = 61, /* "" */ + YYSYMBOL__OR_ = 62, /* "" */ + YYSYMBOL__AND_ = 63, /* "" */ + YYSYMBOL__NOT_ = 64, /* "" */ + YYSYMBOL__DEFINED_ = 65, /* "" */ + YYSYMBOL__EQ_ = 66, /* "==" */ + YYSYMBOL__NEQ_ = 67, /* "!=" */ + YYSYMBOL__LT_ = 68, /* "<" */ + YYSYMBOL__LE_ = 69, /* "<=" */ + YYSYMBOL__GT_ = 70, /* ">" */ + YYSYMBOL__GE_ = 71, /* ">=" */ + YYSYMBOL__SHIFT_LEFT_ = 72, /* "<<" */ + YYSYMBOL__SHIFT_RIGHT_ = 73, /* ">>" */ + YYSYMBOL_74_ = 74, /* '|' */ + YYSYMBOL_75_ = 75, /* '^' */ + YYSYMBOL_76_ = 76, /* '&' */ + YYSYMBOL_77_ = 77, /* '+' */ + YYSYMBOL_78_ = 78, /* '-' */ + YYSYMBOL_79_ = 79, /* '*' */ + YYSYMBOL_80_ = 80, /* '\\' */ + YYSYMBOL_81_ = 81, /* '%' */ + YYSYMBOL_82_ = 82, /* '~' */ + YYSYMBOL_UNARY_MINUS = 83, /* UNARY_MINUS */ + YYSYMBOL_84_include_ = 84, /* "include" */ + YYSYMBOL_85_ = 85, /* '{' */ + YYSYMBOL_86_ = 86, /* '}' */ + YYSYMBOL_87_ = 87, /* ':' */ + YYSYMBOL_88_ = 88, /* '=' */ + YYSYMBOL_89_ = 89, /* '(' */ + YYSYMBOL_90_ = 90, /* ')' */ + YYSYMBOL_91_ = 91, /* '.' */ + YYSYMBOL_92_ = 92, /* '[' */ + YYSYMBOL_93_ = 93, /* ']' */ + YYSYMBOL_94_ = 94, /* ',' */ + YYSYMBOL_YYACCEPT = 95, /* $accept */ + YYSYMBOL_rules = 96, /* rules */ + YYSYMBOL_import = 97, /* import */ + YYSYMBOL_rule = 98, /* rule */ + YYSYMBOL_99_1 = 99, /* @1 */ + YYSYMBOL_100_2 = 100, /* $@2 */ + YYSYMBOL_meta = 101, /* meta */ + YYSYMBOL_strings = 102, /* strings */ + YYSYMBOL_condition = 103, /* condition */ + YYSYMBOL_rule_modifiers = 104, /* rule_modifiers */ + YYSYMBOL_rule_modifier = 105, /* rule_modifier */ + YYSYMBOL_tags = 106, /* tags */ + YYSYMBOL_tag_list = 107, /* tag_list */ + YYSYMBOL_meta_declarations = 108, /* meta_declarations */ + YYSYMBOL_meta_declaration = 109, /* meta_declaration */ + YYSYMBOL_string_declarations = 110, /* string_declarations */ + YYSYMBOL_string_declaration = 111, /* string_declaration */ + YYSYMBOL_112_3 = 112, /* $@3 */ + YYSYMBOL_113_4 = 113, /* $@4 */ + YYSYMBOL_114_5 = 114, /* $@5 */ + YYSYMBOL_string_modifiers = 115, /* string_modifiers */ + YYSYMBOL_string_modifier = 116, /* string_modifier */ + YYSYMBOL_regexp_modifiers = 117, /* regexp_modifiers */ + YYSYMBOL_regexp_modifier = 118, /* regexp_modifier */ + YYSYMBOL_hex_modifiers = 119, /* hex_modifiers */ + YYSYMBOL_hex_modifier = 120, /* hex_modifier */ + YYSYMBOL_identifier = 121, /* identifier */ + YYSYMBOL_arguments = 122, /* arguments */ + YYSYMBOL_arguments_list = 123, /* arguments_list */ + YYSYMBOL_regexp = 124, /* regexp */ + YYSYMBOL_boolean_expression = 125, /* boolean_expression */ + YYSYMBOL_expression = 126, /* expression */ + YYSYMBOL_127_6 = 127, /* $@6 */ + YYSYMBOL_128_7 = 128, /* $@7 */ + YYSYMBOL_129_8 = 129, /* $@8 */ + YYSYMBOL_130_9 = 130, /* $@9 */ + YYSYMBOL_for_iteration = 131, /* for_iteration */ + YYSYMBOL_for_variables = 132, /* for_variables */ + YYSYMBOL_iterator = 133, /* iterator */ + YYSYMBOL_set = 134, /* set */ + YYSYMBOL_range = 135, /* range */ + YYSYMBOL_enumeration = 136, /* enumeration */ + YYSYMBOL_string_iterator = 137, /* string_iterator */ + YYSYMBOL_string_set = 138, /* string_set */ + YYSYMBOL_139_10 = 139, /* $@10 */ + YYSYMBOL_string_enumeration = 140, /* string_enumeration */ + YYSYMBOL_string_enumeration_item = 141, /* string_enumeration_item */ + YYSYMBOL_rule_set = 142, /* rule_set */ + YYSYMBOL_143_11 = 143, /* $@11 */ + YYSYMBOL_rule_enumeration = 144, /* rule_enumeration */ + YYSYMBOL_rule_enumeration_item = 145, /* rule_enumeration_item */ + YYSYMBOL_for_expression = 146, /* for_expression */ + YYSYMBOL_for_quantifier = 147, /* for_quantifier */ + YYSYMBOL_integer_function = 148, /* integer_function */ + YYSYMBOL_primary_expression = 149 /* primary_expression */ }; typedef enum yysymbol_kind_t yysymbol_kind_t; @@ -878,19 +912,19 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 476 +#define YYLAST 519 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 84 +#define YYNTOKENS 95 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 54 +#define YYNNTS 55 /* YYNRULES -- Number of rules. */ -#define YYNRULES 168 +#define YYNRULES 180 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 275 +#define YYNSTATES 287 /* YYMAXUTOK -- Last valid token kind. */ -#define YYMAXUTOK 319 +#define YYMAXUTOK 330 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM @@ -907,16 +941,16 @@ static const yytype_int8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 70, 65, 2, - 78, 79, 68, 66, 83, 67, 80, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 76, 2, - 2, 77, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 81, 76, 2, + 89, 90, 79, 77, 94, 78, 91, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 87, 2, + 2, 88, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 81, 69, 82, 64, 2, 2, 2, 2, 2, + 2, 92, 80, 93, 75, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 74, 63, 75, 71, 2, 2, 2, + 2, 2, 2, 85, 74, 86, 82, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -935,30 +969,34 @@ static const yytype_int8 yytranslate[] = 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 72, 73 + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 68, 69, 70, 71, 72, 73, 83, + 84 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_int16 yyrline[] = { - 0, 361, 361, 362, 363, 364, 365, 366, 367, 375, - 388, 393, 387, 420, 423, 439, 442, 457, 462, 463, - 468, 469, 475, 478, 494, 503, 545, 546, 551, 568, - 582, 596, 610, 628, 629, 635, 634, 651, 650, 671, - 670, 695, 701, 761, 762, 763, 764, 765, 766, 772, - 793, 824, 829, 846, 851, 871, 872, 886, 887, 888, - 889, 890, 894, 895, 909, 913, 1008, 1056, 1117, 1162, - 1163, 1167, 1202, 1255, 1297, 1320, 1326, 1332, 1344, 1354, - 1364, 1374, 1384, 1394, 1404, 1414, 1428, 1443, 1454, 1529, - 1567, 1471, 1695, 1706, 1717, 1736, 1755, 1767, 1804, 1810, - 1816, 1815, 1861, 1860, 1904, 1911, 1918, 1925, 1932, 1939, - 1946, 1950, 1958, 1959, 1984, 2004, 2032, 2106, 2134, 2153, - 2164, 2207, 2223, 2243, 2253, 2252, 2261, 2275, 2276, 2281, - 2291, 2306, 2305, 2318, 2319, 2324, 2357, 2382, 2438, 2445, - 2451, 2457, 2467, 2471, 2479, 2491, 2505, 2512, 2519, 2544, - 2556, 2568, 2580, 2595, 2607, 2622, 2665, 2686, 2721, 2756, - 2790, 2815, 2832, 2842, 2852, 2862, 2872, 2892, 2912 + 0, 373, 373, 374, 375, 376, 377, 378, 379, 387, + 400, 405, 399, 432, 435, 451, 454, 469, 474, 475, + 480, 481, 487, 490, 506, 515, 557, 558, 563, 580, + 594, 608, 622, 640, 641, 647, 646, 663, 662, 683, + 682, 707, 713, 773, 774, 775, 776, 777, 778, 784, + 805, 836, 841, 858, 863, 883, 884, 898, 899, 900, + 901, 902, 906, 907, 921, 925, 1020, 1068, 1129, 1174, + 1175, 1179, 1214, 1267, 1309, 1332, 1338, 1344, 1356, 1366, + 1376, 1386, 1396, 1406, 1416, 1426, 1440, 1455, 1466, 1541, + 1579, 1483, 1707, 1718, 1729, 1748, 1767, 1779, 1816, 1822, + 1828, 1827, 1873, 1872, 1916, 1923, 1930, 1937, 1944, 1973, + 1980, 1984, 1992, 1993, 2018, 2038, 2066, 2140, 2168, 2187, + 2198, 2241, 2257, 2277, 2287, 2286, 2295, 2309, 2310, 2315, + 2325, 2340, 2339, 2352, 2353, 2358, 2391, 2416, 2472, 2479, + 2485, 2491, 2501, 2507, 2513, 2519, 2525, 2531, 2537, 2543, + 2549, 2555, 2561, 2567, 2577, 2581, 2589, 2601, 2611, 2618, + 2625, 2650, 2662, 2674, 2686, 2701, 2713, 2728, 2771, 2792, + 2828, 2864, 2899, 2925, 2943, 2954, 2965, 2976, 2986, 3007, + 3028 }; #endif @@ -980,31 +1018,34 @@ static const char *const yytname[] = "\"identifier\"", "\"string identifier\"", "\"string count\"", "\"string offset\"", "\"string length\"", "\"string identifier with wildcard\"", "\"integer number\"", - "\"floating point number\"", "\"integer function\"", "\"text string\"", - "\"hex string\"", "\"regular expression\"", "\"\"", "\"\"", - "\"\"", "\"\"", "\"\"", "\"\"", - "\"\"", "\"\"", "\"\"", "\"\"", - "\"\"", "\"\"", "\"\"", "\"\"", "\"\"", - "\"\"", "\"\"", "\"\"", "\"\"", - "\"\"", "\"\"", "\"\"", - "\"\"", "\"\"", "\"\"", "\"\"", - "\"\"", "\"\"", "\"\"", "\"\"", "\"\"", - "\"\"", "\"==\"", "\"!=\"", "\"<\"", "\"<=\"", "\">\"", - "\">=\"", "\"<<\"", "\">>\"", "'|'", "'^'", "'&'", "'+'", "'-'", "'*'", - "'\\\\'", "'%'", "'~'", "UNARY_MINUS", "\"include\"", "'{'", "'}'", - "':'", "'='", "'('", "')'", "'.'", "'['", "']'", "','", "$accept", - "rules", "import", "rule", "@1", "$@2", "meta", "strings", "condition", - "rule_modifiers", "rule_modifier", "tags", "tag_list", - "meta_declarations", "meta_declaration", "string_declarations", - "string_declaration", "$@3", "$@4", "$@5", "string_modifiers", - "string_modifier", "regexp_modifiers", "regexp_modifier", - "hex_modifiers", "hex_modifier", "identifier", "arguments", - "arguments_list", "regexp", "boolean_expression", "expression", "$@6", - "$@7", "$@8", "$@9", "for_iteration", "for_variables", "iterator", "set", - "range", "enumeration", "string_iterator", "string_set", "$@10", - "string_enumeration", "string_enumeration_item", "rule_set", "$@11", - "rule_enumeration", "rule_enumeration_item", "for_expression", - "for_quantifier", "primary_expression", YY_NULLPTR + "\"floating point number\"", "\"text string\"", "\"hex string\"", + "\"regular expression\"", "\"\"", "\"\"", "\"\"", + "\"\"", "\"\"", "\"\"", "\"\"", + "\"\"", "\"\"", "\"\"", "\"\"", + "\"\"", "\"\"", "\"\"", "\"\"", + "\"\"", "\"\"", "\"\"", "\"\"", + "\"\"", "\"\"", "\"\"", "\"\"", + "\"\"", "\"\"", "\"\"", "\"\"", "\"\"", + "\"\"", "\"\"", "\"\"", "\"\"", + "\"\"", "\"\"", "\"\"", + "\"\"", "\"\"", "\"\"", "\"\"", + "\"\"", "\"\"", "\"\"", "\"\"", "\"\"", + "\"==\"", "\"!=\"", "\"<\"", "\"<=\"", "\">\"", "\">=\"", "\"<<\"", + "\">>\"", "'|'", "'^'", "'&'", "'+'", "'-'", "'*'", "'\\\\'", "'%'", + "'~'", "UNARY_MINUS", "\"include\"", "'{'", "'}'", "':'", "'='", "'('", + "')'", "'.'", "'['", "']'", "','", "$accept", "rules", "import", "rule", + "@1", "$@2", "meta", "strings", "condition", "rule_modifiers", + "rule_modifier", "tags", "tag_list", "meta_declarations", + "meta_declaration", "string_declarations", "string_declaration", "$@3", + "$@4", "$@5", "string_modifiers", "string_modifier", "regexp_modifiers", + "regexp_modifier", "hex_modifiers", "hex_modifier", "identifier", + "arguments", "arguments_list", "regexp", "boolean_expression", + "expression", "$@6", "$@7", "$@8", "$@9", "for_iteration", + "for_variables", "iterator", "set", "range", "enumeration", + "string_iterator", "string_set", "$@10", "string_enumeration", + "string_enumeration_item", "rule_set", "$@11", "rule_enumeration", + "rule_enumeration_item", "for_expression", "for_quantifier", + "integer_function", "primary_expression", YY_NULLPTR }; static const char * @@ -1014,7 +1055,7 @@ yysymbol_name (yysymbol_kind_t yysymbol) } #endif -#define YYPACT_NINF (-172) +#define YYPACT_NINF (-186) #define yypact_value_is_default(Yyn) \ ((Yyn) == YYPACT_NINF) @@ -1028,34 +1069,35 @@ yysymbol_name (yysymbol_kind_t yysymbol) STATE-NUM. */ static const yytype_int16 yypact[] = { - -172, 121, -172, -39, -172, 2, -172, -172, 151, -172, - -172, -172, -172, 24, -172, -172, -172, -172, -38, 59, - 16, -172, 65, 95, -172, 29, 109, 112, 55, -172, - 71, 112, -172, 130, 163, 22, -172, 101, 130, -172, - 116, 118, -172, -172, -172, -172, 178, -5, -172, 66, - -172, -172, 177, 174, 179, -172, -16, 162, 120, 123, - -172, -172, 124, -172, -172, -172, -172, -172, -172, -172, - 132, -172, -172, 66, 66, 198, 198, 66, 103, -172, - 110, -172, 168, -172, 277, -172, -172, -172, 198, 129, - 129, 198, 198, 198, 198, 7, 376, -172, -172, -172, - -172, 110, 140, 237, 66, 197, 198, -172, -172, -35, - 199, 198, 198, 198, 198, 198, 198, 198, 198, 198, - 198, 198, 198, 198, 198, 198, 198, 198, 198, 198, - 198, 198, 198, 157, 85, 111, 216, 376, 198, -172, - -172, 186, 287, 319, 338, -172, -4, 198, -172, -172, - 144, 142, 139, -172, 297, 66, 66, -172, 215, -15, - -172, -172, 376, 376, 376, 376, 376, 376, 376, 376, - 376, 376, 376, 376, 376, 26, 26, 386, 396, 406, - 117, 117, -172, -172, -35, -172, -172, -172, -172, 149, - 153, 154, -172, -172, -172, -172, -172, -172, -172, -172, - -172, -172, -172, 176, -172, -172, -172, -172, -33, 158, - 4, -172, 66, -172, 181, -172, 20, 225, 198, 129, - -172, -172, 240, 238, 239, 198, -172, -172, -172, -172, - -9, 249, 139, -172, -172, 46, -172, 193, 53, -172, - 376, -172, -48, 183, 184, 357, 188, 198, 103, -172, - -172, -172, -172, -172, 20, -172, -172, 225, 247, -172, - -172, -172, -172, 66, 76, 176, -172, -172, 191, 23, - -172, 198, -172, -172, 376 + -186, 9, -186, -46, -186, 7, -186, -186, 107, -186, + -186, -186, -186, 61, -186, -186, -186, -186, 12, 90, + 47, -186, 92, 111, -186, 49, 132, 139, 66, -186, + 73, 139, -186, 163, 167, 120, -186, 128, 163, -186, + 91, 96, -186, -186, -186, -186, 182, -3, -186, 62, + -186, -186, 198, 197, 200, -186, 68, 174, 130, 142, + -186, -186, -186, -186, -186, -186, -186, -186, -186, -186, + -186, -186, -186, -186, -186, -186, -186, -186, -186, -186, + -186, 141, -186, -186, 62, 62, 252, 252, 62, 54, + -186, -23, -186, 176, -186, 159, 331, -186, -186, -186, + 252, 160, 160, 252, 252, 252, 18, 408, -186, -186, + -186, -186, -23, 161, 291, 62, 239, 252, -186, -186, + -22, 252, 231, 252, 252, 252, 252, 252, 252, 252, + 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, + 252, 252, 252, 252, 252, 214, 170, 94, 247, 408, + 252, -186, -186, 232, 242, 351, -186, -6, 252, -186, + -186, 164, 165, 85, -186, 341, 62, 62, -186, 244, + 69, -186, 370, -186, 408, 408, 408, 408, 408, 408, + 408, 408, 408, 408, 408, 408, 408, 134, 134, 418, + 428, 438, 121, 121, -186, -186, -22, -186, -186, -186, + -186, 169, 171, 172, -186, -186, -186, -186, -186, -186, + -186, -186, -186, -186, -186, 116, -186, -186, -186, -18, + 177, -25, -186, 62, -186, 205, -186, 15, 261, 252, + 160, -186, -186, -186, 269, 268, 270, 252, -186, -186, + -186, -186, -7, 277, 85, -186, -186, 8, -186, 211, + 31, -186, 408, -186, -57, 201, 203, 389, 208, 252, + 54, -186, -186, -186, -186, -186, 15, -186, -186, 261, + 281, -186, -186, -186, -186, 62, 41, 116, -186, -186, + 209, 34, -186, 252, -186, -186, 408 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -1068,40 +1110,41 @@ static const yytype_uint8 yydefact[] = 0, 24, 23, 13, 25, 0, 15, 0, 0, 11, 0, 14, 26, 0, 0, 0, 27, 0, 16, 33, 0, 0, 29, 28, 31, 32, 0, 35, 34, 0, - 12, 30, 0, 0, 0, 65, 85, 150, 152, 154, - 146, 147, 0, 148, 73, 143, 144, 139, 140, 141, - 0, 75, 76, 0, 0, 0, 0, 0, 155, 168, - 17, 74, 0, 138, 110, 41, 55, 62, 0, 0, - 0, 0, 0, 0, 0, 0, 137, 98, 99, 156, - 165, 0, 74, 110, 69, 0, 0, 102, 100, 0, + 12, 30, 0, 0, 0, 65, 85, 162, 164, 166, + 158, 159, 160, 73, 142, 143, 144, 145, 146, 147, + 148, 149, 150, 151, 152, 153, 155, 156, 139, 140, + 141, 0, 75, 76, 0, 0, 0, 0, 0, 167, + 180, 17, 74, 0, 138, 0, 110, 41, 55, 62, + 0, 0, 0, 0, 0, 0, 0, 137, 98, 99, + 168, 177, 0, 74, 110, 69, 0, 0, 102, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 36, 38, 40, 86, 0, 87, - 149, 0, 0, 0, 0, 88, 0, 0, 111, 142, - 0, 70, 71, 66, 0, 0, 0, 126, 124, 92, - 93, 77, 78, 80, 82, 79, 81, 83, 84, 108, - 109, 104, 106, 105, 107, 166, 167, 164, 162, 163, - 157, 158, 159, 160, 0, 161, 47, 44, 43, 48, - 51, 53, 45, 46, 42, 61, 58, 57, 59, 60, - 56, 64, 63, 0, 151, 153, 145, 114, 0, 0, - 0, 68, 0, 67, 103, 101, 0, 0, 0, 0, - 94, 95, 0, 0, 0, 0, 124, 113, 123, 90, - 0, 0, 72, 129, 130, 0, 127, 135, 0, 133, - 97, 96, 0, 0, 0, 0, 0, 0, 116, 112, - 117, 119, 115, 125, 0, 136, 132, 0, 0, 49, - 52, 54, 120, 0, 0, 121, 128, 134, 0, 0, - 118, 0, 50, 91, 122 + 0, 0, 0, 0, 0, 0, 36, 38, 40, 86, + 0, 87, 161, 0, 0, 0, 88, 0, 0, 111, + 154, 0, 70, 71, 66, 0, 0, 0, 126, 124, + 92, 93, 0, 77, 78, 80, 82, 79, 81, 83, + 84, 108, 109, 104, 106, 105, 107, 178, 179, 176, + 174, 175, 169, 170, 171, 172, 0, 173, 47, 44, + 43, 48, 51, 53, 45, 46, 42, 61, 58, 57, + 59, 60, 56, 64, 63, 0, 163, 165, 114, 0, + 0, 0, 68, 0, 67, 103, 101, 0, 0, 0, + 0, 157, 94, 95, 0, 0, 0, 0, 124, 113, + 123, 90, 0, 0, 72, 129, 130, 0, 127, 135, + 0, 133, 97, 96, 0, 0, 0, 0, 0, 0, + 116, 112, 117, 119, 115, 125, 0, 136, 132, 0, + 0, 49, 52, 54, 120, 0, 0, 121, 128, 134, + 0, 0, 118, 0, 50, 91, 122 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -172, -172, 264, 268, -172, -172, -172, -172, -172, -172, - -172, -172, -172, -172, 241, -172, 235, -172, -172, -172, - -172, -172, -172, -172, -172, -172, 45, -172, -172, 175, - -49, -74, -172, -172, -172, -172, -172, -172, -172, -172, - -89, -172, -172, -171, -172, -172, 32, 104, -172, -172, - 30, 219, -172, -65 + -186, -186, 297, 298, -186, -186, -186, -186, -186, -186, + -186, -186, -186, -186, 271, -186, 286, -186, -186, -186, + -186, -186, -186, -186, -186, -186, 84, -186, -186, 206, + -49, -85, -186, -186, -186, -186, -186, -186, -186, -186, + -100, -186, -186, -185, -186, -186, 63, 131, -186, -186, + 64, 250, -186, -186, -80 }; /* YYDEFGOTO[NTERM-NUM]. */ @@ -1109,10 +1152,10 @@ static const yytype_int16 yydefgoto[] = { 0, 1, 6, 7, 18, 34, 26, 29, 41, 8, 16, 20, 22, 31, 32, 38, 39, 52, 53, 54, - 134, 194, 135, 200, 136, 202, 78, 150, 151, 79, - 101, 81, 146, 246, 156, 155, 209, 210, 249, 250, - 139, 264, 227, 159, 216, 235, 236, 160, 217, 238, - 239, 82, 83, 84 + 146, 206, 147, 212, 148, 214, 89, 161, 162, 90, + 112, 92, 157, 258, 167, 166, 220, 221, 261, 262, + 151, 276, 239, 170, 227, 247, 248, 171, 228, 250, + 251, 93, 94, 95, 96 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -1120,162 +1163,173 @@ static const yytype_int16 yydefgoto[] = number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = { - 80, 140, 55, 102, 157, 96, 157, 207, 145, 5, - 99, 100, 103, 220, 88, 218, -39, -37, -89, 258, - 89, 219, 12, 137, 97, 98, 141, 142, 143, 144, - 152, 259, 233, 208, 9, 17, 234, 228, 19, 42, - 230, 154, 43, 158, -89, 226, 162, 163, 164, 165, - 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, - 176, 177, 178, 179, 180, 181, 182, 183, 185, 247, - 21, 44, 45, 203, 107, 108, 24, 55, 56, 57, - 58, 59, 185, 60, 61, 62, 63, 231, 64, 46, - 23, 186, 129, 130, 131, 132, 147, 65, 66, 67, - 68, 69, 273, 25, 70, 27, 214, 215, 187, 188, - 189, 190, 191, 192, 193, 71, 72, 195, 28, 73, - 74, 2, 3, 30, 4, 253, -18, -18, -18, 254, - 241, 33, 256, 75, 196, 197, 257, 76, 232, 198, - 199, 251, 37, 55, 77, 57, 58, 59, 35, 60, - 61, 62, 63, 240, 64, 270, 13, 14, 15, 271, - 245, 107, 108, 65, 66, 67, 68, 69, 55, 5, - 57, 58, 59, 40, 60, 61, 62, 63, 47, 64, - 225, 104, 265, 105, 106, 131, 132, 147, 65, 66, - -74, -74, 49, 50, 184, 51, 86, 85, 90, 75, - 87, 91, 93, 76, 92, 109, 274, 138, 153, 55, - 94, 57, 58, 59, 269, 60, 61, 62, 63, 148, - 64, 64, 201, 211, 75, 212, -131, 222, 76, 65, - 66, 223, 224, 108, 229, 94, 237, 124, 125, 126, - 127, 128, 129, 130, 131, 132, 147, 124, 125, 126, - 127, 128, 129, 130, 131, 132, 147, 242, 243, 244, - 252, 255, 260, 261, 268, 75, 263, 10, 204, 76, - 272, 11, 36, 48, -137, 248, 94, 110, 111, 112, - 113, 114, 115, 116, 117, 161, 266, 267, 221, 95, - 0, 0, 118, 119, 120, 121, 122, 123, 124, 125, - 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, - 0, 0, 0, 0, -137, 0, 149, 110, 111, 112, - 113, 114, 115, 116, 117, 0, 0, 0, 0, 0, - 0, 0, 118, 119, 120, 121, 122, 123, 124, 125, - 126, 127, 128, 129, 130, 131, 132, 133, 124, 125, - 126, 127, 128, 129, 130, 131, 132, 147, 124, 125, - 126, 127, 128, 129, 130, 131, 132, 147, 0, 205, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 213, - 124, 125, 126, 127, 128, 129, 130, 131, 132, 147, - 0, 0, 0, 0, 0, 0, 0, 0, 206, 124, - 125, 126, 127, 128, 129, 130, 131, 132, 147, 0, - 0, 0, 0, 0, 0, 0, 0, 149, 124, 125, - 126, 127, 128, 129, 130, 131, 132, 147, 0, 0, - 0, 0, 0, 0, 0, 0, 262, 124, 125, 126, - 127, 128, 129, 130, 131, 132, 147, 124, 125, 0, - 127, 128, 129, 130, 131, 132, 147, 124, 125, 0, - 0, 128, 129, 130, 131, 132, 147, 124, 125, 0, - 0, 0, 129, 130, 131, 132, 147 + 91, 107, 152, 113, 55, 218, 110, 111, 114, 2, + 3, 232, 4, 5, -18, -18, -18, -39, -37, 156, + 149, 270, 242, 153, 154, 155, 12, 245, 168, -89, + 163, 246, 168, 271, 240, 108, 109, 165, 9, 118, + 119, 172, 219, 174, 175, 176, 177, 178, 179, 180, + 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, + 191, 192, 193, 194, 195, 197, -89, 169, 5, 243, + 215, 238, 17, 55, 56, 57, 58, 59, 197, 60, + 61, 62, 259, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 118, 119, 265, 19, + 207, 21, 266, 24, 76, 77, 78, 79, 80, 100, + 229, 81, 13, 14, 15, 101, 230, 225, 226, 25, + 237, 268, 82, 83, 285, 269, 84, 85, 208, 209, + 253, 282, 23, 210, 211, 283, 27, 42, 244, 43, + 86, 28, 263, 115, 87, 116, 117, -74, -74, 252, + 30, 88, 55, 33, 57, 58, 59, 257, 60, 61, + 62, 35, 63, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 37, 198, 40, 49, 277, + 44, 45, 50, 76, 77, 78, 79, 80, 136, 137, + 138, 139, 140, 141, 142, 143, 144, 158, 46, 51, + 143, 144, 158, 286, 199, 200, 201, 202, 203, 204, + 205, 141, 142, 143, 144, 158, 47, 97, 98, 86, + 99, 102, 103, 87, 120, 55, 281, 57, 58, 59, + 105, 60, 61, 62, 104, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 121, 150, + 164, 159, 63, 213, 222, -131, 76, 77, 234, 223, + 235, 236, 196, 55, 241, 57, 58, 59, 119, 60, + 61, 62, 249, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 254, 255, 264, 256, + 267, 272, 86, 273, 76, 77, 87, 275, 280, 284, + 10, 11, 36, 105, 136, 137, 138, 139, 140, 141, + 142, 143, 144, 158, 136, 137, 138, 139, 140, 141, + 142, 143, 144, 158, 48, 216, 260, 233, 173, 278, + 86, 106, 0, 279, 87, 217, 0, 0, 0, -137, + 0, 105, 122, 123, 124, 125, 126, 127, 128, 129, + 0, 0, 0, 0, 0, 0, 0, 130, 131, 132, + 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 0, 0, 0, 0, 0, 0, -137, + 0, 160, 122, 123, 124, 125, 126, 127, 128, 129, + 0, 0, 0, 0, 0, 0, 0, 130, 131, 132, + 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 158, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 158, 0, 224, 0, 0, 0, 0, 0, + 0, 160, 136, 137, 138, 139, 140, 141, 142, 143, + 144, 158, 0, 0, 0, 0, 0, 0, 0, 0, + 231, 136, 137, 138, 139, 140, 141, 142, 143, 144, + 158, 0, 0, 0, 0, 0, 0, 0, 0, 274, + 136, 137, 138, 139, 140, 141, 142, 143, 144, 158, + 136, 137, 0, 139, 140, 141, 142, 143, 144, 158, + 136, 137, 0, 0, 140, 141, 142, 143, 144, 158, + 136, 137, 0, 0, 0, 141, 142, 143, 144, 158 }; static const yytype_int16 yycheck[] = { - 49, 90, 11, 77, 39, 70, 39, 11, 1, 48, - 75, 76, 77, 184, 30, 30, 21, 22, 11, 67, - 36, 36, 20, 88, 73, 74, 91, 92, 93, 94, - 104, 79, 12, 37, 73, 11, 16, 208, 76, 17, - 36, 106, 20, 78, 37, 78, 111, 112, 113, 114, - 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, - 125, 126, 127, 128, 129, 130, 131, 132, 133, 78, - 11, 49, 50, 138, 51, 52, 11, 11, 12, 13, - 14, 15, 147, 17, 18, 19, 20, 83, 22, 67, - 74, 6, 66, 67, 68, 69, 70, 31, 32, 33, - 34, 35, 79, 8, 38, 76, 155, 156, 23, 24, - 25, 26, 27, 28, 29, 49, 50, 6, 9, 53, - 54, 0, 1, 11, 3, 79, 5, 6, 7, 83, - 219, 76, 79, 67, 23, 24, 83, 71, 212, 28, - 29, 230, 12, 11, 78, 13, 14, 15, 77, 17, - 18, 19, 20, 218, 22, 79, 5, 6, 7, 83, - 225, 51, 52, 31, 32, 33, 34, 35, 11, 48, - 13, 14, 15, 10, 17, 18, 19, 20, 77, 22, - 4, 78, 247, 80, 81, 68, 69, 70, 31, 32, - 51, 52, 76, 75, 37, 17, 22, 20, 36, 67, - 21, 81, 78, 71, 81, 37, 271, 78, 11, 11, - 78, 13, 14, 15, 263, 17, 18, 19, 20, 79, - 22, 22, 6, 79, 67, 83, 11, 78, 71, 31, - 32, 78, 78, 52, 76, 78, 11, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 17, 20, 20, - 11, 68, 79, 79, 17, 67, 78, 3, 82, 71, - 79, 3, 31, 38, 37, 230, 78, 40, 41, 42, - 43, 44, 45, 46, 47, 110, 254, 257, 184, 70, - -1, -1, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, -1, -1, - -1, -1, -1, -1, 37, -1, 79, 40, 41, 42, - 43, 44, 45, 46, 47, -1, -1, -1, -1, -1, - -1, -1, 55, 56, 57, 58, 59, 60, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, -1, 82, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 82, - 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - -1, -1, -1, -1, -1, -1, -1, -1, 79, 61, - 62, 63, 64, 65, 66, 67, 68, 69, 70, -1, - -1, -1, -1, -1, -1, -1, -1, 79, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, -1, -1, - -1, -1, -1, -1, -1, -1, 79, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 61, 62, -1, - 64, 65, 66, 67, 68, 69, 70, 61, 62, -1, - -1, 65, 66, 67, 68, 69, 70, 61, 62, -1, - -1, -1, 66, 67, 68, 69, 70 + 49, 81, 102, 88, 11, 11, 86, 87, 88, 0, + 1, 196, 3, 59, 5, 6, 7, 20, 21, 1, + 100, 78, 47, 103, 104, 105, 19, 12, 50, 11, + 115, 16, 50, 90, 219, 84, 85, 117, 84, 62, + 63, 121, 48, 123, 124, 125, 126, 127, 128, 129, + 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, + 140, 141, 142, 143, 144, 145, 48, 89, 59, 94, + 150, 89, 11, 11, 12, 13, 14, 15, 158, 17, + 18, 19, 89, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 62, 63, 90, 87, + 6, 11, 94, 11, 42, 43, 44, 45, 46, 41, + 41, 49, 5, 6, 7, 47, 47, 166, 167, 8, + 4, 90, 60, 61, 90, 94, 64, 65, 34, 35, + 230, 90, 85, 39, 40, 94, 87, 17, 223, 19, + 78, 9, 242, 89, 82, 91, 92, 62, 63, 229, + 11, 89, 11, 87, 13, 14, 15, 237, 17, 18, + 19, 88, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 12, 6, 10, 87, 259, + 60, 61, 86, 42, 43, 44, 45, 46, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 81, 78, 17, + 79, 80, 81, 283, 34, 35, 36, 37, 38, 39, + 40, 77, 78, 79, 80, 81, 88, 19, 21, 78, + 20, 47, 92, 82, 48, 11, 275, 13, 14, 15, + 89, 17, 18, 19, 92, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 89, 89, + 11, 90, 21, 6, 90, 11, 42, 43, 89, 94, + 89, 89, 48, 11, 87, 13, 14, 15, 63, 17, + 18, 19, 11, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 17, 19, 11, 19, + 79, 90, 78, 90, 42, 43, 82, 89, 17, 90, + 3, 3, 31, 89, 72, 73, 74, 75, 76, 77, + 78, 79, 80, 81, 72, 73, 74, 75, 76, 77, + 78, 79, 80, 81, 38, 93, 242, 196, 122, 266, + 78, 81, -1, 269, 82, 93, -1, -1, -1, 48, + -1, 89, 51, 52, 53, 54, 55, 56, 57, 58, + -1, -1, -1, -1, -1, -1, -1, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, -1, -1, -1, -1, -1, -1, 48, + -1, 90, 51, 52, 53, 54, 55, 56, 57, 58, + -1, -1, -1, -1, -1, -1, -1, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, -1, 93, -1, -1, -1, -1, -1, + -1, 90, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, -1, -1, -1, -1, -1, -1, -1, -1, + 90, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 81, -1, -1, -1, -1, -1, -1, -1, -1, 90, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + 72, 73, -1, 75, 76, 77, 78, 79, 80, 81, + 72, 73, -1, -1, 76, 77, 78, 79, 80, 81, + 72, 73, -1, -1, -1, 77, 78, 79, 80, 81 }; /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 85, 0, 1, 3, 48, 86, 87, 93, 73, - 86, 87, 20, 5, 6, 7, 94, 11, 88, 76, - 95, 11, 96, 74, 11, 8, 90, 76, 9, 91, - 11, 97, 98, 76, 89, 77, 98, 12, 99, 100, - 10, 92, 17, 20, 49, 50, 67, 77, 100, 76, - 75, 17, 101, 102, 103, 11, 12, 13, 14, 15, - 17, 18, 19, 20, 22, 31, 32, 33, 34, 35, - 38, 49, 50, 53, 54, 67, 71, 78, 110, 113, - 114, 115, 135, 136, 137, 20, 22, 21, 30, 36, - 36, 81, 81, 78, 78, 135, 137, 114, 114, 137, - 137, 114, 115, 137, 78, 80, 81, 51, 52, 37, - 40, 41, 42, 43, 44, 45, 46, 47, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 68, 69, 70, 104, 106, 108, 137, 78, 124, - 124, 137, 137, 137, 137, 1, 116, 70, 79, 79, - 111, 112, 115, 11, 137, 119, 118, 39, 78, 127, - 131, 113, 137, 137, 137, 137, 137, 137, 137, 137, - 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, - 137, 137, 137, 137, 37, 137, 6, 23, 24, 25, - 26, 27, 28, 29, 105, 6, 23, 24, 28, 29, - 107, 6, 109, 137, 82, 82, 79, 11, 37, 120, - 121, 79, 83, 82, 114, 114, 128, 132, 30, 36, - 127, 131, 78, 78, 78, 4, 78, 126, 127, 76, - 36, 83, 115, 12, 16, 129, 130, 11, 133, 134, - 137, 124, 17, 20, 20, 137, 117, 78, 110, 122, - 123, 124, 11, 79, 83, 68, 79, 83, 67, 79, - 79, 79, 79, 78, 125, 137, 130, 134, 17, 114, - 79, 83, 79, 79, 137 + 0, 96, 0, 1, 3, 59, 97, 98, 104, 84, + 97, 98, 19, 5, 6, 7, 105, 11, 99, 87, + 106, 11, 107, 85, 11, 8, 101, 87, 9, 102, + 11, 108, 109, 87, 100, 88, 109, 12, 110, 111, + 10, 103, 17, 19, 60, 61, 78, 88, 111, 87, + 86, 17, 112, 113, 114, 11, 12, 13, 14, 15, + 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 42, 43, 44, 45, + 46, 49, 60, 61, 64, 65, 78, 82, 89, 121, + 124, 125, 126, 146, 147, 148, 149, 19, 21, 20, + 41, 47, 47, 92, 92, 89, 146, 149, 125, 125, + 149, 149, 125, 126, 149, 89, 91, 92, 62, 63, + 48, 89, 51, 52, 53, 54, 55, 56, 57, 58, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 81, 115, 117, 119, 149, + 89, 135, 135, 149, 149, 149, 1, 127, 81, 90, + 90, 122, 123, 126, 11, 149, 130, 129, 50, 89, + 138, 142, 149, 124, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 48, 149, 6, 34, + 35, 36, 37, 38, 39, 40, 116, 6, 34, 35, + 39, 40, 118, 6, 120, 149, 93, 93, 11, 48, + 131, 132, 90, 94, 93, 125, 125, 139, 143, 41, + 47, 90, 138, 142, 89, 89, 89, 4, 89, 137, + 138, 87, 47, 94, 126, 12, 16, 140, 141, 11, + 144, 145, 149, 135, 17, 19, 19, 149, 128, 89, + 121, 133, 134, 135, 11, 90, 94, 79, 90, 94, + 78, 90, 90, 90, 90, 89, 136, 149, 141, 145, + 17, 125, 90, 94, 90, 90, 149 }; /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ static const yytype_uint8 yyr1[] = { - 0, 84, 85, 85, 85, 85, 85, 85, 85, 86, - 88, 89, 87, 90, 90, 91, 91, 92, 93, 93, - 94, 94, 95, 95, 96, 96, 97, 97, 98, 98, - 98, 98, 98, 99, 99, 101, 100, 102, 100, 103, - 100, 104, 104, 105, 105, 105, 105, 105, 105, 105, - 105, 105, 105, 105, 105, 106, 106, 107, 107, 107, - 107, 107, 108, 108, 109, 110, 110, 110, 110, 111, - 111, 112, 112, 113, 114, 115, 115, 115, 115, 115, - 115, 115, 115, 115, 115, 115, 115, 115, 115, 116, - 117, 115, 115, 115, 115, 115, 115, 115, 115, 115, - 118, 115, 119, 115, 115, 115, 115, 115, 115, 115, - 115, 115, 120, 120, 121, 121, 122, 122, 123, 123, - 124, 125, 125, 126, 128, 127, 127, 129, 129, 130, - 130, 132, 131, 133, 133, 134, 134, 135, 135, 136, - 136, 136, 137, 137, 137, 137, 137, 137, 137, 137, - 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, - 137, 137, 137, 137, 137, 137, 137, 137, 137 + 0, 95, 96, 96, 96, 96, 96, 96, 96, 97, + 99, 100, 98, 101, 101, 102, 102, 103, 104, 104, + 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, + 109, 109, 109, 110, 110, 112, 111, 113, 111, 114, + 111, 115, 115, 116, 116, 116, 116, 116, 116, 116, + 116, 116, 116, 116, 116, 117, 117, 118, 118, 118, + 118, 118, 119, 119, 120, 121, 121, 121, 121, 122, + 122, 123, 123, 124, 125, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 126, 126, 126, 126, 126, 127, + 128, 126, 126, 126, 126, 126, 126, 126, 126, 126, + 129, 126, 130, 126, 126, 126, 126, 126, 126, 126, + 126, 126, 131, 131, 132, 132, 133, 133, 134, 134, + 135, 136, 136, 137, 139, 138, 138, 140, 140, 141, + 141, 143, 142, 144, 144, 145, 145, 146, 146, 147, + 147, 147, 148, 148, 148, 148, 148, 148, 148, 148, + 148, 148, 148, 148, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, + 149 }; /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ @@ -1295,9 +1349,11 @@ static const yytype_int8 yyr2[] = 1, 3, 3, 2, 1, 3, 1, 1, 3, 1, 5, 1, 3, 1, 0, 4, 1, 1, 3, 1, 1, 0, 4, 1, 3, 1, 2, 1, 1, 1, - 1, 1, 3, 1, 1, 4, 1, 1, 1, 3, - 1, 4, 1, 4, 1, 1, 2, 3, 3, 3, - 3, 3, 3, 3, 3, 2, 3, 3, 1 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 3, 1, 1, 4, 1, 1, + 1, 3, 1, 4, 1, 4, 1, 1, 2, 3, + 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, + 1 }; @@ -1772,61 +1828,61 @@ yydestruct (const char *yymsg, switch (yykind) { case YYSYMBOL__IDENTIFIER_: /* "identifier" */ -#line 312 "libyara/grammar.y" +#line 324 "libyara/grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1778 "libyara/grammar.c" +#line 1834 "libyara/grammar.c" break; case YYSYMBOL__STRING_IDENTIFIER_: /* "string identifier" */ -#line 316 "libyara/grammar.y" +#line 328 "libyara/grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1784 "libyara/grammar.c" +#line 1840 "libyara/grammar.c" break; case YYSYMBOL__STRING_COUNT_: /* "string count" */ -#line 313 "libyara/grammar.y" +#line 325 "libyara/grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1790 "libyara/grammar.c" +#line 1846 "libyara/grammar.c" break; case YYSYMBOL__STRING_OFFSET_: /* "string offset" */ -#line 314 "libyara/grammar.y" +#line 326 "libyara/grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1796 "libyara/grammar.c" +#line 1852 "libyara/grammar.c" break; case YYSYMBOL__STRING_LENGTH_: /* "string length" */ -#line 315 "libyara/grammar.y" +#line 327 "libyara/grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1802 "libyara/grammar.c" +#line 1858 "libyara/grammar.c" break; case YYSYMBOL__STRING_IDENTIFIER_WITH_WILDCARD_: /* "string identifier with wildcard" */ -#line 317 "libyara/grammar.y" +#line 329 "libyara/grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1808 "libyara/grammar.c" +#line 1864 "libyara/grammar.c" break; case YYSYMBOL__TEXT_STRING_: /* "text string" */ -#line 318 "libyara/grammar.y" +#line 330 "libyara/grammar.y" { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } -#line 1814 "libyara/grammar.c" +#line 1870 "libyara/grammar.c" break; case YYSYMBOL__HEX_STRING_: /* "hex string" */ -#line 319 "libyara/grammar.y" +#line 331 "libyara/grammar.y" { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } -#line 1820 "libyara/grammar.c" +#line 1876 "libyara/grammar.c" break; case YYSYMBOL__REGEXP_: /* "regular expression" */ -#line 320 "libyara/grammar.y" +#line 332 "libyara/grammar.y" { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } -#line 1826 "libyara/grammar.c" +#line 1882 "libyara/grammar.c" break; case YYSYMBOL_string_modifiers: /* string_modifiers */ -#line 333 "libyara/grammar.y" +#line 345 "libyara/grammar.y" { if (((*yyvaluep).modifier).alphabet != NULL) { @@ -1834,11 +1890,11 @@ yydestruct (const char *yymsg, ((*yyvaluep).modifier).alphabet = NULL; } } -#line 1838 "libyara/grammar.c" +#line 1894 "libyara/grammar.c" break; case YYSYMBOL_string_modifier: /* string_modifier */ -#line 325 "libyara/grammar.y" +#line 337 "libyara/grammar.y" { if (((*yyvaluep).modifier).alphabet != NULL) { @@ -1846,19 +1902,19 @@ yydestruct (const char *yymsg, ((*yyvaluep).modifier).alphabet = NULL; } } -#line 1850 "libyara/grammar.c" +#line 1906 "libyara/grammar.c" break; case YYSYMBOL_arguments: /* arguments */ -#line 322 "libyara/grammar.y" +#line 334 "libyara/grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1856 "libyara/grammar.c" +#line 1912 "libyara/grammar.c" break; case YYSYMBOL_arguments_list: /* arguments_list */ -#line 323 "libyara/grammar.y" +#line 335 "libyara/grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1862 "libyara/grammar.c" +#line 1918 "libyara/grammar.c" break; default: @@ -2135,15 +2191,15 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); switch (yyn) { case 8: /* rules: rules "end of included file" */ -#line 368 "libyara/grammar.y" +#line 380 "libyara/grammar.y" { _yr_compiler_pop_file_name(compiler); } -#line 2143 "libyara/grammar.c" +#line 2199 "libyara/grammar.c" break; case 9: /* import: "" "text string" */ -#line 376 "libyara/grammar.y" +#line 388 "libyara/grammar.y" { int result = yr_parser_reduce_import(yyscanner, (yyvsp[0].sized_string)); @@ -2151,20 +2207,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2155 "libyara/grammar.c" +#line 2211 "libyara/grammar.c" break; case 10: /* @1: %empty */ -#line 388 "libyara/grammar.y" +#line 400 "libyara/grammar.y" { fail_if_error(yr_parser_reduce_rule_declaration_phase_1( yyscanner, (int32_t) (yyvsp[-2].integer), (yyvsp[0].c_string), &(yyval.rule))); } -#line 2164 "libyara/grammar.c" +#line 2220 "libyara/grammar.c" break; case 11: /* $@2: %empty */ -#line 393 "libyara/grammar.y" +#line 405 "libyara/grammar.y" { YR_RULE* rule = (YR_RULE*) yr_arena_ref_to_ptr( compiler->arena, &(yyvsp[-4].rule)); @@ -2178,11 +2234,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); rule->strings = (YR_STRING*) yr_arena_ref_to_ptr( compiler->arena, &(yyvsp[0].string)); } -#line 2182 "libyara/grammar.c" +#line 2238 "libyara/grammar.c" break; case 12: /* rule: rule_modifiers "" "identifier" @1 tags '{' meta strings $@2 condition '}' */ -#line 407 "libyara/grammar.y" +#line 419 "libyara/grammar.y" { int result = yr_parser_reduce_rule_declaration_phase_2( yyscanner, &(yyvsp[-7].rule)); // rule created in phase 1 @@ -2191,19 +2247,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2195 "libyara/grammar.c" +#line 2251 "libyara/grammar.c" break; case 13: /* meta: %empty */ -#line 420 "libyara/grammar.y" +#line 432 "libyara/grammar.y" { (yyval.meta) = YR_ARENA_NULL_REF; } -#line 2203 "libyara/grammar.c" +#line 2259 "libyara/grammar.c" break; case 14: /* meta: "" ':' meta_declarations */ -#line 424 "libyara/grammar.y" +#line 436 "libyara/grammar.y" { YR_META* meta = yr_arena_get_ptr( compiler->arena, @@ -2214,19 +2270,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.meta) = (yyvsp[0].meta); } -#line 2218 "libyara/grammar.c" +#line 2274 "libyara/grammar.c" break; case 15: /* strings: %empty */ -#line 439 "libyara/grammar.y" +#line 451 "libyara/grammar.y" { (yyval.string) = YR_ARENA_NULL_REF; } -#line 2226 "libyara/grammar.c" +#line 2282 "libyara/grammar.c" break; case 16: /* strings: "" ':' string_declarations */ -#line 443 "libyara/grammar.y" +#line 455 "libyara/grammar.y" { YR_STRING* string = (YR_STRING*) yr_arena_get_ptr( compiler->arena, @@ -2237,43 +2293,43 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.string) = (yyvsp[0].string); } -#line 2241 "libyara/grammar.c" +#line 2297 "libyara/grammar.c" break; case 18: /* rule_modifiers: %empty */ -#line 462 "libyara/grammar.y" +#line 474 "libyara/grammar.y" { (yyval.integer) = 0; } -#line 2247 "libyara/grammar.c" +#line 2303 "libyara/grammar.c" break; case 19: /* rule_modifiers: rule_modifiers rule_modifier */ -#line 463 "libyara/grammar.y" +#line 475 "libyara/grammar.y" { (yyval.integer) = (yyvsp[-1].integer) | (yyvsp[0].integer); } -#line 2253 "libyara/grammar.c" +#line 2309 "libyara/grammar.c" break; case 20: /* rule_modifier: "" */ -#line 468 "libyara/grammar.y" +#line 480 "libyara/grammar.y" { (yyval.integer) = RULE_FLAGS_PRIVATE; } -#line 2259 "libyara/grammar.c" +#line 2315 "libyara/grammar.c" break; case 21: /* rule_modifier: "" */ -#line 469 "libyara/grammar.y" +#line 481 "libyara/grammar.y" { (yyval.integer) = RULE_FLAGS_GLOBAL; } -#line 2265 "libyara/grammar.c" +#line 2321 "libyara/grammar.c" break; case 22: /* tags: %empty */ -#line 475 "libyara/grammar.y" +#line 487 "libyara/grammar.y" { (yyval.tag) = YR_ARENA_NULL_REF; } -#line 2273 "libyara/grammar.c" +#line 2329 "libyara/grammar.c" break; case 23: /* tags: ':' tag_list */ -#line 479 "libyara/grammar.y" +#line 491 "libyara/grammar.y" { // Tags list is represented in the arena as a sequence // of null-terminated strings, the sequence ends with an @@ -2285,11 +2341,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.tag) = (yyvsp[0].tag); } -#line 2289 "libyara/grammar.c" +#line 2345 "libyara/grammar.c" break; case 24: /* tag_list: "identifier" */ -#line 495 "libyara/grammar.y" +#line 507 "libyara/grammar.y" { int result = yr_arena_write_string( yyget_extra(yyscanner)->arena, YR_SZ_POOL, (yyvsp[0].c_string), &(yyval.tag)); @@ -2298,11 +2354,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2302 "libyara/grammar.c" +#line 2358 "libyara/grammar.c" break; case 25: /* tag_list: tag_list "identifier" */ -#line 504 "libyara/grammar.y" +#line 516 "libyara/grammar.y" { YR_ARENA_REF ref; @@ -2339,23 +2395,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.tag) = (yyvsp[-1].tag); } -#line 2343 "libyara/grammar.c" +#line 2399 "libyara/grammar.c" break; case 26: /* meta_declarations: meta_declaration */ -#line 545 "libyara/grammar.y" +#line 557 "libyara/grammar.y" { (yyval.meta) = (yyvsp[0].meta); } -#line 2349 "libyara/grammar.c" +#line 2405 "libyara/grammar.c" break; case 27: /* meta_declarations: meta_declarations meta_declaration */ -#line 546 "libyara/grammar.y" +#line 558 "libyara/grammar.y" { (yyval.meta) = (yyvsp[-1].meta); } -#line 2355 "libyara/grammar.c" +#line 2411 "libyara/grammar.c" break; case 28: /* meta_declaration: "identifier" '=' "text string" */ -#line 552 "libyara/grammar.y" +#line 564 "libyara/grammar.y" { SIZED_STRING* sized_string = (yyvsp[0].sized_string); @@ -2372,11 +2428,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2376 "libyara/grammar.c" +#line 2432 "libyara/grammar.c" break; case 29: /* meta_declaration: "identifier" '=' "integer number" */ -#line 569 "libyara/grammar.y" +#line 581 "libyara/grammar.y" { int result = yr_parser_reduce_meta_declaration( yyscanner, @@ -2390,11 +2446,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2394 "libyara/grammar.c" +#line 2450 "libyara/grammar.c" break; case 30: /* meta_declaration: "identifier" '=' '-' "integer number" */ -#line 583 "libyara/grammar.y" +#line 595 "libyara/grammar.y" { int result = yr_parser_reduce_meta_declaration( yyscanner, @@ -2408,11 +2464,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2412 "libyara/grammar.c" +#line 2468 "libyara/grammar.c" break; case 31: /* meta_declaration: "identifier" '=' "" */ -#line 597 "libyara/grammar.y" +#line 609 "libyara/grammar.y" { int result = yr_parser_reduce_meta_declaration( yyscanner, @@ -2426,11 +2482,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2430 "libyara/grammar.c" +#line 2486 "libyara/grammar.c" break; case 32: /* meta_declaration: "identifier" '=' "" */ -#line 611 "libyara/grammar.y" +#line 623 "libyara/grammar.y" { int result = yr_parser_reduce_meta_declaration( yyscanner, @@ -2444,31 +2500,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2448 "libyara/grammar.c" +#line 2504 "libyara/grammar.c" break; case 33: /* string_declarations: string_declaration */ -#line 628 "libyara/grammar.y" +#line 640 "libyara/grammar.y" { (yyval.string) = (yyvsp[0].string); } -#line 2454 "libyara/grammar.c" +#line 2510 "libyara/grammar.c" break; case 34: /* string_declarations: string_declarations string_declaration */ -#line 629 "libyara/grammar.y" +#line 641 "libyara/grammar.y" { (yyval.string) = (yyvsp[-1].string); } -#line 2460 "libyara/grammar.c" +#line 2516 "libyara/grammar.c" break; case 35: /* $@3: %empty */ -#line 635 "libyara/grammar.y" +#line 647 "libyara/grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2468 "libyara/grammar.c" +#line 2524 "libyara/grammar.c" break; case 36: /* string_declaration: "string identifier" '=' $@3 "text string" string_modifiers */ -#line 639 "libyara/grammar.y" +#line 651 "libyara/grammar.y" { int result = yr_parser_reduce_string_declaration( yyscanner, (yyvsp[0].modifier), (yyvsp[-4].c_string), (yyvsp[-1].sized_string), &(yyval.string)); @@ -2480,19 +2536,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); compiler->current_line = 0; } -#line 2484 "libyara/grammar.c" +#line 2540 "libyara/grammar.c" break; case 37: /* $@4: %empty */ -#line 651 "libyara/grammar.y" +#line 663 "libyara/grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2492 "libyara/grammar.c" +#line 2548 "libyara/grammar.c" break; case 38: /* string_declaration: "string identifier" '=' $@4 "regular expression" regexp_modifiers */ -#line 655 "libyara/grammar.y" +#line 667 "libyara/grammar.y" { int result; @@ -2508,19 +2564,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->current_line = 0; } -#line 2512 "libyara/grammar.c" +#line 2568 "libyara/grammar.c" break; case 39: /* $@5: %empty */ -#line 671 "libyara/grammar.y" +#line 683 "libyara/grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2520 "libyara/grammar.c" +#line 2576 "libyara/grammar.c" break; case 40: /* string_declaration: "string identifier" '=' $@5 "hex string" hex_modifiers */ -#line 675 "libyara/grammar.y" +#line 687 "libyara/grammar.y" { int result; @@ -2536,22 +2592,22 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->current_line = 0; } -#line 2540 "libyara/grammar.c" +#line 2596 "libyara/grammar.c" break; case 41: /* string_modifiers: %empty */ -#line 695 "libyara/grammar.y" +#line 707 "libyara/grammar.y" { (yyval.modifier).flags = 0; (yyval.modifier).xor_min = 0; (yyval.modifier).xor_max = 0; (yyval.modifier).alphabet = NULL; } -#line 2551 "libyara/grammar.c" +#line 2607 "libyara/grammar.c" break; case 42: /* string_modifiers: string_modifiers string_modifier */ -#line 702 "libyara/grammar.y" +#line 714 "libyara/grammar.y" { (yyval.modifier) = (yyvsp[-1].modifier); @@ -2607,51 +2663,51 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyval.modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2611 "libyara/grammar.c" +#line 2667 "libyara/grammar.c" break; case 43: /* string_modifier: "" */ -#line 761 "libyara/grammar.y" +#line 773 "libyara/grammar.y" { (yyval.modifier).flags = STRING_FLAGS_WIDE; } -#line 2617 "libyara/grammar.c" +#line 2673 "libyara/grammar.c" break; case 44: /* string_modifier: "" */ -#line 762 "libyara/grammar.y" +#line 774 "libyara/grammar.y" { (yyval.modifier).flags = STRING_FLAGS_ASCII; } -#line 2623 "libyara/grammar.c" +#line 2679 "libyara/grammar.c" break; case 45: /* string_modifier: "" */ -#line 763 "libyara/grammar.y" +#line 775 "libyara/grammar.y" { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } -#line 2629 "libyara/grammar.c" +#line 2685 "libyara/grammar.c" break; case 46: /* string_modifier: "" */ -#line 764 "libyara/grammar.y" +#line 776 "libyara/grammar.y" { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } -#line 2635 "libyara/grammar.c" +#line 2691 "libyara/grammar.c" break; case 47: /* string_modifier: "" */ -#line 765 "libyara/grammar.y" +#line 777 "libyara/grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2641 "libyara/grammar.c" +#line 2697 "libyara/grammar.c" break; case 48: /* string_modifier: "" */ -#line 767 "libyara/grammar.y" +#line 779 "libyara/grammar.y" { (yyval.modifier).flags = STRING_FLAGS_XOR; (yyval.modifier).xor_min = 0; (yyval.modifier).xor_max = 255; } -#line 2651 "libyara/grammar.c" +#line 2707 "libyara/grammar.c" break; case 49: /* string_modifier: "" '(' "integer number" ')' */ -#line 773 "libyara/grammar.y" +#line 785 "libyara/grammar.y" { int result = ERROR_SUCCESS; @@ -2667,11 +2723,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).xor_min = (uint8_t) (yyvsp[-1].integer); (yyval.modifier).xor_max = (uint8_t) (yyvsp[-1].integer); } -#line 2671 "libyara/grammar.c" +#line 2727 "libyara/grammar.c" break; case 50: /* string_modifier: "" '(' "integer number" '-' "integer number" ')' */ -#line 794 "libyara/grammar.y" +#line 806 "libyara/grammar.y" { int result = ERROR_SUCCESS; @@ -2702,20 +2758,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).xor_min = (uint8_t) (yyvsp[-3].integer); (yyval.modifier).xor_max = (uint8_t) (yyvsp[-1].integer); } -#line 2706 "libyara/grammar.c" +#line 2762 "libyara/grammar.c" break; case 51: /* string_modifier: "" */ -#line 825 "libyara/grammar.y" +#line 837 "libyara/grammar.y" { (yyval.modifier).flags = STRING_FLAGS_BASE64; (yyval.modifier).alphabet = ss_new(DEFAULT_BASE64_ALPHABET); } -#line 2715 "libyara/grammar.c" +#line 2771 "libyara/grammar.c" break; case 52: /* string_modifier: "" '(' "text string" ')' */ -#line 830 "libyara/grammar.y" +#line 842 "libyara/grammar.y" { int result = ERROR_SUCCESS; @@ -2732,20 +2788,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = STRING_FLAGS_BASE64; (yyval.modifier).alphabet = (yyvsp[-1].sized_string); } -#line 2736 "libyara/grammar.c" +#line 2792 "libyara/grammar.c" break; case 53: /* string_modifier: "" */ -#line 847 "libyara/grammar.y" +#line 859 "libyara/grammar.y" { (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; (yyval.modifier).alphabet = ss_new(DEFAULT_BASE64_ALPHABET); } -#line 2745 "libyara/grammar.c" +#line 2801 "libyara/grammar.c" break; case 54: /* string_modifier: "" '(' "text string" ')' */ -#line 852 "libyara/grammar.y" +#line 864 "libyara/grammar.y" { int result = ERROR_SUCCESS; @@ -2762,17 +2818,17 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; (yyval.modifier).alphabet = (yyvsp[-1].sized_string); } -#line 2766 "libyara/grammar.c" +#line 2822 "libyara/grammar.c" break; case 55: /* regexp_modifiers: %empty */ -#line 871 "libyara/grammar.y" +#line 883 "libyara/grammar.y" { (yyval.modifier).flags = 0; } -#line 2772 "libyara/grammar.c" +#line 2828 "libyara/grammar.c" break; case 56: /* regexp_modifiers: regexp_modifiers regexp_modifier */ -#line 873 "libyara/grammar.y" +#line 885 "libyara/grammar.y" { if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) { @@ -2783,47 +2839,47 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyvsp[-1].modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2787 "libyara/grammar.c" +#line 2843 "libyara/grammar.c" break; case 57: /* regexp_modifier: "" */ -#line 886 "libyara/grammar.y" +#line 898 "libyara/grammar.y" { (yyval.modifier).flags = STRING_FLAGS_WIDE; } -#line 2793 "libyara/grammar.c" +#line 2849 "libyara/grammar.c" break; case 58: /* regexp_modifier: "" */ -#line 887 "libyara/grammar.y" +#line 899 "libyara/grammar.y" { (yyval.modifier).flags = STRING_FLAGS_ASCII; } -#line 2799 "libyara/grammar.c" +#line 2855 "libyara/grammar.c" break; case 59: /* regexp_modifier: "" */ -#line 888 "libyara/grammar.y" +#line 900 "libyara/grammar.y" { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } -#line 2805 "libyara/grammar.c" +#line 2861 "libyara/grammar.c" break; case 60: /* regexp_modifier: "" */ -#line 889 "libyara/grammar.y" +#line 901 "libyara/grammar.y" { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } -#line 2811 "libyara/grammar.c" +#line 2867 "libyara/grammar.c" break; case 61: /* regexp_modifier: "" */ -#line 890 "libyara/grammar.y" +#line 902 "libyara/grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2817 "libyara/grammar.c" +#line 2873 "libyara/grammar.c" break; case 62: /* hex_modifiers: %empty */ -#line 894 "libyara/grammar.y" +#line 906 "libyara/grammar.y" { (yyval.modifier).flags = 0; } -#line 2823 "libyara/grammar.c" +#line 2879 "libyara/grammar.c" break; case 63: /* hex_modifiers: hex_modifiers hex_modifier */ -#line 896 "libyara/grammar.y" +#line 908 "libyara/grammar.y" { if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) { @@ -2834,17 +2890,17 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyvsp[-1].modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2838 "libyara/grammar.c" +#line 2894 "libyara/grammar.c" break; case 64: /* hex_modifier: "" */ -#line 909 "libyara/grammar.y" +#line 921 "libyara/grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2844 "libyara/grammar.c" +#line 2900 "libyara/grammar.c" break; case 65: /* identifier: "identifier" */ -#line 914 "libyara/grammar.y" +#line 926 "libyara/grammar.y" { YR_EXPRESSION expr; @@ -2939,11 +2995,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2943 "libyara/grammar.c" +#line 2999 "libyara/grammar.c" break; case 66: /* identifier: identifier '.' "identifier" */ -#line 1009 "libyara/grammar.y" +#line 1021 "libyara/grammar.y" { int result = ERROR_SUCCESS; YR_OBJECT* field = NULL; @@ -2991,11 +3047,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2995 "libyara/grammar.c" +#line 3051 "libyara/grammar.c" break; case 67: /* identifier: identifier '[' primary_expression ']' */ -#line 1057 "libyara/grammar.y" +#line 1069 "libyara/grammar.y" { int result = ERROR_SUCCESS; YR_OBJECT_ARRAY* array; @@ -3055,11 +3111,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3059 "libyara/grammar.c" +#line 3115 "libyara/grammar.c" break; case 68: /* identifier: identifier '(' arguments ')' */ -#line 1118 "libyara/grammar.y" +#line 1130 "libyara/grammar.y" { YR_ARENA_REF ref = YR_ARENA_NULL_REF; int result = ERROR_SUCCESS; @@ -3100,23 +3156,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3104 "libyara/grammar.c" +#line 3160 "libyara/grammar.c" break; case 69: /* arguments: %empty */ -#line 1162 "libyara/grammar.y" +#line 1174 "libyara/grammar.y" { (yyval.c_string) = yr_strdup(""); } -#line 3110 "libyara/grammar.c" +#line 3166 "libyara/grammar.c" break; case 70: /* arguments: arguments_list */ -#line 1163 "libyara/grammar.y" +#line 1175 "libyara/grammar.y" { (yyval.c_string) = (yyvsp[0].c_string); } -#line 3116 "libyara/grammar.c" +#line 3172 "libyara/grammar.c" break; case 71: /* arguments_list: expression */ -#line 1168 "libyara/grammar.y" +#line 1180 "libyara/grammar.y" { (yyval.c_string) = (char*) yr_malloc(YR_MAX_FUNCTION_ARGS + 1); @@ -3151,11 +3207,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); assert(compiler->last_error != ERROR_SUCCESS); } } -#line 3155 "libyara/grammar.c" +#line 3211 "libyara/grammar.c" break; case 72: /* arguments_list: arguments_list ',' expression */ -#line 1203 "libyara/grammar.y" +#line 1215 "libyara/grammar.y" { int result = ERROR_SUCCESS; @@ -3204,11 +3260,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.c_string) = (yyvsp[-2].c_string); } -#line 3208 "libyara/grammar.c" +#line 3264 "libyara/grammar.c" break; case 73: /* regexp: "regular expression" */ -#line 1256 "libyara/grammar.y" +#line 1268 "libyara/grammar.y" { YR_ARENA_REF re_ref; RE_ERROR error; @@ -3246,11 +3302,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_REGEXP; } -#line 3250 "libyara/grammar.c" +#line 3306 "libyara/grammar.c" break; case 74: /* boolean_expression: expression */ -#line 1298 "libyara/grammar.y" +#line 1310 "libyara/grammar.y" { if ((yyvsp[0].expression).type == EXPRESSION_TYPE_STRING) { @@ -3270,31 +3326,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3274 "libyara/grammar.c" +#line 3330 "libyara/grammar.c" break; case 75: /* expression: "" */ -#line 1321 "libyara/grammar.y" +#line 1333 "libyara/grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, 1)); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3284 "libyara/grammar.c" +#line 3340 "libyara/grammar.c" break; case 76: /* expression: "" */ -#line 1327 "libyara/grammar.y" +#line 1339 "libyara/grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, 0)); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3294 "libyara/grammar.c" +#line 3350 "libyara/grammar.c" break; case 77: /* expression: primary_expression "" regexp */ -#line 1333 "libyara/grammar.y" +#line 1345 "libyara/grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "matches"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_REGEXP, "matches"); @@ -3306,11 +3362,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3310 "libyara/grammar.c" +#line 3366 "libyara/grammar.c" break; case 78: /* expression: primary_expression "" primary_expression */ -#line 1345 "libyara/grammar.y" +#line 1357 "libyara/grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "contains"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "contains"); @@ -3320,11 +3376,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3324 "libyara/grammar.c" +#line 3380 "libyara/grammar.c" break; case 79: /* expression: primary_expression "" primary_expression */ -#line 1355 "libyara/grammar.y" +#line 1367 "libyara/grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "icontains"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "icontains"); @@ -3334,11 +3390,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3338 "libyara/grammar.c" +#line 3394 "libyara/grammar.c" break; case 80: /* expression: primary_expression "" primary_expression */ -#line 1365 "libyara/grammar.y" +#line 1377 "libyara/grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "startswith"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "startswith"); @@ -3348,11 +3404,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3352 "libyara/grammar.c" +#line 3408 "libyara/grammar.c" break; case 81: /* expression: primary_expression "" primary_expression */ -#line 1375 "libyara/grammar.y" +#line 1387 "libyara/grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "istartswith"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "istartswith"); @@ -3362,11 +3418,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3366 "libyara/grammar.c" +#line 3422 "libyara/grammar.c" break; case 82: /* expression: primary_expression "" primary_expression */ -#line 1385 "libyara/grammar.y" +#line 1397 "libyara/grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "endswith"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "endswith"); @@ -3376,11 +3432,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3380 "libyara/grammar.c" +#line 3436 "libyara/grammar.c" break; case 83: /* expression: primary_expression "" primary_expression */ -#line 1395 "libyara/grammar.y" +#line 1407 "libyara/grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "iendswith"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "iendswith"); @@ -3390,11 +3446,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3394 "libyara/grammar.c" +#line 3450 "libyara/grammar.c" break; case 84: /* expression: primary_expression "" primary_expression */ -#line 1405 "libyara/grammar.y" +#line 1417 "libyara/grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "iequals"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "iequals"); @@ -3404,11 +3460,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3408 "libyara/grammar.c" +#line 3464 "libyara/grammar.c" break; case 85: /* expression: "string identifier" */ -#line 1415 "libyara/grammar.y" +#line 1427 "libyara/grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, @@ -3422,11 +3478,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3426 "libyara/grammar.c" +#line 3482 "libyara/grammar.c" break; case 86: /* expression: "string identifier" "" primary_expression */ -#line 1429 "libyara/grammar.y" +#line 1441 "libyara/grammar.y" { int result; @@ -3441,11 +3497,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3445 "libyara/grammar.c" +#line 3501 "libyara/grammar.c" break; case 87: /* expression: "string identifier" "" range */ -#line 1444 "libyara/grammar.y" +#line 1456 "libyara/grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-2].c_string), OP_FOUND_IN, YR_UNDEFINED); @@ -3456,11 +3512,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3460 "libyara/grammar.c" +#line 3516 "libyara/grammar.c" break; case 88: /* expression: "" for_expression error */ -#line 1455 "libyara/grammar.y" +#line 1467 "libyara/grammar.y" { // Free all the loop variable identifiers, including the variables for // the current loop (represented by loop_index), and set loop_index to @@ -3477,11 +3533,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->loop_index = -1; YYERROR; } -#line 3481 "libyara/grammar.c" +#line 3537 "libyara/grammar.c" break; case 89: /* $@6: %empty */ -#line 1529 "libyara/grammar.y" +#line 1541 "libyara/grammar.y" { // var_frame is used for accessing local variables used in this loop. // All local variables are accessed using var_frame as a reference, @@ -3519,11 +3575,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(yr_parser_emit_with_arg( yyscanner, OP_POP_M, var_frame + 2, NULL, NULL)); } -#line 3523 "libyara/grammar.c" +#line 3579 "libyara/grammar.c" break; case 90: /* $@7: %empty */ -#line 1567 "libyara/grammar.y" +#line 1579 "libyara/grammar.y" { YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; YR_FIXUP* fixup; @@ -3572,11 +3628,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); loop_ctx->start_ref = loop_start_ref; } -#line 3576 "libyara/grammar.c" +#line 3632 "libyara/grammar.c" break; case 91: /* expression: "" for_expression $@6 for_iteration ':' $@7 '(' boolean_expression ')' */ -#line 1616 "libyara/grammar.y" +#line 1628 "libyara/grammar.y" { int32_t jmp_offset; YR_FIXUP* fixup; @@ -3656,11 +3712,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3660 "libyara/grammar.c" +#line 3716 "libyara/grammar.c" break; case 92: /* expression: for_expression "" string_set */ -#line 1696 "libyara/grammar.y" +#line 1708 "libyara/grammar.y" { if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER && (yyvsp[-2].expression).value.integer > (yyvsp[0].integer)) { @@ -3671,11 +3727,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3675 "libyara/grammar.c" +#line 3731 "libyara/grammar.c" break; case 93: /* expression: for_expression "" rule_set */ -#line 1707 "libyara/grammar.y" +#line 1719 "libyara/grammar.y" { if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER && (yyvsp[-2].expression).value.integer > (yyvsp[0].integer)) { @@ -3686,11 +3742,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3690 "libyara/grammar.c" +#line 3746 "libyara/grammar.c" break; case 94: /* expression: primary_expression '%' "" string_set */ -#line 1718 "libyara/grammar.y" +#line 1730 "libyara/grammar.y" { check_type((yyvsp[-3].expression), EXPRESSION_TYPE_INTEGER, "%"); @@ -3709,11 +3765,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yr_parser_emit_with_arg(yyscanner, OP_OF_PERCENT, OF_STRING_SET, NULL, NULL); } -#line 3713 "libyara/grammar.c" +#line 3769 "libyara/grammar.c" break; case 95: /* expression: primary_expression '%' "" rule_set */ -#line 1737 "libyara/grammar.y" +#line 1749 "libyara/grammar.y" { check_type((yyvsp[-3].expression), EXPRESSION_TYPE_INTEGER, "%"); @@ -3732,11 +3788,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yr_parser_emit_with_arg(yyscanner, OP_OF_PERCENT, OF_RULE_SET, NULL, NULL); } -#line 3736 "libyara/grammar.c" +#line 3792 "libyara/grammar.c" break; case 96: /* expression: for_expression "" string_set "" range */ -#line 1756 "libyara/grammar.y" +#line 1768 "libyara/grammar.y" { if ((yyvsp[-4].expression).type == EXPRESSION_TYPE_INTEGER && (yyvsp[-4].expression).value.integer > (yyvsp[-2].integer)) { @@ -3748,11 +3804,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3752 "libyara/grammar.c" +#line 3808 "libyara/grammar.c" break; case 97: /* expression: for_expression "" string_set "" primary_expression */ -#line 1768 "libyara/grammar.y" +#line 1780 "libyara/grammar.y" { if ((yyvsp[0].expression).type != EXPRESSION_TYPE_INTEGER) { @@ -3789,30 +3845,30 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3793 "libyara/grammar.c" +#line 3849 "libyara/grammar.c" break; case 98: /* expression: "" boolean_expression */ -#line 1805 "libyara/grammar.y" +#line 1817 "libyara/grammar.y" { yr_parser_emit(yyscanner, OP_NOT, NULL); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3803 "libyara/grammar.c" +#line 3859 "libyara/grammar.c" break; case 99: /* expression: "" boolean_expression */ -#line 1811 "libyara/grammar.y" +#line 1823 "libyara/grammar.y" { yr_parser_emit(yyscanner, OP_DEFINED, NULL); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3812 "libyara/grammar.c" +#line 3868 "libyara/grammar.c" break; case 100: /* $@8: %empty */ -#line 1816 "libyara/grammar.y" +#line 1828 "libyara/grammar.y" { YR_FIXUP* fixup; YR_ARENA_REF jmp_offset_ref; @@ -3834,11 +3890,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fixup->next = compiler->fixup_stack_head; compiler->fixup_stack_head = fixup; } -#line 3838 "libyara/grammar.c" +#line 3894 "libyara/grammar.c" break; case 101: /* expression: boolean_expression "" $@8 boolean_expression */ -#line 1838 "libyara/grammar.y" +#line 1850 "libyara/grammar.y" { YR_FIXUP* fixup; @@ -3861,11 +3917,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3865 "libyara/grammar.c" +#line 3921 "libyara/grammar.c" break; case 102: /* $@9: %empty */ -#line 1861 "libyara/grammar.y" +#line 1873 "libyara/grammar.y" { YR_FIXUP* fixup; YR_ARENA_REF jmp_offset_ref; @@ -3886,11 +3942,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fixup->next = compiler->fixup_stack_head; compiler->fixup_stack_head = fixup; } -#line 3890 "libyara/grammar.c" +#line 3946 "libyara/grammar.c" break; case 103: /* expression: boolean_expression "" $@9 boolean_expression */ -#line 1882 "libyara/grammar.y" +#line 1894 "libyara/grammar.y" { YR_FIXUP* fixup; @@ -3913,99 +3969,121 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3917 "libyara/grammar.c" +#line 3973 "libyara/grammar.c" break; case 104: /* expression: primary_expression "<" primary_expression */ -#line 1905 "libyara/grammar.y" +#line 1917 "libyara/grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, "<", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3928 "libyara/grammar.c" +#line 3984 "libyara/grammar.c" break; case 105: /* expression: primary_expression ">" primary_expression */ -#line 1912 "libyara/grammar.y" +#line 1924 "libyara/grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, ">", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3939 "libyara/grammar.c" +#line 3995 "libyara/grammar.c" break; case 106: /* expression: primary_expression "<=" primary_expression */ -#line 1919 "libyara/grammar.y" +#line 1931 "libyara/grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, "<=", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3950 "libyara/grammar.c" +#line 4006 "libyara/grammar.c" break; case 107: /* expression: primary_expression ">=" primary_expression */ -#line 1926 "libyara/grammar.y" +#line 1938 "libyara/grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, ">=", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3961 "libyara/grammar.c" +#line 4017 "libyara/grammar.c" break; case 108: /* expression: primary_expression "==" primary_expression */ -#line 1933 "libyara/grammar.y" +#line 1945 "libyara/grammar.y" { + int result = ERROR_SUCCESS; + + if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER && + (yyvsp[-2].expression).width != 0 && + (yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER && + (yyvsp[0].expression).value.integer != YR_UNDEFINED) + { + result = yr_parser_integer_width_check((yyvsp[-2].expression), (yyvsp[0].expression)); + if (result != ERROR_SUCCESS) + yywarning(yyscanner, + "integer function comparison always false"); + } else if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER && + (yyvsp[-2].expression).value.integer != YR_UNDEFINED && + (yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER && + (yyvsp[0].expression).width != 0) + { + result = yr_parser_integer_width_check((yyvsp[0].expression), (yyvsp[-2].expression)); + if (result != ERROR_SUCCESS) + yywarning(yyscanner, + "integer function comparison always false"); + } + fail_if_error(yr_parser_reduce_operation( yyscanner, "==", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3972 "libyara/grammar.c" +#line 4050 "libyara/grammar.c" break; case 109: /* expression: primary_expression "!=" primary_expression */ -#line 1940 "libyara/grammar.y" +#line 1974 "libyara/grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, "!=", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3983 "libyara/grammar.c" +#line 4061 "libyara/grammar.c" break; case 110: /* expression: primary_expression */ -#line 1947 "libyara/grammar.y" +#line 1981 "libyara/grammar.y" { (yyval.expression) = (yyvsp[0].expression); } -#line 3991 "libyara/grammar.c" +#line 4069 "libyara/grammar.c" break; case 111: /* expression: '(' expression ')' */ -#line 1951 "libyara/grammar.y" +#line 1985 "libyara/grammar.y" { (yyval.expression) = (yyvsp[-1].expression); } -#line 3999 "libyara/grammar.c" +#line 4077 "libyara/grammar.c" break; case 112: /* for_iteration: for_variables "" iterator */ -#line 1958 "libyara/grammar.y" +#line 1992 "libyara/grammar.y" { (yyval.integer) = FOR_ITERATION_ITERATOR; } -#line 4005 "libyara/grammar.c" +#line 4083 "libyara/grammar.c" break; case 113: /* for_iteration: "" string_iterator */ -#line 1960 "libyara/grammar.y" +#line 1994 "libyara/grammar.y" { int var_frame; int result = ERROR_SUCCESS; @@ -4026,11 +4104,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = FOR_ITERATION_STRING_SET; } -#line 4030 "libyara/grammar.c" +#line 4108 "libyara/grammar.c" break; case 114: /* for_variables: "identifier" */ -#line 1985 "libyara/grammar.y" +#line 2019 "libyara/grammar.y" { int result = ERROR_SUCCESS; @@ -4050,11 +4128,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); assert(loop_ctx->vars_count <= YR_MAX_LOOP_VARS); } -#line 4054 "libyara/grammar.c" +#line 4132 "libyara/grammar.c" break; case 115: /* for_variables: for_variables ',' "identifier" */ -#line 2005 "libyara/grammar.y" +#line 2039 "libyara/grammar.y" { int result = ERROR_SUCCESS; @@ -4079,11 +4157,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); loop_ctx->vars[loop_ctx->vars_count++].identifier.ptr = (yyvsp[0].c_string); } -#line 4083 "libyara/grammar.c" +#line 4161 "libyara/grammar.c" break; case 116: /* iterator: identifier */ -#line 2033 "libyara/grammar.y" +#line 2067 "libyara/grammar.y" { YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; @@ -4157,11 +4235,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4161 "libyara/grammar.c" +#line 4239 "libyara/grammar.c" break; case 117: /* iterator: set */ -#line 2107 "libyara/grammar.y" +#line 2141 "libyara/grammar.y" { int result = ERROR_SUCCESS; @@ -4185,11 +4263,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4189 "libyara/grammar.c" +#line 4267 "libyara/grammar.c" break; case 118: /* set: '(' enumeration ')' */ -#line 2135 "libyara/grammar.y" +#line 2169 "libyara/grammar.y" { // $2.count contains the number of items in the enumeration fail_if_error(yr_parser_emit_push_const(yyscanner, (yyvsp[-1].enumeration).count)); @@ -4208,22 +4286,22 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.enumeration).type = (yyvsp[-1].enumeration).type; } -#line 4212 "libyara/grammar.c" +#line 4290 "libyara/grammar.c" break; case 119: /* set: range */ -#line 2154 "libyara/grammar.y" +#line 2188 "libyara/grammar.y" { fail_if_error(yr_parser_emit( yyscanner, OP_ITER_START_INT_RANGE, NULL)); (yyval.enumeration).type = EXPRESSION_TYPE_INTEGER; } -#line 4223 "libyara/grammar.c" +#line 4301 "libyara/grammar.c" break; case 120: /* range: '(' primary_expression ".." primary_expression ')' */ -#line 2165 "libyara/grammar.y" +#line 2199 "libyara/grammar.y" { int result = ERROR_SUCCESS; @@ -4262,11 +4340,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4266 "libyara/grammar.c" +#line 4344 "libyara/grammar.c" break; case 121: /* enumeration: primary_expression */ -#line 2208 "libyara/grammar.y" +#line 2242 "libyara/grammar.y" { int result = ERROR_SUCCESS; @@ -4282,11 +4360,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.enumeration).type = (yyvsp[0].expression).type; (yyval.enumeration).count = 1; } -#line 4286 "libyara/grammar.c" +#line 4364 "libyara/grammar.c" break; case 122: /* enumeration: enumeration ',' primary_expression */ -#line 2224 "libyara/grammar.y" +#line 2258 "libyara/grammar.y" { int result = ERROR_SUCCESS; @@ -4302,38 +4380,38 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.enumeration).type = (yyvsp[-2].enumeration).type; (yyval.enumeration).count = (yyvsp[-2].enumeration).count + 1; } -#line 4306 "libyara/grammar.c" +#line 4384 "libyara/grammar.c" break; case 123: /* string_iterator: string_set */ -#line 2244 "libyara/grammar.y" +#line 2278 "libyara/grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, (yyvsp[0].integer))); fail_if_error(yr_parser_emit(yyscanner, OP_ITER_START_STRING_SET, NULL)); } -#line 4316 "libyara/grammar.c" +#line 4394 "libyara/grammar.c" break; case 124: /* $@10: %empty */ -#line 2253 "libyara/grammar.y" +#line 2287 "libyara/grammar.y" { // Push end-of-list marker yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); } -#line 4325 "libyara/grammar.c" +#line 4403 "libyara/grammar.c" break; case 125: /* string_set: '(' $@10 string_enumeration ')' */ -#line 2258 "libyara/grammar.y" +#line 2292 "libyara/grammar.y" { (yyval.integer) = (yyvsp[-1].integer); } -#line 4333 "libyara/grammar.c" +#line 4411 "libyara/grammar.c" break; case 126: /* string_set: "" */ -#line 2262 "libyara/grammar.y" +#line 2296 "libyara/grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, YR_UNDEFINED)); @@ -4343,23 +4421,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = count; } -#line 4347 "libyara/grammar.c" +#line 4425 "libyara/grammar.c" break; case 127: /* string_enumeration: string_enumeration_item */ -#line 2275 "libyara/grammar.y" +#line 2309 "libyara/grammar.y" { (yyval.integer) = (yyvsp[0].integer); } -#line 4353 "libyara/grammar.c" +#line 4431 "libyara/grammar.c" break; case 128: /* string_enumeration: string_enumeration ',' string_enumeration_item */ -#line 2276 "libyara/grammar.y" +#line 2310 "libyara/grammar.y" { (yyval.integer) = (yyvsp[-2].integer) + (yyvsp[0].integer); } -#line 4359 "libyara/grammar.c" +#line 4437 "libyara/grammar.c" break; case 129: /* string_enumeration_item: "string identifier" */ -#line 2282 "libyara/grammar.y" +#line 2316 "libyara/grammar.y" { int count = 0; int result = yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[0].c_string), &count); @@ -4369,11 +4447,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = count; } -#line 4373 "libyara/grammar.c" +#line 4451 "libyara/grammar.c" break; case 130: /* string_enumeration_item: "string identifier with wildcard" */ -#line 2292 "libyara/grammar.y" +#line 2326 "libyara/grammar.y" { int count = 0; int result = yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[0].c_string), &count); @@ -4383,40 +4461,40 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = count; } -#line 4387 "libyara/grammar.c" +#line 4465 "libyara/grammar.c" break; case 131: /* $@11: %empty */ -#line 2306 "libyara/grammar.y" +#line 2340 "libyara/grammar.y" { // Push end-of-list marker yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); } -#line 4396 "libyara/grammar.c" +#line 4474 "libyara/grammar.c" break; case 132: /* rule_set: '(' $@11 rule_enumeration ')' */ -#line 2311 "libyara/grammar.y" +#line 2345 "libyara/grammar.y" { (yyval.integer) = (yyvsp[-1].integer); } -#line 4404 "libyara/grammar.c" +#line 4482 "libyara/grammar.c" break; case 133: /* rule_enumeration: rule_enumeration_item */ -#line 2318 "libyara/grammar.y" +#line 2352 "libyara/grammar.y" { (yyval.integer) = (yyvsp[0].integer); } -#line 4410 "libyara/grammar.c" +#line 4488 "libyara/grammar.c" break; case 134: /* rule_enumeration: rule_enumeration ',' rule_enumeration_item */ -#line 2319 "libyara/grammar.y" +#line 2353 "libyara/grammar.y" { (yyval.integer) = (yyvsp[-2].integer) + (yyvsp[0].integer); } -#line 4416 "libyara/grammar.c" +#line 4494 "libyara/grammar.c" break; case 135: /* rule_enumeration_item: "identifier" */ -#line 2325 "libyara/grammar.y" +#line 2359 "libyara/grammar.y" { int result = ERROR_SUCCESS; @@ -4449,11 +4527,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = 1; } -#line 4453 "libyara/grammar.c" +#line 4531 "libyara/grammar.c" break; case 136: /* rule_enumeration_item: "identifier" '*' */ -#line 2358 "libyara/grammar.y" +#line 2392 "libyara/grammar.y" { int count = 0; YR_NAMESPACE* ns = (YR_NAMESPACE*) yr_arena_get_ptr( @@ -4474,11 +4552,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = count; } -#line 4478 "libyara/grammar.c" +#line 4556 "libyara/grammar.c" break; case 137: /* for_expression: primary_expression */ -#line 2383 "libyara/grammar.y" +#line 2417 "libyara/grammar.y" { if ((yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER && !IS_UNDEFINED((yyvsp[0].expression).value.integer)) { @@ -4534,57 +4612,177 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).value.integer = (yyvsp[0].expression).value.integer; } -#line 4538 "libyara/grammar.c" +#line 4616 "libyara/grammar.c" break; case 138: /* for_expression: for_quantifier */ -#line 2439 "libyara/grammar.y" +#line 2473 "libyara/grammar.y" { (yyval.expression).value.integer = (yyvsp[0].expression).value.integer; } -#line 4546 "libyara/grammar.c" +#line 4624 "libyara/grammar.c" break; case 139: /* for_quantifier: "" */ -#line 2446 "libyara/grammar.y" +#line 2480 "libyara/grammar.y" { yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); (yyval.expression).type = EXPRESSION_TYPE_QUANTIFIER; (yyval.expression).value.integer = FOR_EXPRESSION_ALL; } -#line 4556 "libyara/grammar.c" +#line 4634 "libyara/grammar.c" break; case 140: /* for_quantifier: "" */ -#line 2452 "libyara/grammar.y" +#line 2486 "libyara/grammar.y" { yr_parser_emit_push_const(yyscanner, 1); (yyval.expression).type = EXPRESSION_TYPE_QUANTIFIER; (yyval.expression).value.integer = FOR_EXPRESSION_ANY; } -#line 4566 "libyara/grammar.c" +#line 4644 "libyara/grammar.c" break; case 141: /* for_quantifier: "" */ -#line 2458 "libyara/grammar.y" +#line 2492 "libyara/grammar.y" { yr_parser_emit_push_const(yyscanner, 0); (yyval.expression).type = EXPRESSION_TYPE_QUANTIFIER; (yyval.expression).value.integer = FOR_EXPRESSION_NONE; } -#line 4576 "libyara/grammar.c" +#line 4654 "libyara/grammar.c" + break; + + case 142: /* integer_function: "" */ +#line 2502 "libyara/grammar.y" + { + (yyval.expression).type = EXPRESSION_TYPE_INTEGER_FUNCTION; + (yyval.expression).width = 8; + (yyval.expression).value.integer = OP_INT8; + } +#line 4664 "libyara/grammar.c" + break; + + case 143: /* integer_function: "" */ +#line 2508 "libyara/grammar.y" + { + (yyval.expression).type = EXPRESSION_TYPE_INTEGER_FUNCTION; + (yyval.expression).width = 8; + (yyval.expression).value.integer = OP_UINT8; + } +#line 4674 "libyara/grammar.c" + break; + + case 144: /* integer_function: "" */ +#line 2514 "libyara/grammar.y" + { + (yyval.expression).type = EXPRESSION_TYPE_INTEGER_FUNCTION; + (yyval.expression).width = 16; + (yyval.expression).value.integer = OP_INT16; + } +#line 4684 "libyara/grammar.c" + break; + + case 145: /* integer_function: "" */ +#line 2520 "libyara/grammar.y" + { + (yyval.expression).type = EXPRESSION_TYPE_INTEGER_FUNCTION; + (yyval.expression).width = 16; + (yyval.expression).value.integer = OP_UINT16; + } +#line 4694 "libyara/grammar.c" + break; + + case 146: /* integer_function: "" */ +#line 2526 "libyara/grammar.y" + { + (yyval.expression).type = EXPRESSION_TYPE_INTEGER_FUNCTION; + (yyval.expression).width = 32; + (yyval.expression).value.integer = OP_INT32; + } +#line 4704 "libyara/grammar.c" + break; + + case 147: /* integer_function: "" */ +#line 2532 "libyara/grammar.y" + { + (yyval.expression).type = EXPRESSION_TYPE_INTEGER_FUNCTION; + (yyval.expression).width = 32; + (yyval.expression).value.integer = OP_UINT32; + } +#line 4714 "libyara/grammar.c" + break; + + case 148: /* integer_function: "" */ +#line 2538 "libyara/grammar.y" + { + (yyval.expression).type = EXPRESSION_TYPE_INTEGER_FUNCTION; + (yyval.expression).width = 8; + (yyval.expression).value.integer = OP_INT8BE; + } +#line 4724 "libyara/grammar.c" + break; + + case 149: /* integer_function: "" */ +#line 2544 "libyara/grammar.y" + { + (yyval.expression).type = EXPRESSION_TYPE_INTEGER_FUNCTION; + (yyval.expression).width = 8; + (yyval.expression).value.integer = OP_UINT8BE; + } +#line 4734 "libyara/grammar.c" + break; + + case 150: /* integer_function: "" */ +#line 2550 "libyara/grammar.y" + { + (yyval.expression).type = EXPRESSION_TYPE_INTEGER_FUNCTION; + (yyval.expression).width = 16; + (yyval.expression).value.integer = OP_INT16BE; + } +#line 4744 "libyara/grammar.c" + break; + + case 151: /* integer_function: "" */ +#line 2556 "libyara/grammar.y" + { + (yyval.expression).type = EXPRESSION_TYPE_INTEGER_FUNCTION; + (yyval.expression).width = 16; + (yyval.expression).value.integer = OP_UINT16BE; + } +#line 4754 "libyara/grammar.c" + break; + + case 152: /* integer_function: "" */ +#line 2562 "libyara/grammar.y" + { + (yyval.expression).type = EXPRESSION_TYPE_INTEGER_FUNCTION; + (yyval.expression).width = 32; + (yyval.expression).value.integer = OP_INT32BE; + } +#line 4764 "libyara/grammar.c" break; - case 142: /* primary_expression: '(' primary_expression ')' */ -#line 2468 "libyara/grammar.y" + case 153: /* integer_function: "" */ +#line 2568 "libyara/grammar.y" + { + (yyval.expression).type = EXPRESSION_TYPE_INTEGER_FUNCTION; + (yyval.expression).width = 32; + (yyval.expression).value.integer = OP_UINT32BE; + } +#line 4774 "libyara/grammar.c" + break; + + case 154: /* primary_expression: '(' primary_expression ')' */ +#line 2578 "libyara/grammar.y" { (yyval.expression) = (yyvsp[-1].expression); } -#line 4584 "libyara/grammar.c" +#line 4782 "libyara/grammar.c" break; - case 143: /* primary_expression: "" */ -#line 2472 "libyara/grammar.y" + case 155: /* primary_expression: "" */ +#line 2582 "libyara/grammar.y" { fail_if_error(yr_parser_emit( yyscanner, OP_FILESIZE, NULL)); @@ -4592,11 +4790,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4596 "libyara/grammar.c" +#line 4794 "libyara/grammar.c" break; - case 144: /* primary_expression: "" */ -#line 2480 "libyara/grammar.y" + case 156: /* primary_expression: "" */ +#line 2590 "libyara/grammar.y" { yywarning(yyscanner, "using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " @@ -4608,51 +4806,47 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4612 "libyara/grammar.c" +#line 4810 "libyara/grammar.c" break; - case 145: /* primary_expression: "integer function" '(' primary_expression ')' */ -#line 2492 "libyara/grammar.y" + case 157: /* primary_expression: integer_function '(' primary_expression ')' */ +#line 2602 "libyara/grammar.y" { check_type((yyvsp[-1].expression), EXPRESSION_TYPE_INTEGER, "intXXXX or uintXXXX"); - // _INTEGER_FUNCTION_ could be any of int8, int16, int32, uint8, - // uint32, etc. $1 contains an index that added to OP_READ_INT results - // in the proper OP_INTXX opcode. - fail_if_error(yr_parser_emit( - yyscanner, (uint8_t) (OP_READ_INT + (yyvsp[-3].integer)), NULL)); + yyscanner, (uint8_t) (yyvsp[-3].expression).value.integer, NULL)); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4630 "libyara/grammar.c" +#line 4824 "libyara/grammar.c" break; - case 146: /* primary_expression: "integer number" */ -#line 2506 "libyara/grammar.y" + case 158: /* primary_expression: "integer number" */ +#line 2612 "libyara/grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, (yyvsp[0].integer))); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = (yyvsp[0].integer); } -#line 4641 "libyara/grammar.c" +#line 4835 "libyara/grammar.c" break; - case 147: /* primary_expression: "floating point number" */ -#line 2513 "libyara/grammar.y" + case 159: /* primary_expression: "floating point number" */ +#line 2619 "libyara/grammar.y" { fail_if_error(yr_parser_emit_with_arg_double( yyscanner, OP_PUSH, (yyvsp[0].double_), NULL, NULL)); (yyval.expression).type = EXPRESSION_TYPE_FLOAT; } -#line 4652 "libyara/grammar.c" +#line 4846 "libyara/grammar.c" break; - case 148: /* primary_expression: "text string" */ -#line 2520 "libyara/grammar.y" + case 160: /* primary_expression: "text string" */ +#line 2626 "libyara/grammar.y" { YR_ARENA_REF ref; @@ -4677,11 +4871,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_STRING; (yyval.expression).value.sized_string_ref = ref; } -#line 4681 "libyara/grammar.c" +#line 4875 "libyara/grammar.c" break; - case 149: /* primary_expression: "string count" "" range */ -#line 2545 "libyara/grammar.y" + case 161: /* primary_expression: "string count" "" range */ +#line 2651 "libyara/grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-2].c_string), OP_COUNT_IN, YR_UNDEFINED); @@ -4693,11 +4887,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4697 "libyara/grammar.c" +#line 4891 "libyara/grammar.c" break; - case 150: /* primary_expression: "string count" */ -#line 2557 "libyara/grammar.y" + case 162: /* primary_expression: "string count" */ +#line 2663 "libyara/grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[0].c_string), OP_COUNT, YR_UNDEFINED); @@ -4709,11 +4903,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4713 "libyara/grammar.c" +#line 4907 "libyara/grammar.c" break; - case 151: /* primary_expression: "string offset" '[' primary_expression ']' */ -#line 2569 "libyara/grammar.y" + case 163: /* primary_expression: "string offset" '[' primary_expression ']' */ +#line 2675 "libyara/grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-3].c_string), OP_OFFSET, YR_UNDEFINED); @@ -4725,11 +4919,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4729 "libyara/grammar.c" +#line 4923 "libyara/grammar.c" break; - case 152: /* primary_expression: "string offset" */ -#line 2581 "libyara/grammar.y" + case 164: /* primary_expression: "string offset" */ +#line 2687 "libyara/grammar.y" { int result = yr_parser_emit_push_const(yyscanner, 1); @@ -4744,11 +4938,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4748 "libyara/grammar.c" +#line 4942 "libyara/grammar.c" break; - case 153: /* primary_expression: "string length" '[' primary_expression ']' */ -#line 2596 "libyara/grammar.y" + case 165: /* primary_expression: "string length" '[' primary_expression ']' */ +#line 2702 "libyara/grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-3].c_string), OP_LENGTH, YR_UNDEFINED); @@ -4760,11 +4954,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4764 "libyara/grammar.c" +#line 4958 "libyara/grammar.c" break; - case 154: /* primary_expression: "string length" */ -#line 2608 "libyara/grammar.y" + case 166: /* primary_expression: "string length" */ +#line 2714 "libyara/grammar.y" { int result = yr_parser_emit_push_const(yyscanner, 1); @@ -4779,11 +4973,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4783 "libyara/grammar.c" +#line 4977 "libyara/grammar.c" break; - case 155: /* primary_expression: identifier */ -#line 2623 "libyara/grammar.y" + case 167: /* primary_expression: identifier */ +#line 2729 "libyara/grammar.y" { int result = ERROR_SUCCESS; @@ -4826,11 +5020,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4830 "libyara/grammar.c" +#line 5024 "libyara/grammar.c" break; - case 156: /* primary_expression: '-' primary_expression */ -#line 2666 "libyara/grammar.y" + case 168: /* primary_expression: '-' primary_expression */ +#line 2772 "libyara/grammar.y" { int result = ERROR_SUCCESS; @@ -4851,11 +5045,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4855 "libyara/grammar.c" +#line 5049 "libyara/grammar.c" break; - case 157: /* primary_expression: primary_expression '+' primary_expression */ -#line 2687 "libyara/grammar.y" + case 169: /* primary_expression: primary_expression '+' primary_expression */ +#line 2793 "libyara/grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "+", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4889,12 +5083,13 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); } fail_if_error(result); + (yyval.expression).width = 0; } -#line 4894 "libyara/grammar.c" +#line 5089 "libyara/grammar.c" break; - case 158: /* primary_expression: primary_expression '-' primary_expression */ -#line 2722 "libyara/grammar.y" + case 170: /* primary_expression: primary_expression '-' primary_expression */ +#line 2829 "libyara/grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "-", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4928,12 +5123,13 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); } fail_if_error(result); + (yyval.expression).width = 0; } -#line 4933 "libyara/grammar.c" +#line 5129 "libyara/grammar.c" break; - case 159: /* primary_expression: primary_expression '*' primary_expression */ -#line 2757 "libyara/grammar.y" + case 171: /* primary_expression: primary_expression '*' primary_expression */ +#line 2865 "libyara/grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "*", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4966,12 +5162,13 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); } fail_if_error(result); + (yyval.expression).width = 0; } -#line 4971 "libyara/grammar.c" +#line 5168 "libyara/grammar.c" break; - case 160: /* primary_expression: primary_expression '\\' primary_expression */ -#line 2791 "libyara/grammar.y" + case 172: /* primary_expression: primary_expression '\\' primary_expression */ +#line 2900 "libyara/grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "\\", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4995,12 +5192,13 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); } fail_if_error(result); + (yyval.expression).width = 0; } -#line 5000 "libyara/grammar.c" +#line 5198 "libyara/grammar.c" break; - case 161: /* primary_expression: primary_expression '%' primary_expression */ -#line 2816 "libyara/grammar.y" + case 173: /* primary_expression: primary_expression '%' primary_expression */ +#line 2926 "libyara/grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "%"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "%"); @@ -5016,12 +5214,13 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); { fail_if_error(ERROR_DIVISION_BY_ZERO); } + (yyval.expression).width = 0; } -#line 5021 "libyara/grammar.c" +#line 5220 "libyara/grammar.c" break; - case 162: /* primary_expression: primary_expression '^' primary_expression */ -#line 2833 "libyara/grammar.y" + case 174: /* primary_expression: primary_expression '^' primary_expression */ +#line 2944 "libyara/grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); @@ -5030,12 +5229,13 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = OPERATION(^, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer); + (yyval.expression).width = 0; } -#line 5035 "libyara/grammar.c" +#line 5235 "libyara/grammar.c" break; - case 163: /* primary_expression: primary_expression '&' primary_expression */ -#line 2843 "libyara/grammar.y" + case 175: /* primary_expression: primary_expression '&' primary_expression */ +#line 2955 "libyara/grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); @@ -5044,12 +5244,13 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = OPERATION(&, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer); + (yyval.expression).width = 0; } -#line 5049 "libyara/grammar.c" +#line 5250 "libyara/grammar.c" break; - case 164: /* primary_expression: primary_expression '|' primary_expression */ -#line 2853 "libyara/grammar.y" + case 176: /* primary_expression: primary_expression '|' primary_expression */ +#line 2966 "libyara/grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "|"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "|"); @@ -5058,12 +5259,13 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = OPERATION(|, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer); + (yyval.expression).width = 0; } -#line 5063 "libyara/grammar.c" +#line 5265 "libyara/grammar.c" break; - case 165: /* primary_expression: '~' primary_expression */ -#line 2863 "libyara/grammar.y" + case 177: /* primary_expression: '~' primary_expression */ +#line 2977 "libyara/grammar.y" { check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "~"); @@ -5073,11 +5275,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).value.integer = ((yyvsp[0].expression).value.integer == YR_UNDEFINED) ? YR_UNDEFINED : ~((yyvsp[0].expression).value.integer); } -#line 5077 "libyara/grammar.c" +#line 5279 "libyara/grammar.c" break; - case 166: /* primary_expression: primary_expression "<<" primary_expression */ -#line 2873 "libyara/grammar.y" + case 178: /* primary_expression: primary_expression "<<" primary_expression */ +#line 2987 "libyara/grammar.y" { int result; @@ -5094,14 +5296,15 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).value.integer = OPERATION(<<, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).width = 0; fail_if_error(result); } -#line 5101 "libyara/grammar.c" +#line 5304 "libyara/grammar.c" break; - case 167: /* primary_expression: primary_expression ">>" primary_expression */ -#line 2893 "libyara/grammar.y" + case 179: /* primary_expression: primary_expression ">>" primary_expression */ +#line 3008 "libyara/grammar.y" { int result; @@ -5118,22 +5321,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).value.integer = OPERATION(<<, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).width = 0; fail_if_error(result); } -#line 5125 "libyara/grammar.c" +#line 5329 "libyara/grammar.c" break; - case 168: /* primary_expression: regexp */ -#line 2913 "libyara/grammar.y" + case 180: /* primary_expression: regexp */ +#line 3029 "libyara/grammar.y" { (yyval.expression) = (yyvsp[0].expression); } -#line 5133 "libyara/grammar.c" +#line 5337 "libyara/grammar.c" break; -#line 5137 "libyara/grammar.c" +#line 5341 "libyara/grammar.c" default: break; } @@ -5357,5 +5561,5 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); return yyresult; } -#line 2918 "libyara/grammar.y" +#line 3034 "libyara/grammar.y" diff --git a/libyara/grammar.h b/libyara/grammar.h index 7a2a217afe..55efc1519e 100644 --- a/libyara/grammar.h +++ b/libyara/grammar.h @@ -70,51 +70,62 @@ extern int yara_yydebug; _STRING_IDENTIFIER_WITH_WILDCARD_ = 271, /* "string identifier with wildcard" */ _NUMBER_ = 272, /* "integer number" */ _DOUBLE_ = 273, /* "floating point number" */ - _INTEGER_FUNCTION_ = 274, /* "integer function" */ - _TEXT_STRING_ = 275, /* "text string" */ - _HEX_STRING_ = 276, /* "hex string" */ - _REGEXP_ = 277, /* "regular expression" */ - _ASCII_ = 278, /* "" */ - _WIDE_ = 279, /* "" */ - _XOR_ = 280, /* "" */ - _BASE64_ = 281, /* "" */ - _BASE64_WIDE_ = 282, /* "" */ - _NOCASE_ = 283, /* "" */ - _FULLWORD_ = 284, /* "" */ - _AT_ = 285, /* "" */ - _FILESIZE_ = 286, /* "" */ - _ENTRYPOINT_ = 287, /* "" */ - _ALL_ = 288, /* "" */ - _ANY_ = 289, /* "" */ - _NONE_ = 290, /* "" */ - _IN_ = 291, /* "" */ - _OF_ = 292, /* "" */ - _FOR_ = 293, /* "" */ - _THEM_ = 294, /* "" */ - _MATCHES_ = 295, /* "" */ - _CONTAINS_ = 296, /* "" */ - _STARTSWITH_ = 297, /* "" */ - _ENDSWITH_ = 298, /* "" */ - _ICONTAINS_ = 299, /* "" */ - _ISTARTSWITH_ = 300, /* "" */ - _IENDSWITH_ = 301, /* "" */ - _IEQUALS_ = 302, /* "" */ - _IMPORT_ = 303, /* "" */ - _TRUE_ = 304, /* "" */ - _FALSE_ = 305, /* "" */ - _OR_ = 306, /* "" */ - _AND_ = 307, /* "" */ - _NOT_ = 308, /* "" */ - _DEFINED_ = 309, /* "" */ - _EQ_ = 310, /* "==" */ - _NEQ_ = 311, /* "!=" */ - _LT_ = 312, /* "<" */ - _LE_ = 313, /* "<=" */ - _GT_ = 314, /* ">" */ - _GE_ = 315, /* ">=" */ - _SHIFT_LEFT_ = 316, /* "<<" */ - _SHIFT_RIGHT_ = 317, /* ">>" */ - UNARY_MINUS = 318 /* UNARY_MINUS */ + _TEXT_STRING_ = 274, /* "text string" */ + _HEX_STRING_ = 275, /* "hex string" */ + _REGEXP_ = 276, /* "regular expression" */ + _INT8_FUNCTION_ = 277, /* "" */ + _UINT8_FUNCTION_ = 278, /* "" */ + _INT16_FUNCTION_ = 279, /* "" */ + _UINT16_FUNCTION_ = 280, /* "" */ + _INT32_FUNCTION_ = 281, /* "" */ + _UINT32_FUNCTION_ = 282, /* "" */ + _INT8BE_FUNCTION_ = 283, /* "" */ + _UINT8BE_FUNCTION_ = 284, /* "" */ + _INT16BE_FUNCTION_ = 285, /* "" */ + _UINT16BE_FUNCTION_ = 286, /* "" */ + _INT32BE_FUNCTION_ = 287, /* "" */ + _UINT32BE_FUNCTION_ = 288, /* "" */ + _ASCII_ = 289, /* "" */ + _WIDE_ = 290, /* "" */ + _XOR_ = 291, /* "" */ + _BASE64_ = 292, /* "" */ + _BASE64_WIDE_ = 293, /* "" */ + _NOCASE_ = 294, /* "" */ + _FULLWORD_ = 295, /* "" */ + _AT_ = 296, /* "" */ + _FILESIZE_ = 297, /* "" */ + _ENTRYPOINT_ = 298, /* "" */ + _ALL_ = 299, /* "" */ + _ANY_ = 300, /* "" */ + _NONE_ = 301, /* "" */ + _IN_ = 302, /* "" */ + _OF_ = 303, /* "" */ + _FOR_ = 304, /* "" */ + _THEM_ = 305, /* "" */ + _MATCHES_ = 306, /* "" */ + _CONTAINS_ = 307, /* "" */ + _STARTSWITH_ = 308, /* "" */ + _ENDSWITH_ = 309, /* "" */ + _ICONTAINS_ = 310, /* "" */ + _ISTARTSWITH_ = 311, /* "" */ + _IENDSWITH_ = 312, /* "" */ + _IEQUALS_ = 313, /* "" */ + _IMPORT_ = 314, /* "" */ + _TRUE_ = 315, /* "" */ + _FALSE_ = 316, /* "" */ + _OR_ = 317, /* "" */ + _AND_ = 318, /* "" */ + _NOT_ = 319, /* "" */ + _DEFINED_ = 320, /* "" */ + _EQ_ = 321, /* "==" */ + _NEQ_ = 322, /* "!=" */ + _LT_ = 323, /* "<" */ + _LE_ = 324, /* "<=" */ + _GT_ = 325, /* ">" */ + _GE_ = 326, /* ">=" */ + _SHIFT_LEFT_ = 327, /* "<<" */ + _SHIFT_RIGHT_ = 328, /* ">>" */ + UNARY_MINUS = 329 /* UNARY_MINUS */ }; typedef enum yytokentype yytoken_kind_t; #endif @@ -139,57 +150,68 @@ extern int yara_yydebug; #define _STRING_IDENTIFIER_WITH_WILDCARD_ 271 #define _NUMBER_ 272 #define _DOUBLE_ 273 -#define _INTEGER_FUNCTION_ 274 -#define _TEXT_STRING_ 275 -#define _HEX_STRING_ 276 -#define _REGEXP_ 277 -#define _ASCII_ 278 -#define _WIDE_ 279 -#define _XOR_ 280 -#define _BASE64_ 281 -#define _BASE64_WIDE_ 282 -#define _NOCASE_ 283 -#define _FULLWORD_ 284 -#define _AT_ 285 -#define _FILESIZE_ 286 -#define _ENTRYPOINT_ 287 -#define _ALL_ 288 -#define _ANY_ 289 -#define _NONE_ 290 -#define _IN_ 291 -#define _OF_ 292 -#define _FOR_ 293 -#define _THEM_ 294 -#define _MATCHES_ 295 -#define _CONTAINS_ 296 -#define _STARTSWITH_ 297 -#define _ENDSWITH_ 298 -#define _ICONTAINS_ 299 -#define _ISTARTSWITH_ 300 -#define _IENDSWITH_ 301 -#define _IEQUALS_ 302 -#define _IMPORT_ 303 -#define _TRUE_ 304 -#define _FALSE_ 305 -#define _OR_ 306 -#define _AND_ 307 -#define _NOT_ 308 -#define _DEFINED_ 309 -#define _EQ_ 310 -#define _NEQ_ 311 -#define _LT_ 312 -#define _LE_ 313 -#define _GT_ 314 -#define _GE_ 315 -#define _SHIFT_LEFT_ 316 -#define _SHIFT_RIGHT_ 317 -#define UNARY_MINUS 318 +#define _TEXT_STRING_ 274 +#define _HEX_STRING_ 275 +#define _REGEXP_ 276 +#define _INT8_FUNCTION_ 277 +#define _UINT8_FUNCTION_ 278 +#define _INT16_FUNCTION_ 279 +#define _UINT16_FUNCTION_ 280 +#define _INT32_FUNCTION_ 281 +#define _UINT32_FUNCTION_ 282 +#define _INT8BE_FUNCTION_ 283 +#define _UINT8BE_FUNCTION_ 284 +#define _INT16BE_FUNCTION_ 285 +#define _UINT16BE_FUNCTION_ 286 +#define _INT32BE_FUNCTION_ 287 +#define _UINT32BE_FUNCTION_ 288 +#define _ASCII_ 289 +#define _WIDE_ 290 +#define _XOR_ 291 +#define _BASE64_ 292 +#define _BASE64_WIDE_ 293 +#define _NOCASE_ 294 +#define _FULLWORD_ 295 +#define _AT_ 296 +#define _FILESIZE_ 297 +#define _ENTRYPOINT_ 298 +#define _ALL_ 299 +#define _ANY_ 300 +#define _NONE_ 301 +#define _IN_ 302 +#define _OF_ 303 +#define _FOR_ 304 +#define _THEM_ 305 +#define _MATCHES_ 306 +#define _CONTAINS_ 307 +#define _STARTSWITH_ 308 +#define _ENDSWITH_ 309 +#define _ICONTAINS_ 310 +#define _ISTARTSWITH_ 311 +#define _IENDSWITH_ 312 +#define _IEQUALS_ 313 +#define _IMPORT_ 314 +#define _TRUE_ 315 +#define _FALSE_ 316 +#define _OR_ 317 +#define _AND_ 318 +#define _NOT_ 319 +#define _DEFINED_ 320 +#define _EQ_ 321 +#define _NEQ_ 322 +#define _LT_ 323 +#define _LE_ 324 +#define _GT_ 325 +#define _GE_ 326 +#define _SHIFT_LEFT_ 327 +#define _SHIFT_RIGHT_ 328 +#define UNARY_MINUS 329 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { -#line 342 "libyara/grammar.y" +#line 354 "libyara/grammar.y" YR_EXPRESSION expression; SIZED_STRING* sized_string; @@ -204,7 +226,7 @@ union YYSTYPE YR_ARENA_REF meta; YR_ARENA_REF string; -#line 208 "libyara/grammar.h" +#line 230 "libyara/grammar.h" }; typedef union YYSTYPE YYSTYPE; diff --git a/libyara/grammar.y b/libyara/grammar.y index 2c1cda2f82..a66c40d1c4 100644 --- a/libyara/grammar.y +++ b/libyara/grammar.y @@ -203,10 +203,21 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. "string identifier with wildcard" %token _NUMBER_ "integer number" %token _DOUBLE_ "floating point number" -%token _INTEGER_FUNCTION_ "integer function" %token _TEXT_STRING_ "text string" %token _HEX_STRING_ "hex string" %token _REGEXP_ "regular expression" +%token _INT8_FUNCTION_ "" +%token _UINT8_FUNCTION_ "" +%token _INT16_FUNCTION_ "" +%token _UINT16_FUNCTION_ "" +%token _INT32_FUNCTION_ "" +%token _UINT32_FUNCTION_ "" +%token _INT8BE_FUNCTION_ "" +%token _UINT8BE_FUNCTION_ "" +%token _INT16BE_FUNCTION_ "" +%token _UINT16BE_FUNCTION_ "" +%token _INT32BE_FUNCTION_ "" +%token _UINT32BE_FUNCTION_ "" %token _ASCII_ "" %token _WIDE_ "" %token _XOR_ "" @@ -304,6 +315,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %type regexp %type for_expression %type for_quantifier +%type integer_function %type arguments @@ -1931,6 +1943,28 @@ expression } | primary_expression _EQ_ primary_expression { + int result = ERROR_SUCCESS; + + if ($1.type == EXPRESSION_TYPE_INTEGER && + $1.width != 0 && + $3.type == EXPRESSION_TYPE_INTEGER && + $3.value.integer != YR_UNDEFINED) + { + result = yr_parser_integer_width_check($1, $3); + if (result != ERROR_SUCCESS) + yywarning(yyscanner, + "integer function comparison always false"); + } else if ($1.type == EXPRESSION_TYPE_INTEGER && + $1.value.integer != YR_UNDEFINED && + $3.type == EXPRESSION_TYPE_INTEGER && + $3.width != 0) + { + result = yr_parser_integer_width_check($3, $1); + if (result != ERROR_SUCCESS) + yywarning(yyscanner, + "integer function comparison always false"); + } + fail_if_error(yr_parser_reduce_operation( yyscanner, "==", $1, $3)); @@ -2463,6 +2497,82 @@ for_quantifier ; +integer_function + : _INT8_FUNCTION_ + { + $$.type = EXPRESSION_TYPE_INTEGER_FUNCTION; + $$.width = 8; + $$.value.integer = OP_INT8; + } + | _UINT8_FUNCTION_ + { + $$.type = EXPRESSION_TYPE_INTEGER_FUNCTION; + $$.width = 8; + $$.value.integer = OP_UINT8; + } + | _INT16_FUNCTION_ + { + $$.type = EXPRESSION_TYPE_INTEGER_FUNCTION; + $$.width = 16; + $$.value.integer = OP_INT16; + } + | _UINT16_FUNCTION_ + { + $$.type = EXPRESSION_TYPE_INTEGER_FUNCTION; + $$.width = 16; + $$.value.integer = OP_UINT16; + } + | _INT32_FUNCTION_ + { + $$.type = EXPRESSION_TYPE_INTEGER_FUNCTION; + $$.width = 32; + $$.value.integer = OP_INT32; + } + | _UINT32_FUNCTION_ + { + $$.type = EXPRESSION_TYPE_INTEGER_FUNCTION; + $$.width = 32; + $$.value.integer = OP_UINT32; + } + | _INT8BE_FUNCTION_ + { + $$.type = EXPRESSION_TYPE_INTEGER_FUNCTION; + $$.width = 8; + $$.value.integer = OP_INT8BE; + } + | _UINT8BE_FUNCTION_ + { + $$.type = EXPRESSION_TYPE_INTEGER_FUNCTION; + $$.width = 8; + $$.value.integer = OP_UINT8BE; + } + | _INT16BE_FUNCTION_ + { + $$.type = EXPRESSION_TYPE_INTEGER_FUNCTION; + $$.width = 16; + $$.value.integer = OP_INT16BE; + } + | _UINT16BE_FUNCTION_ + { + $$.type = EXPRESSION_TYPE_INTEGER_FUNCTION; + $$.width = 16; + $$.value.integer = OP_UINT16BE; + } + | _INT32BE_FUNCTION_ + { + $$.type = EXPRESSION_TYPE_INTEGER_FUNCTION; + $$.width = 32; + $$.value.integer = OP_INT32BE; + } + | _UINT32BE_FUNCTION_ + { + $$.type = EXPRESSION_TYPE_INTEGER_FUNCTION; + $$.width = 32; + $$.value.integer = OP_UINT32BE; + } + ; + + primary_expression : '(' primary_expression ')' { @@ -2488,16 +2598,12 @@ primary_expression $$.type = EXPRESSION_TYPE_INTEGER; $$.value.integer = YR_UNDEFINED; } - | _INTEGER_FUNCTION_ '(' primary_expression ')' + | integer_function '(' primary_expression ')' { check_type($3, EXPRESSION_TYPE_INTEGER, "intXXXX or uintXXXX"); - // _INTEGER_FUNCTION_ could be any of int8, int16, int32, uint8, - // uint32, etc. $1 contains an index that added to OP_READ_INT results - // in the proper OP_INTXX opcode. - fail_if_error(yr_parser_emit( - yyscanner, (uint8_t) (OP_READ_INT + $1), NULL)); + yyscanner, (uint8_t) $1.value.integer, NULL)); $$.type = EXPRESSION_TYPE_INTEGER; $$.value.integer = YR_UNDEFINED; @@ -2717,6 +2823,7 @@ primary_expression } fail_if_error(result); + $$.width = 0; } | primary_expression '-' primary_expression { @@ -2752,6 +2859,7 @@ primary_expression } fail_if_error(result); + $$.width = 0; } | primary_expression '*' primary_expression { @@ -2786,6 +2894,7 @@ primary_expression } fail_if_error(result); + $$.width = 0; } | primary_expression '\\' primary_expression { @@ -2811,6 +2920,7 @@ primary_expression } fail_if_error(result); + $$.width = 0; } | primary_expression '%' primary_expression { @@ -2828,6 +2938,7 @@ primary_expression { fail_if_error(ERROR_DIVISION_BY_ZERO); } + $$.width = 0; } | primary_expression '^' primary_expression { @@ -2838,6 +2949,7 @@ primary_expression $$.type = EXPRESSION_TYPE_INTEGER; $$.value.integer = OPERATION(^, $1.value.integer, $3.value.integer); + $$.width = 0; } | primary_expression '&' primary_expression { @@ -2848,6 +2960,7 @@ primary_expression $$.type = EXPRESSION_TYPE_INTEGER; $$.value.integer = OPERATION(&, $1.value.integer, $3.value.integer); + $$.width = 0; } | primary_expression '|' primary_expression { @@ -2858,6 +2971,7 @@ primary_expression $$.type = EXPRESSION_TYPE_INTEGER; $$.value.integer = OPERATION(|, $1.value.integer, $3.value.integer); + $$.width = 0; } | '~' primary_expression { @@ -2886,6 +3000,7 @@ primary_expression $$.value.integer = OPERATION(<<, $1.value.integer, $3.value.integer); $$.type = EXPRESSION_TYPE_INTEGER; + $$.width = 0; fail_if_error(result); } @@ -2906,6 +3021,7 @@ primary_expression $$.value.integer = OPERATION(<<, $1.value.integer, $3.value.integer); $$.type = EXPRESSION_TYPE_INTEGER; + $$.width = 0; fail_if_error(result); } diff --git a/libyara/include/yara/compiler.h b/libyara/include/yara/compiler.h index acd173c8ca..a7466f0c67 100644 --- a/libyara/include/yara/compiler.h +++ b/libyara/include/yara/compiler.h @@ -42,14 +42,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define YARA_ERROR_LEVEL_WARNING 1 // Expression type constants are powers of two because they are used as flags. -#define EXPRESSION_TYPE_UNKNOWN 0 -#define EXPRESSION_TYPE_BOOLEAN 1 -#define EXPRESSION_TYPE_INTEGER 2 -#define EXPRESSION_TYPE_STRING 4 -#define EXPRESSION_TYPE_REGEXP 8 -#define EXPRESSION_TYPE_OBJECT 16 -#define EXPRESSION_TYPE_FLOAT 32 -#define EXPRESSION_TYPE_QUANTIFIER 64 +#define EXPRESSION_TYPE_UNKNOWN 0 +#define EXPRESSION_TYPE_BOOLEAN 1 +#define EXPRESSION_TYPE_INTEGER 2 +#define EXPRESSION_TYPE_STRING 4 +#define EXPRESSION_TYPE_REGEXP 8 +#define EXPRESSION_TYPE_OBJECT 16 +#define EXPRESSION_TYPE_FLOAT 32 +#define EXPRESSION_TYPE_QUANTIFIER 64 +#define EXPRESSION_TYPE_INTEGER_FUNCTION 128 // The compiler uses an arena to store the data it generates during the // compilation. Each buffer in the arena is used for storing a different type @@ -84,6 +85,7 @@ typedef struct _YR_ENUMERATION typedef struct _YR_EXPRESSION { int type; + int width; // Used to store the width of intXX expressions. union { diff --git a/libyara/include/yara/exec.h b/libyara/include/yara/exec.h index 945c5a7b10..21718df9f1 100644 --- a/libyara/include/yara/exec.h +++ b/libyara/include/yara/exec.h @@ -179,19 +179,21 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define IS_DBL_OP(x) ((x) >= OP_DBL_BEGIN && (x) <= OP_DBL_END) #define IS_STR_OP(x) ((x) >= OP_STR_BEGIN && (x) <= OP_STR_END) +// OP_READ_INT is unused now that the lexer is returning proper tokens for each +// invididual intXX operation. #define OP_READ_INT 240 -#define OP_INT8 (OP_READ_INT + 0) -#define OP_INT16 (OP_READ_INT + 1) -#define OP_INT32 (OP_READ_INT + 2) -#define OP_UINT8 (OP_READ_INT + 3) -#define OP_UINT16 (OP_READ_INT + 4) -#define OP_UINT32 (OP_READ_INT + 5) -#define OP_INT8BE (OP_READ_INT + 6) -#define OP_INT16BE (OP_READ_INT + 7) -#define OP_INT32BE (OP_READ_INT + 8) -#define OP_UINT8BE (OP_READ_INT + 9) -#define OP_UINT16BE (OP_READ_INT + 10) -#define OP_UINT32BE (OP_READ_INT + 11) +#define OP_INT8 240 +#define OP_INT16 241 +#define OP_INT32 242 +#define OP_UINT8 243 +#define OP_UINT16 244 +#define OP_UINT32 245 +#define OP_INT8BE 246 +#define OP_INT16BE 247 +#define OP_INT32BE 248 +#define OP_UINT8BE 249 +#define OP_UINT16BE 250 +#define OP_UINT32BE 251 #define OPERATION(operator, op1, op2) \ (IS_UNDEFINED(op1) || IS_UNDEFINED(op2)) ? (YR_UNDEFINED) : (op1 operator op2) diff --git a/libyara/include/yara/parser.h b/libyara/include/yara/parser.h index 437e64259d..933a8705ab 100644 --- a/libyara/include/yara/parser.h +++ b/libyara/include/yara/parser.h @@ -121,7 +121,7 @@ int yr_parser_emit_pushes_for_strings( int yr_parser_emit_pushes_for_rules( yyscan_t yyscanner, const char* identifier, - int *count); + int* count); int yr_parser_reduce_external( yyscan_t yyscanner, @@ -136,4 +136,8 @@ int yr_parser_reduce_operation( YR_EXPRESSION left_operand, YR_EXPRESSION right_operand); +int yr_parser_integer_width_check( + YR_EXPRESSION int_func_expr, + YR_EXPRESSION int_expr); + #endif diff --git a/libyara/lexer.c b/libyara/lexer.c index 9e940aaaab..58995e83d9 100644 --- a/libyara/lexer.c +++ b/libyara/lexer.c @@ -1,6 +1,6 @@ -#line 1 "lexer.c" +#line 1 "libyara/lexer.c" -#line 3 "lexer.c" +#line 3 "libyara/lexer.c" #define YY_INT_ALIGNED short int @@ -269,6 +269,7 @@ typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; @@ -407,7 +408,7 @@ typedef size_t yy_size_t; */ #define YY_LESS_LINENO(n) \ do { \ - int yyl;\ + yy_size_t yyl;\ for ( yyl = n; yyl < yyleng; ++yyl )\ if ( yytext[yyl] == '\n' )\ --yylineno;\ @@ -452,7 +453,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -529,7 +530,7 @@ static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); void *yyalloc ( yy_size_t , yyscan_t yyscanner ); void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); @@ -576,12 +577,12 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); */ #define YY_DO_BEFORE_ACTION \ yyg->yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 86 -#define YY_END_OF_BUFFER 87 +#define YY_NUM_RULES 97 +#define YY_END_OF_BUFFER 98 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -589,41 +590,43 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[295] = +static const flex_int16_t yy_accept[313] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 87, 85, 84, 84, 59, 81, 57, 56, 85, 82, - 62, 62, 2, 85, 3, 58, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 85, 73, 74, 66, 86, - 79, 80, 76, 86, 53, 54, 50, 50, 59, 7, - 57, 55, 56, 1, 48, 51, 0, 62, 0, 0, - 0, 0, 8, 4, 6, 5, 9, 58, 61, 61, - 61, 61, 28, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 29, 61, 61, 61, 61, - - 30, 27, 61, 61, 61, 61, 61, 61, 61, 61, - 0, 0, 73, 75, 70, 71, 69, 68, 67, 75, - 79, 76, 76, 78, 77, 53, 49, 51, 63, 62, - 65, 64, 33, 26, 34, 61, 61, 61, 61, 61, - 61, 61, 61, 32, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 25, 61, 61, - 61, 61, 61, 61, 61, 61, 17, 83, 0, 0, - 0, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 60, - 61, 61, 13, 61, 35, 61, 12, 61, 61, 31, - - 23, 16, 0, 0, 0, 0, 72, 15, 61, 61, - 61, 61, 61, 61, 24, 61, 61, 61, 61, 61, - 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, - 18, 61, 61, 61, 61, 61, 61, 61, 11, 61, - 61, 61, 46, 61, 60, 61, 61, 21, 61, 61, - 61, 61, 61, 61, 47, 61, 61, 61, 61, 61, - 61, 45, 61, 61, 38, 10, 61, 14, 61, 61, - 39, 41, 61, 37, 20, 61, 61, 0, 61, 61, - 61, 22, 61, 42, 44, 52, 61, 61, 19, 36, - 61, 40, 43, 0 - + 98, 96, 95, 95, 71, 92, 69, 68, 96, 93, + 73, 73, 2, 96, 3, 70, 72, 72, 72, 72, + 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, + 72, 72, 72, 72, 72, 96, 84, 85, 77, 97, + 90, 91, 87, 97, 65, 66, 62, 62, 71, 7, + 69, 67, 68, 1, 60, 63, 0, 73, 0, 0, + 0, 0, 8, 4, 6, 5, 9, 70, 72, 72, + 72, 72, 28, 72, 72, 72, 72, 72, 72, 72, + 72, 72, 72, 72, 72, 29, 72, 72, 72, 72, + + 30, 27, 72, 72, 72, 72, 72, 72, 72, 72, + 0, 0, 84, 86, 81, 82, 80, 79, 78, 86, + 90, 87, 87, 89, 88, 65, 61, 63, 74, 73, + 76, 75, 33, 26, 34, 72, 72, 72, 72, 72, + 72, 72, 72, 32, 72, 72, 72, 72, 72, 72, + 72, 72, 72, 72, 72, 72, 72, 25, 72, 72, + 72, 72, 72, 72, 72, 72, 17, 94, 0, 0, + 0, 72, 72, 72, 72, 72, 72, 72, 72, 72, + 72, 72, 72, 72, 72, 72, 72, 72, 72, 48, + 72, 72, 13, 72, 35, 72, 12, 72, 72, 31, + + 23, 72, 16, 0, 0, 0, 0, 83, 15, 72, + 72, 72, 72, 72, 72, 24, 72, 72, 72, 72, + 72, 72, 72, 72, 50, 52, 72, 72, 72, 72, + 72, 72, 72, 72, 72, 49, 18, 72, 72, 72, + 72, 72, 72, 72, 11, 72, 72, 72, 46, 72, + 72, 72, 54, 72, 72, 21, 72, 72, 72, 51, + 53, 72, 72, 72, 72, 47, 72, 72, 72, 72, + 72, 72, 45, 72, 56, 58, 72, 38, 10, 72, + 14, 72, 72, 55, 72, 72, 39, 41, 72, 37, + 20, 72, 72, 0, 72, 72, 57, 59, 72, 22, + + 72, 42, 44, 64, 72, 72, 19, 36, 72, 40, + 43, 0 } ; static const YY_CHAR yy_ec[256] = @@ -668,85 +671,89 @@ static const YY_CHAR yy_meta[59] = 11, 11, 11, 12, 11, 11, 1, 1 } ; -static const flex_int16_t yy_base[318] = +static const flex_int16_t yy_base[336] = { 0, - 0, 0, 56, 57, 58, 61, 502, 501, 496, 495, - 504, 509, 509, 509, 480, 509, 0, 492, 490, 55, - 55, 61, 46, 477, 51, 0, 0, 52, 466, 453, - 460, 452, 62, 453, 73, 43, 449, 33, 445, 441, - 441, 38, 449, 448, 443, 475, 0, 509, 509, 87, - 0, 509, 56, 474, 0, 509, 509, 473, 461, 509, - 0, 509, 473, 509, 509, 0, 0, 0, 455, 454, - 110, 0, 509, 509, 509, 509, 509, 0, 0, 438, - 43, 444, 0, 429, 433, 438, 83, 433, 432, 425, - 430, 426, 425, 67, 423, 86, 418, 417, 416, 95, - - 0, 0, 424, 422, 99, 426, 411, 417, 424, 411, - 92, 128, 0, 509, 509, 509, 509, 509, 509, 0, - 0, 409, 509, 509, 509, 0, 509, 0, 0, 509, - 138, 0, 0, 0, 0, 416, 419, 84, 414, 405, - 405, 403, 414, 0, 408, 415, 404, 411, 395, 400, - 402, 128, 410, 407, 408, 407, 402, 0, 386, 400, - 388, 394, 391, 396, 382, 394, 0, 509, 420, 426, - 0, 387, 408, 385, 392, 380, 370, 367, 384, 371, - 366, 385, 367, 367, 382, 366, 362, 393, 396, 376, - 361, 368, 0, 358, 0, 373, 0, 355, 360, 0, - - 0, 0, 393, 148, 399, 131, 509, 0, 384, 350, - 358, 361, 356, 349, 0, 325, 318, 309, 306, 272, - 275, 263, 253, 251, 234, 244, 243, 229, 224, 229, - 212, 223, 219, 225, 206, 209, 197, 200, 0, 147, - 146, 137, 0, 148, 0, 135, 134, 0, 145, 128, - 131, 138, 133, 128, 0, 136, 134, 137, 137, 128, - 121, 0, 168, 116, 0, 0, 127, 0, 131, 122, - 0, 0, 121, 0, 0, 115, 122, 157, 120, 99, - 109, 0, 62, 0, 0, 509, 49, 43, 0, 0, - 42, 0, 0, 509, 189, 202, 215, 228, 234, 239, - - 247, 254, 259, 264, 275, 285, 297, 310, 322, 335, - 348, 69, 354, 357, 367, 380, 386 + 0, 0, 56, 57, 58, 61, 517, 516, 511, 510, + 519, 524, 524, 524, 495, 524, 0, 507, 505, 55, + 55, 61, 46, 492, 51, 0, 0, 52, 481, 468, + 475, 467, 62, 468, 73, 43, 464, 33, 460, 456, + 456, 38, 464, 463, 458, 490, 0, 524, 524, 87, + 0, 524, 56, 489, 0, 524, 524, 488, 476, 524, + 0, 524, 488, 524, 524, 0, 0, 0, 470, 469, + 110, 0, 524, 524, 524, 524, 524, 0, 0, 453, + 43, 459, 0, 444, 448, 453, 83, 448, 447, 440, + 445, 441, 440, 67, 438, 86, 433, 432, 431, 95, + + 0, 0, 439, 437, 99, 441, 426, 432, 439, 426, + 92, 128, 0, 524, 524, 524, 524, 524, 524, 0, + 0, 424, 524, 524, 524, 0, 524, 0, 0, 524, + 138, 0, 0, 0, 0, 431, 434, 84, 429, 420, + 420, 418, 429, 0, 423, 430, 419, 426, 410, 415, + 417, 128, 425, 422, 423, 422, 417, 0, 401, 415, + 403, 409, 406, 411, 397, 409, 0, 524, 435, 441, + 0, 402, 423, 400, 407, 395, 385, 382, 399, 386, + 381, 400, 382, 382, 397, 381, 377, 408, 411, 391, + 376, 383, 0, 373, 0, 388, 0, 370, 375, 0, + + 0, 144, 0, 408, 149, 414, 131, 524, 0, 399, + 365, 373, 376, 371, 365, 0, 369, 364, 366, 374, + 353, 363, 354, 367, 368, 367, 363, 349, 361, 360, + 345, 317, 324, 332, 324, 291, 264, 272, 245, 252, + 234, 236, 224, 231, 0, 232, 227, 216, 0, 227, + 226, 224, 0, 207, 205, 0, 216, 195, 139, 153, + 152, 148, 143, 138, 133, 0, 141, 139, 142, 142, + 133, 126, 0, 173, 0, 0, 121, 0, 0, 132, + 0, 135, 134, 0, 134, 125, 0, 0, 124, 0, + 0, 118, 125, 160, 122, 99, 0, 0, 109, 0, + + 62, 0, 0, 524, 49, 43, 0, 0, 42, 0, + 0, 524, 189, 202, 215, 228, 234, 239, 247, 254, + 259, 264, 275, 285, 297, 310, 322, 335, 348, 69, + 354, 357, 367, 380, 386 } ; -static const flex_int16_t yy_def[318] = +static const flex_int16_t yy_def[336] = { 0, - 294, 1, 295, 295, 296, 296, 297, 297, 298, 298, - 294, 294, 294, 294, 299, 294, 300, 301, 294, 294, - 302, 302, 294, 294, 294, 303, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 305, 306, 294, 294, 307, - 308, 294, 294, 309, 310, 294, 294, 294, 299, 294, - 300, 294, 301, 294, 294, 311, 312, 22, 294, 294, - 294, 313, 294, 294, 294, 294, 294, 303, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 305, 294, 306, 294, 294, 294, 294, 294, 294, 314, - 308, 294, 294, 294, 294, 310, 294, 311, 312, 294, - 294, 313, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 294, 315, 316, - 317, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - - 304, 304, 315, 315, 316, 305, 294, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, - 304, 304, 304, 304, 304, 304, 304, 294, 304, 304, - 304, 304, 304, 304, 304, 294, 304, 304, 304, 304, - 304, 304, 304, 0, 294, 294, 294, 294, 294, 294, - - 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, - 294, 294, 294, 294, 294, 294, 294 + 312, 1, 313, 313, 314, 314, 315, 315, 316, 316, + 312, 312, 312, 312, 317, 312, 318, 319, 312, 312, + 320, 320, 312, 312, 312, 321, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 323, 324, 312, 312, 325, + 326, 312, 312, 327, 328, 312, 312, 312, 317, 312, + 318, 312, 319, 312, 312, 329, 330, 22, 312, 312, + 312, 331, 312, 312, 312, 312, 312, 321, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 323, 312, 324, 312, 312, 312, 312, 312, 312, 332, + 326, 312, 312, 312, 312, 328, 312, 329, 330, 312, + 312, 331, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 312, 333, 334, + 335, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + + 322, 322, 322, 333, 333, 334, 323, 312, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 322, 322, 322, 322, 322, 322, 322, + 322, 322, 322, 312, 322, 322, 322, 322, 322, 322, + + 322, 322, 322, 312, 322, 322, 322, 322, 322, 322, + 322, 0, 312, 312, 312, 312, 312, 312, 312, 312, + 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, + 312, 312, 312, 312, 312 } ; -static const flex_int16_t yy_nxt[568] = +static const flex_int16_t yy_nxt[583] = { 0, 12, 13, 14, 13, 15, 16, 17, 18, 12, 12, 19, 20, 21, 22, 22, 22, 22, 22, 22, 22, @@ -756,63 +763,65 @@ static const flex_int16_t yy_nxt[568] = 43, 27, 44, 45, 27, 27, 46, 12, 48, 48, 52, 49, 49, 52, 65, 67, 66, 73, 74, 53, 101, 67, 53, 76, 77, 98, 129, 106, 134, 99, - 102, 293, 292, 69, 70, 107, 50, 50, 54, 69, - 70, 54, 115, 80, 88, 81, 122, 135, 291, 71, + 102, 311, 310, 69, 70, 107, 50, 50, 54, 69, + 70, 54, 115, 80, 88, 81, 122, 135, 309, 71, - 82, 83, 89, 112, 123, 294, 90, 93, 72, 94, - 148, 290, 91, 149, 294, 95, 96, 116, 140, 174, + 82, 83, 89, 112, 123, 312, 90, 93, 72, 94, + 148, 308, 91, 149, 312, 95, 96, 116, 140, 174, 151, 97, 131, 131, 131, 131, 131, 131, 131, 156, 117, 161, 141, 175, 118, 152, 119, 169, 157, 170, - 120, 188, 112, 189, 158, 289, 162, 190, 288, 168, - 131, 131, 131, 131, 131, 131, 131, 204, 278, 111, - 287, 285, 286, 284, 283, 282, 281, 280, 279, 278, - 277, 276, 275, 274, 273, 272, 271, 270, 269, 268, - 267, 266, 265, 264, 263, 262, 261, 260, 168, 47, + 120, 188, 112, 189, 158, 307, 162, 190, 306, 168, + 131, 131, 131, 131, 131, 131, 131, 234, 205, 235, + 111, 294, 305, 236, 303, 304, 302, 301, 300, 299, + 298, 297, 296, 295, 294, 293, 292, 291, 290, 289, + 288, 287, 286, 285, 284, 283, 282, 281, 168, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 59, 59, 59, 59, 59, 61, 259, 61, 61, - 61, 63, 258, 257, 63, 256, 63, 63, 63, 68, - 255, 68, 254, 253, 252, 68, 78, 251, 78, 78, - 78, 79, 250, 79, 79, 79, 111, 111, 249, 248, - 247, 111, 111, 246, 111, 113, 113, 245, 244, 113, + 57, 59, 59, 59, 59, 59, 61, 280, 61, 61, + 61, 63, 279, 278, 63, 277, 63, 63, 63, 68, + 276, 68, 275, 274, 273, 68, 78, 272, 78, 78, + 78, 79, 271, 79, 79, 79, 111, 111, 270, 269, + 268, 111, 111, 267, 111, 113, 113, 266, 265, 113, 113, 113, 113, 113, 113, 113, 113, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, - 121, 121, 243, 121, 121, 121, 242, 121, 121, 121, - 121, 121, 124, 124, 241, 124, 124, 124, 124, 124, - 124, 124, 124, 124, 124, 126, 126, 126, 240, 126, + 121, 121, 264, 121, 121, 121, 263, 121, 121, 121, + 121, 121, 124, 124, 262, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 126, 126, 126, 261, 126, 126, 126, 126, 126, 126, 126, 126, 126, 128, 128, - 239, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 132, 238, 132, 171, 237, 171, 203, 203, 203, - 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 207, 236, 207, 235, 234, 233, 232, - - 231, 206, 204, 230, 229, 228, 227, 226, 225, 224, - 190, 190, 223, 222, 221, 220, 219, 218, 217, 216, - 215, 214, 213, 212, 211, 210, 209, 208, 206, 204, - 202, 152, 201, 200, 199, 198, 197, 196, 195, 194, - 193, 192, 191, 187, 186, 185, 184, 183, 182, 181, - 180, 179, 178, 177, 176, 173, 172, 123, 167, 166, - 165, 164, 163, 160, 159, 155, 154, 153, 150, 147, - 146, 145, 144, 143, 142, 139, 138, 137, 136, 133, - 130, 130, 62, 294, 127, 125, 112, 110, 109, 108, - 105, 104, 103, 100, 92, 87, 86, 85, 84, 75, - - 64, 62, 60, 294, 58, 58, 56, 56, 11, 294, - 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, - 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, - 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, - 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, - 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, - 294, 294, 294, 294, 294, 294, 294 + 260, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 132, 259, 132, 171, 258, 171, 204, 204, 204, + 204, 204, 204, 204, 204, 204, 204, 204, 204, 204, + 206, 206, 206, 206, 206, 206, 206, 206, 206, 206, + 206, 206, 206, 208, 257, 208, 256, 255, 254, 253, + + 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, + 242, 241, 240, 239, 238, 237, 207, 205, 233, 232, + 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, + 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, + 211, 210, 209, 207, 205, 203, 202, 201, 200, 199, + 198, 197, 196, 195, 194, 193, 192, 191, 187, 186, + 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, + 173, 172, 123, 167, 166, 165, 164, 163, 160, 159, + 155, 154, 153, 150, 147, 146, 145, 144, 143, 142, + 139, 138, 137, 136, 133, 130, 130, 62, 312, 127, + + 125, 112, 110, 109, 108, 105, 104, 103, 100, 92, + 87, 86, 85, 84, 75, 64, 62, 60, 312, 58, + 58, 56, 56, 11, 312, 312, 312, 312, 312, 312, + 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, + 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, + 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, + 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, + 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, + 312, 312 } ; -static const flex_int16_t yy_chk[568] = +static const flex_int16_t yy_chk[583] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -821,71 +830,73 @@ static const flex_int16_t yy_chk[568] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4, 5, 3, 4, 6, 20, 21, 20, 23, 23, 5, - 38, 22, 6, 25, 25, 36, 312, 42, 81, 36, - 38, 291, 288, 21, 21, 42, 3, 4, 5, 22, - 22, 6, 50, 28, 33, 28, 53, 81, 287, 21, + 38, 22, 6, 25, 25, 36, 330, 42, 81, 36, + 38, 309, 306, 21, 21, 42, 3, 4, 5, 22, + 22, 6, 50, 28, 33, 28, 53, 81, 305, 21, 28, 28, 33, 111, 53, 22, 33, 35, 21, 35, - 94, 283, 33, 94, 22, 35, 35, 50, 87, 138, + 94, 301, 33, 94, 22, 35, 35, 50, 87, 138, 96, 35, 71, 71, 71, 71, 71, 71, 71, 100, 50, 105, 87, 138, 50, 96, 50, 112, 100, 112, - 50, 152, 206, 152, 100, 281, 105, 152, 280, 111, - 131, 131, 131, 131, 131, 131, 131, 204, 278, 204, - 279, 277, 278, 276, 273, 270, 269, 267, 264, 263, - 261, 260, 259, 258, 257, 256, 254, 253, 252, 251, - 250, 249, 247, 246, 244, 242, 241, 240, 206, 295, - 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, - - 295, 295, 296, 296, 296, 296, 296, 296, 296, 296, - 296, 296, 296, 296, 296, 297, 297, 297, 297, 297, - 297, 297, 297, 297, 297, 297, 297, 297, 298, 298, - 298, 298, 298, 298, 298, 298, 298, 298, 298, 298, - 298, 299, 299, 299, 299, 299, 300, 238, 300, 300, - 300, 301, 237, 236, 301, 235, 301, 301, 301, 302, - 234, 302, 233, 232, 231, 302, 303, 230, 303, 303, - 303, 304, 229, 304, 304, 304, 305, 305, 228, 227, - 226, 305, 305, 225, 305, 306, 306, 224, 223, 306, - 306, 306, 306, 306, 306, 306, 306, 307, 307, 307, - - 307, 307, 307, 307, 307, 307, 307, 307, 307, 307, - 308, 308, 222, 308, 308, 308, 221, 308, 308, 308, - 308, 308, 309, 309, 220, 309, 309, 309, 309, 309, - 309, 309, 309, 309, 309, 310, 310, 310, 219, 310, - 310, 310, 310, 310, 310, 310, 310, 310, 311, 311, - 218, 311, 311, 311, 311, 311, 311, 311, 311, 311, - 311, 313, 217, 313, 314, 216, 314, 315, 315, 315, - 315, 315, 315, 315, 315, 315, 315, 315, 315, 315, + 50, 152, 207, 152, 100, 299, 105, 152, 296, 111, + 131, 131, 131, 131, 131, 131, 131, 202, 205, 202, + 205, 294, 295, 202, 293, 294, 292, 289, 286, 285, + 283, 282, 280, 277, 274, 272, 271, 270, 269, 268, + 267, 265, 264, 263, 262, 261, 260, 259, 207, 313, + 313, 313, 313, 313, 313, 313, 313, 313, 313, 313, + + 313, 313, 314, 314, 314, 314, 314, 314, 314, 314, + 314, 314, 314, 314, 314, 315, 315, 315, 315, 315, + 315, 315, 315, 315, 315, 315, 315, 315, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, - 316, 316, 316, 317, 214, 317, 213, 212, 211, 210, - - 209, 205, 203, 199, 198, 196, 194, 192, 191, 190, - 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, - 179, 178, 177, 176, 175, 174, 173, 172, 170, 169, - 166, 165, 164, 163, 162, 161, 160, 159, 157, 156, - 155, 154, 153, 151, 150, 149, 148, 147, 146, 145, - 143, 142, 141, 140, 139, 137, 136, 122, 110, 109, - 108, 107, 106, 104, 103, 99, 98, 97, 95, 93, - 92, 91, 90, 89, 88, 86, 85, 84, 82, 80, - 70, 69, 63, 59, 58, 54, 46, 45, 44, 43, - 41, 40, 39, 37, 34, 32, 31, 30, 29, 24, - - 19, 18, 15, 11, 10, 9, 8, 7, 294, 294, - 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, - 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, - 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, - 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, - 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, - 294, 294, 294, 294, 294, 294, 294 + 316, 317, 317, 317, 317, 317, 318, 258, 318, 318, + 318, 319, 257, 255, 319, 254, 319, 319, 319, 320, + 252, 320, 251, 250, 248, 320, 321, 247, 321, 321, + 321, 322, 246, 322, 322, 322, 323, 323, 244, 243, + 242, 323, 323, 241, 323, 324, 324, 240, 239, 324, + 324, 324, 324, 324, 324, 324, 324, 325, 325, 325, + + 325, 325, 325, 325, 325, 325, 325, 325, 325, 325, + 326, 326, 238, 326, 326, 326, 237, 326, 326, 326, + 326, 326, 327, 327, 236, 327, 327, 327, 327, 327, + 327, 327, 327, 327, 327, 328, 328, 328, 235, 328, + 328, 328, 328, 328, 328, 328, 328, 328, 329, 329, + 234, 329, 329, 329, 329, 329, 329, 329, 329, 329, + 329, 331, 233, 331, 332, 232, 332, 333, 333, 333, + 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, + 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, + 334, 334, 334, 335, 231, 335, 230, 229, 228, 227, + + 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, + 215, 214, 213, 212, 211, 210, 206, 204, 199, 198, + 196, 194, 192, 191, 190, 189, 188, 187, 186, 185, + 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, + 174, 173, 172, 170, 169, 166, 165, 164, 163, 162, + 161, 160, 159, 157, 156, 155, 154, 153, 151, 150, + 149, 148, 147, 146, 145, 143, 142, 141, 140, 139, + 137, 136, 122, 110, 109, 108, 107, 106, 104, 103, + 99, 98, 97, 95, 93, 92, 91, 90, 89, 88, + 86, 85, 84, 82, 80, 70, 69, 63, 59, 58, + + 54, 46, 45, 44, 43, 41, 40, 39, 37, 34, + 32, 31, 30, 29, 24, 19, 18, 15, 11, 10, + 9, 8, 7, 312, 312, 312, 312, 312, 312, 312, + 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, + 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, + 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, + 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, + 312, 312, 312, 312, 312, 312, 312, 312, 312, 312, + 312, 312 } ; /* Table of booleans, true if rule could match eol. */ -static const flex_int32_t yy_rule_can_match_eol[87] = +static const flex_int32_t yy_rule_can_match_eol[98] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, - 1, 0, 0, 1, 1, 0, 0, }; + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -894,7 +905,7 @@ static const flex_int32_t yy_rule_can_match_eol[87] = #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -#line 1 "lexer.l" +#line 1 "libyara/lexer.l" /* Copyright (c) 2007-2013. The YARA Authors. All Rights Reserved. @@ -924,7 +935,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Lexical analyzer for YARA */ -#line 33 "lexer.l" +#line 33 "libyara/lexer.l" /* Disable warnings for unused functions in this file. @@ -1030,11 +1041,11 @@ static bool is_absolute_path( #endif } -#line 1033 "lexer.c" +#line 1044 "libyara/lexer.c" #define YY_NO_UNISTD_H 1 #define YY_NO_INPUT 1 -#line 1037 "lexer.c" +#line 1048 "libyara/lexer.c" #define INITIAL 0 #define str 1 @@ -1067,8 +1078,8 @@ struct yyguts_t size_t yy_buffer_stack_max; /**< capacity of stack. */ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ char yy_hold_char; - int yy_n_chars; - int yyleng_r; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; char *yy_c_buf_p; int yy_init; int yy_start; @@ -1121,7 +1132,7 @@ FILE *yyget_out ( yyscan_t yyscanner ); void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); - int yyget_leng ( yyscan_t yyscanner ); + yy_size_t yyget_leng ( yyscan_t yyscanner ); char *yyget_text ( yyscan_t yyscanner ); @@ -1196,7 +1207,7 @@ static int input ( yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - int n; \ + yy_size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1310,10 +1321,10 @@ YY_DECL } { -#line 163 "lexer.l" +#line 163 "libyara/lexer.l" -#line 1316 "lexer.c" +#line 1327 "libyara/lexer.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1340,13 +1351,13 @@ YY_DECL while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 295 ) + if ( yy_current_state >= 313 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_current_state != 294 ); + while ( yy_current_state != 312 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -1357,7 +1368,7 @@ YY_DECL if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) { - int yyl; + yy_size_t yyl; for ( yyl = 0; yyl < yyleng; ++yyl ) if ( yytext[yyl] == '\n' ) @@ -1380,278 +1391,338 @@ YY_DECL case 1: YY_RULE_SETUP -#line 165 "lexer.l" -{ return _DOT_DOT_; } +#line 165 "libyara/lexer.l" +{ return _DOT_DOT_; } YY_BREAK case 2: YY_RULE_SETUP -#line 166 "lexer.l" -{ return _LT_; } +#line 166 "libyara/lexer.l" +{ return _LT_; } YY_BREAK case 3: YY_RULE_SETUP -#line 167 "lexer.l" -{ return _GT_; } +#line 167 "libyara/lexer.l" +{ return _GT_; } YY_BREAK case 4: YY_RULE_SETUP -#line 168 "lexer.l" -{ return _LE_; } +#line 168 "libyara/lexer.l" +{ return _LE_; } YY_BREAK case 5: YY_RULE_SETUP -#line 169 "lexer.l" -{ return _GE_; } +#line 169 "libyara/lexer.l" +{ return _GE_; } YY_BREAK case 6: YY_RULE_SETUP -#line 170 "lexer.l" -{ return _EQ_; } +#line 170 "libyara/lexer.l" +{ return _EQ_; } YY_BREAK case 7: YY_RULE_SETUP -#line 171 "lexer.l" -{ return _NEQ_; } +#line 171 "libyara/lexer.l" +{ return _NEQ_; } YY_BREAK case 8: YY_RULE_SETUP -#line 172 "lexer.l" -{ return _SHIFT_LEFT_; } +#line 172 "libyara/lexer.l" +{ return _SHIFT_LEFT_; } YY_BREAK case 9: YY_RULE_SETUP -#line 173 "lexer.l" -{ return _SHIFT_RIGHT_; } +#line 173 "libyara/lexer.l" +{ return _SHIFT_RIGHT_; } YY_BREAK case 10: YY_RULE_SETUP -#line 174 "lexer.l" -{ return _PRIVATE_; } +#line 174 "libyara/lexer.l" +{ return _PRIVATE_; } YY_BREAK case 11: YY_RULE_SETUP -#line 175 "lexer.l" -{ return _GLOBAL_; } +#line 175 "libyara/lexer.l" +{ return _GLOBAL_; } YY_BREAK case 12: YY_RULE_SETUP -#line 176 "lexer.l" -{ return _RULE_; } +#line 176 "libyara/lexer.l" +{ return _RULE_; } YY_BREAK case 13: YY_RULE_SETUP -#line 177 "lexer.l" -{ return _META_; } +#line 177 "libyara/lexer.l" +{ return _META_; } YY_BREAK case 14: YY_RULE_SETUP -#line 178 "lexer.l" -{ return _STRINGS_; } +#line 178 "libyara/lexer.l" +{ return _STRINGS_; } YY_BREAK case 15: YY_RULE_SETUP -#line 179 "lexer.l" -{ return _ASCII_; } +#line 179 "libyara/lexer.l" +{ return _ASCII_; } YY_BREAK case 16: YY_RULE_SETUP -#line 180 "lexer.l" -{ return _WIDE_; } +#line 180 "libyara/lexer.l" +{ return _WIDE_; } YY_BREAK case 17: YY_RULE_SETUP -#line 181 "lexer.l" -{ return _XOR_; } +#line 181 "libyara/lexer.l" +{ return _XOR_; } YY_BREAK case 18: YY_RULE_SETUP -#line 182 "lexer.l" -{ return _BASE64_; } +#line 182 "libyara/lexer.l" +{ return _BASE64_; } YY_BREAK case 19: YY_RULE_SETUP -#line 183 "lexer.l" -{ return _BASE64_WIDE_; } +#line 183 "libyara/lexer.l" +{ return _BASE64_WIDE_; } YY_BREAK case 20: YY_RULE_SETUP -#line 184 "lexer.l" -{ return _FULLWORD_; } +#line 184 "libyara/lexer.l" +{ return _FULLWORD_; } YY_BREAK case 21: YY_RULE_SETUP -#line 185 "lexer.l" -{ return _NOCASE_; } +#line 185 "libyara/lexer.l" +{ return _NOCASE_; } YY_BREAK case 22: YY_RULE_SETUP -#line 186 "lexer.l" -{ return _CONDITION_; } +#line 186 "libyara/lexer.l" +{ return _CONDITION_; } YY_BREAK case 23: YY_RULE_SETUP -#line 187 "lexer.l" -{ return _TRUE_; } +#line 187 "libyara/lexer.l" +{ return _TRUE_; } YY_BREAK case 24: YY_RULE_SETUP -#line 188 "lexer.l" -{ return _FALSE_; } +#line 188 "libyara/lexer.l" +{ return _FALSE_; } YY_BREAK case 25: YY_RULE_SETUP -#line 189 "lexer.l" -{ return _NOT_; } +#line 189 "libyara/lexer.l" +{ return _NOT_; } YY_BREAK case 26: YY_RULE_SETUP -#line 190 "lexer.l" -{ return _AND_; } +#line 190 "libyara/lexer.l" +{ return _AND_; } YY_BREAK case 27: YY_RULE_SETUP -#line 191 "lexer.l" -{ return _OR_; } +#line 191 "libyara/lexer.l" +{ return _OR_; } YY_BREAK case 28: YY_RULE_SETUP -#line 192 "lexer.l" -{ return _AT_; } +#line 192 "libyara/lexer.l" +{ return _AT_; } YY_BREAK case 29: YY_RULE_SETUP -#line 193 "lexer.l" -{ return _IN_; } +#line 193 "libyara/lexer.l" +{ return _IN_; } YY_BREAK case 30: YY_RULE_SETUP -#line 194 "lexer.l" -{ return _OF_; } +#line 194 "libyara/lexer.l" +{ return _OF_; } YY_BREAK case 31: YY_RULE_SETUP -#line 195 "lexer.l" -{ return _THEM_; } +#line 195 "libyara/lexer.l" +{ return _THEM_; } YY_BREAK case 32: YY_RULE_SETUP -#line 196 "lexer.l" -{ return _FOR_; } +#line 196 "libyara/lexer.l" +{ return _FOR_; } YY_BREAK case 33: YY_RULE_SETUP -#line 197 "lexer.l" -{ return _ALL_; } +#line 197 "libyara/lexer.l" +{ return _ALL_; } YY_BREAK case 34: YY_RULE_SETUP -#line 198 "lexer.l" -{ return _ANY_; } +#line 198 "libyara/lexer.l" +{ return _ANY_; } YY_BREAK case 35: YY_RULE_SETUP -#line 199 "lexer.l" -{ return _NONE_; } +#line 199 "libyara/lexer.l" +{ return _NONE_; } YY_BREAK case 36: YY_RULE_SETUP -#line 200 "lexer.l" -{ return _ENTRYPOINT_; } +#line 200 "libyara/lexer.l" +{ return _ENTRYPOINT_; } YY_BREAK case 37: YY_RULE_SETUP -#line 201 "lexer.l" -{ return _FILESIZE_; } +#line 201 "libyara/lexer.l" +{ return _FILESIZE_; } YY_BREAK case 38: YY_RULE_SETUP -#line 202 "lexer.l" -{ return _MATCHES_; } +#line 202 "libyara/lexer.l" +{ return _MATCHES_; } YY_BREAK case 39: YY_RULE_SETUP -#line 203 "lexer.l" -{ return _CONTAINS_; } +#line 203 "libyara/lexer.l" +{ return _CONTAINS_; } YY_BREAK case 40: YY_RULE_SETUP -#line 204 "lexer.l" -{ return _STARTSWITH_; } +#line 204 "libyara/lexer.l" +{ return _STARTSWITH_; } YY_BREAK case 41: YY_RULE_SETUP -#line 205 "lexer.l" -{ return _ENDSWITH_; } +#line 205 "libyara/lexer.l" +{ return _ENDSWITH_; } YY_BREAK case 42: YY_RULE_SETUP -#line 206 "lexer.l" -{ return _ICONTAINS_; } +#line 206 "libyara/lexer.l" +{ return _ICONTAINS_; } YY_BREAK case 43: YY_RULE_SETUP -#line 207 "lexer.l" -{ return _ISTARTSWITH_; } +#line 207 "libyara/lexer.l" +{ return _ISTARTSWITH_; } YY_BREAK case 44: YY_RULE_SETUP -#line 208 "lexer.l" -{ return _IENDSWITH_; } +#line 208 "libyara/lexer.l" +{ return _IENDSWITH_; } YY_BREAK case 45: YY_RULE_SETUP -#line 209 "lexer.l" -{ return _IEQUALS_; } +#line 209 "libyara/lexer.l" +{ return _IEQUALS_; } YY_BREAK case 46: YY_RULE_SETUP -#line 210 "lexer.l" -{ return _IMPORT_; } +#line 210 "libyara/lexer.l" +{ return _IMPORT_; } YY_BREAK case 47: YY_RULE_SETUP -#line 211 "lexer.l" -{ return _DEFINED_; } +#line 211 "libyara/lexer.l" +{ return _DEFINED_; } YY_BREAK case 48: YY_RULE_SETUP -#line 214 "lexer.l" -{ BEGIN(comment); } +#line 212 "libyara/lexer.l" +{ return _INT8_FUNCTION_; } YY_BREAK case 49: YY_RULE_SETUP -#line 215 "lexer.l" -{ BEGIN(INITIAL); } +#line 213 "libyara/lexer.l" +{ return _UINT8_FUNCTION_; } YY_BREAK case 50: -/* rule 50 can match eol */ YY_RULE_SETUP -#line 216 "lexer.l" -{ /* skip comments */ } +#line 214 "libyara/lexer.l" +{ return _INT16_FUNCTION_; } YY_BREAK case 51: YY_RULE_SETUP -#line 219 "lexer.l" -{ /* skip single-line comments */ } +#line 215 "libyara/lexer.l" +{ return _UINT16_FUNCTION_; } YY_BREAK case 52: YY_RULE_SETUP -#line 222 "lexer.l" +#line 216 "libyara/lexer.l" +{ return _INT32_FUNCTION_; } + YY_BREAK +case 53: +YY_RULE_SETUP +#line 217 "libyara/lexer.l" +{ return _UINT32_FUNCTION_; } + YY_BREAK +case 54: +YY_RULE_SETUP +#line 218 "libyara/lexer.l" +{ return _INT8BE_FUNCTION_; } + YY_BREAK +case 55: +YY_RULE_SETUP +#line 219 "libyara/lexer.l" +{ return _UINT8BE_FUNCTION_; } + YY_BREAK +case 56: +YY_RULE_SETUP +#line 220 "libyara/lexer.l" +{ return _INT16BE_FUNCTION_; } + YY_BREAK +case 57: +YY_RULE_SETUP +#line 221 "libyara/lexer.l" +{ return _UINT16BE_FUNCTION_; } + YY_BREAK +case 58: +YY_RULE_SETUP +#line 222 "libyara/lexer.l" +{ return _INT32BE_FUNCTION_; } + YY_BREAK +case 59: +YY_RULE_SETUP +#line 223 "libyara/lexer.l" +{ return _UINT32BE_FUNCTION_; } + YY_BREAK +case 60: +YY_RULE_SETUP +#line 226 "libyara/lexer.l" +{ BEGIN(comment); } + YY_BREAK +case 61: +YY_RULE_SETUP +#line 227 "libyara/lexer.l" +{ BEGIN(INITIAL); } + YY_BREAK +case 62: +/* rule 62 can match eol */ +YY_RULE_SETUP +#line 228 "libyara/lexer.l" +{ /* skip comments */ } + YY_BREAK +case 63: +YY_RULE_SETUP +#line 231 "libyara/lexer.l" +{ /* skip single-line comments */ } + YY_BREAK +case 64: +YY_RULE_SETUP +#line 234 "libyara/lexer.l" { yyextra->lex_buf_ptr = yyextra->lex_buf; yyextra->lex_buf_len = 0; BEGIN(include); } YY_BREAK -case 53: -/* rule 53 can match eol */ +case 65: +/* rule 65 can match eol */ YY_RULE_SETUP -#line 229 "lexer.l" +#line 241 "libyara/lexer.l" { yytext_to_buffer; } YY_BREAK -case 54: +case 66: YY_RULE_SETUP -#line 232 "lexer.l" +#line 244 "libyara/lexer.l" { if (compiler->include_callback != NULL) @@ -1788,7 +1859,7 @@ case YY_STATE_EOF(str): case YY_STATE_EOF(regexp): case YY_STATE_EOF(include): case YY_STATE_EOF(comment): -#line 364 "lexer.l" +#line 376 "libyara/lexer.l" { yypop_buffer_state(yyscanner); @@ -1799,9 +1870,9 @@ case YY_STATE_EOF(comment): return _END_OF_INCLUDED_FILE_; } YY_BREAK -case 55: +case 67: YY_RULE_SETUP -#line 375 "lexer.l" +#line 387 "libyara/lexer.l" { yylval->c_string = yr_strdup(yytext); @@ -1812,9 +1883,9 @@ YY_RULE_SETUP return _STRING_IDENTIFIER_WITH_WILDCARD_; } YY_BREAK -case 56: +case 68: YY_RULE_SETUP -#line 386 "lexer.l" +#line 398 "libyara/lexer.l" { yylval->c_string = yr_strdup(yytext); @@ -1825,9 +1896,9 @@ YY_RULE_SETUP return _STRING_IDENTIFIER_; } YY_BREAK -case 57: +case 69: YY_RULE_SETUP -#line 397 "lexer.l" +#line 409 "libyara/lexer.l" { yylval->c_string = yr_strdup(yytext); @@ -1844,9 +1915,9 @@ YY_RULE_SETUP return _STRING_COUNT_; } YY_BREAK -case 58: +case 70: YY_RULE_SETUP -#line 414 "lexer.l" +#line 426 "libyara/lexer.l" { yylval->c_string = yr_strdup(yytext); @@ -1863,9 +1934,9 @@ YY_RULE_SETUP return _STRING_OFFSET_; } YY_BREAK -case 59: +case 71: YY_RULE_SETUP -#line 431 "lexer.l" +#line 443 "libyara/lexer.l" { yylval->c_string = yr_strdup(yytext); @@ -1882,50 +1953,9 @@ YY_RULE_SETUP return _STRING_LENGTH_; } YY_BREAK -case 60: -YY_RULE_SETUP -#line 448 "lexer.l" -{ - - char* text = yytext; - - if (*text == 'u') - { - yylval->integer = 3; - text++; - } - else - { - yylval->integer = 0; - } - - if (strstr(text, "int8") == text) - { - yylval->integer += 0; - text += 4; - } - else if (strstr(text, "int16") == text) - { - yylval->integer += 1; - text += 5; - } - else if (strstr(text, "int32") == text) - { - yylval->integer += 2; - text += 5; - } - - if (strcmp(text, "be") == 0) - { - yylval->integer += 6; - } - - return _INTEGER_FUNCTION_; -} - YY_BREAK -case 61: +case 72: YY_RULE_SETUP -#line 487 "lexer.l" +#line 460 "libyara/lexer.l" { if (strlen(yytext) > 128) @@ -1939,9 +1969,9 @@ YY_RULE_SETUP return _IDENTIFIER_; } YY_BREAK -case 62: +case 73: YY_RULE_SETUP -#line 501 "lexer.l" +#line 474 "libyara/lexer.l" { char *endptr; @@ -1982,17 +2012,17 @@ YY_RULE_SETUP return _NUMBER_; } YY_BREAK -case 63: +case 74: YY_RULE_SETUP -#line 541 "lexer.l" +#line 514 "libyara/lexer.l" { yylval->double_ = atof(yytext); return _DOUBLE_; } YY_BREAK -case 64: +case 75: YY_RULE_SETUP -#line 546 "lexer.l" +#line 519 "libyara/lexer.l" { char *endptr; @@ -2009,9 +2039,9 @@ YY_RULE_SETUP return _NUMBER_; } YY_BREAK -case 65: +case 76: YY_RULE_SETUP -#line 562 "lexer.l" +#line 535 "libyara/lexer.l" { char *endptr; @@ -2028,9 +2058,9 @@ YY_RULE_SETUP return _NUMBER_; } YY_BREAK -case 66: +case 77: YY_RULE_SETUP -#line 579 "lexer.l" +#line 552 "libyara/lexer.l" { /* saw closing quote - all done */ alloc_sized_string(s, yyextra->lex_buf_len); @@ -2045,9 +2075,9 @@ YY_RULE_SETUP return _TEXT_STRING_; } YY_BREAK -case 67: +case 78: YY_RULE_SETUP -#line 594 "lexer.l" +#line 567 "libyara/lexer.l" { lex_check_space_ok("\t", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); @@ -2055,9 +2085,9 @@ YY_RULE_SETUP yyextra->lex_buf_len++; } YY_BREAK -case 68: +case 79: YY_RULE_SETUP -#line 602 "lexer.l" +#line 575 "libyara/lexer.l" { lex_check_space_ok("\r", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); @@ -2065,9 +2095,9 @@ YY_RULE_SETUP yyextra->lex_buf_len++; } YY_BREAK -case 69: +case 80: YY_RULE_SETUP -#line 610 "lexer.l" +#line 583 "libyara/lexer.l" { lex_check_space_ok("\n", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); @@ -2075,9 +2105,9 @@ YY_RULE_SETUP yyextra->lex_buf_len++; } YY_BREAK -case 70: +case 81: YY_RULE_SETUP -#line 618 "lexer.l" +#line 591 "libyara/lexer.l" { lex_check_space_ok("\"", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); @@ -2085,9 +2115,9 @@ YY_RULE_SETUP yyextra->lex_buf_len++; } YY_BREAK -case 71: +case 82: YY_RULE_SETUP -#line 626 "lexer.l" +#line 599 "libyara/lexer.l" { lex_check_space_ok("\\", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); @@ -2095,9 +2125,9 @@ YY_RULE_SETUP yyextra->lex_buf_len++; } YY_BREAK -case 72: +case 83: YY_RULE_SETUP -#line 634 "lexer.l" +#line 607 "libyara/lexer.l" { int result; @@ -2108,30 +2138,30 @@ YY_RULE_SETUP yyextra->lex_buf_len++; } YY_BREAK -case 73: +case 84: YY_RULE_SETUP -#line 645 "lexer.l" +#line 618 "libyara/lexer.l" { yytext_to_buffer; } YY_BREAK -case 74: -/* rule 74 can match eol */ +case 85: +/* rule 85 can match eol */ YY_RULE_SETUP -#line 648 "lexer.l" +#line 621 "libyara/lexer.l" { syntax_error("unterminated string"); } YY_BREAK -case 75: -/* rule 75 can match eol */ +case 86: +/* rule 86 can match eol */ YY_RULE_SETUP -#line 653 "lexer.l" +#line 626 "libyara/lexer.l" { syntax_error("illegal escape sequence"); } YY_BREAK -case 76: +case 87: YY_RULE_SETUP -#line 658 "lexer.l" +#line 631 "libyara/lexer.l" { if (yyextra->lex_buf_len > 0) @@ -2158,9 +2188,9 @@ YY_RULE_SETUP return _REGEXP_; } YY_BREAK -case 77: +case 88: YY_RULE_SETUP -#line 685 "lexer.l" +#line 658 "libyara/lexer.l" { lex_check_space_ok("/", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); @@ -2168,9 +2198,9 @@ YY_RULE_SETUP yyextra->lex_buf_len++ ; } YY_BREAK -case 78: +case 89: YY_RULE_SETUP -#line 693 "lexer.l" +#line 666 "libyara/lexer.l" { lex_check_space_ok("\\.", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); @@ -2183,22 +2213,22 @@ YY_RULE_SETUP yyextra->lex_buf_len += 2; } YY_BREAK -case 79: +case 90: YY_RULE_SETUP -#line 706 "lexer.l" +#line 679 "libyara/lexer.l" { yytext_to_buffer; } YY_BREAK -case 80: -/* rule 80 can match eol */ +case 91: +/* rule 91 can match eol */ YY_RULE_SETUP -#line 709 "lexer.l" +#line 682 "libyara/lexer.l" { syntax_error("unterminated regular expression"); } YY_BREAK -case 81: +case 92: YY_RULE_SETUP -#line 714 "lexer.l" +#line 687 "libyara/lexer.l" { yylval->sized_string = NULL; @@ -2207,9 +2237,9 @@ YY_RULE_SETUP BEGIN(str); } YY_BREAK -case 82: +case 93: YY_RULE_SETUP -#line 723 "lexer.l" +#line 696 "libyara/lexer.l" { yylval->sized_string = NULL; @@ -2218,10 +2248,10 @@ YY_RULE_SETUP BEGIN(regexp); } YY_BREAK -case 83: -/* rule 83 can match eol */ +case 94: +/* rule 94 can match eol */ YY_RULE_SETUP -#line 732 "lexer.l" +#line 705 "libyara/lexer.l" { // Match hex-digits with whitespace or comments. The latter are stripped // out by hex_lexer.l @@ -2238,15 +2268,15 @@ YY_RULE_SETUP return _HEX_STRING_; } YY_BREAK -case 84: -/* rule 84 can match eol */ +case 95: +/* rule 95 can match eol */ YY_RULE_SETUP -#line 749 "lexer.l" +#line 722 "libyara/lexer.l" /* skip whitespace */ YY_BREAK -case 85: +case 96: YY_RULE_SETUP -#line 751 "lexer.l" +#line 724 "libyara/lexer.l" { if (yytext[0] >= 32 && yytext[0] < 127) @@ -2259,12 +2289,12 @@ YY_RULE_SETUP } } YY_BREAK -case 86: +case 97: YY_RULE_SETUP -#line 763 "lexer.l" +#line 736 "libyara/lexer.l" ECHO; YY_BREAK -#line 2267 "lexer.c" +#line 2297 "libyara/lexer.c" case YY_END_OF_BUFFER: { @@ -2451,7 +2481,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { - int num_to_read = + yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -2465,7 +2495,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; + yy_size_t new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -2523,7 +2553,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) @@ -2562,7 +2592,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 295 ) + if ( yy_current_state >= 313 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -2591,11 +2621,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 295 ) + if ( yy_current_state >= 313 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 294); + yy_is_jam = (yy_current_state == 312); (void)yyg; return yy_is_jam ? 0 : yy_current_state; @@ -2630,7 +2660,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) else { /* need more input */ - int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; ++yyg->yy_c_buf_p; switch ( yy_get_next_buffer( yyscanner ) ) @@ -3015,12 +3045,12 @@ YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - int i; + yy_size_t i; /* Get memory for full buffer, including space for trailing EOB's. */ n = (yy_size_t) (_yybytes_len + 2); @@ -3064,7 +3094,7 @@ static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) do \ { \ /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ + yy_size_t yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = yyg->yy_hold_char; \ yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ @@ -3132,7 +3162,7 @@ FILE *yyget_out (yyscan_t yyscanner) /** Get the length of the current token. * @param yyscanner The scanner object. */ -int yyget_leng (yyscan_t yyscanner) +yy_size_t yyget_leng (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; return yyleng; @@ -3413,7 +3443,7 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 763 "lexer.l" +#line 736 "libyara/lexer.l" diff --git a/libyara/lexer.l b/libyara/lexer.l index 53e6d58851..0ba155fe58 100644 --- a/libyara/lexer.l +++ b/libyara/lexer.l @@ -162,53 +162,65 @@ octdigit [0-7] %% -".." { return _DOT_DOT_; } -"<" { return _LT_; } -">" { return _GT_; } -"<=" { return _LE_; } -">=" { return _GE_; } -"==" { return _EQ_; } -"!=" { return _NEQ_; } -"<<" { return _SHIFT_LEFT_; } -">>" { return _SHIFT_RIGHT_; } -"private" { return _PRIVATE_; } -"global" { return _GLOBAL_; } -"rule" { return _RULE_; } -"meta" { return _META_; } -"strings" { return _STRINGS_; } -"ascii" { return _ASCII_; } -"wide" { return _WIDE_; } -"xor" { return _XOR_; } -"base64" { return _BASE64_; } -"base64wide" { return _BASE64_WIDE_; } -"fullword" { return _FULLWORD_; } -"nocase" { return _NOCASE_; } -"condition" { return _CONDITION_; } -"true" { return _TRUE_; } -"false" { return _FALSE_; } -"not" { return _NOT_; } -"and" { return _AND_; } -"or" { return _OR_; } -"at" { return _AT_; } -"in" { return _IN_; } -"of" { return _OF_; } -"them" { return _THEM_; } -"for" { return _FOR_; } -"all" { return _ALL_; } -"any" { return _ANY_; } -"none" { return _NONE_; } -"entrypoint" { return _ENTRYPOINT_; } -"filesize" { return _FILESIZE_; } -"matches" { return _MATCHES_; } -"contains" { return _CONTAINS_; } -"startswith" { return _STARTSWITH_; } -"endswith" { return _ENDSWITH_; } -"icontains" { return _ICONTAINS_; } -"istartswith" { return _ISTARTSWITH_; } -"iendswith" { return _IENDSWITH_; } -"iequals" { return _IEQUALS_; } -"import" { return _IMPORT_; } -"defined" { return _DEFINED_; } +".." { return _DOT_DOT_; } +"<" { return _LT_; } +">" { return _GT_; } +"<=" { return _LE_; } +">=" { return _GE_; } +"==" { return _EQ_; } +"!=" { return _NEQ_; } +"<<" { return _SHIFT_LEFT_; } +">>" { return _SHIFT_RIGHT_; } +"private" { return _PRIVATE_; } +"global" { return _GLOBAL_; } +"rule" { return _RULE_; } +"meta" { return _META_; } +"strings" { return _STRINGS_; } +"ascii" { return _ASCII_; } +"wide" { return _WIDE_; } +"xor" { return _XOR_; } +"base64" { return _BASE64_; } +"base64wide" { return _BASE64_WIDE_; } +"fullword" { return _FULLWORD_; } +"nocase" { return _NOCASE_; } +"condition" { return _CONDITION_; } +"true" { return _TRUE_; } +"false" { return _FALSE_; } +"not" { return _NOT_; } +"and" { return _AND_; } +"or" { return _OR_; } +"at" { return _AT_; } +"in" { return _IN_; } +"of" { return _OF_; } +"them" { return _THEM_; } +"for" { return _FOR_; } +"all" { return _ALL_; } +"any" { return _ANY_; } +"none" { return _NONE_; } +"entrypoint" { return _ENTRYPOINT_; } +"filesize" { return _FILESIZE_; } +"matches" { return _MATCHES_; } +"contains" { return _CONTAINS_; } +"startswith" { return _STARTSWITH_; } +"endswith" { return _ENDSWITH_; } +"icontains" { return _ICONTAINS_; } +"istartswith" { return _ISTARTSWITH_; } +"iendswith" { return _IENDSWITH_; } +"iequals" { return _IEQUALS_; } +"import" { return _IMPORT_; } +"defined" { return _DEFINED_; } +"int8" { return _INT8_FUNCTION_; } +"uint8" { return _UINT8_FUNCTION_; } +"int16" { return _INT16_FUNCTION_; } +"uint16" { return _UINT16_FUNCTION_; } +"int32" { return _INT32_FUNCTION_; } +"uint32" { return _UINT32_FUNCTION_; } +"int8be" { return _INT8BE_FUNCTION_; } +"uint8be" { return _UINT8BE_FUNCTION_; } +"int16be" { return _INT16BE_FUNCTION_; } +"uint16be" { return _UINT16BE_FUNCTION_; } +"int32be" { return _INT32BE_FUNCTION_; } +"uint32be" { return _UINT32BE_FUNCTION_; } "/*" { BEGIN(comment); } @@ -445,45 +457,6 @@ $({letter}|{digit}|_)* { } -u?int(8|16|32)(be)? { - - char* text = yytext; - - if (*text == 'u') - { - yylval->integer = 3; - text++; - } - else - { - yylval->integer = 0; - } - - if (strstr(text, "int8") == text) - { - yylval->integer += 0; - text += 4; - } - else if (strstr(text, "int16") == text) - { - yylval->integer += 1; - text += 5; - } - else if (strstr(text, "int32") == text) - { - yylval->integer += 2; - text += 5; - } - - if (strcmp(text, "be") == 0) - { - yylval->integer += 6; - } - - return _INTEGER_FUNCTION_; -} - - ({letter}|_)({letter}|{digit}|_)* { if (strlen(yytext) > 128) diff --git a/libyara/parser.c b/libyara/parser.c index f536e42eac..334d08f199 100644 --- a/libyara/parser.c +++ b/libyara/parser.c @@ -1120,7 +1120,7 @@ int yr_parser_reduce_string_identifier( YR_STRING* string; YR_COMPILER* compiler = yyget_extra(yyscanner); - if (strcmp(identifier, "$") == 0) // is an anonymous string ? + if (strcmp(identifier, "$") == 0) // is an anonymous string ? { if (compiler->loop_for_of_var_index >= 0) // inside a loop ? { @@ -1380,6 +1380,15 @@ static int _yr_parser_operator_to_opcode(const char* op, int expression_type) return OP_ERROR; } +int yr_parser_integer_width_check( + YR_EXPRESSION int_func_expr, + YR_EXPRESSION int_expr) +{ + return (int_expr.value.integer & ~(1 << int_func_expr.width)) + ? ERROR_INVALID_ARGUMENT + : ERROR_SUCCESS; +} + int yr_parser_reduce_operation( yyscan_t yyscanner, const char* op, diff --git a/tests/test-rules.c b/tests/test-rules.c index b8dbca20c1..0e8f71e237 100644 --- a/tests/test-rules.c +++ b/tests/test-rules.c @@ -512,6 +512,15 @@ static void test_syntax() "rule test { strings: $a = \"a\" condition: for 3.14159 of them: ($) }", ERROR_INVALID_VALUE); + assert_error( + "rule test { \ + strings: \ + $a = \"AXSERS\" \ + condition: \ + 1 of them at \"x\"\ + }", + ERROR_INVALID_VALUE); + YR_DEBUG_FPRINTF(1, stderr, "} // %s()\n", __FUNCTION__); } @@ -634,14 +643,34 @@ static void test_warnings() 2 of ($a*) at 0\ }"); - assert_error( - "rule test { \ - strings: \ - $a = \"AXSERS\" \ - condition: \ - 1 of them at \"x\"\ - }", - ERROR_INVALID_VALUE); + // Be sure to check both orders of expressions. + assert_warnings("rule test { \ + condition: \ + int8(0) == 0x1100 and \ + int8be(0) == 0x1100 and \ + uint8(0) == 0x1100 and \ + uint8be(0) == 0x1100 and \ + int16(0) == 0x110000 and \ + int16be(0) == 0x110000 and \ + uint16(0) == 0x110000 and \ + uint16be(0) == 0x110000 and \ + int32(0) == 0x1100000000 and \ + int32be(0) == 0x1100000000 and \ + uint32(0) == 0x1100000000 and \ + uint32be(0) == 0x1100000000 and \ + 0x1100 == int8(0) and \ + 0x1100 == int8be(0) and \ + 0x1100 == uint8(0) and \ + 0x1100 == uint8be(0) and \ + 0x110000 == int16(0) and \ + 0x110000 == int16be(0) and \ + 0x110000 == uint16(0) and \ + 0x110000 == uint16be(0) and \ + 0x1100000000 == int32(0) and \ + 0x1100000000 == int32be(0) and \ + 0x1100000000 == uint32(0) and \ + 0x1100000000 == uint32be(0) \ + }", 24); YR_DEBUG_FPRINTF(1, stderr, "} // %s()\n", __FUNCTION__); } @@ -3329,6 +3358,28 @@ void test_integer_functions() "rule test { condition: uint32be(1024) == 0xAABBCCDD}", TEXT_1024_BYTES "\xaa\xbb\xcc\xdd"); + // https://github.com/VirusTotal/yara/issues/1918 + // Make sure we only have warnings when we have a defined integer to compare + // against. + assert_no_warnings("rule test { condition: uint8(0) == filesize }"); + + // Make sure that intXX operations are changed to integer expressions. + assert_no_warnings("rule test { condition: uint8(uint8(0)) }"); + + // Make sure any operation which can change the width of the expression resets + // the expression width to zero. Failure to do this will cause warnings that + // do not apply. + assert_no_warnings("rule a { condition: uint8(0) + 1 == 0x1100 }"); + assert_no_warnings("rule b { condition: uint8(0) - 1 == 0x1100 }"); + assert_no_warnings("rule c { condition: uint8(0) * 1 == 0x1100 }"); + assert_no_warnings("rule d { condition: uint8(0) \\ 1 == 0x1100 }"); + assert_no_warnings("rule e { condition: uint8(0) % 1 == 0x1100 }"); + assert_no_warnings("rule f { condition: uint8(0) ^ 1 == 0x1100 }"); + assert_no_warnings("rule g { condition: uint8(0) & 1 == 0x1100 }"); + assert_no_warnings("rule h { condition: uint8(0) | 1 == 0x1100 }"); + assert_no_warnings("rule i { condition: uint8(0) << 8 == 0x1100 }"); + assert_no_warnings("rule j { condition: uint8(0) >> 8 == 0x1100 }"); + YR_DEBUG_FPRINTF(1, stderr, "} // %s()\n", __FUNCTION__); }