diff --git a/libyara/compiler.c b/libyara/compiler.c index 598817e1fe..15b4afdbf0 100644 --- a/libyara/compiler.c +++ b/libyara/compiler.c @@ -270,6 +270,9 @@ YR_API int yr_compiler_create( if (result == ERROR_SUCCESS) result = yr_hash_table_create(1000, &new_compiler->objects_table); + if (result == ERROR_SUCCESS) + result = yr_hash_table_create(10, &new_compiler->current_internal_variables_table); + if (result == ERROR_SUCCESS) result = yr_hash_table_create(10000, &new_compiler->strings_table); @@ -322,6 +325,10 @@ YR_API void yr_compiler_destroy( compiler->objects_table, (YR_HASH_TABLE_FREE_VALUE_FUNC) yr_object_destroy); + yr_hash_table_destroy( + compiler->current_internal_variables_table, + (YR_HASH_TABLE_FREE_VALUE_FUNC) yr_object_destroy); + if (compiler->atoms_config.free_quality_table) yr_free(compiler->atoms_config.quality_table); @@ -702,6 +709,7 @@ static int _yr_compiler_compile_rules( { YR_RULE null_rule; YR_EXTERNAL_VARIABLE null_external; + YR_INTERNAL_VARIABLE null_internal; uint8_t halt = OP_HALT; @@ -735,6 +743,17 @@ static int _yr_compiler_compile_rules( sizeof(YR_EXTERNAL_VARIABLE), NULL)); + // Write a null internal indicating the end. + memset(&null_internal, 0xFA, sizeof(YR_INTERNAL_VARIABLE)); + null_internal.type = OBJECT_TYPE_UNDEFINED; + + FAIL_ON_ERROR(yr_arena_write_data( + compiler->arena, + YR_INTERNAL_VARIABLES_TABLE, + &null_internal, + sizeof(YR_INTERNAL_VARIABLE), + NULL)); + // Write Aho-Corasick automaton to arena. FAIL_ON_ERROR(yr_ac_compile( compiler->automaton, diff --git a/libyara/exec.c b/libyara/exec.c index 5ba8fde55c..5cad04794a 100644 --- a/libyara/exec.c +++ b/libyara/exec.c @@ -899,14 +899,59 @@ int yr_execute_code( #endif r1.o = (YR_OBJECT*) yr_hash_table_lookup( - context->objects_table, + context->internal_variable_tables[current_rule_idx], identifier, NULL); + if(r1.o == NULL) + r1.o = (YR_OBJECT*) yr_hash_table_lookup( + context->objects_table, + identifier, + NULL); + assert(r1.o != NULL); push(r1); break; + case OP_OBJ_STORE: + identifier = *(char**)(ip); + ip += sizeof(uint64_t); + + #if YR_PARANOID_EXEC + ensure_within_rules_arena(identifier); + #endif + + pop(r1); + + YR_OBJECT* obj = (YR_OBJECT*) yr_hash_table_lookup( + context->internal_variable_tables[current_rule_idx], + identifier, + NULL); + + assert(obj != NULL); + + switch(obj->type) { + case OBJECT_TYPE_INTEGER: + yr_object_set_integer(r1.i, obj, NULL); + break; + case OBJECT_TYPE_FLOAT: + yr_object_set_float(r1.d, obj, NULL); + break; + case OBJECT_TYPE_STRING: + yr_object_set_string( + r1.ss->c_string, + strlen(r1.ss->c_string), + obj, + NULL); + break; + case OBJECT_TYPE_STRUCTURE: + yr_object_set_object(r1.o, obj, NULL); + break; + default: + assert(false); + } + break; + case OP_OBJ_FIELD: identifier = *(char**)(ip); ip += sizeof(uint64_t); @@ -957,7 +1002,12 @@ int yr_execute_code( else r1.ss = r1.o->value.ss; break; - + case OBJECT_TYPE_STRUCTURE: + case OBJECT_TYPE_DICTIONARY: + case OBJECT_TYPE_ARRAY: + case OBJECT_TYPE_FUNCTION: + // do nothing + break; default: assert(false); } diff --git a/libyara/grammar.c b/libyara/grammar.c index 52dc22daff..cb6f1183cd 100644 --- a/libyara/grammar.c +++ b/libyara/grammar.c @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.5. */ +/* A Bison parser, made by GNU Bison 3.6.4. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,6 +34,10 @@ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. @@ -44,7 +49,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.5" +#define YYBISON_VERSION "3.6.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -66,9 +71,8 @@ #define yydebug yara_yydebug #define yynerrs yara_yynerrs - -/* Copy the first part of user declarations. */ -#line 30 "grammar.y" /* yacc.c:339 */ +/* First part of user prologue. */ +#line 30 "grammar.y" @@ -178,26 +182,31 @@ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" -#line 182 "grammar.c" /* yacc.c:339 */ +#line 186 "grammar.c" +# ifndef YY_CAST +# ifdef __cplusplus +# define YY_CAST(Type, Val) static_cast (Val) +# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast (Val) +# else +# define YY_CAST(Type, Val) ((Type) (Val)) +# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) +# endif +# endif # ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif # else -# define YY_NULLPTR 0 +# define YY_NULLPTR ((void*)0) # endif # endif -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* In a future release of Bison, this section will be replaced - by #include "y.tab.h". */ +/* Use api.header.include to #include this header + instead of duplicating it here. */ #ifndef YY_YARA_YY_GRAMMAR_H_INCLUDED # define YY_YARA_YY_GRAMMAR_H_INCLUDED /* Debug traces. */ @@ -208,69 +217,76 @@ extern int yara_yydebug; #endif -/* Token type. */ +/* Token kinds. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { - _END_OF_FILE_ = 0, - _END_OF_INCLUDED_FILE_ = 258, - _DOT_DOT_ = 259, - _RULE_ = 260, - _PRIVATE_ = 261, - _GLOBAL_ = 262, - _META_ = 263, - _STRINGS_ = 264, - _CONDITION_ = 265, - _IDENTIFIER_ = 266, - _STRING_IDENTIFIER_ = 267, - _STRING_COUNT_ = 268, - _STRING_OFFSET_ = 269, - _STRING_LENGTH_ = 270, - _STRING_IDENTIFIER_WITH_WILDCARD_ = 271, - _NUMBER_ = 272, - _DOUBLE_ = 273, - _INTEGER_FUNCTION_ = 274, - _TEXT_STRING_ = 275, - _HEX_STRING_ = 276, - _REGEXP_ = 277, - _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, - _IN_ = 290, - _OF_ = 291, - _FOR_ = 292, - _THEM_ = 293, - _MATCHES_ = 294, - _CONTAINS_ = 295, - _IMPORT_ = 296, - _TRUE_ = 297, - _FALSE_ = 298, - _OR_ = 299, - _AND_ = 300, - _NOT_ = 301, - _EQ_ = 302, - _NEQ_ = 303, - _LT_ = 304, - _LE_ = 305, - _GT_ = 306, - _GE_ = 307, - _SHIFT_LEFT_ = 308, - _SHIFT_RIGHT_ = 309, - UNARY_MINUS = 310 + YYEMPTY = -2, + _END_OF_FILE_ = 0, /* "end of file" */ + YYerror = 256, /* error */ + YYUNDEF = 257, /* "invalid token" */ + _END_OF_INCLUDED_FILE_ = 258, /* "end of included file" */ + _DOT_DOT_ = 259, /* ".." */ + _RULE_ = 260, /* "" */ + _PRIVATE_ = 261, /* "" */ + _GLOBAL_ = 262, /* "" */ + _META_ = 263, /* "" */ + _STRINGS_ = 264, /* "" */ + _VARIABLES_ = 265, /* "" */ + _CONDITION_ = 266, /* "" */ + _IDENTIFIER_ = 267, /* "identifier" */ + _STRING_IDENTIFIER_ = 268, /* "string identifier" */ + _STRING_COUNT_ = 269, /* "string count" */ + _STRING_OFFSET_ = 270, /* "string offset" */ + _STRING_LENGTH_ = 271, /* "string length" */ + _STRING_IDENTIFIER_WITH_WILDCARD_ = 272, /* "string identifier with wildcard" */ + _NUMBER_ = 273, /* "integer number" */ + _DOUBLE_ = 274, /* "floating point number" */ + _INTEGER_FUNCTION_ = 275, /* "integer function" */ + _TEXT_STRING_ = 276, /* "text string" */ + _HEX_STRING_ = 277, /* "hex string" */ + _REGEXP_ = 278, /* "regular expression" */ + _ASCII_ = 279, /* "" */ + _WIDE_ = 280, /* "" */ + _XOR_ = 281, /* "" */ + _BASE64_ = 282, /* "" */ + _BASE64_WIDE_ = 283, /* "" */ + _NOCASE_ = 284, /* "" */ + _FULLWORD_ = 285, /* "" */ + _AT_ = 286, /* "" */ + _FILESIZE_ = 287, /* "" */ + _ENTRYPOINT_ = 288, /* "" */ + _ALL_ = 289, /* "" */ + _ANY_ = 290, /* "" */ + _IN_ = 291, /* "" */ + _OF_ = 292, /* "" */ + _FOR_ = 293, /* "" */ + _THEM_ = 294, /* "" */ + _MATCHES_ = 295, /* "" */ + _CONTAINS_ = 296, /* "" */ + _IMPORT_ = 297, /* "" */ + _TRUE_ = 298, /* "" */ + _FALSE_ = 299, /* "" */ + _AND_ = 301, /* "" */ + _NOT_ = 302, /* "" */ + _EQ_ = 303, /* "==" */ + _NEQ_ = 304, /* "!=" */ + _LT_ = 305, /* "<" */ + _LE_ = 306, /* "<=" */ + _GT_ = 307, /* ">" */ + _GE_ = 308, /* ">=" */ + _SHIFT_LEFT_ = 309, /* "<<" */ + _SHIFT_RIGHT_ = 310, /* ">>" */ + UNARY_MINUS = 311 /* UNARY_MINUS */ }; + typedef enum yytokentype yytoken_kind_t; #endif -/* Tokens. */ +/* Token kinds. */ #define _END_OF_FILE_ 0 +#define YYerror 256 +#define YYUNDEF 257 #define _END_OF_INCLUDED_FILE_ 258 #define _DOT_DOT_ 259 #define _RULE_ 260 @@ -278,59 +294,59 @@ extern int yara_yydebug; #define _GLOBAL_ 262 #define _META_ 263 #define _STRINGS_ 264 -#define _CONDITION_ 265 -#define _IDENTIFIER_ 266 -#define _STRING_IDENTIFIER_ 267 -#define _STRING_COUNT_ 268 -#define _STRING_OFFSET_ 269 -#define _STRING_LENGTH_ 270 -#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 _IN_ 290 -#define _OF_ 291 -#define _FOR_ 292 -#define _THEM_ 293 -#define _MATCHES_ 294 -#define _CONTAINS_ 295 -#define _IMPORT_ 296 -#define _TRUE_ 297 -#define _FALSE_ 298 -#define _OR_ 299 -#define _AND_ 300 -#define _NOT_ 301 -#define _EQ_ 302 -#define _NEQ_ 303 -#define _LT_ 304 -#define _LE_ 305 -#define _GT_ 306 -#define _GE_ 307 -#define _SHIFT_LEFT_ 308 -#define _SHIFT_RIGHT_ 309 -#define UNARY_MINUS 310 +#define _VARIABLES_ 265 +#define _CONDITION_ 266 +#define _IDENTIFIER_ 267 +#define _STRING_IDENTIFIER_ 268 +#define _STRING_COUNT_ 269 +#define _STRING_OFFSET_ 270 +#define _STRING_LENGTH_ 271 +#define _STRING_IDENTIFIER_WITH_WILDCARD_ 272 +#define _NUMBER_ 273 +#define _DOUBLE_ 274 +#define _INTEGER_FUNCTION_ 275 +#define _TEXT_STRING_ 276 +#define _HEX_STRING_ 277 +#define _REGEXP_ 278 +#define _ASCII_ 279 +#define _WIDE_ 280 +#define _XOR_ 281 +#define _BASE64_ 282 +#define _BASE64_WIDE_ 283 +#define _NOCASE_ 284 +#define _FULLWORD_ 285 +#define _AT_ 286 +#define _FILESIZE_ 287 +#define _ENTRYPOINT_ 288 +#define _ALL_ 289 +#define _ANY_ 290 +#define _IN_ 291 +#define _OF_ 292 +#define _FOR_ 293 +#define _THEM_ 294 +#define _MATCHES_ 295 +#define _CONTAINS_ 296 +#define _IMPORT_ 297 +#define _TRUE_ 298 +#define _FALSE_ 299 +#define _OR_ 300 +#define _AND_ 301 +#define _NOT_ 302 +#define _EQ_ 303 +#define _NEQ_ 304 +#define _LT_ 305 +#define _LE_ 306 +#define _GT_ 307 +#define _GE_ 308 +#define _SHIFT_LEFT_ 309 +#define _SHIFT_RIGHT_ 310 +#define UNARY_MINUS 311 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - union YYSTYPE { -#line 297 "grammar.y" /* yacc.c:355 */ +#line 305 "grammar.y" YR_EXPRESSION expression; SIZED_STRING* sized_string; @@ -344,9 +360,9 @@ union YYSTYPE YR_ARENA_REF meta; YR_ARENA_REF string; -#line 348 "grammar.c" /* yacc.c:355 */ -}; +#line 364 "grammar.c" +}; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 @@ -357,37 +373,221 @@ typedef union YYSTYPE YYSTYPE; int yara_yyparse (void *yyscanner, YR_COMPILER* compiler); #endif /* !YY_YARA_YY_GRAMMAR_H_INCLUDED */ +/* Symbol kind. */ +enum yysymbol_kind_t +{ + YYSYMBOL_YYEMPTY = -2, + YYSYMBOL_YYEOF = 0, /* "end of file" */ + YYSYMBOL_YYerror = 1, /* error */ + YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ + YYSYMBOL__END_OF_INCLUDED_FILE_ = 3, /* "end of included file" */ + YYSYMBOL__DOT_DOT_ = 4, /* ".." */ + YYSYMBOL__RULE_ = 5, /* "" */ + YYSYMBOL__PRIVATE_ = 6, /* "" */ + YYSYMBOL__GLOBAL_ = 7, /* "" */ + YYSYMBOL__META_ = 8, /* "" */ + YYSYMBOL__STRINGS_ = 9, /* "" */ + YYSYMBOL__VARIABLES_ = 10, /* "" */ + YYSYMBOL__CONDITION_ = 11, /* "" */ + YYSYMBOL__IDENTIFIER_ = 12, /* "identifier" */ + YYSYMBOL__STRING_IDENTIFIER_ = 13, /* "string identifier" */ + YYSYMBOL__STRING_COUNT_ = 14, /* "string count" */ + YYSYMBOL__STRING_OFFSET_ = 15, /* "string offset" */ + YYSYMBOL__STRING_LENGTH_ = 16, /* "string length" */ + YYSYMBOL__STRING_IDENTIFIER_WITH_WILDCARD_ = 17, /* "string identifier with wildcard" */ + YYSYMBOL__NUMBER_ = 18, /* "integer number" */ + YYSYMBOL__DOUBLE_ = 19, /* "floating point number" */ + YYSYMBOL__INTEGER_FUNCTION_ = 20, /* "integer function" */ + YYSYMBOL__TEXT_STRING_ = 21, /* "text string" */ + YYSYMBOL__HEX_STRING_ = 22, /* "hex string" */ + YYSYMBOL__REGEXP_ = 23, /* "regular expression" */ + YYSYMBOL__ASCII_ = 24, /* "" */ + YYSYMBOL__WIDE_ = 25, /* "" */ + YYSYMBOL__XOR_ = 26, /* "" */ + YYSYMBOL__BASE64_ = 27, /* "" */ + YYSYMBOL__BASE64_WIDE_ = 28, /* "" */ + YYSYMBOL__NOCASE_ = 29, /* "" */ + YYSYMBOL__FULLWORD_ = 30, /* "" */ + YYSYMBOL__AT_ = 31, /* "" */ + YYSYMBOL__FILESIZE_ = 32, /* "" */ + YYSYMBOL__ENTRYPOINT_ = 33, /* "" */ + YYSYMBOL__ALL_ = 34, /* "" */ + YYSYMBOL__ANY_ = 35, /* "" */ + YYSYMBOL__IN_ = 36, /* "" */ + YYSYMBOL__OF_ = 37, /* "" */ + YYSYMBOL__FOR_ = 38, /* "" */ + YYSYMBOL__THEM_ = 39, /* "" */ + YYSYMBOL__MATCHES_ = 40, /* "" */ + YYSYMBOL__CONTAINS_ = 41, /* "" */ + YYSYMBOL__IMPORT_ = 42, /* "" */ + YYSYMBOL__TRUE_ = 43, /* "" */ + YYSYMBOL__FALSE_ = 44, /* "" */ + YYSYMBOL__AND_ = 46, /* "" */ + YYSYMBOL__NOT_ = 47, /* "" */ + YYSYMBOL__EQ_ = 48, /* "==" */ + YYSYMBOL__NEQ_ = 49, /* "!=" */ + YYSYMBOL__LT_ = 50, /* "<" */ + YYSYMBOL__LE_ = 51, /* "<=" */ + YYSYMBOL__GT_ = 52, /* ">" */ + YYSYMBOL__GE_ = 53, /* ">=" */ + YYSYMBOL__SHIFT_LEFT_ = 54, /* "<<" */ + YYSYMBOL__SHIFT_RIGHT_ = 55, /* ">>" */ + YYSYMBOL_56_ = 56, /* '|' */ + YYSYMBOL_57_ = 57, /* '^' */ + YYSYMBOL_58_ = 58, /* '&' */ + YYSYMBOL_59_ = 59, /* '+' */ + YYSYMBOL_60_ = 60, /* '-' */ + YYSYMBOL_61_ = 61, /* '*' */ + YYSYMBOL_62_ = 62, /* '\\' */ + YYSYMBOL_63_ = 63, /* '%' */ + YYSYMBOL_64_ = 64, /* '~' */ + YYSYMBOL_UNARY_MINUS = 65, /* UNARY_MINUS */ + YYSYMBOL_66_include_ = 66, /* "include" */ + YYSYMBOL_67_ = 67, /* '{' */ + YYSYMBOL_68_ = 68, /* '}' */ + YYSYMBOL_69_ = 69, /* ':' */ + YYSYMBOL_70_ = 70, /* '=' */ + YYSYMBOL_71_ = 71, /* '(' */ + YYSYMBOL_72_ = 72, /* ')' */ + YYSYMBOL_73_ = 73, /* '.' */ + YYSYMBOL_74_ = 74, /* '[' */ + YYSYMBOL_75_ = 75, /* ']' */ + YYSYMBOL_76_ = 76, /* ',' */ + YYSYMBOL_YYACCEPT = 77, /* $accept */ + YYSYMBOL_rules = 78, /* rules */ + YYSYMBOL_import = 79, /* import */ + YYSYMBOL_rule = 80, /* rule */ + YYSYMBOL_81_1 = 81, /* @1 */ + YYSYMBOL_82_2 = 82, /* $@2 */ + YYSYMBOL_meta = 83, /* meta */ + YYSYMBOL_strings = 84, /* strings */ + YYSYMBOL_variables = 85, /* variables */ + YYSYMBOL_condition = 86, /* condition */ + YYSYMBOL_rule_modifiers = 87, /* rule_modifiers */ + YYSYMBOL_rule_modifier = 88, /* rule_modifier */ + YYSYMBOL_tags = 89, /* tags */ + YYSYMBOL_tag_list = 90, /* tag_list */ + YYSYMBOL_meta_declarations = 91, /* meta_declarations */ + YYSYMBOL_meta_declaration = 92, /* meta_declaration */ + YYSYMBOL_variable_declarations = 93, /* variable_declarations */ + YYSYMBOL_variable_declaration = 94, /* variable_declaration */ + YYSYMBOL_95_3 = 95, /* $@3 */ + YYSYMBOL_string_declarations = 96, /* string_declarations */ + YYSYMBOL_string_declaration = 97, /* string_declaration */ + YYSYMBOL_98_4 = 98, /* $@4 */ + YYSYMBOL_99_5 = 99, /* $@5 */ + YYSYMBOL_100_6 = 100, /* $@6 */ + YYSYMBOL_string_modifiers = 101, /* string_modifiers */ + YYSYMBOL_string_modifier = 102, /* string_modifier */ + YYSYMBOL_regexp_modifiers = 103, /* regexp_modifiers */ + YYSYMBOL_regexp_modifier = 104, /* regexp_modifier */ + YYSYMBOL_hex_modifiers = 105, /* hex_modifiers */ + YYSYMBOL_hex_modifier = 106, /* hex_modifier */ + YYSYMBOL_identifier = 107, /* identifier */ + YYSYMBOL_arguments = 108, /* arguments */ + YYSYMBOL_arguments_list = 109, /* arguments_list */ + YYSYMBOL_regexp = 110, /* regexp */ + YYSYMBOL_boolean_expression = 111, /* boolean_expression */ + YYSYMBOL_complex_expression = 112, /* complex_expression */ + YYSYMBOL_113_7 = 113, /* $@7 */ + YYSYMBOL_114_8 = 114, /* $@8 */ + YYSYMBOL_115_9 = 115, /* $@9 */ + YYSYMBOL_116_10 = 116, /* $@10 */ + YYSYMBOL_117_11 = 117, /* $@11 */ + YYSYMBOL_for_variables = 118, /* for_variables */ + YYSYMBOL_iterator = 119, /* iterator */ + YYSYMBOL_integer_set = 120, /* integer_set */ + YYSYMBOL_range = 121, /* range */ + YYSYMBOL_integer_enumeration = 122, /* integer_enumeration */ + YYSYMBOL_string_set = 123, /* string_set */ + YYSYMBOL_124_12 = 124, /* $@12 */ + YYSYMBOL_string_enumeration = 125, /* string_enumeration */ + YYSYMBOL_string_enumeration_item = 126, /* string_enumeration_item */ + YYSYMBOL_for_expression = 127, /* for_expression */ + YYSYMBOL_primary_expression = 128, /* primary_expression */ + YYSYMBOL_nonprimary_expression = 129, /* nonprimary_expression */ + YYSYMBOL_expression = 130, /* expression */ + YYSYMBOL_object = 131 /* object */ +}; +typedef enum yysymbol_kind_t yysymbol_kind_t; + -/* Copy the second part of user declarations. */ -#line 364 "grammar.c" /* yacc.c:358 */ #ifdef short # undef short #endif -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; +/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure + and (if available) are included + so that the code can choose integer types of a good width. */ + +#ifndef __PTRDIFF_MAX__ +# include /* INFRINGES ON USER NAME SPACE */ +# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_STDINT_H +# endif #endif -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; +/* Narrow types that promote to a signed type and that can represent a + signed or unsigned integer of at least N bits. In tables they can + save space and decrease cache pressure. Promoting to a signed type + helps avoid bugs in integer arithmetic. */ + +#ifdef __INT_LEAST8_MAX__ +typedef __INT_LEAST8_TYPE__ yytype_int8; +#elif defined YY_STDINT_H +typedef int_least8_t yytype_int8; #else typedef signed char yytype_int8; #endif -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; +#ifdef __INT_LEAST16_MAX__ +typedef __INT_LEAST16_TYPE__ yytype_int16; +#elif defined YY_STDINT_H +typedef int_least16_t yytype_int16; +#else +typedef short yytype_int16; +#endif + +#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST8_TYPE__ yytype_uint8; +#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST8_MAX <= INT_MAX) +typedef uint_least8_t yytype_uint8; +#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX +typedef unsigned char yytype_uint8; #else -typedef unsigned short int yytype_uint16; +typedef short yytype_uint8; #endif -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; +#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ +typedef __UINT_LEAST16_TYPE__ yytype_uint16; +#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ + && UINT_LEAST16_MAX <= INT_MAX) +typedef uint_least16_t yytype_uint16; +#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX +typedef unsigned short yytype_uint16; #else -typedef short int yytype_int16; +typedef int yytype_uint16; +#endif + +#ifndef YYPTRDIFF_T +# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ +# define YYPTRDIFF_T __PTRDIFF_TYPE__ +# define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ +# elif defined PTRDIFF_MAX +# ifndef ptrdiff_t +# include /* INFRINGES ON USER NAME SPACE */ +# endif +# define YYPTRDIFF_T ptrdiff_t +# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX +# else +# define YYPTRDIFF_T long +# define YYPTRDIFF_MAXIMUM LONG_MAX +# endif #endif #ifndef YYSIZE_T @@ -395,15 +595,28 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T +# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) +#define YYSIZE_MAXIMUM \ + YY_CAST (YYPTRDIFF_T, \ + (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ + ? YYPTRDIFF_MAXIMUM \ + : YY_CAST (YYSIZE_T, -1))) + +#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) + + +/* Stored state numbers (used for stacks). */ +typedef yytype_uint8 yy_state_t; + +/* State numbers in computations. */ +typedef int yy_state_fast_t; #ifndef YY_ # if defined YYENABLE_NLS && YYENABLE_NLS @@ -417,30 +630,20 @@ typedef short int yytype_int16; # endif #endif -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) -# else -# define YY_ATTRIBUTE(Spec) /* empty */ -# endif -#endif #ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define YY_ATTRIBUTE_PURE +# endif #endif #ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) +# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) +# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) # else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# define YY_ATTRIBUTE_UNUSED # endif #endif @@ -451,13 +654,13 @@ typedef short int yytype_int16; # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ -# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ _Pragma ("GCC diagnostic pop") #else # define YY_INITIAL_VALUE(Value) Value @@ -470,8 +673,22 @@ typedef short int yytype_int16; # define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif +#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ +# define YY_IGNORE_USELESS_CAST_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") +# define YY_IGNORE_USELESS_CAST_END \ + _Pragma ("GCC diagnostic pop") +#endif +#ifndef YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_BEGIN +# define YY_IGNORE_USELESS_CAST_END +#endif + + +#define YY_ASSERT(E) ((void) (0 && (E))) -#if ! defined yyoverflow || YYERROR_VERBOSE +#if !defined yyoverflow /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -536,8 +753,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - +#endif /* !defined yyoverflow */ #if (! defined yyoverflow \ && (! defined __cplusplus \ @@ -546,17 +762,17 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss_alloc; + yy_state_t yyss_alloc; YYSTYPE yyvs_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) +# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) # define YYCOPY_NEEDED 1 @@ -569,11 +785,11 @@ union yyalloc # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ - YYSIZE_T yynewbytes; \ + YYPTRDIFF_T yynewbytes; \ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ } \ while (0) @@ -585,12 +801,12 @@ union yyalloc # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) + __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) # else # define YYCOPY(Dst, Src, Count) \ do \ { \ - YYSIZE_T yyi; \ + YYPTRDIFF_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (Dst)[yyi] = (Src)[yyi]; \ } \ @@ -602,42 +818,44 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 387 +#define YYLAST 354 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 76 +#define YYNTOKENS 77 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 48 +#define YYNNTS 55 /* YYNRULES -- Number of rules. */ -#define YYNRULES 146 +#define YYNRULES 156 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 242 +#define YYNSTATES 256 + +#define YYMAXUTOK 312 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 311 -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ +#define YYTRANSLATE(YYX) \ + (0 <= (YYX) && (YYX) <= YYMAXUTOK \ + ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ + : YYSYMBOL_YYUNDEF) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ -static const yytype_uint8 yytranslate[] = + as returned by yylex. */ +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, 62, 57, 2, - 70, 71, 60, 58, 75, 59, 72, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 68, 2, - 2, 69, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 63, 58, 2, + 71, 72, 61, 59, 76, 60, 73, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 69, 2, + 2, 70, 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, 73, 61, 74, 56, 2, 2, 2, 2, 2, + 2, 74, 62, 75, 57, 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, 66, 55, 67, 63, 2, 2, 2, + 2, 2, 2, 67, 56, 68, 64, 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, @@ -656,121 +874,138 @@ static const yytype_uint8 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, - 64, 65 + 55, 65, 66 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = +static const yytype_int16 yyrline[] = { - 0, 314, 314, 316, 317, 318, 319, 320, 321, 329, - 342, 347, 341, 374, 377, 393, 396, 411, 416, 417, - 422, 423, 429, 432, 448, 457, 499, 500, 505, 522, - 536, 550, 564, 582, 583, 589, 588, 605, 604, 625, - 624, 649, 655, 715, 716, 717, 718, 719, 720, 726, - 747, 778, 783, 800, 805, 825, 826, 840, 841, 842, - 843, 844, 848, 849, 863, 867, 962, 1010, 1071, 1118, - 1119, 1123, 1158, 1211, 1254, 1277, 1284, 1291, 1303, 1313, - 1327, 1342, 1353, 1432, 1470, 1372, 1630, 1629, 1719, 1725, - 1732, 1731, 1777, 1776, 1820, 1827, 1834, 1841, 1848, 1855, - 1862, 1866, 1874, 1894, 1922, 1996, 2024, 2033, 2042, 2066, - 2081, 2101, 2100, 2106, 2118, 2119, 2124, 2131, 2142, 2146, - 2151, 2160, 2164, 2172, 2184, 2198, 2206, 2213, 2238, 2250, - 2262, 2278, 2290, 2306, 2349, 2370, 2405, 2440, 2474, 2499, - 2516, 2526, 2536, 2546, 2556, 2576, 2596 + 0, 323, 323, 324, 325, 326, 327, 328, 329, 337, + 350, 355, 349, 382, 385, 401, 404, 419, 422, 429, + 434, 435, 440, 441, 447, 450, 466, 475, 517, 518, + 523, 540, 554, 568, 582, 599, 600, 605, 604, 702, + 703, 709, 708, 725, 724, 745, 744, 769, 775, 835, + 836, 837, 838, 839, 840, 846, 867, 898, 903, 920, + 925, 945, 946, 960, 961, 962, 963, 964, 968, 969, + 983, 987, 1089, 1137, 1198, 1245, 1246, 1250, 1285, 1338, + 1381, 1404, 1410, 1416, 1428, 1438, 1452, 1467, 1478, 1557, + 1595, 1497, 1755, 1754, 1844, 1850, 1857, 1856, 1902, 1901, + 1945, 1952, 1959, 1966, 1973, 1980, 1987, 1995, 2015, 2043, + 2117, 2145, 2153, 2162, 2186, 2201, 2221, 2220, 2226, 2237, + 2238, 2243, 2250, 2261, 2265, 2270, 2278, 2317, 2321, 2329, + 2341, 2355, 2362, 2369, 2394, 2406, 2418, 2433, 2445, 2460, + 2502, 2523, 2558, 2593, 2627, 2652, 2669, 2679, 2689, 2699, + 2709, 2729, 2749, 2756, 2760, 2767, 2771 }; #endif -#if YYDEBUG || YYERROR_VERBOSE || 0 +/** Accessing symbol of state STATE. */ +#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) + +#if YYDEBUG || 0 +/* The user-facing name of the symbol whose (internal) number is + YYSYMBOL. No bounds checking. */ +static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { - "\"end of file\"", "error", "$undefined", "\"end of included file\"", - "\"..\"", "\"\"", "\"\"", "\"\"", "\"\"", - "\"\"", "\"\"", "\"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", "$@10", "for_variables", - "iterator", "integer_set", "range", "integer_enumeration", "string_set", - "$@11", "string_enumeration", "string_enumeration_item", - "for_expression", "primary_expression", YY_NULLPTR + "\"end of file\"", "error", "\"invalid token\"", + "\"end of included file\"", "\"..\"", "\"\"", "\"\"", + "\"\"", "\"\"", "\"\"", "\"\"", + "\"\"", "\"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", "variables", "condition", + "rule_modifiers", "rule_modifier", "tags", "tag_list", + "meta_declarations", "meta_declaration", "variable_declarations", + "variable_declaration", "$@3", "string_declarations", + "string_declaration", "$@4", "$@5", "$@6", "string_modifiers", + "string_modifier", "regexp_modifiers", "regexp_modifier", + "hex_modifiers", "hex_modifier", "identifier", "arguments", + "arguments_list", "regexp", "boolean_expression", "complex_expression", + "$@7", "$@8", "$@9", "$@10", "$@11", "for_variables", "iterator", + "integer_set", "range", "integer_enumeration", "string_set", "$@12", + "string_enumeration", "string_enumeration_item", "for_expression", + "primary_expression", "nonprimary_expression", "expression", "object", YY_NULLPTR }; + +static const char * +yysymbol_name (yysymbol_kind_t yysymbol) +{ + return yytname[yysymbol]; +} #endif -# ifdef YYPRINT +#ifdef YYPRINT /* YYTOKNUM[NUM] -- (External) token number corresponding to the (internal) symbol number NUM (which must be that of a token). */ -static const yytype_uint16 yytoknum[] = +static const yytype_int16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 124, 94, 38, 43, 45, - 42, 92, 37, 126, 310, 311, 123, 125, 58, 61, - 40, 41, 46, 91, 93, 44 + 305, 306, 307, 308, 309, 310, 124, 94, 38, 43, + 45, 42, 92, 37, 126, 311, 312, 123, 125, 58, + 61, 40, 41, 46, 91, 93, 44 }; -# endif +#endif -#define YYPACT_NINF -74 +#define YYPACT_NINF (-87) -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-74))) +#define yypact_value_is_default(Yyn) \ + ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF -119 +#define YYTABLE_NINF (-157) -#define yytable_value_is_error(Yytable_value) \ +#define yytable_value_is_error(Yyn) \ 0 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ static const yytype_int16 yypact[] = { - -74, 97, -74, -38, -74, -11, -74, -74, 153, -74, - -74, -74, -74, 0, -74, -74, -74, -74, -50, 13, - -29, -74, 21, 58, -74, -10, 68, 77, 17, -74, - 22, 77, -74, 87, 98, 14, -74, 41, 87, -74, - 47, 57, -74, -74, -74, -74, 120, 8, -74, 50, - -74, -74, 109, 121, 128, -74, -22, -74, 81, 84, - -74, -74, 91, -74, -74, -74, -74, -74, -74, 108, - -74, -74, 50, 133, 133, 50, 44, -74, 124, -74, - 127, 206, -74, -74, -74, 133, 100, 133, 133, 133, - 133, 24, 315, -74, -74, -74, 124, 115, 179, 50, - 176, 133, -74, -74, -34, 166, 133, 133, 133, 133, - 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, - 133, 133, 133, 156, 83, 183, 315, 133, -74, 216, - 226, 258, 277, -74, -34, 180, -74, -74, 149, 129, - 131, -74, 248, 50, 50, -74, -74, -74, -74, 315, - 315, 315, 315, 315, 315, 315, 74, 74, 325, 140, - 163, 112, 112, -74, -74, -74, -74, -74, -74, 125, - 173, 174, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, -74, 152, -74, -74, -74, 181, -74, -20, - -74, 50, -74, 202, -74, -2, 231, 232, 269, 133, - -74, 1, 240, 131, -74, -74, 5, -74, -43, 220, - 221, 296, 223, 133, 44, 227, -74, -74, -74, -74, - -2, 279, -74, -74, -74, -74, 50, 15, 152, -74, - -74, 228, 30, -74, 133, 224, -74, -74, 315, 50, - 34, -74 + -87, 35, -87, -33, -87, -17, -87, -87, 6, -87, + -87, -87, -87, 7, -87, -87, -87, -87, -47, 51, + 2, -87, 66, 75, -87, 28, 116, 117, 67, 124, + 73, 117, -87, 134, 87, -87, 130, -87, 101, 134, + -87, 137, 164, -87, -87, -87, -87, 161, 9, -87, + 111, 137, -87, 115, 121, -87, 206, 205, 207, -87, + -87, 52, -87, -87, -87, -87, 52, -87, -21, -87, + 156, 158, -87, -87, 160, -87, -87, -87, -87, -87, + -87, 86, -87, -87, 52, 112, 112, 52, 20, -87, + 65, -87, 196, 145, -87, -87, 185, 210, 230, 65, + 157, 166, -87, 112, 190, 112, 112, 112, 112, 80, + 257, -87, -87, -87, 165, 191, 52, 252, 112, -87, + -87, -34, 242, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, + -87, -87, -87, 195, 198, 199, -87, -87, -87, -87, + -87, -87, -87, -87, -87, -87, -87, 257, 112, -87, + 163, 187, 219, 257, -87, -34, 255, -87, -87, 211, + 192, 142, -87, 197, 52, 52, -87, -87, -87, -87, + 257, 257, 257, 257, 257, 257, 257, 79, 79, 267, + 277, 287, 92, 92, -87, -87, -87, 253, 263, 264, + 104, -87, -87, -87, 217, -87, -2, -87, 52, -87, + 241, -87, 1, -52, 216, 218, 112, -87, -9, 290, + 142, -87, -87, -51, -87, 271, -87, -87, -87, 238, + 232, 112, 20, 235, -87, -87, -87, -87, 1, 233, + -87, 52, 4, 104, -87, -87, -87, -29, -87, 112, + 236, -87, 257, 52, 43, -87 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -778,51 +1013,54 @@ static const yytype_int16 yypact[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 2, 0, 1, 18, 8, 0, 4, 3, 0, 7, - 6, 5, 9, 0, 20, 21, 19, 10, 22, 0, - 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, 79, 128, 130, 132, - 125, 126, 0, 127, 73, 122, 123, 119, 120, 0, - 75, 76, 0, 0, 0, 0, 133, 146, 17, 74, - 0, 100, 41, 55, 62, 0, 0, 0, 0, 0, - 0, 0, 118, 89, 134, 143, 0, 74, 100, 69, - 0, 0, 92, 90, 0, 0, 0, 0, 0, 0, + 2, 0, 1, 20, 8, 0, 4, 3, 0, 7, + 6, 5, 9, 0, 22, 23, 21, 10, 24, 0, + 0, 26, 25, 13, 27, 0, 15, 0, 0, 17, + 0, 14, 28, 0, 0, 11, 0, 29, 0, 16, + 39, 0, 0, 31, 30, 33, 34, 0, 41, 40, + 0, 18, 35, 0, 0, 32, 0, 0, 0, 37, + 36, 0, 12, 47, 61, 68, 0, 71, 85, 134, + 136, 138, 131, 132, 0, 133, 79, 128, 129, 124, + 125, 0, 81, 82, 0, 0, 0, 0, 139, 152, + 19, 153, 0, 154, 126, 80, 42, 44, 46, 0, + 153, 126, 38, 0, 0, 0, 0, 0, 0, 0, + 123, 95, 140, 149, 126, 80, 75, 0, 0, 98, + 96, 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, 80, 0, 81, 0, - 0, 0, 0, 82, 0, 0, 101, 121, 0, 70, - 71, 66, 0, 0, 0, 113, 111, 88, 77, 78, - 98, 99, 94, 96, 95, 97, 144, 145, 142, 140, - 141, 135, 136, 137, 138, 139, 47, 44, 43, 48, - 51, 53, 45, 46, 42, 61, 58, 57, 59, 60, - 56, 64, 63, 0, 129, 131, 124, 0, 102, 0, - 68, 0, 67, 93, 91, 0, 0, 0, 0, 0, - 86, 0, 0, 72, 116, 117, 0, 114, 0, 0, - 0, 0, 0, 0, 104, 0, 105, 107, 103, 112, - 0, 0, 49, 52, 54, 108, 0, 0, 109, 84, - 115, 0, 0, 106, 0, 0, 50, 87, 110, 0, - 0, 85 + 53, 50, 49, 54, 57, 59, 51, 52, 48, 67, + 64, 63, 65, 66, 62, 70, 69, 86, 0, 87, + 0, 0, 0, 0, 88, 0, 0, 127, 106, 0, + 76, 77, 72, 0, 0, 0, 118, 116, 94, 83, + 84, 104, 105, 100, 102, 101, 103, 150, 151, 148, + 146, 147, 141, 142, 143, 144, 145, 0, 0, 0, + 0, 135, 137, 130, 0, 107, 0, 74, 0, 73, + 99, 97, 0, 0, 0, 0, 0, 92, 0, 0, + 78, 121, 122, 0, 119, 0, 55, 58, 60, 0, + 0, 0, 109, 0, 110, 112, 108, 117, 0, 0, + 113, 0, 0, 114, 90, 120, 56, 0, 111, 0, + 0, 93, 115, 0, 0, 91 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -74, -74, 294, 295, -74, -74, -74, -74, -74, -74, - -74, -74, -74, -74, 290, -74, 285, -74, -74, -74, - -74, -74, -74, -74, -74, -74, 123, -74, -74, 222, - -49, -73, -74, -74, -74, -74, -74, -74, -74, -74, - 139, -74, 191, -74, -74, 106, 259, -68 + -87, -87, 303, 305, -87, -87, -87, -87, -87, -87, + -87, -87, -87, -87, -87, 278, -87, 272, -87, -87, + 294, -87, -87, -87, -87, -87, -87, -87, -87, -87, + 125, -87, -87, 212, -61, 279, -87, -87, -87, -87, + -87, -87, -87, -87, 126, -87, 186, -87, -87, 114, + 273, -79, -5, -86, -87 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 1, 6, 7, 18, 34, 26, 29, 41, 8, - 16, 20, 22, 31, 32, 38, 39, 52, 53, 54, - 123, 174, 124, 180, 125, 182, 76, 138, 139, 77, - 96, 79, 135, 235, 212, 144, 143, 189, 215, 216, - 128, 227, 147, 195, 206, 207, 80, 81 + -1, 1, 6, 7, 18, 42, 26, 29, 35, 54, + 8, 16, 20, 22, 31, 32, 51, 52, 66, 39, + 40, 56, 57, 58, 96, 148, 97, 154, 98, 156, + 88, 169, 170, 89, 99, 91, 166, 250, 230, 175, + 174, 206, 233, 234, 159, 242, 178, 212, 223, 224, + 92, 93, 94, 95, 102 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -830,166 +1068,163 @@ static const yytype_int16 yydefgoto[] = number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = { - 78, 92, 97, 5, 145, 94, 95, 98, 85, 12, - 204, 17, 55, 86, 205, 201, 221, 126, 19, 129, - 130, 131, 132, 93, 21, 133, 140, 9, 222, -39, - -37, 42, 24, 142, 43, -83, 146, 23, 149, 150, - 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, - 161, 162, 163, 164, 165, 202, 44, 45, 27, 183, - 134, 55, 56, 57, 58, 59, 25, 60, 61, 62, - 63, 213, 64, 46, 102, 103, 219, 28, 102, 103, - 220, 65, 66, 67, 68, 33, 233, 69, 30, 175, - 234, 35, 70, 71, 193, 194, 72, 2, 3, 37, - 4, 237, -18, -18, -18, 241, 176, 177, 40, 73, - 47, 178, 179, 74, 99, 49, 100, 101, 203, 55, - 75, 57, 58, 59, 50, 60, 61, 62, 63, 82, - 64, 211, 118, 119, 120, 121, 122, 51, 5, 65, - 66, 67, 68, 83, 55, 228, 57, 58, 59, 84, - 60, 61, 62, 63, 87, 64, 199, 88, 13, 14, - 15, 89, 166, 104, 65, 66, 238, 73, 102, 103, - 127, 74, 120, 121, 122, -74, -74, 232, 90, 167, - 168, 169, 170, 171, 172, 173, 136, 141, 64, 181, - 240, 188, 73, 113, 114, 196, 74, 117, 118, 119, - 120, 121, 122, 90, 191, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 122, -118, 113, 114, 105, 106, - 190, 118, 119, 120, 121, 122, 107, 108, 109, 110, - 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, - 121, 122, -118, 197, 198, 105, 106, 103, 208, 200, - 137, 218, 209, 107, 108, 109, 110, 111, 112, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 210, - 184, 223, 224, 226, 239, 229, 231, 10, 11, 236, - 185, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 113, 114, 115, 116, 117, 118, 119, 120, 121, - 122, 36, 192, 48, 214, 187, 230, 148, 91, 186, - 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, - 217, 0, 0, 0, 0, 0, 0, 0, 137, 113, - 114, 115, 116, 117, 118, 119, 120, 121, 122, 0, - 0, 0, 0, 0, 0, 0, 0, 225, 113, 114, - 115, 116, 117, 118, 119, 120, 121, 122, 113, 114, - 0, 116, 117, 118, 119, 120, 121, 122 + 90, 115, 110, 67, 12, 176, 112, 113, 225, 5, + 103, 13, 14, 15, 221, 104, 119, 120, 222, 17, + 226, 237, 19, 111, 157, 238, 160, 161, 162, 163, + 171, -45, -43, 9, 218, 2, 3, 177, 4, 173, + -20, -20, -20, 251, 180, 181, 182, 183, 184, 185, + 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, + 196, 101, 231, 21, 67, 68, 69, 70, 71, 23, + 72, 73, 74, 75, 219, 76, 248, 5, 24, 200, + 249, 164, 114, 25, 77, 78, 79, 80, 119, 120, + 81, 116, -89, 117, 118, 82, 83, 27, 67, 84, + 69, 70, 71, 114, 72, 73, 74, 75, 216, 76, + 119, 120, 85, 210, 211, 255, 86, 165, 77, 78, + 79, 80, 220, 87, 67, 28, 69, 70, 71, 30, + 72, 73, 74, 75, 34, 76, 33, 229, 135, 136, + 137, 138, 139, 36, 77, 78, 85, 38, 43, 50, + 86, 44, 243, 137, 138, 139, 41, 108, 130, 131, + 132, 133, 134, 135, 136, 137, 138, 139, -155, -155, + 252, 48, 85, 45, 46, 53, 86, -156, -156, 55, + 247, 59, -123, 108, 61, 122, 123, -80, -80, 62, + 47, 140, 254, 124, 125, 126, 127, 128, 129, 130, + 131, 132, 133, 134, 135, 136, 137, 138, 139, 141, + 142, 143, 144, 145, 146, 147, 149, 130, 131, 132, + 133, 134, 135, 136, 137, 138, 139, 63, 64, 65, + 105, 107, 106, 121, 150, 151, 155, 167, 201, 152, + 153, 130, 131, 132, 133, 134, 135, 136, 137, 138, + 139, 130, 131, 132, 133, 134, 135, 136, 137, 138, + 139, 158, 202, 168, 172, 76, 197, 205, 208, 198, + 199, 213, 209, 130, 131, 132, 133, 134, 135, 136, + 137, 138, 139, 207, 214, 215, 217, 120, 227, 239, + 228, 203, 130, 131, 132, 133, 134, 135, 136, 137, + 138, 139, 236, 241, 244, 246, 10, 253, 11, 37, + 240, 130, 131, 132, 133, 134, 135, 136, 137, 138, + 139, 130, 131, 60, 133, 134, 135, 136, 137, 138, + 139, 130, 131, 49, 179, 134, 135, 136, 137, 138, + 139, 130, 131, 232, 235, 100, 135, 136, 137, 138, + 139, 204, 245, 0, 109 }; static const yytype_int16 yycheck[] = { - 49, 69, 75, 41, 38, 73, 74, 75, 30, 20, - 12, 11, 11, 35, 16, 35, 59, 85, 68, 87, - 88, 89, 90, 72, 11, 1, 99, 65, 71, 21, - 22, 17, 11, 101, 20, 11, 70, 66, 106, 107, - 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, - 118, 119, 120, 121, 122, 75, 42, 43, 68, 127, - 36, 11, 12, 13, 14, 15, 8, 17, 18, 19, - 20, 70, 22, 59, 44, 45, 71, 9, 44, 45, - 75, 31, 32, 33, 34, 68, 71, 37, 11, 6, - 75, 69, 42, 43, 143, 144, 46, 0, 1, 12, - 3, 71, 5, 6, 7, 71, 23, 24, 10, 59, - 69, 28, 29, 63, 70, 68, 72, 73, 191, 11, - 70, 13, 14, 15, 67, 17, 18, 19, 20, 20, - 22, 199, 58, 59, 60, 61, 62, 17, 41, 31, - 32, 33, 34, 22, 11, 213, 13, 14, 15, 21, - 17, 18, 19, 20, 73, 22, 4, 73, 5, 6, - 7, 70, 6, 36, 31, 32, 234, 59, 44, 45, - 70, 63, 60, 61, 62, 44, 45, 226, 70, 23, - 24, 25, 26, 27, 28, 29, 71, 11, 22, 6, - 239, 11, 59, 53, 54, 70, 63, 57, 58, 59, - 60, 61, 62, 70, 75, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 36, 53, 54, 39, 40, - 71, 58, 59, 60, 61, 62, 47, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 36, 70, 70, 39, 40, 45, 17, 68, - 71, 11, 20, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 20, - 74, 71, 71, 70, 70, 68, 17, 3, 3, 71, - 74, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 53, 54, 55, 56, 57, 58, 59, 60, 61, - 62, 31, 74, 38, 201, 134, 220, 105, 69, 71, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, - 201, -1, -1, -1, -1, -1, -1, -1, 71, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, -1, - -1, -1, -1, -1, -1, -1, -1, 71, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 53, 54, - -1, 56, 57, 58, 59, 60, 61, 62 + 61, 87, 81, 12, 21, 39, 85, 86, 60, 42, + 31, 5, 6, 7, 13, 36, 45, 46, 17, 12, + 72, 72, 69, 84, 103, 76, 105, 106, 107, 108, + 116, 22, 23, 66, 36, 0, 1, 71, 3, 118, + 5, 6, 7, 72, 123, 124, 125, 126, 127, 128, + 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, + 139, 66, 71, 12, 12, 13, 14, 15, 16, 67, + 18, 19, 20, 21, 76, 23, 72, 42, 12, 158, + 76, 1, 87, 8, 32, 33, 34, 35, 45, 46, + 38, 71, 12, 73, 74, 43, 44, 69, 12, 47, + 14, 15, 16, 108, 18, 19, 20, 21, 4, 23, + 45, 46, 60, 174, 175, 72, 64, 37, 32, 33, + 34, 35, 208, 71, 12, 9, 14, 15, 16, 12, + 18, 19, 20, 21, 10, 23, 69, 216, 59, 60, + 61, 62, 63, 70, 32, 33, 60, 13, 18, 12, + 64, 21, 231, 61, 62, 63, 69, 71, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 11, 12, + 249, 70, 60, 43, 44, 11, 64, 11, 12, 18, + 241, 70, 37, 71, 69, 40, 41, 45, 46, 68, + 60, 6, 253, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 24, + 25, 26, 27, 28, 29, 30, 6, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 21, 23, 22, + 74, 71, 74, 37, 24, 25, 6, 72, 75, 29, + 30, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 71, 75, 72, 12, 23, 71, 12, 76, 71, + 71, 18, 75, 54, 55, 56, 57, 58, 59, 60, + 61, 62, 63, 72, 21, 21, 69, 46, 72, 18, + 72, 72, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 12, 71, 69, 72, 3, 71, 3, 31, + 72, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 54, 55, 51, 57, 58, 59, 60, 61, 62, + 63, 54, 55, 39, 122, 58, 59, 60, 61, 62, + 63, 54, 55, 218, 218, 66, 59, 60, 61, 62, + 63, 165, 238, -1, 81 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 77, 0, 1, 3, 41, 78, 79, 85, 65, - 78, 79, 20, 5, 6, 7, 86, 11, 80, 68, - 87, 11, 88, 66, 11, 8, 82, 68, 9, 83, - 11, 89, 90, 68, 81, 69, 90, 12, 91, 92, - 10, 84, 17, 20, 42, 43, 59, 69, 92, 68, - 67, 17, 93, 94, 95, 11, 12, 13, 14, 15, - 17, 18, 19, 20, 22, 31, 32, 33, 34, 37, - 42, 43, 46, 59, 63, 70, 102, 105, 106, 107, - 122, 123, 20, 22, 21, 30, 35, 73, 73, 70, - 70, 122, 123, 106, 123, 123, 106, 107, 123, 70, - 72, 73, 44, 45, 36, 39, 40, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 96, 98, 100, 123, 70, 116, 123, - 123, 123, 123, 1, 36, 108, 71, 71, 103, 104, - 107, 11, 123, 112, 111, 38, 70, 118, 105, 123, - 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, - 123, 123, 123, 123, 123, 123, 6, 23, 24, 25, - 26, 27, 28, 29, 97, 6, 23, 24, 28, 29, - 99, 6, 101, 123, 74, 74, 71, 118, 11, 113, - 71, 75, 74, 106, 106, 119, 70, 70, 70, 4, - 68, 35, 75, 107, 12, 16, 120, 121, 17, 20, - 20, 123, 110, 70, 102, 114, 115, 116, 11, 71, - 75, 59, 71, 71, 71, 71, 70, 117, 123, 68, - 121, 17, 106, 71, 75, 109, 71, 71, 123, 70, - 106, 71 + 0, 78, 0, 1, 3, 42, 79, 80, 87, 66, + 79, 80, 21, 5, 6, 7, 88, 12, 81, 69, + 89, 12, 90, 67, 12, 8, 83, 69, 9, 84, + 12, 91, 92, 69, 10, 85, 70, 92, 13, 96, + 97, 69, 82, 18, 21, 43, 44, 60, 70, 97, + 12, 93, 94, 11, 86, 18, 98, 99, 100, 70, + 94, 69, 68, 21, 23, 22, 95, 12, 13, 14, + 15, 16, 18, 19, 20, 21, 23, 32, 33, 34, + 35, 38, 43, 44, 47, 60, 64, 71, 107, 110, + 111, 112, 127, 128, 129, 130, 101, 103, 105, 111, + 112, 129, 131, 31, 36, 74, 74, 71, 71, 127, + 128, 111, 128, 128, 129, 130, 71, 73, 74, 45, + 46, 37, 40, 41, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 6, 24, 25, 26, 27, 28, 29, 30, 102, 6, + 24, 25, 29, 30, 104, 6, 106, 128, 71, 121, + 128, 128, 128, 128, 1, 37, 113, 72, 72, 108, + 109, 130, 12, 128, 117, 116, 39, 71, 123, 110, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 71, 71, 71, + 128, 75, 75, 72, 123, 12, 118, 72, 76, 75, + 111, 111, 124, 18, 21, 21, 4, 69, 36, 76, + 130, 13, 17, 125, 126, 60, 72, 72, 72, 128, + 115, 71, 107, 119, 120, 121, 12, 72, 76, 18, + 72, 71, 122, 128, 69, 126, 72, 111, 72, 76, + 114, 72, 128, 71, 111, 72 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 76, 77, 77, 77, 77, 77, 77, 77, 78, - 80, 81, 79, 82, 82, 83, 83, 84, 85, 85, - 86, 86, 87, 87, 88, 88, 89, 89, 90, 90, - 90, 90, 90, 91, 91, 93, 92, 94, 92, 95, - 92, 96, 96, 97, 97, 97, 97, 97, 97, 97, - 97, 97, 97, 97, 97, 98, 98, 99, 99, 99, - 99, 99, 100, 100, 101, 102, 102, 102, 102, 103, - 103, 104, 104, 105, 106, 107, 107, 107, 107, 107, - 107, 107, 107, 108, 109, 107, 110, 107, 107, 107, - 111, 107, 112, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 113, 113, 114, 114, 115, 115, 116, 117, - 117, 119, 118, 118, 120, 120, 121, 121, 122, 122, - 122, 123, 123, 123, 123, 123, 123, 123, 123, 123, - 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, - 123, 123, 123, 123, 123, 123, 123 + 0, 77, 78, 78, 78, 78, 78, 78, 78, 79, + 81, 82, 80, 83, 83, 84, 84, 85, 85, 86, + 87, 87, 88, 88, 89, 89, 90, 90, 91, 91, + 92, 92, 92, 92, 92, 93, 93, 95, 94, 96, + 96, 98, 97, 99, 97, 100, 97, 101, 101, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 103, 103, 104, 104, 104, 104, 104, 105, 105, + 106, 107, 107, 107, 107, 108, 108, 109, 109, 110, + 111, 112, 112, 112, 112, 112, 112, 112, 112, 113, + 114, 112, 115, 112, 112, 112, 116, 112, 117, 112, + 112, 112, 112, 112, 112, 112, 112, 118, 118, 119, + 119, 120, 120, 121, 122, 122, 124, 123, 123, 125, + 125, 126, 126, 127, 127, 127, 128, 129, 129, 129, + 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, + 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, + 129, 129, 129, 130, 130, 131, 131 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = +static const yytype_int8 yyr2[] = { 0, 2, 0, 2, 2, 3, 3, 3, 2, 2, - 0, 0, 11, 0, 3, 0, 3, 3, 0, 2, - 1, 1, 0, 2, 1, 2, 1, 2, 3, 3, - 4, 3, 3, 1, 2, 0, 5, 0, 5, 0, - 5, 0, 2, 1, 1, 1, 1, 1, 1, 4, - 6, 1, 4, 1, 4, 0, 2, 1, 1, 1, - 1, 1, 0, 2, 1, 1, 3, 4, 4, 0, - 1, 1, 3, 1, 1, 1, 1, 3, 3, 1, - 3, 3, 3, 0, 0, 11, 0, 9, 3, 2, - 0, 4, 0, 4, 3, 3, 3, 3, 3, 3, - 1, 3, 1, 3, 1, 1, 3, 1, 5, 1, - 3, 0, 4, 1, 1, 3, 1, 1, 1, 1, - 1, 3, 1, 1, 4, 1, 1, 1, 1, 4, - 1, 4, 1, 1, 2, 3, 3, 3, 3, 3, - 3, 3, 3, 2, 3, 3, 1 + 0, 0, 12, 0, 3, 0, 3, 0, 3, 3, + 0, 2, 1, 1, 0, 2, 1, 2, 1, 2, + 3, 3, 4, 3, 3, 1, 2, 0, 4, 1, + 2, 0, 5, 0, 5, 0, 5, 0, 2, 1, + 1, 1, 1, 1, 1, 4, 6, 1, 4, 1, + 4, 0, 2, 1, 1, 1, 1, 1, 0, 2, + 1, 1, 3, 4, 4, 0, 1, 1, 3, 1, + 1, 1, 1, 3, 3, 1, 3, 3, 3, 0, + 0, 11, 0, 9, 3, 2, 0, 4, 0, 4, + 3, 3, 3, 3, 3, 3, 3, 1, 3, 1, + 1, 3, 1, 5, 1, 3, 0, 4, 1, 1, + 3, 1, 1, 1, 1, 1, 1, 3, 1, 1, + 4, 1, 1, 1, 1, 4, 1, 4, 1, 1, + 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, + 3, 3, 1, 1, 1, 1, 1 }; +enum { YYENOMEM = -2 }; + #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab @@ -998,27 +1233,26 @@ static const yytype_uint8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (yyscanner, compiler, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) - -/* Error token number */ -#define YYTERROR 1 -#define YYERRCODE 256 - +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (yyscanner, compiler, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) + +/* Backward compatibility with an undocumented macro. + Use YYerror or YYUNDEF. */ +#define YYERRCODE YYUNDEF /* Enable debugging if requested. */ @@ -1036,56 +1270,60 @@ do { \ } while (0) /* This macro is provided for backward compatibility. */ -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif +# ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ - Type, Value, yyscanner, compiler); \ + Kind, Value, yyscanner, compiler); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *yyscanner, YR_COMPILER* compiler) +yy_symbol_value_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, void *yyscanner, YR_COMPILER* compiler) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YYUSE (yyoutput); YYUSE (yyscanner); YYUSE (compiler); if (!yyvaluep) return; # ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); + if (yykind < YYNTOKENS) + YYPRINT (yyo, yytoknum[yykind], *yyvaluep); # endif - YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yykind); + YY_IGNORE_MAYBE_UNINITIALIZED_END } -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *yyscanner, YR_COMPILER* compiler) +yy_symbol_print (FILE *yyo, + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, void *yyscanner, YR_COMPILER* compiler) { - YYFPRINTF (yyoutput, "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + YYFPRINTF (yyo, "%s %s (", + yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, compiler); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yykind, yyvaluep, yyscanner, compiler); + YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. @@ -1094,7 +1332,7 @@ yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, voi `------------------------------------------------------------------*/ static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -1117,21 +1355,21 @@ do { \ `------------------------------------------------*/ static void -yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, void *yyscanner, YR_COMPILER* compiler) +yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, + int yyrule, void *yyscanner, YR_COMPILER* compiler) { - unsigned long int yylno = yyrline[yyrule]; + int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, - yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) - , yyscanner, compiler); + YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), + &yyvsp[(yyi + 1) - (yynrhs)], yyscanner, compiler); YYFPRINTF (stderr, "\n"); } } @@ -1146,8 +1384,8 @@ do { \ multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YYDPRINTF(Args) ((void) 0) +# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ @@ -1170,337 +1408,118 @@ int yydebug; #endif -#if YYERROR_VERBOSE -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -yystrlen (const char *yystr) -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -yystpcpy (char *yydest, const char *yysrc) -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) -{ - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; - - /* There are many possibilities here to consider: - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) - { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } - } - - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - default: /* Avoid compiler warnings. */ - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } - - { - YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; -} -#endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *yyscanner, YR_COMPILER* compiler) +yydestruct (const char *yymsg, + yysymbol_kind_t yykind, YYSTYPE *yyvaluep, void *yyscanner, YR_COMPILER* compiler) { YYUSE (yyvaluep); YYUSE (yyscanner); YYUSE (compiler); if (!yymsg) yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN - switch (yytype) + switch (yykind) { - case 11: /* "identifier" */ -#line 267 "grammar.y" /* yacc.c:1258 */ - { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1417 "grammar.c" /* yacc.c:1258 */ + case 12: /* "identifier" */ +#line 275 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1437 "grammar.c" break; - case 12: /* "string identifier" */ -#line 271 "grammar.y" /* yacc.c:1258 */ - { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1423 "grammar.c" /* yacc.c:1258 */ + case 13: /* "string identifier" */ +#line 279 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1443 "grammar.c" break; - case 13: /* "string count" */ -#line 268 "grammar.y" /* yacc.c:1258 */ - { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1429 "grammar.c" /* yacc.c:1258 */ + case 14: /* "string count" */ +#line 276 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1449 "grammar.c" break; - case 14: /* "string offset" */ -#line 269 "grammar.y" /* yacc.c:1258 */ - { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1435 "grammar.c" /* yacc.c:1258 */ + case 15: /* "string offset" */ +#line 277 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1455 "grammar.c" break; - case 15: /* "string length" */ -#line 270 "grammar.y" /* yacc.c:1258 */ - { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1441 "grammar.c" /* yacc.c:1258 */ + case 16: /* "string length" */ +#line 278 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1461 "grammar.c" break; - case 16: /* "string identifier with wildcard" */ -#line 272 "grammar.y" /* yacc.c:1258 */ - { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1447 "grammar.c" /* yacc.c:1258 */ + case 17: /* "string identifier with wildcard" */ +#line 280 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1467 "grammar.c" break; - case 20: /* "text string" */ -#line 273 "grammar.y" /* yacc.c:1258 */ - { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } -#line 1453 "grammar.c" /* yacc.c:1258 */ + case 21: /* "text string" */ +#line 281 "grammar.y" + { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } +#line 1473 "grammar.c" break; - case 21: /* "hex string" */ -#line 274 "grammar.y" /* yacc.c:1258 */ - { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } -#line 1459 "grammar.c" /* yacc.c:1258 */ + case 22: /* "hex string" */ +#line 282 "grammar.y" + { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } +#line 1479 "grammar.c" break; - case 22: /* "regular expression" */ -#line 275 "grammar.y" /* yacc.c:1258 */ - { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } -#line 1465 "grammar.c" /* yacc.c:1258 */ + case 23: /* "regular expression" */ +#line 283 "grammar.y" + { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } +#line 1485 "grammar.c" break; - case 96: /* string_modifiers */ -#line 288 "grammar.y" /* yacc.c:1258 */ - { + case 101: /* string_modifiers */ +#line 296 "grammar.y" + { if (((*yyvaluep).modifier).alphabet != NULL) { yr_free(((*yyvaluep).modifier).alphabet); ((*yyvaluep).modifier).alphabet = NULL; } } -#line 1477 "grammar.c" /* yacc.c:1258 */ +#line 1497 "grammar.c" break; - case 97: /* string_modifier */ -#line 280 "grammar.y" /* yacc.c:1258 */ - { + case 102: /* string_modifier */ +#line 288 "grammar.y" + { if (((*yyvaluep).modifier).alphabet != NULL) { yr_free(((*yyvaluep).modifier).alphabet); ((*yyvaluep).modifier).alphabet = NULL; } } -#line 1489 "grammar.c" /* yacc.c:1258 */ +#line 1509 "grammar.c" break; - case 103: /* arguments */ -#line 277 "grammar.y" /* yacc.c:1258 */ - { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1495 "grammar.c" /* yacc.c:1258 */ + case 108: /* arguments */ +#line 285 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1515 "grammar.c" break; - case 104: /* arguments_list */ -#line 278 "grammar.y" /* yacc.c:1258 */ - { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1501 "grammar.c" /* yacc.c:1258 */ + case 109: /* arguments_list */ +#line 286 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1521 "grammar.c" break; - default: break; } @@ -1510,6 +1529,8 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *yyscanner, Y + + /*----------. | yyparse. | `----------*/ @@ -1530,7 +1551,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); /* Number of syntax errors so far. */ int yynerrs; - int yystate; + yy_state_fast_t yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; @@ -1541,32 +1562,29 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ + /* Their size. */ + YYPTRDIFF_T yystacksize; + /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; + yy_state_t yyssa[YYINITDEPTH]; + yy_state_t *yyss; + yy_state_t *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs; YYSTYPE *yyvsp; - YYSIZE_T yystacksize; - int yyn; + /* The return value of yyparse. */ int yyresult; /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; + yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif + #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) @@ -1574,58 +1592,69 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); Keep to zero when no symbol should be popped. */ int yylen = 0; + yynerrs = 0; + yystate = 0; + yyerrstatus = 0; + + yystacksize = YYINITDEPTH; yyssp = yyss = yyssa; yyvsp = yyvs = yyvsa; - yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| yysetstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + YY_IGNORE_USELESS_CAST_BEGIN + *yyssp = YY_CAST (yy_state_t, yystate); + YY_IGNORE_USELESS_CAST_END + YY_STACK_PRINT (yyss, yyssp); if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYPTRDIFF_T yysize = yyssp - yyss + 1; -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ + yy_state_t *yyss1 = yyss; YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), + &yyss1, yysize * YYSIZEOF (*yyssp), + &yyvs1, yysize * YYSIZEOF (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1634,9 +1663,10 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; + yy_state_t *yyss1 = yyss; union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + YY_CAST (union yyalloc *, + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); @@ -1646,30 +1676,30 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + YY_IGNORE_USELESS_CAST_BEGIN + YYDPRINTF ((stderr, "Stack size increased to %ld\n", + YY_CAST (long, yystacksize))); + YY_IGNORE_USELESS_CAST_END if (yyss + yystacksize - 1 <= yyssp) YYABORT; } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ if (yystate == YYFINAL) YYACCEPT; goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1680,18 +1710,29 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ if (yychar == YYEMPTY) { - YYDPRINTF ((stderr, "Reading a token: ")); + YYDPRINTF ((stderr, "Reading a token\n")); yychar = yylex (&yylval, yyscanner, compiler); } - if (yychar <= YYEOF) + if (yychar <= _END_OF_FILE_) { - yychar = yytoken = YYEOF; + yychar = _END_OF_FILE_; + yytoken = YYSYMBOL_YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } + else if (yychar == YYerror) + { + /* The scanner already issued an error message, process directly + to error recovery. But do not keep the error token as + lookahead, it is too special and may lead us to an endless + loop in error recovery. */ + yychar = YYUNDEF; + yytoken = YYSYMBOL_YYerror; + goto yyerrlab1; + } else { yytoken = YYTRANSLATE (yychar); @@ -1719,15 +1760,13 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - yystate = yyn; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END + /* Discard the shifted token. */ + yychar = YYEMPTY; goto yynewstate; @@ -1742,7 +1781,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1762,77 +1801,77 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); YY_REDUCE_PRINT (yyn); switch (yyn) { - case 8: -#line 322 "grammar.y" /* yacc.c:1663 */ - { + case 8: +#line 330 "grammar.y" + { _yr_compiler_pop_file_name(compiler); } -#line 1771 "grammar.c" /* yacc.c:1663 */ +#line 1810 "grammar.c" break; case 9: -#line 330 "grammar.y" /* yacc.c:1663 */ - { +#line 338 "grammar.y" + { int result = yr_parser_reduce_import(yyscanner, (yyvsp[0].sized_string)); yr_free((yyvsp[0].sized_string)); fail_if_error(result); } -#line 1783 "grammar.c" /* yacc.c:1663 */ +#line 1822 "grammar.c" break; case 10: -#line 342 "grammar.y" /* yacc.c:1663 */ - { +#line 350 "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 1792 "grammar.c" /* yacc.c:1663 */ +#line 1831 "grammar.c" break; case 11: -#line 347 "grammar.y" /* yacc.c:1663 */ - { +#line 355 "grammar.y" + { YR_RULE* rule = (YR_RULE*) yr_arena_ref_to_ptr( - compiler->arena, &(yyvsp[-4].rule)); + compiler->arena, &(yyvsp[-5].rule)); rule->tags = (char*) yr_arena_ref_to_ptr( - compiler->arena, &(yyvsp[-3].tag)); + compiler->arena, &(yyvsp[-4].tag)); rule->metas = (YR_META*) yr_arena_ref_to_ptr( - compiler->arena, &(yyvsp[-1].meta)); + compiler->arena, &(yyvsp[-2].meta)); rule->strings = (YR_STRING*) yr_arena_ref_to_ptr( - compiler->arena, &(yyvsp[0].string)); + compiler->arena, &(yyvsp[-1].string)); } -#line 1810 "grammar.c" /* yacc.c:1663 */ +#line 1849 "grammar.c" break; case 12: -#line 361 "grammar.y" /* yacc.c:1663 */ - { +#line 369 "grammar.y" + { int result = yr_parser_reduce_rule_declaration_phase_2( - yyscanner, &(yyvsp[-7].rule)); // rule created in phase 1 + yyscanner, &(yyvsp[-8].rule)); // rule created in phase 1 - yr_free((yyvsp[-8].c_string)); + yr_free((yyvsp[-9].c_string)); fail_if_error(result); } -#line 1823 "grammar.c" /* yacc.c:1663 */ +#line 1862 "grammar.c" break; case 13: -#line 374 "grammar.y" /* yacc.c:1663 */ - { +#line 382 "grammar.y" + { (yyval.meta) = YR_ARENA_NULL_REF; } -#line 1831 "grammar.c" /* yacc.c:1663 */ +#line 1870 "grammar.c" break; case 14: -#line 378 "grammar.y" /* yacc.c:1663 */ - { +#line 386 "grammar.y" + { YR_META* meta = yr_arena_get_ptr( compiler->arena, YR_METAS_TABLE, @@ -1842,20 +1881,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.meta) = (yyvsp[0].meta); } -#line 1846 "grammar.c" /* yacc.c:1663 */ +#line 1885 "grammar.c" break; case 15: -#line 393 "grammar.y" /* yacc.c:1663 */ - { +#line 401 "grammar.y" + { (yyval.string) = YR_ARENA_NULL_REF; } -#line 1854 "grammar.c" /* yacc.c:1663 */ +#line 1893 "grammar.c" break; case 16: -#line 397 "grammar.y" /* yacc.c:1663 */ - { +#line 405 "grammar.y" + { YR_STRING* string = (YR_STRING*) yr_arena_get_ptr( compiler->arena, YR_STRINGS_TABLE, @@ -1865,44 +1904,60 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.string) = (yyvsp[0].string); } -#line 1869 "grammar.c" /* yacc.c:1663 */ +#line 1908 "grammar.c" break; - case 18: -#line 416 "grammar.y" /* yacc.c:1663 */ - { (yyval.integer) = 0; } -#line 1875 "grammar.c" /* yacc.c:1663 */ + case 17: +#line 419 "grammar.y" + { + (yyval.expression).type = EXPRESSION_TYPE_UNKNOWN; + } +#line 1916 "grammar.c" break; - case 19: -#line 417 "grammar.y" /* yacc.c:1663 */ - { (yyval.integer) = (yyvsp[-1].integer) | (yyvsp[0].integer); } -#line 1881 "grammar.c" /* yacc.c:1663 */ + case 18: +#line 423 "grammar.y" + { + (yyval.expression) = (yyvsp[0].expression); + } +#line 1924 "grammar.c" break; case 20: -#line 422 "grammar.y" /* yacc.c:1663 */ - { (yyval.integer) = RULE_FLAGS_PRIVATE; } -#line 1887 "grammar.c" /* yacc.c:1663 */ +#line 434 "grammar.y" + { (yyval.integer) = 0; } +#line 1930 "grammar.c" break; case 21: -#line 423 "grammar.y" /* yacc.c:1663 */ - { (yyval.integer) = RULE_FLAGS_GLOBAL; } -#line 1893 "grammar.c" /* yacc.c:1663 */ +#line 435 "grammar.y" + { (yyval.integer) = (yyvsp[-1].integer) | (yyvsp[0].integer); } +#line 1936 "grammar.c" break; case 22: -#line 429 "grammar.y" /* yacc.c:1663 */ - { +#line 440 "grammar.y" + { (yyval.integer) = RULE_FLAGS_PRIVATE; } +#line 1942 "grammar.c" + break; + + case 23: +#line 441 "grammar.y" + { (yyval.integer) = RULE_FLAGS_GLOBAL; } +#line 1948 "grammar.c" + break; + + case 24: +#line 447 "grammar.y" + { (yyval.tag) = YR_ARENA_NULL_REF; } -#line 1901 "grammar.c" /* yacc.c:1663 */ +#line 1956 "grammar.c" break; - case 23: -#line 433 "grammar.y" /* yacc.c:1663 */ - { + case 25: +#line 451 "grammar.y" + { // Tags list is represented in the arena as a sequence // of null-terminated strings, the sequence ends with an // additional null character. Here we write the ending null @@ -1913,12 +1968,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.tag) = (yyvsp[0].tag); } -#line 1917 "grammar.c" /* yacc.c:1663 */ +#line 1972 "grammar.c" break; - case 24: -#line 449 "grammar.y" /* yacc.c:1663 */ - { + case 26: +#line 467 "grammar.y" + { int result = yr_arena_write_string( yyget_extra(yyscanner)->arena, YR_SZ_POOL, (yyvsp[0].c_string), &(yyval.tag)); @@ -1926,12 +1981,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 1930 "grammar.c" /* yacc.c:1663 */ +#line 1985 "grammar.c" break; - case 25: -#line 458 "grammar.y" /* yacc.c:1663 */ - { + case 27: +#line 476 "grammar.y" + { YR_ARENA_REF ref; // Write the new tag identifier. @@ -1967,24 +2022,24 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.tag) = (yyvsp[-1].tag); } -#line 1971 "grammar.c" /* yacc.c:1663 */ +#line 2026 "grammar.c" break; - case 26: -#line 499 "grammar.y" /* yacc.c:1663 */ - { (yyval.meta) = (yyvsp[0].meta); } -#line 1977 "grammar.c" /* yacc.c:1663 */ + case 28: +#line 517 "grammar.y" + { (yyval.meta) = (yyvsp[0].meta); } +#line 2032 "grammar.c" break; - case 27: -#line 500 "grammar.y" /* yacc.c:1663 */ - { (yyval.meta) = (yyvsp[-1].meta); } -#line 1983 "grammar.c" /* yacc.c:1663 */ + case 29: +#line 518 "grammar.y" + { (yyval.meta) = (yyvsp[-1].meta); } +#line 2038 "grammar.c" break; - case 28: -#line 506 "grammar.y" /* yacc.c:1663 */ - { + case 30: +#line 524 "grammar.y" + { SIZED_STRING* sized_string = (yyvsp[0].sized_string); int result = yr_parser_reduce_meta_declaration( @@ -2000,12 +2055,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2004 "grammar.c" /* yacc.c:1663 */ +#line 2059 "grammar.c" break; - case 29: -#line 523 "grammar.y" /* yacc.c:1663 */ - { + case 31: +#line 541 "grammar.y" + { int result = yr_parser_reduce_meta_declaration( yyscanner, META_TYPE_INTEGER, @@ -2018,12 +2073,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2022 "grammar.c" /* yacc.c:1663 */ +#line 2077 "grammar.c" break; - case 30: -#line 537 "grammar.y" /* yacc.c:1663 */ - { + case 32: +#line 555 "grammar.y" + { int result = yr_parser_reduce_meta_declaration( yyscanner, META_TYPE_INTEGER, @@ -2036,12 +2091,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2040 "grammar.c" /* yacc.c:1663 */ +#line 2095 "grammar.c" break; - case 31: -#line 551 "grammar.y" /* yacc.c:1663 */ - { + case 33: +#line 569 "grammar.y" + { int result = yr_parser_reduce_meta_declaration( yyscanner, META_TYPE_BOOLEAN, @@ -2054,12 +2109,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2058 "grammar.c" /* yacc.c:1663 */ +#line 2113 "grammar.c" break; - case 32: -#line 565 "grammar.y" /* yacc.c:1663 */ - { + case 34: +#line 583 "grammar.y" + { int result = yr_parser_reduce_meta_declaration( yyscanner, META_TYPE_BOOLEAN, @@ -2072,62 +2127,177 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2076 "grammar.c" /* yacc.c:1663 */ - break; - - case 33: -#line 582 "grammar.y" /* yacc.c:1663 */ - { (yyval.string) = (yyvsp[0].string); } -#line 2082 "grammar.c" /* yacc.c:1663 */ - break; - - case 34: -#line 583 "grammar.y" /* yacc.c:1663 */ - { (yyval.string) = (yyvsp[-1].string); } -#line 2088 "grammar.c" /* yacc.c:1663 */ +#line 2131 "grammar.c" break; case 35: -#line 589 "grammar.y" /* yacc.c:1663 */ - { - compiler->current_line = yyget_lineno(yyscanner); - } -#line 2096 "grammar.c" /* yacc.c:1663 */ +#line 599 "grammar.y" + { (yyval.expression) = (yyvsp[0].expression); } +#line 2137 "grammar.c" break; case 36: -#line 593 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_string_declaration( - yyscanner, (yyvsp[0].modifier), (yyvsp[-4].c_string), (yyvsp[-1].sized_string), &(yyval.string)); - - yr_free((yyvsp[-4].c_string)); - yr_free((yyvsp[-1].sized_string)); - yr_free((yyvsp[0].modifier).alphabet); - - fail_if_error(result); - compiler->current_line = 0; - } -#line 2112 "grammar.c" /* yacc.c:1663 */ +#line 600 "grammar.y" + { (yyval.expression) = (yyvsp[-1].expression); } +#line 2143 "grammar.c" break; case 37: -#line 605 "grammar.y" /* yacc.c:1663 */ - { +#line 605 "grammar.y" + { compiler->current_line = yyget_lineno(yyscanner); } -#line 2120 "grammar.c" /* yacc.c:1663 */ +#line 2151 "grammar.c" break; case 38: -#line 609 "grammar.y" /* yacc.c:1663 */ - { - int result; +#line 609 "grammar.y" + { + YR_INTERNAL_VARIABLE* int_var; + YR_ARENA_REF int_ref; + YR_ARENA_REF identifier_ref; - (yyvsp[0].modifier).flags |= STRING_FLAGS_REGEXP; + // Check for duplicated identifier in scope with external variables + YR_OBJECT* object = (YR_OBJECT*)yr_hash_table_lookup( + compiler->objects_table, + (yyvsp[-3].c_string), + NULL); + + if(object != NULL) { + yywarning(yyscanner, + "External variable overrides definition of internal variable \"%s\".", + (yyvsp[-3].c_string)); + yr_parser_emit(yyscanner, OP_POP, NULL); + } else { + // Check for duplicated identifier in local rule scope + object = (YR_OBJECT*)yr_hash_table_lookup( + compiler->current_internal_variables_table, + (yyvsp[-3].c_string), + NULL); - result = yr_parser_reduce_string_declaration( - yyscanner, (yyvsp[0].modifier), (yyvsp[-4].c_string), (yyvsp[-1].sized_string), &(yyval.string)); + if(object != NULL) { + fail_with_error(ERROR_DUPLICATED_IDENTIFIER); + } + + yr_arena_allocate_struct( + compiler->arena, + YR_INTERNAL_VARIABLES_TABLE, + sizeof(YR_INTERNAL_VARIABLE), + &int_ref, + offsetof(YR_INTERNAL_VARIABLE, identifier), + EOL); + + int_var = yr_arena_ref_to_ptr(compiler->arena, &int_ref); + + _yr_compiler_store_string( + compiler, + (yyvsp[-3].c_string), + &identifier_ref); + + int_var->identifier = yr_arena_ref_to_ptr( + compiler->arena, &identifier_ref); + int_var->rule_idx = compiler->current_rule_idx; + + switch((yyvsp[0].expression).type) { + case EXPRESSION_TYPE_BOOLEAN: + case EXPRESSION_TYPE_INTEGER: + int_var->type = OBJECT_TYPE_INTEGER; + break; + case EXPRESSION_TYPE_FLOAT: + int_var->type = OBJECT_TYPE_FLOAT; + break; + case EXPRESSION_TYPE_STRING: + int_var->type = OBJECT_TYPE_STRING; + break; + case EXPRESSION_TYPE_OBJECT: + int_var->type = (yyvsp[0].expression).value.object->type; + break; + } + + if((yyvsp[0].expression).type == EXPRESSION_TYPE_OBJECT) { + yr_object_copy((yyvsp[0].expression).value.object, &object); + } else { + yr_object_create( + int_var->type, + int_var->identifier, + NULL, + &object); + } + + FAIL_ON_ERROR_WITH_CLEANUP(yr_hash_table_add( + compiler->current_internal_variables_table, + (yyvsp[-3].c_string), + NULL, + (void*) object), + yr_object_destroy(object)); + + // Pop value on stack to variable + yr_parser_emit_with_arg_reloc( + yyscanner, + OP_OBJ_STORE, + (void*)int_var->identifier, + NULL, + NULL); + } + + yr_free((yyvsp[-3].c_string)); + } +#line 2246 "grammar.c" + break; + + case 39: +#line 702 "grammar.y" + { (yyval.string) = (yyvsp[0].string); } +#line 2252 "grammar.c" + break; + + case 40: +#line 703 "grammar.y" + { (yyval.string) = (yyvsp[-1].string); } +#line 2258 "grammar.c" + break; + + case 41: +#line 709 "grammar.y" + { + compiler->current_line = yyget_lineno(yyscanner); + } +#line 2266 "grammar.c" + break; + + case 42: +#line 713 "grammar.y" + { + int result = yr_parser_reduce_string_declaration( + yyscanner, (yyvsp[0].modifier), (yyvsp[-4].c_string), (yyvsp[-1].sized_string), &(yyval.string)); + + yr_free((yyvsp[-4].c_string)); + yr_free((yyvsp[-1].sized_string)); + yr_free((yyvsp[0].modifier).alphabet); + + fail_if_error(result); + compiler->current_line = 0; + } +#line 2282 "grammar.c" + break; + + case 43: +#line 725 "grammar.y" + { + compiler->current_line = yyget_lineno(yyscanner); + } +#line 2290 "grammar.c" + break; + + case 44: +#line 729 "grammar.y" + { + int result; + + (yyvsp[0].modifier).flags |= STRING_FLAGS_REGEXP; + + result = yr_parser_reduce_string_declaration( + yyscanner, (yyvsp[0].modifier), (yyvsp[-4].c_string), (yyvsp[-1].sized_string), &(yyval.string)); yr_free((yyvsp[-4].c_string)); yr_free((yyvsp[-1].sized_string)); @@ -2136,20 +2306,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->current_line = 0; } -#line 2140 "grammar.c" /* yacc.c:1663 */ +#line 2310 "grammar.c" break; - case 39: -#line 625 "grammar.y" /* yacc.c:1663 */ - { + case 45: +#line 745 "grammar.y" + { compiler->current_line = yyget_lineno(yyscanner); } -#line 2148 "grammar.c" /* yacc.c:1663 */ +#line 2318 "grammar.c" break; - case 40: -#line 629 "grammar.y" /* yacc.c:1663 */ - { + case 46: +#line 749 "grammar.y" + { int result; (yyvsp[0].modifier).flags |= STRING_FLAGS_HEXADECIMAL; @@ -2164,23 +2334,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->current_line = 0; } -#line 2168 "grammar.c" /* yacc.c:1663 */ +#line 2338 "grammar.c" break; - case 41: -#line 649 "grammar.y" /* yacc.c:1663 */ - { + case 47: +#line 769 "grammar.y" + { (yyval.modifier).flags = 0; (yyval.modifier).xor_min = 0; (yyval.modifier).xor_max = 0; (yyval.modifier).alphabet = NULL; } -#line 2179 "grammar.c" /* yacc.c:1663 */ +#line 2349 "grammar.c" break; - case 42: -#line 656 "grammar.y" /* yacc.c:1663 */ - { + case 48: +#line 776 "grammar.y" + { (yyval.modifier) = (yyvsp[-1].modifier); // Only set the xor minimum and maximum if we are dealing with the @@ -2235,52 +2405,52 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyval.modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2239 "grammar.c" /* yacc.c:1663 */ +#line 2409 "grammar.c" break; - case 43: -#line 715 "grammar.y" /* yacc.c:1663 */ - { (yyval.modifier).flags = STRING_FLAGS_WIDE; } -#line 2245 "grammar.c" /* yacc.c:1663 */ + case 49: +#line 835 "grammar.y" + { (yyval.modifier).flags = STRING_FLAGS_WIDE; } +#line 2415 "grammar.c" break; - case 44: -#line 716 "grammar.y" /* yacc.c:1663 */ - { (yyval.modifier).flags = STRING_FLAGS_ASCII; } -#line 2251 "grammar.c" /* yacc.c:1663 */ + case 50: +#line 836 "grammar.y" + { (yyval.modifier).flags = STRING_FLAGS_ASCII; } +#line 2421 "grammar.c" break; - case 45: -#line 717 "grammar.y" /* yacc.c:1663 */ - { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } -#line 2257 "grammar.c" /* yacc.c:1663 */ + case 51: +#line 837 "grammar.y" + { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } +#line 2427 "grammar.c" break; - case 46: -#line 718 "grammar.y" /* yacc.c:1663 */ - { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } -#line 2263 "grammar.c" /* yacc.c:1663 */ + case 52: +#line 838 "grammar.y" + { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } +#line 2433 "grammar.c" break; - case 47: -#line 719 "grammar.y" /* yacc.c:1663 */ - { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2269 "grammar.c" /* yacc.c:1663 */ + case 53: +#line 839 "grammar.y" + { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } +#line 2439 "grammar.c" break; - case 48: -#line 721 "grammar.y" /* yacc.c:1663 */ - { + case 54: +#line 841 "grammar.y" + { (yyval.modifier).flags = STRING_FLAGS_XOR; (yyval.modifier).xor_min = 0; (yyval.modifier).xor_max = 255; } -#line 2279 "grammar.c" /* yacc.c:1663 */ +#line 2449 "grammar.c" break; - case 49: -#line 727 "grammar.y" /* yacc.c:1663 */ - { + case 55: +#line 847 "grammar.y" + { int result = ERROR_SUCCESS; if ((yyvsp[-1].integer) < 0 || (yyvsp[-1].integer) > 255) @@ -2295,12 +2465,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).xor_min = (yyvsp[-1].integer); (yyval.modifier).xor_max = (yyvsp[-1].integer); } -#line 2299 "grammar.c" /* yacc.c:1663 */ +#line 2469 "grammar.c" break; - case 50: -#line 748 "grammar.y" /* yacc.c:1663 */ - { + case 56: +#line 868 "grammar.y" + { int result = ERROR_SUCCESS; if ((yyvsp[-3].integer) < 0) @@ -2330,21 +2500,21 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).xor_min = (yyvsp[-3].integer); (yyval.modifier).xor_max = (yyvsp[-1].integer); } -#line 2334 "grammar.c" /* yacc.c:1663 */ +#line 2504 "grammar.c" break; - case 51: -#line 779 "grammar.y" /* yacc.c:1663 */ - { + case 57: +#line 899 "grammar.y" + { (yyval.modifier).flags = STRING_FLAGS_BASE64; (yyval.modifier).alphabet = sized_string_new(DEFAULT_BASE64_ALPHABET); } -#line 2343 "grammar.c" /* yacc.c:1663 */ +#line 2513 "grammar.c" break; - case 52: -#line 784 "grammar.y" /* yacc.c:1663 */ - { + case 58: +#line 904 "grammar.y" + { int result = ERROR_SUCCESS; if ((yyvsp[-1].sized_string)->length != 64) @@ -2360,21 +2530,21 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = STRING_FLAGS_BASE64; (yyval.modifier).alphabet = (yyvsp[-1].sized_string); } -#line 2364 "grammar.c" /* yacc.c:1663 */ +#line 2534 "grammar.c" break; - case 53: -#line 801 "grammar.y" /* yacc.c:1663 */ - { + case 59: +#line 921 "grammar.y" + { (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; (yyval.modifier).alphabet = sized_string_new(DEFAULT_BASE64_ALPHABET); } -#line 2373 "grammar.c" /* yacc.c:1663 */ +#line 2543 "grammar.c" break; - case 54: -#line 806 "grammar.y" /* yacc.c:1663 */ - { + case 60: +#line 926 "grammar.y" + { int result = ERROR_SUCCESS; if ((yyvsp[-1].sized_string)->length != 64) @@ -2390,18 +2560,18 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; (yyval.modifier).alphabet = (yyvsp[-1].sized_string); } -#line 2394 "grammar.c" /* yacc.c:1663 */ +#line 2564 "grammar.c" break; - case 55: -#line 825 "grammar.y" /* yacc.c:1663 */ - { (yyval.modifier).flags = 0; } -#line 2400 "grammar.c" /* yacc.c:1663 */ + case 61: +#line 945 "grammar.y" + { (yyval.modifier).flags = 0; } +#line 2570 "grammar.c" break; - case 56: -#line 827 "grammar.y" /* yacc.c:1663 */ - { + case 62: +#line 947 "grammar.y" + { if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) { fail_with_error(ERROR_DUPLICATED_MODIFIER); @@ -2411,48 +2581,48 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyvsp[-1].modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2415 "grammar.c" /* yacc.c:1663 */ +#line 2585 "grammar.c" break; - case 57: -#line 840 "grammar.y" /* yacc.c:1663 */ - { (yyval.modifier).flags = STRING_FLAGS_WIDE; } -#line 2421 "grammar.c" /* yacc.c:1663 */ + case 63: +#line 960 "grammar.y" + { (yyval.modifier).flags = STRING_FLAGS_WIDE; } +#line 2591 "grammar.c" break; - case 58: -#line 841 "grammar.y" /* yacc.c:1663 */ - { (yyval.modifier).flags = STRING_FLAGS_ASCII; } -#line 2427 "grammar.c" /* yacc.c:1663 */ + case 64: +#line 961 "grammar.y" + { (yyval.modifier).flags = STRING_FLAGS_ASCII; } +#line 2597 "grammar.c" break; - case 59: -#line 842 "grammar.y" /* yacc.c:1663 */ - { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } -#line 2433 "grammar.c" /* yacc.c:1663 */ + case 65: +#line 962 "grammar.y" + { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } +#line 2603 "grammar.c" break; - case 60: -#line 843 "grammar.y" /* yacc.c:1663 */ - { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } -#line 2439 "grammar.c" /* yacc.c:1663 */ + case 66: +#line 963 "grammar.y" + { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } +#line 2609 "grammar.c" break; - case 61: -#line 844 "grammar.y" /* yacc.c:1663 */ - { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2445 "grammar.c" /* yacc.c:1663 */ + case 67: +#line 964 "grammar.y" + { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } +#line 2615 "grammar.c" break; - case 62: -#line 848 "grammar.y" /* yacc.c:1663 */ - { (yyval.modifier).flags = 0; } -#line 2451 "grammar.c" /* yacc.c:1663 */ + case 68: +#line 968 "grammar.y" + { (yyval.modifier).flags = 0; } +#line 2621 "grammar.c" break; - case 63: -#line 850 "grammar.y" /* yacc.c:1663 */ - { + case 69: +#line 970 "grammar.y" + { if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) { fail_with_error(ERROR_DUPLICATED_MODIFIER); @@ -2462,18 +2632,18 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyvsp[-1].modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2466 "grammar.c" /* yacc.c:1663 */ +#line 2636 "grammar.c" break; - case 64: -#line 863 "grammar.y" /* yacc.c:1663 */ - { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2472 "grammar.c" /* yacc.c:1663 */ + case 70: +#line 983 "grammar.y" + { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } +#line 2642 "grammar.c" break; - case 65: -#line 868 "grammar.y" /* yacc.c:1663 */ - { + case 71: +#line 988 "grammar.y" + { YR_EXPRESSION expr; int result = ERROR_SUCCESS; @@ -2495,11 +2665,18 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); } else { - // Search for identifier within the global namespace, where the - // externals variables reside. + // Search for identifier in current rule scope. + YR_OBJECT* object = yr_hash_table_lookup( + compiler->current_internal_variables_table, + (yyvsp[0].c_string), + NULL); - YR_OBJECT* object = (YR_OBJECT*) yr_hash_table_lookup( - compiler->objects_table, (yyvsp[0].c_string), NULL); + if (object == NULL) { + // Search for identifier within the global namespace, where the + // externals variables reside. + object = (YR_OBJECT*) yr_hash_table_lookup( + compiler->objects_table, (yyvsp[0].c_string), NULL); + } YR_NAMESPACE* ns = (YR_NAMESPACE*) yr_arena_get_ptr( compiler->arena, @@ -2567,12 +2744,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2571 "grammar.c" /* yacc.c:1663 */ +#line 2748 "grammar.c" break; - case 66: -#line 963 "grammar.y" /* yacc.c:1663 */ - { + case 72: +#line 1090 "grammar.y" + { int result = ERROR_SUCCESS; YR_OBJECT* field = NULL; @@ -2619,12 +2796,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2623 "grammar.c" /* yacc.c:1663 */ +#line 2800 "grammar.c" break; - case 67: -#line 1011 "grammar.y" /* yacc.c:1663 */ - { + case 73: +#line 1138 "grammar.y" + { int result = ERROR_SUCCESS; YR_OBJECT_ARRAY* array; YR_OBJECT_DICTIONARY* dict; @@ -2683,12 +2860,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2687 "grammar.c" /* yacc.c:1663 */ +#line 2864 "grammar.c" break; - case 68: -#line 1072 "grammar.y" /* yacc.c:1663 */ - { + case 74: +#line 1199 "grammar.y" + { YR_ARENA_REF ref; int result = ERROR_SUCCESS; YR_OBJECT_FUNCTION* function; @@ -2730,24 +2907,24 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2734 "grammar.c" /* yacc.c:1663 */ +#line 2911 "grammar.c" break; - case 69: -#line 1118 "grammar.y" /* yacc.c:1663 */ - { (yyval.c_string) = yr_strdup(""); } -#line 2740 "grammar.c" /* yacc.c:1663 */ + case 75: +#line 1245 "grammar.y" + { (yyval.c_string) = yr_strdup(""); } +#line 2917 "grammar.c" break; - case 70: -#line 1119 "grammar.y" /* yacc.c:1663 */ - { (yyval.c_string) = (yyvsp[0].c_string); } -#line 2746 "grammar.c" /* yacc.c:1663 */ + case 76: +#line 1246 "grammar.y" + { (yyval.c_string) = (yyvsp[0].c_string); } +#line 2923 "grammar.c" break; - case 71: -#line 1124 "grammar.y" /* yacc.c:1663 */ - { + case 77: +#line 1251 "grammar.y" + { (yyval.c_string) = (char*) yr_malloc(YR_MAX_FUNCTION_ARGS + 1); if ((yyval.c_string) == NULL) @@ -2781,12 +2958,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); assert(compiler->last_error != ERROR_SUCCESS); } } -#line 2785 "grammar.c" /* yacc.c:1663 */ +#line 2962 "grammar.c" break; - case 72: -#line 1159 "grammar.y" /* yacc.c:1663 */ - { + case 78: +#line 1286 "grammar.y" + { int result = ERROR_SUCCESS; if (strlen((yyvsp[-2].c_string)) == YR_MAX_FUNCTION_ARGS) @@ -2834,12 +3011,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.c_string) = (yyvsp[-2].c_string); } -#line 2838 "grammar.c" /* yacc.c:1663 */ +#line 3015 "grammar.c" break; - case 73: -#line 1212 "grammar.y" /* yacc.c:1663 */ - { + case 79: +#line 1339 "grammar.y" + { SIZED_STRING* sized_string = (yyvsp[0].sized_string); YR_ARENA_REF re_ref; RE_ERROR error; @@ -2877,12 +3054,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_REGEXP; } -#line 2881 "grammar.c" /* yacc.c:1663 */ +#line 3058 "grammar.c" break; - case 74: -#line 1255 "grammar.y" /* yacc.c:1663 */ - { + case 80: +#line 1382 "grammar.y" + { if ((yyvsp[0].expression).type == EXPRESSION_TYPE_STRING) { if (!YR_ARENA_IS_NULL_REF((yyvsp[0].expression).value.sized_string_ref)) @@ -2901,34 +3078,32 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 2905 "grammar.c" /* yacc.c:1663 */ +#line 3082 "grammar.c" break; - case 75: -#line 1278 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_PUSH, 1, NULL, NULL)); + case 81: +#line 1405 "grammar.y" + { + fail_if_error(yr_parser_emit_push_const(yyscanner, 1)); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 2916 "grammar.c" /* yacc.c:1663 */ +#line 3092 "grammar.c" break; - case 76: -#line 1285 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_PUSH, 0, NULL, NULL)); + case 82: +#line 1411 "grammar.y" + { + fail_if_error(yr_parser_emit_push_const(yyscanner, 0)); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 2927 "grammar.c" /* yacc.c:1663 */ +#line 3102 "grammar.c" break; - case 77: -#line 1292 "grammar.y" /* yacc.c:1663 */ - { + case 83: +#line 1417 "grammar.y" + { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "matches"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_REGEXP, "matches"); @@ -2939,12 +3114,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 2943 "grammar.c" /* yacc.c:1663 */ +#line 3118 "grammar.c" break; - case 78: -#line 1304 "grammar.y" /* yacc.c:1663 */ - { + case 84: +#line 1429 "grammar.y" + { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "contains"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "contains"); @@ -2953,12 +3128,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 2957 "grammar.c" /* yacc.c:1663 */ +#line 3132 "grammar.c" break; - case 79: -#line 1314 "grammar.y" /* yacc.c:1663 */ - { + case 85: +#line 1439 "grammar.y" + { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[0].c_string), @@ -2971,12 +3146,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 2975 "grammar.c" /* yacc.c:1663 */ +#line 3150 "grammar.c" break; - case 80: -#line 1328 "grammar.y" /* yacc.c:1663 */ - { + case 86: +#line 1453 "grammar.y" + { int result; check_type_with_cleanup((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "at", yr_free((yyvsp[-2].c_string))); @@ -2990,12 +3165,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 2994 "grammar.c" /* yacc.c:1663 */ +#line 3169 "grammar.c" break; - case 81: -#line 1343 "grammar.y" /* yacc.c:1663 */ - { + case 87: +#line 1468 "grammar.y" + { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-2].c_string), OP_FOUND_IN, YR_UNDEFINED); @@ -3005,12 +3180,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3009 "grammar.c" /* yacc.c:1663 */ +#line 3184 "grammar.c" break; - case 82: -#line 1354 "grammar.y" /* yacc.c:1663 */ - { + case 88: +#line 1479 "grammar.y" + { int i; // Free all the loop variable identifiers, including the variables for @@ -3028,12 +3203,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->loop_index = -1; YYERROR; } -#line 3032 "grammar.c" /* yacc.c:1663 */ +#line 3207 "grammar.c" break; - case 83: -#line 1432 "grammar.y" /* yacc.c:1663 */ - { + case 89: +#line 1557 "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, // like var_frame + 0, var_frame + 1, etc. Here we initialize var_frame @@ -3070,12 +3245,12 @@ 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 3074 "grammar.c" /* yacc.c:1663 */ +#line 3249 "grammar.c" break; - case 84: -#line 1470 "grammar.y" /* yacc.c:1663 */ - { + case 90: +#line 1595 "grammar.y" + { YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; YR_FIXUP* fixup; @@ -3124,12 +3299,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); loop_ctx->start_ref = loop_start_ref; } -#line 3128 "grammar.c" /* yacc.c:1663 */ +#line 3303 "grammar.c" break; - case 85: -#line 1520 "grammar.y" /* yacc.c:1663 */ - { + case 91: +#line 1645 "grammar.y" + { int32_t jmp_offset; YR_FIXUP* fixup; YR_ARENA_REF pop_ref; @@ -3238,12 +3413,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3242 "grammar.c" /* yacc.c:1663 */ +#line 3417 "grammar.c" break; - case 86: -#line 1630 "grammar.y" /* yacc.c:1663 */ - { + case 92: +#line 1755 "grammar.y" + { YR_ARENA_REF ref; int result = ERROR_SUCCESS; @@ -3277,12 +3452,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->loop[compiler->loop_index].vars_internal_count = \ YR_INTERNAL_LOOP_VARS; } -#line 3281 "grammar.c" /* yacc.c:1663 */ +#line 3456 "grammar.c" break; - case 87: -#line 1665 "grammar.y" /* yacc.c:1663 */ - { + case 93: +#line 1790 "grammar.y" + { int var_frame = 0; compiler->loop_for_of_var_index = -1; @@ -3336,32 +3511,32 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3340 "grammar.c" /* yacc.c:1663 */ +#line 3515 "grammar.c" break; - case 88: -#line 1720 "grammar.y" /* yacc.c:1663 */ - { + case 94: +#line 1845 "grammar.y" + { yr_parser_emit(yyscanner, OP_OF, NULL); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3350 "grammar.c" /* yacc.c:1663 */ +#line 3525 "grammar.c" break; - case 89: -#line 1726 "grammar.y" /* yacc.c:1663 */ - { + case 95: +#line 1851 "grammar.y" + { yr_parser_emit(yyscanner, OP_NOT, NULL); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3360 "grammar.c" /* yacc.c:1663 */ +#line 3535 "grammar.c" break; - case 90: -#line 1732 "grammar.y" /* yacc.c:1663 */ - { + case 96: +#line 1857 "grammar.y" + { YR_FIXUP* fixup; YR_ARENA_REF jmp_offset_ref; @@ -3382,12 +3557,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fixup->next = compiler->fixup_stack_head; compiler->fixup_stack_head = fixup; } -#line 3386 "grammar.c" /* yacc.c:1663 */ +#line 3561 "grammar.c" break; - case 91: -#line 1754 "grammar.y" /* yacc.c:1663 */ - { + case 97: +#line 1879 "grammar.y" + { YR_FIXUP* fixup; fail_if_error(yr_parser_emit(yyscanner, OP_AND, NULL)); @@ -3409,12 +3584,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3413 "grammar.c" /* yacc.c:1663 */ +#line 3588 "grammar.c" break; - case 92: -#line 1777 "grammar.y" /* yacc.c:1663 */ - { + case 98: +#line 1902 "grammar.y" + { YR_FIXUP* fixup; YR_ARENA_REF jmp_offset_ref; @@ -3434,12 +3609,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fixup->next = compiler->fixup_stack_head; compiler->fixup_stack_head = fixup; } -#line 3438 "grammar.c" /* yacc.c:1663 */ +#line 3613 "grammar.c" break; - case 93: -#line 1798 "grammar.y" /* yacc.c:1663 */ - { + case 99: +#line 1923 "grammar.y" + { YR_FIXUP* fixup; fail_if_error(yr_parser_emit(yyscanner, OP_OR, NULL)); @@ -3461,94 +3636,86 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3465 "grammar.c" /* yacc.c:1663 */ +#line 3640 "grammar.c" break; - case 94: -#line 1821 "grammar.y" /* yacc.c:1663 */ - { + case 100: +#line 1946 "grammar.y" + { fail_if_error(yr_parser_reduce_operation( yyscanner, "<", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3476 "grammar.c" /* yacc.c:1663 */ +#line 3651 "grammar.c" break; - case 95: -#line 1828 "grammar.y" /* yacc.c:1663 */ - { + case 101: +#line 1953 "grammar.y" + { fail_if_error(yr_parser_reduce_operation( yyscanner, ">", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3487 "grammar.c" /* yacc.c:1663 */ +#line 3662 "grammar.c" break; - case 96: -#line 1835 "grammar.y" /* yacc.c:1663 */ - { + case 102: +#line 1960 "grammar.y" + { fail_if_error(yr_parser_reduce_operation( yyscanner, "<=", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3498 "grammar.c" /* yacc.c:1663 */ +#line 3673 "grammar.c" break; - case 97: -#line 1842 "grammar.y" /* yacc.c:1663 */ - { + case 103: +#line 1967 "grammar.y" + { fail_if_error(yr_parser_reduce_operation( yyscanner, ">=", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3509 "grammar.c" /* yacc.c:1663 */ +#line 3684 "grammar.c" break; - case 98: -#line 1849 "grammar.y" /* yacc.c:1663 */ - { + case 104: +#line 1974 "grammar.y" + { fail_if_error(yr_parser_reduce_operation( yyscanner, "==", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3520 "grammar.c" /* yacc.c:1663 */ +#line 3695 "grammar.c" break; - case 99: -#line 1856 "grammar.y" /* yacc.c:1663 */ - { + case 105: +#line 1981 "grammar.y" + { fail_if_error(yr_parser_reduce_operation( yyscanner, "!=", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3531 "grammar.c" /* yacc.c:1663 */ - break; - - case 100: -#line 1863 "grammar.y" /* yacc.c:1663 */ - { - (yyval.expression) = (yyvsp[0].expression); - } -#line 3539 "grammar.c" /* yacc.c:1663 */ +#line 3706 "grammar.c" break; - case 101: -#line 1867 "grammar.y" /* yacc.c:1663 */ - { + case 106: +#line 1988 "grammar.y" + { (yyval.expression) = (yyvsp[-1].expression); } -#line 3547 "grammar.c" /* yacc.c:1663 */ +#line 3714 "grammar.c" break; - case 102: -#line 1875 "grammar.y" /* yacc.c:1663 */ - { + case 107: +#line 1996 "grammar.y" + { int result = ERROR_SUCCESS; YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; @@ -3567,12 +3734,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); assert(loop_ctx->vars_count <= YR_MAX_LOOP_VARS); } -#line 3571 "grammar.c" /* yacc.c:1663 */ +#line 3738 "grammar.c" break; - case 103: -#line 1895 "grammar.y" /* yacc.c:1663 */ - { + case 108: +#line 2016 "grammar.y" + { int result = ERROR_SUCCESS; YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; @@ -3596,12 +3763,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); loop_ctx->vars[loop_ctx->vars_count++].identifier.ptr = (yyvsp[0].c_string); } -#line 3600 "grammar.c" /* yacc.c:1663 */ +#line 3767 "grammar.c" break; - case 104: -#line 1923 "grammar.y" /* yacc.c:1663 */ - { + case 109: +#line 2044 "grammar.y" + { YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; // Initially we assume that the identifier is from a non-iterable type, @@ -3674,12 +3841,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3678 "grammar.c" /* yacc.c:1663 */ +#line 3845 "grammar.c" break; - case 105: -#line 1997 "grammar.y" /* yacc.c:1663 */ - { + case 110: +#line 2118 "grammar.y" + { int result = ERROR_SUCCESS; YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; @@ -3702,34 +3869,33 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3706 "grammar.c" /* yacc.c:1663 */ +#line 3873 "grammar.c" break; - case 106: -#line 2025 "grammar.y" /* yacc.c:1663 */ - { + case 111: +#line 2146 "grammar.y" + { // $2 contains the number of integers in the enumeration - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_PUSH, (yyvsp[-1].integer), NULL, NULL)); + fail_if_error(yr_parser_emit_push_const(yyscanner, (yyvsp[-1].integer))); fail_if_error(yr_parser_emit( yyscanner, OP_ITER_START_INT_ENUM, NULL)); } -#line 3719 "grammar.c" /* yacc.c:1663 */ +#line 3885 "grammar.c" break; - case 107: -#line 2034 "grammar.y" /* yacc.c:1663 */ - { + case 112: +#line 2154 "grammar.y" + { fail_if_error(yr_parser_emit( yyscanner, OP_ITER_START_INT_RANGE, NULL)); } -#line 3728 "grammar.c" /* yacc.c:1663 */ +#line 3894 "grammar.c" break; - case 108: -#line 2043 "grammar.y" /* yacc.c:1663 */ - { + case 113: +#line 2163 "grammar.y" + { int result = ERROR_SUCCESS; if ((yyvsp[-3].expression).type != EXPRESSION_TYPE_INTEGER) @@ -3748,12 +3914,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3752 "grammar.c" /* yacc.c:1663 */ +#line 3918 "grammar.c" break; - case 109: -#line 2067 "grammar.y" /* yacc.c:1663 */ - { + case 114: +#line 2187 "grammar.y" + { int result = ERROR_SUCCESS; if ((yyvsp[0].expression).type != EXPRESSION_TYPE_INTEGER) @@ -3767,12 +3933,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = 1; } -#line 3771 "grammar.c" /* yacc.c:1663 */ +#line 3937 "grammar.c" break; - case 110: -#line 2082 "grammar.y" /* yacc.c:1663 */ - { + case 115: +#line 2202 "grammar.y" + { int result = ERROR_SUCCESS; if ((yyvsp[0].expression).type != EXPRESSION_TYPE_INTEGER) @@ -3786,101 +3952,141 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = (yyvsp[-2].integer) + 1; } -#line 3790 "grammar.c" /* yacc.c:1663 */ +#line 3956 "grammar.c" break; - case 111: -#line 2101 "grammar.y" /* yacc.c:1663 */ - { + case 116: +#line 2221 "grammar.y" + { // Push end-of-list marker - yr_parser_emit_with_arg(yyscanner, OP_PUSH, YR_UNDEFINED, NULL, NULL); + yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); } -#line 3799 "grammar.c" /* yacc.c:1663 */ +#line 3965 "grammar.c" break; - case 113: -#line 2107 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_PUSH, YR_UNDEFINED, NULL, NULL)); + case 118: +#line 2227 "grammar.y" + { + fail_if_error(yr_parser_emit_push_const(yyscanner, YR_UNDEFINED)); fail_if_error(yr_parser_emit_pushes_for_strings( yyscanner, "$*")); } -#line 3811 "grammar.c" /* yacc.c:1663 */ +#line 3976 "grammar.c" break; - case 116: -#line 2125 "grammar.y" /* yacc.c:1663 */ - { + case 121: +#line 2244 "grammar.y" + { int result = yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[0].c_string)); yr_free((yyvsp[0].c_string)); fail_if_error(result); } -#line 3822 "grammar.c" /* yacc.c:1663 */ +#line 3987 "grammar.c" break; - case 117: -#line 2132 "grammar.y" /* yacc.c:1663 */ - { + case 122: +#line 2251 "grammar.y" + { int result = yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[0].c_string)); yr_free((yyvsp[0].c_string)); fail_if_error(result); } -#line 3833 "grammar.c" /* yacc.c:1663 */ +#line 3998 "grammar.c" break; - case 118: -#line 2143 "grammar.y" /* yacc.c:1663 */ - { + case 123: +#line 2262 "grammar.y" + { (yyval.integer) = FOR_EXPRESSION_ANY; } -#line 3841 "grammar.c" /* yacc.c:1663 */ +#line 4006 "grammar.c" break; - case 119: -#line 2147 "grammar.y" /* yacc.c:1663 */ - { - yr_parser_emit_with_arg(yyscanner, OP_PUSH, YR_UNDEFINED, NULL, NULL); + case 124: +#line 2266 "grammar.y" + { + yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); (yyval.integer) = FOR_EXPRESSION_ALL; } -#line 3850 "grammar.c" /* yacc.c:1663 */ +#line 4015 "grammar.c" break; - case 120: -#line 2152 "grammar.y" /* yacc.c:1663 */ - { - yr_parser_emit_with_arg(yyscanner, OP_PUSH, 1, NULL, NULL); + case 125: +#line 2271 "grammar.y" + { + yr_parser_emit_push_const(yyscanner, 1); (yyval.integer) = FOR_EXPRESSION_ANY; } -#line 3859 "grammar.c" /* yacc.c:1663 */ +#line 4024 "grammar.c" break; - case 121: -#line 2161 "grammar.y" /* yacc.c:1663 */ - { + case 126: +#line 2279 "grammar.y" + { + int result = ERROR_SUCCESS; + + if ((yyvsp[0].expression).type == EXPRESSION_TYPE_OBJECT) + { + result = yr_parser_emit( + yyscanner, OP_OBJ_VALUE, NULL); + + switch((yyvsp[0].expression).value.object->type) + { + case OBJECT_TYPE_INTEGER: + case OBJECT_TYPE_FLOAT: + case OBJECT_TYPE_STRING: + (yyval.expression) = (yyvsp[0].expression); + break; + default: + // In a primary expression any identifier that corresponds to an + // object must be of type integer, float or string. If "foobar" is + // either a function, structure, dictionary or array you can not + // use it as: + // condition: foobar + yr_compiler_set_error_extra_info_fmt( + compiler, + "wrong usage of identifier \"%s\"", + expression_identifier((yyvsp[0].expression))); + + result = ERROR_WRONG_TYPE; + } + } + else + { + (yyval.expression) = (yyvsp[0].expression); + } + + fail_if_error(result); + } +#line 4065 "grammar.c" + break; + + case 127: +#line 2318 "grammar.y" + { (yyval.expression) = (yyvsp[-1].expression); } -#line 3867 "grammar.c" /* yacc.c:1663 */ +#line 4073 "grammar.c" break; - case 122: -#line 2165 "grammar.y" /* yacc.c:1663 */ - { + case 128: +#line 2322 "grammar.y" + { fail_if_error(yr_parser_emit( yyscanner, OP_FILESIZE, NULL)); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 3879 "grammar.c" /* yacc.c:1663 */ +#line 4085 "grammar.c" break; - case 123: -#line 2173 "grammar.y" /* yacc.c:1663 */ - { + case 129: +#line 2330 "grammar.y" + { yywarning(yyscanner, "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " "function from PE module instead."); @@ -3891,12 +4097,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 3895 "grammar.c" /* yacc.c:1663 */ +#line 4101 "grammar.c" break; - case 124: -#line 2185 "grammar.y" /* yacc.c:1663 */ - { + case 130: +#line 2342 "grammar.y" + { check_type((yyvsp[-1].expression), EXPRESSION_TYPE_INTEGER, "intXXXX or uintXXXX"); // _INTEGER_FUNCTION_ could be any of int8, int16, int32, uint8, @@ -3909,35 +4115,34 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 3913 "grammar.c" /* yacc.c:1663 */ +#line 4119 "grammar.c" break; - case 125: -#line 2199 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_PUSH, (yyvsp[0].integer), NULL, NULL)); + case 131: +#line 2356 "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 3925 "grammar.c" /* yacc.c:1663 */ +#line 4130 "grammar.c" break; - case 126: -#line 2207 "grammar.y" /* yacc.c:1663 */ - { + case 132: +#line 2363 "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 3936 "grammar.c" /* yacc.c:1663 */ +#line 4141 "grammar.c" break; - case 127: -#line 2214 "grammar.y" /* yacc.c:1663 */ - { + case 133: +#line 2370 "grammar.y" + { YR_ARENA_REF ref; int result = _yr_compiler_store_data( @@ -3961,12 +4166,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_STRING; (yyval.expression).value.sized_string_ref = ref; } -#line 3965 "grammar.c" /* yacc.c:1663 */ +#line 4170 "grammar.c" break; - case 128: -#line 2239 "grammar.y" /* yacc.c:1663 */ - { + case 134: +#line 2395 "grammar.y" + { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[0].c_string), OP_COUNT, YR_UNDEFINED); @@ -3977,12 +4182,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 3981 "grammar.c" /* yacc.c:1663 */ +#line 4186 "grammar.c" break; - case 129: -#line 2251 "grammar.y" /* yacc.c:1663 */ - { + case 135: +#line 2407 "grammar.y" + { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-3].c_string), OP_OFFSET, YR_UNDEFINED); @@ -3993,14 +4198,13 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 3997 "grammar.c" /* yacc.c:1663 */ +#line 4202 "grammar.c" break; - case 130: -#line 2263 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_emit_with_arg( - yyscanner, OP_PUSH, 1, NULL, NULL); + case 136: +#line 2419 "grammar.y" + { + int result = yr_parser_emit_push_const(yyscanner, 1); if (result == ERROR_SUCCESS) result = yr_parser_reduce_string_identifier( @@ -4013,12 +4217,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4017 "grammar.c" /* yacc.c:1663 */ +#line 4221 "grammar.c" break; - case 131: -#line 2279 "grammar.y" /* yacc.c:1663 */ - { + case 137: +#line 2434 "grammar.y" + { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-3].c_string), OP_LENGTH, YR_UNDEFINED); @@ -4029,14 +4233,13 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4033 "grammar.c" /* yacc.c:1663 */ +#line 4237 "grammar.c" break; - case 132: -#line 2291 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_emit_with_arg( - yyscanner, OP_PUSH, 1, NULL, NULL); + case 138: +#line 2446 "grammar.y" + { + int result = yr_parser_emit_push_const(yyscanner, 1); if (result == ERROR_SUCCESS) result = yr_parser_reduce_string_identifier( @@ -4049,12 +4252,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4053 "grammar.c" /* yacc.c:1663 */ +#line 4256 "grammar.c" break; - case 133: -#line 2307 "grammar.y" /* yacc.c:1663 */ - { + case 139: +#line 2461 "grammar.y" + { int result = ERROR_SUCCESS; if ((yyvsp[0].expression).type == EXPRESSION_TYPE_OBJECT) @@ -4075,12 +4278,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_STRING; (yyval.expression).value.sized_string_ref = YR_ARENA_NULL_REF; break; + case OBJECT_TYPE_STRUCTURE: + (yyval.expression).type = EXPRESSION_TYPE_OBJECT; + (yyval.expression).value.object = (yyvsp[0].expression).value.object; + break; default: - // In a primary expression any identifier that corresponds to an - // object must be of type integer, float or string. If "foobar" is - // either a function, structure, dictionary or array you can not - // use it as: - // condition: foobar yr_compiler_set_error_extra_info_fmt( compiler, "wrong usage of identifier \"%s\"", @@ -4096,12 +4298,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4100 "grammar.c" /* yacc.c:1663 */ +#line 4302 "grammar.c" break; - case 134: -#line 2350 "grammar.y" /* yacc.c:1663 */ - { + case 140: +#line 2503 "grammar.y" + { int result = ERROR_SUCCESS; check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER | EXPRESSION_TYPE_FLOAT, "-"); @@ -4121,12 +4323,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4125 "grammar.c" /* yacc.c:1663 */ +#line 4327 "grammar.c" break; - case 135: -#line 2371 "grammar.y" /* yacc.c:1663 */ - { + case 141: +#line 2524 "grammar.y" + { int result = yr_parser_reduce_operation( yyscanner, "+", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4160,12 +4362,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4164 "grammar.c" /* yacc.c:1663 */ +#line 4366 "grammar.c" break; - case 136: -#line 2406 "grammar.y" /* yacc.c:1663 */ - { + case 142: +#line 2559 "grammar.y" + { int result = yr_parser_reduce_operation( yyscanner, "-", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4199,12 +4401,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4203 "grammar.c" /* yacc.c:1663 */ +#line 4405 "grammar.c" break; - case 137: -#line 2441 "grammar.y" /* yacc.c:1663 */ - { + case 143: +#line 2594 "grammar.y" + { int result = yr_parser_reduce_operation( yyscanner, "*", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4237,12 +4439,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4241 "grammar.c" /* yacc.c:1663 */ +#line 4443 "grammar.c" break; - case 138: -#line 2475 "grammar.y" /* yacc.c:1663 */ - { + case 144: +#line 2628 "grammar.y" + { int result = yr_parser_reduce_operation( yyscanner, "\\", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4266,12 +4468,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4270 "grammar.c" /* yacc.c:1663 */ +#line 4472 "grammar.c" break; - case 139: -#line 2500 "grammar.y" /* yacc.c:1663 */ - { + case 145: +#line 2653 "grammar.y" + { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "%"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "%"); @@ -4287,12 +4489,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(ERROR_DIVISION_BY_ZERO); } } -#line 4291 "grammar.c" /* yacc.c:1663 */ +#line 4493 "grammar.c" break; - case 140: -#line 2517 "grammar.y" /* yacc.c:1663 */ - { + case 146: +#line 2670 "grammar.y" + { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); @@ -4301,12 +4503,12 @@ 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); } -#line 4305 "grammar.c" /* yacc.c:1663 */ +#line 4507 "grammar.c" break; - case 141: -#line 2527 "grammar.y" /* yacc.c:1663 */ - { + case 147: +#line 2680 "grammar.y" + { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); @@ -4315,12 +4517,12 @@ 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); } -#line 4319 "grammar.c" /* yacc.c:1663 */ +#line 4521 "grammar.c" break; - case 142: -#line 2537 "grammar.y" /* yacc.c:1663 */ - { + case 148: +#line 2690 "grammar.y" + { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "|"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "|"); @@ -4329,12 +4531,12 @@ 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); } -#line 4333 "grammar.c" /* yacc.c:1663 */ +#line 4535 "grammar.c" break; - case 143: -#line 2547 "grammar.y" /* yacc.c:1663 */ - { + case 149: +#line 2700 "grammar.y" + { check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "~"); fail_if_error(yr_parser_emit(yyscanner, OP_BITWISE_NOT, NULL)); @@ -4343,12 +4545,12 @@ 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 4347 "grammar.c" /* yacc.c:1663 */ +#line 4549 "grammar.c" break; - case 144: -#line 2557 "grammar.y" /* yacc.c:1663 */ - { + case 150: +#line 2710 "grammar.y" + { int result; check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "<<"); @@ -4367,12 +4569,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4371 "grammar.c" /* yacc.c:1663 */ +#line 4573 "grammar.c" break; - case 145: -#line 2577 "grammar.y" /* yacc.c:1663 */ - { + case 151: +#line 2730 "grammar.y" + { int result; check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, ">>"); @@ -4391,19 +4593,52 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4395 "grammar.c" /* yacc.c:1663 */ +#line 4597 "grammar.c" break; - case 146: -#line 2597 "grammar.y" /* yacc.c:1663 */ - { + case 152: +#line 2750 "grammar.y" + { + (yyval.expression) = (yyvsp[0].expression); + } +#line 4605 "grammar.c" + break; + + case 153: +#line 2757 "grammar.y" + { (yyval.expression) = (yyvsp[0].expression); } -#line 4403 "grammar.c" /* yacc.c:1663 */ +#line 4613 "grammar.c" break; + case 154: +#line 2761 "grammar.y" + { + (yyval.expression) = (yyvsp[0].expression); + } +#line 4621 "grammar.c" + break; + + case 155: +#line 2768 "grammar.y" + { + (yyval.expression) = (yyvsp[0].expression); + } +#line 4629 "grammar.c" + break; + + case 156: +#line 2772 "grammar.y" + { + (yyval.expression) = (yyvsp[0].expression); + } +#line 4637 "grammar.c" + break; + + +#line 4641 "grammar.c" -#line 4407 "grammar.c" /* yacc.c:1663 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4417,25 +4652,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); case of YYERROR or YYBACKUP, subsequent parser actions might lead to an incorrect destructor call or verbose syntax error message before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; - YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + } goto yynewstate; @@ -4446,59 +4679,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yyerrlab: /* Make sure we have latest lookahead translation. See comments at user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - + yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; -#if ! YYERROR_VERBOSE yyerror (yyscanner, compiler, YY_("syntax error")); -#else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) - { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (yyscanner, compiler, yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; - } -# undef YYSYNTAX_ERROR -#endif } - - if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an error, discard it. */ - if (yychar <= YYEOF) + if (yychar <= _END_OF_FILE_) { /* Return failure if at end of input. */ - if (yychar == YYEOF) + if (yychar == _END_OF_FILE_) YYABORT; } else @@ -4518,12 +4715,10 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -4540,13 +4735,14 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ + /* Pop stack until we find a state that shifts the error token. */ for (;;) { yyn = yypact[yystate]; if (!yypact_value_is_default (yyn)) { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + yyn += YYSYMBOL_YYerror; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) { yyn = yytable[yyn]; if (0 < yyn) @@ -4560,7 +4756,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yydestruct ("Error: popping", - yystos[yystate], yyvsp, yyscanner, compiler); + YY_ACCESSING_SYMBOL (yystate), yyvsp, yyscanner, compiler); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -4572,7 +4768,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -4585,6 +4781,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -4592,7 +4789,8 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yyresult = 1; goto yyreturn; -#if !defined yyoverflow || YYERROR_VERBOSE + +#if !defined yyoverflow /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -4602,6 +4800,10 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); /* Fall through. */ #endif + +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -4618,17 +4820,16 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, yyscanner, compiler); + YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, yyscanner, compiler); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif + return yyresult; } -#line 2602 "grammar.y" /* yacc.c:1907 */ + +#line 2777 "grammar.y" + diff --git a/libyara/grammar.h b/libyara/grammar.h index 367434dd4f..ba49ea9edf 100644 --- a/libyara/grammar.h +++ b/libyara/grammar.h @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.5. */ +/* A Bison parser, made by GNU Bison 3.6.4. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,6 +31,10 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ +/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, + especially those whose name start with YY_ or yy_. They are + private implementation details that can be changed or removed. */ + #ifndef YY_YARA_YY_GRAMMAR_H_INCLUDED # define YY_YARA_YY_GRAMMAR_H_INCLUDED /* Debug traces. */ @@ -40,69 +45,76 @@ extern int yara_yydebug; #endif -/* Token type. */ +/* Token kinds. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE enum yytokentype { - _END_OF_FILE_ = 0, - _END_OF_INCLUDED_FILE_ = 258, - _DOT_DOT_ = 259, - _RULE_ = 260, - _PRIVATE_ = 261, - _GLOBAL_ = 262, - _META_ = 263, - _STRINGS_ = 264, - _CONDITION_ = 265, - _IDENTIFIER_ = 266, - _STRING_IDENTIFIER_ = 267, - _STRING_COUNT_ = 268, - _STRING_OFFSET_ = 269, - _STRING_LENGTH_ = 270, - _STRING_IDENTIFIER_WITH_WILDCARD_ = 271, - _NUMBER_ = 272, - _DOUBLE_ = 273, - _INTEGER_FUNCTION_ = 274, - _TEXT_STRING_ = 275, - _HEX_STRING_ = 276, - _REGEXP_ = 277, - _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, - _IN_ = 290, - _OF_ = 291, - _FOR_ = 292, - _THEM_ = 293, - _MATCHES_ = 294, - _CONTAINS_ = 295, - _IMPORT_ = 296, - _TRUE_ = 297, - _FALSE_ = 298, - _OR_ = 299, - _AND_ = 300, - _NOT_ = 301, - _EQ_ = 302, - _NEQ_ = 303, - _LT_ = 304, - _LE_ = 305, - _GT_ = 306, - _GE_ = 307, - _SHIFT_LEFT_ = 308, - _SHIFT_RIGHT_ = 309, - UNARY_MINUS = 310 + YYEMPTY = -2, + _END_OF_FILE_ = 0, /* "end of file" */ + YYerror = 256, /* error */ + YYUNDEF = 257, /* "invalid token" */ + _END_OF_INCLUDED_FILE_ = 258, /* "end of included file" */ + _DOT_DOT_ = 259, /* ".." */ + _RULE_ = 260, /* "" */ + _PRIVATE_ = 261, /* "" */ + _GLOBAL_ = 262, /* "" */ + _META_ = 263, /* "" */ + _STRINGS_ = 264, /* "" */ + _VARIABLES_ = 265, /* "" */ + _CONDITION_ = 266, /* "" */ + _IDENTIFIER_ = 267, /* "identifier" */ + _STRING_IDENTIFIER_ = 268, /* "string identifier" */ + _STRING_COUNT_ = 269, /* "string count" */ + _STRING_OFFSET_ = 270, /* "string offset" */ + _STRING_LENGTH_ = 271, /* "string length" */ + _STRING_IDENTIFIER_WITH_WILDCARD_ = 272, /* "string identifier with wildcard" */ + _NUMBER_ = 273, /* "integer number" */ + _DOUBLE_ = 274, /* "floating point number" */ + _INTEGER_FUNCTION_ = 275, /* "integer function" */ + _TEXT_STRING_ = 276, /* "text string" */ + _HEX_STRING_ = 277, /* "hex string" */ + _REGEXP_ = 278, /* "regular expression" */ + _ASCII_ = 279, /* "" */ + _WIDE_ = 280, /* "" */ + _XOR_ = 281, /* "" */ + _BASE64_ = 282, /* "" */ + _BASE64_WIDE_ = 283, /* "" */ + _NOCASE_ = 284, /* "" */ + _FULLWORD_ = 285, /* "" */ + _AT_ = 286, /* "" */ + _FILESIZE_ = 287, /* "" */ + _ENTRYPOINT_ = 288, /* "" */ + _ALL_ = 289, /* "" */ + _ANY_ = 290, /* "" */ + _IN_ = 291, /* "" */ + _OF_ = 292, /* "" */ + _FOR_ = 293, /* "" */ + _THEM_ = 294, /* "" */ + _MATCHES_ = 295, /* "" */ + _CONTAINS_ = 296, /* "" */ + _IMPORT_ = 297, /* "" */ + _TRUE_ = 298, /* "" */ + _FALSE_ = 299, /* "" */ + _AND_ = 301, /* "" */ + _NOT_ = 302, /* "" */ + _EQ_ = 303, /* "==" */ + _NEQ_ = 304, /* "!=" */ + _LT_ = 305, /* "<" */ + _LE_ = 306, /* "<=" */ + _GT_ = 307, /* ">" */ + _GE_ = 308, /* ">=" */ + _SHIFT_LEFT_ = 309, /* "<<" */ + _SHIFT_RIGHT_ = 310, /* ">>" */ + UNARY_MINUS = 311 /* UNARY_MINUS */ }; + typedef enum yytokentype yytoken_kind_t; #endif -/* Tokens. */ +/* Token kinds. */ #define _END_OF_FILE_ 0 +#define YYerror 256 +#define YYUNDEF 257 #define _END_OF_INCLUDED_FILE_ 258 #define _DOT_DOT_ 259 #define _RULE_ 260 @@ -110,59 +122,59 @@ extern int yara_yydebug; #define _GLOBAL_ 262 #define _META_ 263 #define _STRINGS_ 264 -#define _CONDITION_ 265 -#define _IDENTIFIER_ 266 -#define _STRING_IDENTIFIER_ 267 -#define _STRING_COUNT_ 268 -#define _STRING_OFFSET_ 269 -#define _STRING_LENGTH_ 270 -#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 _IN_ 290 -#define _OF_ 291 -#define _FOR_ 292 -#define _THEM_ 293 -#define _MATCHES_ 294 -#define _CONTAINS_ 295 -#define _IMPORT_ 296 -#define _TRUE_ 297 -#define _FALSE_ 298 -#define _OR_ 299 -#define _AND_ 300 -#define _NOT_ 301 -#define _EQ_ 302 -#define _NEQ_ 303 -#define _LT_ 304 -#define _LE_ 305 -#define _GT_ 306 -#define _GE_ 307 -#define _SHIFT_LEFT_ 308 -#define _SHIFT_RIGHT_ 309 -#define UNARY_MINUS 310 +#define _VARIABLES_ 265 +#define _CONDITION_ 266 +#define _IDENTIFIER_ 267 +#define _STRING_IDENTIFIER_ 268 +#define _STRING_COUNT_ 269 +#define _STRING_OFFSET_ 270 +#define _STRING_LENGTH_ 271 +#define _STRING_IDENTIFIER_WITH_WILDCARD_ 272 +#define _NUMBER_ 273 +#define _DOUBLE_ 274 +#define _INTEGER_FUNCTION_ 275 +#define _TEXT_STRING_ 276 +#define _HEX_STRING_ 277 +#define _REGEXP_ 278 +#define _ASCII_ 279 +#define _WIDE_ 280 +#define _XOR_ 281 +#define _BASE64_ 282 +#define _BASE64_WIDE_ 283 +#define _NOCASE_ 284 +#define _FULLWORD_ 285 +#define _AT_ 286 +#define _FILESIZE_ 287 +#define _ENTRYPOINT_ 288 +#define _ALL_ 289 +#define _ANY_ 290 +#define _IN_ 291 +#define _OF_ 292 +#define _FOR_ 293 +#define _THEM_ 294 +#define _MATCHES_ 295 +#define _CONTAINS_ 296 +#define _IMPORT_ 297 +#define _TRUE_ 298 +#define _FALSE_ 299 +#define _OR_ 300 +#define _AND_ 301 +#define _NOT_ 302 +#define _EQ_ 303 +#define _NEQ_ 304 +#define _LT_ 305 +#define _LE_ 306 +#define _GT_ 307 +#define _GE_ 308 +#define _SHIFT_LEFT_ 309 +#define _SHIFT_RIGHT_ 310 +#define UNARY_MINUS 311 /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - union YYSTYPE { -#line 297 "grammar.y" /* yacc.c:1916 */ +#line 305 "grammar.y" YR_EXPRESSION expression; SIZED_STRING* sized_string; @@ -176,9 +188,9 @@ union YYSTYPE YR_ARENA_REF meta; YR_ARENA_REF string; -#line 180 "grammar.h" /* yacc.c:1916 */ -}; +#line 192 "grammar.h" +}; typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 diff --git a/libyara/grammar.y b/libyara/grammar.y index 79f61fe6c5..f89b9cbc1a 100644 --- a/libyara/grammar.y +++ b/libyara/grammar.y @@ -166,6 +166,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %token _GLOBAL_ "" %token _META_ "" %token _STRINGS_ "" +%token _VARIABLES_ "" %token _CONDITION_ "" %token _IDENTIFIER_ "identifier" %token _STRING_IDENTIFIER_ "string identifier" @@ -229,6 +230,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %type rule +%type variables +%type variable_declaration +%type variable_declarations + %type strings %type string_declaration %type string_declarations @@ -256,8 +261,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %type rule_modifiers %type primary_expression +%type nonprimary_expression +%type complex_expression %type boolean_expression %type expression +%type object %type identifier %type regexp @@ -343,7 +351,7 @@ rule fail_if_error(yr_parser_reduce_rule_declaration_phase_1( yyscanner, (int32_t) $1, $3, &$$)); } - tags '{' meta strings + tags '{' meta strings variables { YR_RULE* rule = (YR_RULE*) yr_arena_ref_to_ptr( compiler->arena, &$4); @@ -406,6 +414,16 @@ strings } ; +variables + : /* empty */ + { + $$.type = EXPRESSION_TYPE_UNKNOWN; + } + | _VARIABLES_ ':' variable_declarations + { + $$ = $3; + } + ; condition : _CONDITION_ ':' boolean_expression @@ -577,6 +595,108 @@ meta_declaration } ; +variable_declarations + : variable_declaration { $$ = $1; } + | variable_declarations variable_declaration { $$ = $1; } + ; + +variable_declaration + : _IDENTIFIER_ '=' + { + compiler->current_line = yyget_lineno(yyscanner); + } + object + { + YR_INTERNAL_VARIABLE* int_var; + YR_ARENA_REF int_ref; + YR_ARENA_REF identifier_ref; + + // Check for duplicated identifier in scope with external variables + YR_OBJECT* object = (YR_OBJECT*)yr_hash_table_lookup( + compiler->objects_table, + $1, + NULL); + + if(object != NULL) { + yywarning(yyscanner, + "External variable overrides definition of internal variable \"%s\".", + $1); + yr_parser_emit(yyscanner, OP_POP, NULL); + } else { + // Check for duplicated identifier in local rule scope + object = (YR_OBJECT*)yr_hash_table_lookup( + compiler->current_internal_variables_table, + $1, + NULL); + + if(object != NULL) { + fail_with_error(ERROR_DUPLICATED_IDENTIFIER); + } + + yr_arena_allocate_struct( + compiler->arena, + YR_INTERNAL_VARIABLES_TABLE, + sizeof(YR_INTERNAL_VARIABLE), + &int_ref, + offsetof(YR_INTERNAL_VARIABLE, identifier), + EOL); + + int_var = yr_arena_ref_to_ptr(compiler->arena, &int_ref); + + _yr_compiler_store_string( + compiler, + $1, + &identifier_ref); + + int_var->identifier = yr_arena_ref_to_ptr( + compiler->arena, &identifier_ref); + int_var->rule_idx = compiler->current_rule_idx; + + switch($4.type) { + case EXPRESSION_TYPE_BOOLEAN: + case EXPRESSION_TYPE_INTEGER: + int_var->type = OBJECT_TYPE_INTEGER; + break; + case EXPRESSION_TYPE_FLOAT: + int_var->type = OBJECT_TYPE_FLOAT; + break; + case EXPRESSION_TYPE_STRING: + int_var->type = OBJECT_TYPE_STRING; + break; + case EXPRESSION_TYPE_OBJECT: + int_var->type = $4.value.object->type; + break; + } + + if($4.type == EXPRESSION_TYPE_OBJECT) { + yr_object_copy($4.value.object, &object); + } else { + yr_object_create( + int_var->type, + int_var->identifier, + NULL, + &object); + } + + FAIL_ON_ERROR_WITH_CLEANUP(yr_hash_table_add( + compiler->current_internal_variables_table, + $1, + NULL, + (void*) object), + yr_object_destroy(object)); + + // Pop value on stack to variable + yr_parser_emit_with_arg_reloc( + yyscanner, + OP_OBJ_STORE, + (void*)int_var->identifier, + NULL, + NULL); + } + + yr_free($1); + } + ; string_declarations : string_declaration { $$ = $1; } @@ -887,11 +1007,18 @@ identifier } else { - // Search for identifier within the global namespace, where the - // externals variables reside. + // Search for identifier in current rule scope. + YR_OBJECT* object = yr_hash_table_lookup( + compiler->current_internal_variables_table, + $1, + NULL); - YR_OBJECT* object = (YR_OBJECT*) yr_hash_table_lookup( - compiler->objects_table, $1, NULL); + if (object == NULL) { + // Search for identifier within the global namespace, where the + // externals variables reside. + object = (YR_OBJECT*) yr_hash_table_lookup( + compiler->objects_table, $1, NULL); + } YR_NAMESPACE* ns = (YR_NAMESPACE*) yr_arena_get_ptr( compiler->arena, @@ -1273,7 +1400,7 @@ boolean_expression } ; -expression +complex_expression : _TRUE_ { fail_if_error(yr_parser_emit_push_const(yyscanner, 1)); @@ -1857,10 +1984,6 @@ expression $$.type = EXPRESSION_TYPE_BOOLEAN; } - | primary_expression - { - $$ = $1; - } |'(' expression ')' { $$ = $2; @@ -2151,9 +2274,47 @@ for_expression } ; - primary_expression - : '(' primary_expression ')' + : nonprimary_expression + { + int result = ERROR_SUCCESS; + + if ($1.type == EXPRESSION_TYPE_OBJECT) + { + result = yr_parser_emit( + yyscanner, OP_OBJ_VALUE, NULL); + + switch($1.value.object->type) + { + case OBJECT_TYPE_INTEGER: + case OBJECT_TYPE_FLOAT: + case OBJECT_TYPE_STRING: + $$ = $1; + break; + default: + // In a primary expression any identifier that corresponds to an + // object must be of type integer, float or string. If "foobar" is + // either a function, structure, dictionary or array you can not + // use it as: + // condition: foobar + yr_compiler_set_error_extra_info_fmt( + compiler, + "wrong usage of identifier \"%s\"", + expression_identifier($1)); + + result = ERROR_WRONG_TYPE; + } + } + else + { + $$ = $1; + } + + fail_if_error(result); + } + +nonprimary_expression + : '(' nonprimary_expression ')' { $$ = $2; } @@ -2318,12 +2479,11 @@ primary_expression $$.type = EXPRESSION_TYPE_STRING; $$.value.sized_string_ref = YR_ARENA_NULL_REF; break; + case OBJECT_TYPE_STRUCTURE: + $$.type = EXPRESSION_TYPE_OBJECT; + $$.value.object = $1.value.object; + break; default: - // In a primary expression any identifier that corresponds to an - // object must be of type integer, float or string. If "foobar" is - // either a function, structure, dictionary or array you can not - // use it as: - // condition: foobar yr_compiler_set_error_extra_info_fmt( compiler, "wrong usage of identifier \"%s\"", @@ -2592,4 +2752,26 @@ primary_expression } ; +expression + : complex_expression + { + $$ = $1; + } + | primary_expression + { + $$ = $1; + } + ; + +object + : complex_expression + { + $$ = $1; + } + | nonprimary_expression + { + $$ = $1; + } + ; + %% diff --git a/libyara/include/yara/compiler.h b/libyara/include/yara/compiler.h index c7d9e55d7d..0ea93a2652 100644 --- a/libyara/include/yara/compiler.h +++ b/libyara/include/yara/compiler.h @@ -62,18 +62,19 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define YR_METAS_TABLE 2 #define YR_STRINGS_TABLE 3 #define YR_EXTERNAL_VARIABLES_TABLE 4 -#define YR_SZ_POOL 5 -#define YR_CODE_SECTION 6 -#define YR_RE_CODE_SECTION 7 -#define YR_AC_TRANSITION_TABLE 8 -#define YR_AC_STATE_MATCHES_TABLE 9 -#define YR_AC_STATE_MATCHES_POOL 10 -#define YR_SUMMARY_SECTION 11 +#define YR_INTERNAL_VARIABLES_TABLE 5 +#define YR_SZ_POOL 6 +#define YR_CODE_SECTION 7 +#define YR_RE_CODE_SECTION 8 +#define YR_AC_TRANSITION_TABLE 9 +#define YR_AC_STATE_MATCHES_TABLE 10 +#define YR_AC_STATE_MATCHES_POOL 11 +#define YR_SUMMARY_SECTION 12 // This is the number of buffers used by the compiler, should match the number // of items in the list above. -#define YR_NUM_SECTIONS 12 +#define YR_NUM_SECTIONS 13 // Number of variables used by loops. This doesn't include user defined @@ -182,6 +183,9 @@ typedef struct _YR_COMPILER // YR_EXTERNAL_VARIABLES_TABLE: // An array of YR_EXTERNAL_VARIABLE structures, one per each external // variable defined. + // YR_INTERNAL_VARIABLES_TABLE: + // An array of YR_INTERNAL_VARIABLE structures, one per each internal + // variable defined. // YR_SZ_POOL: // A collection of null-terminated strings. This buffer contains // identifiers, literal strings, and in general any null-terminated @@ -242,6 +246,7 @@ typedef struct _YR_COMPILER YR_HASH_TABLE* rules_table; YR_HASH_TABLE* objects_table; YR_HASH_TABLE* strings_table; + YR_HASH_TABLE* current_internal_variables_table; // Hash table that contains all the strings that has been written to the // YR_SZ_POOL buffer in the compiler's arena. Values in the hash table are diff --git a/libyara/include/yara/exec.h b/libyara/include/yara/exec.h index da461faa4c..4950e2cde0 100644 --- a/libyara/include/yara/exec.h +++ b/libyara/include/yara/exec.h @@ -59,54 +59,55 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define OP_POP 14 #define OP_CALL 15 #define OP_OBJ_LOAD 16 -#define OP_OBJ_VALUE 17 -#define OP_OBJ_FIELD 18 -#define OP_INDEX_ARRAY 19 -#define OP_COUNT 20 -#define OP_LENGTH 21 -#define OP_FOUND 22 -#define OP_FOUND_AT 23 -#define OP_FOUND_IN 24 -#define OP_OFFSET 25 -#define OP_OF 26 -#define OP_PUSH_RULE 27 -#define OP_INIT_RULE 28 -#define OP_MATCH_RULE 29 -#define OP_INCR_M 30 -#define OP_CLEAR_M 31 -#define OP_ADD_M 32 -#define OP_POP_M 33 -#define OP_PUSH_M 34 -#define OP_SET_M 35 -#define OP_SWAPUNDEF 36 -#define OP_FILESIZE 37 -#define OP_ENTRYPOINT 38 -#define OP_CONTAINS 39 -#define OP_MATCHES 40 -#define OP_IMPORT 41 -#define OP_LOOKUP_DICT 42 -#define OP_JUNDEF 43 /* Not used */ -#define OP_JUNDEF_P 44 -#define OP_JNUNDEF 45 -#define OP_JNUNDEF_P 46 /* Not used */ -#define OP_JFALSE 47 -#define OP_JFALSE_P 48 -#define OP_JTRUE 49 -#define OP_JTRUE_P 50 -#define OP_JL_P 51 -#define OP_JLE_P 52 -#define OP_ITER_NEXT 53 -#define OP_ITER_START_ARRAY 54 -#define OP_ITER_START_DICT 55 -#define OP_ITER_START_INT_RANGE 56 -#define OP_ITER_START_INT_ENUM 57 -#define OP_JZ 58 -#define OP_JZ_P 59 - -#define OP_PUSH_8 60 -#define OP_PUSH_16 61 -#define OP_PUSH_32 62 -#define OP_PUSH_U 63 +#define OP_OBJ_STORE 17 +#define OP_OBJ_VALUE 18 +#define OP_OBJ_FIELD 19 +#define OP_INDEX_ARRAY 20 +#define OP_COUNT 21 +#define OP_LENGTH 22 +#define OP_FOUND 23 +#define OP_FOUND_AT 24 +#define OP_FOUND_IN 25 +#define OP_OFFSET 26 +#define OP_OF 27 +#define OP_PUSH_RULE 28 +#define OP_INIT_RULE 29 +#define OP_MATCH_RULE 30 +#define OP_INCR_M 31 +#define OP_CLEAR_M 32 +#define OP_ADD_M 33 +#define OP_POP_M 34 +#define OP_PUSH_M 35 +#define OP_SET_M 36 +#define OP_SWAPUNDEF 37 +#define OP_FILESIZE 38 +#define OP_ENTRYPOINT 39 +#define OP_CONTAINS 40 +#define OP_MATCHES 41 +#define OP_IMPORT 42 +#define OP_LOOKUP_DICT 43 +#define OP_JUNDEF 44 /* Not used */ +#define OP_JUNDEF_P 45 +#define OP_JNUNDEF 46 +#define OP_JNUNDEF_P 47 /* Not used */ +#define OP_JFALSE 48 +#define OP_JFALSE_P 49 +#define OP_JTRUE 50 +#define OP_JTRUE_P 51 +#define OP_JL_P 52 +#define OP_JLE_P 53 +#define OP_ITER_NEXT 54 +#define OP_ITER_START_ARRAY 55 +#define OP_ITER_START_DICT 56 +#define OP_ITER_START_INT_RANGE 57 +#define OP_ITER_START_INT_ENUM 58 +#define OP_JZ 59 +#define OP_JZ_P 60 + +#define OP_PUSH_8 61 +#define OP_PUSH_16 62 +#define OP_PUSH_32 63 +#define OP_PUSH_U 64 #define _OP_EQ 0 #define _OP_NEQ 1 diff --git a/libyara/include/yara/object.h b/libyara/include/yara/object.h index f1d2a46f3b..18311e2a42 100644 --- a/libyara/include/yara/object.h +++ b/libyara/include/yara/object.h @@ -53,6 +53,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define OBJECT_CREATE 1 +#define OBJECT_TYPE_UNDEFINED 0 #define OBJECT_TYPE_INTEGER 1 #define OBJECT_TYPE_STRING 2 #define OBJECT_TYPE_STRUCTURE 3 @@ -153,6 +154,12 @@ int yr_object_set_string( ...) YR_PRINTF_LIKE(4, 5); +int yr_object_set_object( + YR_OBJECT* value, + YR_OBJECT* object, + const char* field, + ...) YR_PRINTF_LIKE(3,4); + int yr_object_array_length( YR_OBJECT* object); diff --git a/libyara/include/yara/types.h b/libyara/include/yara/types.h index 9570284ebe..ecf47b36d8 100644 --- a/libyara/include/yara/types.h +++ b/libyara/include/yara/types.h @@ -185,6 +185,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define EXTERNAL_VARIABLE_IS_NULL(x) \ ((x) != NULL ? (x)->type == EXTERNAL_VARIABLE_TYPE_NULL : true) +#define INTERNAL_VARIABLE_IS_NULL(x) \ + ((x) != NULL ? (x)->type == OBJECT_TYPE_UNDEFINED : true) typedef struct RE RE; typedef struct RE_AST RE_AST; @@ -212,6 +214,7 @@ typedef struct YR_RULES_STATS YR_RULES_STATS; typedef struct YR_PROFILING_INFO YR_PROFILING_INFO; typedef struct YR_RULE_PROFILING_INFO YR_RULE_PROFILING_INFO; typedef struct YR_EXTERNAL_VARIABLE YR_EXTERNAL_VARIABLE; +typedef struct YR_INTERNAL_VARIABLE YR_INTERNAL_VARIABLE; typedef struct YR_MATCH YR_MATCH; typedef struct YR_SCAN_CONTEXT YR_SCAN_CONTEXT; @@ -353,6 +356,13 @@ struct YR_EXTERNAL_VARIABLE DECLARE_REFERENCE(const char*, identifier); }; +struct YR_INTERNAL_VARIABLE +{ + int32_t type; + uint32_t rule_idx; + + DECLARE_REFERENCE(const char*, identifier); +}; struct YR_AC_MATCH { @@ -574,6 +584,7 @@ struct YR_RULES YR_RULE* rules_list_head; YR_STRING* strings_list_head; YR_EXTERNAL_VARIABLE* externals_list_head; + YR_INTERNAL_VARIABLE* internals_list_head; YR_AC_TRANSITION* ac_transition_table; YR_AC_MATCH* ac_match_pool; @@ -731,6 +742,9 @@ struct YR_SCAN_CONTEXT // contains entries for external variables and modules. YR_HASH_TABLE* objects_table; + // Array of hashmaps that map identifiers to each rule's internal variables + YR_HASH_TABLE** internal_variable_tables; + // Notebook used for storing YR_MATCH structures associated to the matches // found. YR_NOTEBOOK * matches_notebook; diff --git a/libyara/lexer.c b/libyara/lexer.c index 5c4b0ab91d..b125c8d9c0 100644 --- a/libyara/lexer.c +++ b/libyara/lexer.c @@ -580,8 +580,8 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); yyg->yy_hold_char = *yy_cp; \ *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 78 -#define YY_END_OF_BUFFER 79 +#define YY_NUM_RULES 79 +#define YY_END_OF_BUFFER 80 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -589,36 +589,37 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[259] = +static const flex_int16_t yy_accept[268] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 79, 77, 76, 76, 51, 73, 49, 48, 77, 74, - 54, 54, 2, 77, 3, 50, 53, 53, 53, 53, - 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, - 53, 53, 53, 53, 77, 65, 66, 58, 78, 71, - 72, 68, 78, 45, 46, 42, 42, 51, 7, 49, - 47, 48, 1, 40, 43, 0, 54, 0, 0, 0, - 0, 8, 4, 6, 5, 9, 50, 53, 53, 53, - 53, 28, 53, 53, 53, 53, 53, 53, 53, 53, - 53, 29, 53, 53, 53, 30, 27, 53, 53, 53, - - 53, 53, 53, 53, 53, 0, 0, 65, 67, 62, - 63, 61, 60, 59, 67, 71, 68, 68, 70, 69, - 45, 41, 43, 55, 54, 57, 56, 33, 26, 34, - 53, 53, 53, 53, 53, 53, 32, 53, 53, 53, - 53, 53, 53, 53, 53, 25, 53, 53, 53, 53, - 53, 53, 53, 17, 75, 0, 0, 0, 53, 53, - 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, - 53, 52, 53, 13, 53, 53, 12, 53, 31, 23, - 16, 0, 0, 0, 0, 0, 75, 64, 15, 53, - 53, 53, 53, 24, 53, 53, 53, 53, 53, 53, - - 53, 53, 53, 53, 0, 0, 18, 53, 53, 53, - 53, 53, 11, 39, 53, 52, 53, 21, 53, 53, - 0, 0, 0, 0, 0, 75, 53, 53, 53, 53, - 53, 53, 53, 37, 10, 14, 0, 75, 0, 0, - 0, 53, 53, 38, 53, 36, 20, 0, 0, 0, - 0, 53, 22, 53, 44, 19, 35, 0 + 80, 78, 77, 77, 52, 74, 50, 49, 78, 75, + 55, 55, 2, 78, 3, 51, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 78, 66, 67, 59, 79, + 72, 73, 69, 79, 46, 47, 43, 43, 52, 7, + 50, 48, 49, 1, 41, 44, 0, 55, 0, 0, + 0, 0, 8, 4, 6, 5, 9, 51, 54, 54, + 54, 54, 29, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 30, 54, 54, 54, 31, 28, 54, 54, + + 54, 54, 54, 54, 54, 54, 54, 0, 0, 66, + 68, 63, 64, 62, 61, 60, 68, 72, 69, 69, + 71, 70, 46, 42, 44, 56, 55, 58, 57, 34, + 27, 35, 54, 54, 54, 54, 54, 54, 33, 54, + 54, 54, 54, 54, 54, 54, 54, 26, 54, 54, + 54, 54, 54, 54, 54, 54, 18, 76, 0, 0, + 0, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 53, 54, 13, 54, 54, 12, + 54, 32, 24, 54, 17, 0, 0, 0, 0, 0, + 76, 65, 16, 54, 54, 54, 54, 25, 54, 54, + + 54, 54, 54, 54, 54, 54, 54, 54, 54, 0, + 0, 19, 54, 54, 54, 54, 54, 11, 40, 54, + 53, 54, 22, 54, 54, 54, 0, 0, 0, 0, + 0, 76, 54, 54, 54, 54, 54, 54, 54, 38, + 10, 15, 54, 0, 76, 0, 0, 0, 54, 54, + 39, 54, 37, 21, 0, 54, 0, 0, 0, 54, + 23, 54, 45, 14, 20, 36, 0 } ; static const YY_CHAR yy_ec[256] = @@ -663,151 +664,153 @@ static const YY_CHAR yy_meta[58] = 11, 11, 12, 11, 11, 1, 1 } ; -static const flex_int16_t yy_base[281] = +static const flex_int16_t yy_base[290] = { 0, - 0, 0, 55, 56, 57, 60, 588, 587, 582, 581, - 590, 595, 595, 595, 566, 595, 0, 578, 576, 54, - 54, 60, 45, 563, 50, 0, 0, 33, 552, 539, - 539, 52, 540, 35, 43, 536, 54, 533, 529, 529, - 56, 536, 535, 530, 562, 0, 595, 595, 88, 0, - 595, 63, 561, 0, 595, 595, 560, 548, 595, 0, - 595, 560, 595, 595, 0, 0, 0, 542, 541, 107, - 0, 595, 595, 595, 595, 595, 0, 0, 525, 62, - 531, 0, 517, 520, 514, 520, 519, 513, 517, 513, - 511, 60, 507, 506, 65, 0, 0, 513, 511, 505, - - 514, 500, 505, 512, 500, 58, 96, 0, 595, 595, - 595, 595, 595, 595, 0, 0, 498, 595, 595, 595, - 0, 595, 0, 0, 595, 129, 0, 0, 0, 0, - 504, 507, 81, 496, 494, 504, 0, 498, 505, 493, - 495, 113, 501, 502, 501, 0, 482, 495, 490, 487, - 492, 479, 490, 0, 595, 516, 148, 0, 484, 505, - 482, 489, 467, 483, 471, 466, 484, 469, 465, 495, - 498, 477, 455, 0, 444, 447, 0, 424, 0, 0, - 0, 444, 100, 0, 0, 124, 0, 595, 0, 429, - 393, 377, 371, 0, 372, 365, 367, 359, 366, 360, - - 357, 356, 343, 351, 205, 128, 333, 342, 338, 332, - 262, 269, 0, 0, 278, 0, 266, 0, 276, 264, - 0, 0, 261, 299, 256, 0, 269, 264, 260, 266, - 269, 269, 302, 0, 0, 0, 257, 293, 273, 289, - 274, 255, 228, 0, 95, 0, 0, 287, 280, 0, - 290, 94, 0, 79, 595, 0, 0, 595, 318, 331, - 344, 357, 363, 368, 376, 383, 388, 393, 404, 414, - 426, 439, 451, 464, 477, 110, 483, 486, 496, 502 + 0, 0, 55, 56, 57, 60, 596, 595, 590, 589, + 598, 603, 603, 603, 574, 603, 0, 586, 584, 54, + 54, 60, 45, 571, 50, 0, 0, 33, 560, 547, + 547, 52, 548, 35, 43, 544, 54, 541, 537, 537, + 56, 544, 551, 542, 537, 569, 0, 603, 603, 88, + 0, 603, 63, 568, 0, 603, 603, 567, 555, 603, + 0, 603, 567, 603, 603, 0, 0, 0, 549, 548, + 107, 0, 603, 603, 603, 603, 603, 0, 0, 532, + 62, 538, 0, 524, 527, 521, 527, 526, 520, 524, + 520, 518, 60, 514, 513, 65, 0, 0, 520, 518, + + 512, 521, 507, 512, 508, 518, 506, 58, 96, 0, + 603, 603, 603, 603, 603, 603, 0, 0, 504, 603, + 603, 603, 0, 603, 0, 0, 603, 129, 0, 0, + 0, 0, 510, 513, 81, 502, 500, 510, 0, 504, + 511, 499, 501, 113, 507, 508, 507, 0, 488, 501, + 496, 493, 498, 485, 492, 495, 0, 603, 521, 148, + 0, 489, 510, 487, 494, 472, 488, 476, 471, 489, + 474, 470, 500, 503, 483, 476, 0, 467, 481, 0, + 469, 0, 0, 478, 0, 485, 100, 0, 0, 124, + 0, 603, 0, 475, 431, 427, 408, 0, 405, 397, + + 376, 368, 377, 373, 372, 371, 353, 358, 360, 205, + 128, 341, 351, 346, 340, 328, 335, 0, 0, 340, + 0, 269, 0, 279, 267, 272, 0, 0, 261, 301, + 256, 0, 271, 266, 262, 268, 271, 271, 304, 0, + 0, 0, 268, 257, 294, 273, 291, 274, 265, 247, + 0, 228, 0, 0, 287, 91, 280, 0, 290, 94, + 0, 79, 603, 0, 0, 0, 603, 318, 331, 344, + 357, 363, 368, 376, 383, 388, 393, 404, 414, 426, + 439, 451, 464, 477, 110, 483, 486, 496, 502 } ; -static const flex_int16_t yy_def[281] = +static const flex_int16_t yy_def[290] = { 0, - 258, 1, 259, 259, 260, 260, 261, 261, 262, 262, - 258, 258, 258, 258, 263, 258, 264, 265, 258, 258, - 266, 266, 258, 258, 258, 267, 268, 268, 268, 268, - 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - 268, 268, 268, 268, 269, 270, 258, 258, 271, 272, - 258, 258, 273, 274, 258, 258, 258, 263, 258, 264, - 258, 265, 258, 258, 275, 276, 22, 258, 258, 258, - 277, 258, 258, 258, 258, 258, 267, 268, 268, 268, - 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - - 268, 268, 268, 268, 268, 269, 258, 270, 258, 258, - 258, 258, 258, 258, 278, 272, 258, 258, 258, 258, - 274, 258, 275, 276, 258, 258, 277, 268, 268, 268, - 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - 268, 268, 268, 268, 258, 279, 258, 280, 268, 268, - 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - 268, 279, 279, 157, 157, 157, 157, 258, 268, 268, - 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - - 268, 268, 268, 268, 258, 157, 268, 268, 268, 268, - 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - 205, 205, 279, 205, 205, 205, 268, 268, 268, 268, - 268, 268, 268, 268, 268, 268, 279, 279, 157, 205, - 205, 268, 268, 268, 268, 268, 268, 258, 279, 205, - 205, 268, 268, 268, 258, 268, 268, 0, 258, 258, - 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - 258, 258, 258, 258, 258, 258, 258, 258, 258, 258 + 267, 1, 268, 268, 269, 269, 270, 270, 271, 271, + 267, 267, 267, 267, 272, 267, 273, 274, 267, 267, + 275, 275, 267, 267, 267, 276, 277, 277, 277, 277, + 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, + 277, 277, 277, 277, 277, 278, 279, 267, 267, 280, + 281, 267, 267, 282, 283, 267, 267, 267, 272, 267, + 273, 267, 274, 267, 267, 284, 285, 22, 267, 267, + 267, 286, 267, 267, 267, 267, 267, 276, 277, 277, + 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, + 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, + + 277, 277, 277, 277, 277, 277, 277, 278, 267, 279, + 267, 267, 267, 267, 267, 267, 287, 281, 267, 267, + 267, 267, 283, 267, 284, 285, 267, 267, 286, 277, + 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, + 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, + 277, 277, 277, 277, 277, 277, 277, 267, 288, 267, + 289, 277, 277, 277, 277, 277, 277, 277, 277, 277, + 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, + 277, 277, 277, 277, 277, 288, 288, 160, 160, 160, + 160, 267, 277, 277, 277, 277, 277, 277, 277, 277, + + 277, 277, 277, 277, 277, 277, 277, 277, 277, 267, + 160, 277, 277, 277, 277, 277, 277, 277, 277, 277, + 277, 277, 277, 277, 277, 277, 210, 210, 288, 210, + 210, 210, 277, 277, 277, 277, 277, 277, 277, 277, + 277, 277, 277, 288, 288, 160, 210, 210, 277, 277, + 277, 277, 277, 277, 267, 277, 288, 210, 210, 277, + 277, 277, 267, 277, 277, 277, 0, 267, 267, 267, + 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + 267, 267, 267, 267, 267, 267, 267, 267, 267 } ; -static const flex_int16_t yy_nxt[653] = +static const flex_int16_t yy_nxt[661] = { 0, 12, 13, 14, 13, 15, 16, 17, 18, 12, 12, 19, 20, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 24, 25, 26, 27, 27, 27, 27, 27, 12, 27, 28, 29, 30, 27, 31, 32, 33, 27, 34, 27, 35, 36, 37, 38, 39, 40, 41, 42, - 27, 43, 44, 27, 27, 45, 12, 47, 47, 51, - 48, 48, 51, 64, 66, 65, 72, 73, 52, 107, - 66, 52, 75, 76, 79, 93, 80, 91, 92, 94, - 81, 82, 68, 69, 86, 49, 49, 53, 68, 69, - 53, 96, 87, 110, 141, 101, 88, 129, 70, 145, - - 97, 89, 102, 117, 258, 156, 71, 157, 142, 183, - 118, 106, 258, 146, 155, 130, 161, 124, 111, 126, - 126, 126, 126, 126, 126, 126, 170, 257, 171, 162, - 256, 112, 172, 205, 113, 206, 114, 205, 254, 206, - 115, 126, 126, 126, 126, 126, 126, 126, 184, 185, - 106, 185, 184, 184, 184, 184, 185, 184, 184, 186, - 185, 185, 185, 185, 185, 185, 185, 185, 185, 184, - 184, 184, 184, 185, 185, 184, 184, 184, 184, 184, - 185, 185, 185, 185, 185, 185, 184, 184, 184, 184, - 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, - - 184, 184, 184, 184, 187, 221, 222, 223, 222, 221, - 221, 221, 221, 222, 224, 221, 225, 222, 222, 222, - 222, 222, 222, 222, 222, 222, 221, 221, 221, 221, - 222, 222, 221, 221, 221, 221, 221, 222, 222, 222, - 222, 222, 222, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 226, 223, 223, 223, 240, 249, 241, 250, 223, - 183, 253, 237, 223, 223, 223, 223, 223, 223, 223, - 223, 223, 205, 240, 206, 241, 223, 223, 248, 183, - 252, 223, 255, 223, 223, 223, 223, 223, 223, 240, - - 251, 241, 183, 248, 247, 246, 245, 244, 243, 242, - 239, 236, 235, 234, 233, 232, 231, 238, 46, 46, - 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, - 46, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 54, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 58, 58, 58, 58, 58, 60, 230, 60, 60, 60, - 62, 229, 228, 62, 227, 62, 62, 62, 67, 220, - 67, 219, 218, 217, 67, 77, 216, 77, 77, 77, - - 78, 215, 78, 78, 78, 106, 106, 214, 213, 212, - 106, 106, 211, 106, 108, 108, 210, 209, 108, 108, - 108, 108, 108, 108, 108, 108, 109, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, 109, 116, - 116, 208, 116, 116, 116, 207, 116, 116, 116, 116, - 116, 119, 119, 183, 119, 119, 119, 119, 119, 119, - 119, 119, 119, 119, 121, 121, 121, 204, 121, 121, - 121, 121, 121, 121, 121, 121, 121, 123, 123, 203, - 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, - 127, 202, 127, 158, 201, 158, 182, 182, 182, 182, - - 182, 182, 182, 182, 182, 182, 182, 182, 182, 188, - 200, 188, 172, 172, 199, 198, 197, 196, 195, 194, - 193, 192, 191, 190, 189, 183, 181, 142, 180, 179, - 178, 177, 176, 175, 174, 173, 169, 168, 167, 166, - 165, 164, 163, 160, 159, 118, 154, 153, 152, 151, - 150, 149, 148, 147, 144, 143, 140, 139, 138, 137, - 136, 135, 134, 133, 132, 131, 128, 125, 125, 61, - 258, 122, 120, 107, 105, 104, 103, 100, 99, 98, - 95, 90, 85, 84, 83, 74, 63, 61, 59, 258, - 57, 57, 55, 55, 11, 258, 258, 258, 258, 258, - - 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - 258, 258 + 43, 44, 45, 27, 27, 46, 12, 48, 48, 52, + 49, 49, 52, 65, 67, 66, 73, 74, 53, 109, + 67, 53, 76, 77, 80, 94, 81, 92, 93, 95, + 82, 83, 69, 70, 87, 50, 50, 54, 69, 70, + 54, 97, 88, 112, 143, 102, 89, 131, 71, 147, + + 98, 90, 103, 119, 267, 159, 72, 160, 144, 187, + 120, 108, 267, 148, 158, 132, 164, 126, 113, 128, + 128, 128, 128, 128, 128, 128, 173, 266, 174, 165, + 265, 114, 175, 210, 115, 211, 116, 210, 264, 211, + 117, 128, 128, 128, 128, 128, 128, 128, 188, 189, + 108, 189, 188, 188, 188, 188, 189, 188, 188, 190, + 189, 189, 189, 189, 189, 189, 189, 189, 189, 188, + 188, 188, 188, 189, 189, 188, 188, 188, 188, 188, + 189, 189, 189, 189, 189, 189, 188, 188, 188, 188, + 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, + + 188, 188, 188, 188, 191, 227, 228, 229, 228, 227, + 227, 227, 227, 228, 230, 227, 231, 228, 228, 228, + 228, 228, 228, 228, 228, 228, 227, 227, 227, 227, + 228, 228, 227, 227, 227, 227, 227, 228, 228, 228, + 228, 228, 228, 227, 227, 227, 227, 227, 227, 227, + 227, 227, 227, 227, 227, 227, 227, 227, 227, 227, + 227, 232, 229, 229, 229, 247, 257, 248, 258, 229, + 187, 262, 244, 229, 229, 229, 229, 229, 229, 229, + 229, 229, 210, 247, 211, 248, 229, 229, 255, 187, + 261, 229, 263, 229, 229, 229, 229, 229, 229, 247, + + 260, 248, 259, 187, 256, 255, 254, 253, 252, 251, + 250, 249, 246, 243, 242, 241, 240, 245, 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, 239, 61, 61, 61, + 63, 238, 237, 63, 236, 63, 63, 63, 68, 235, + 68, 234, 233, 226, 68, 78, 225, 78, 78, 78, + + 79, 224, 79, 79, 79, 108, 108, 223, 222, 221, + 108, 108, 220, 108, 110, 110, 219, 218, 110, 110, + 110, 110, 110, 110, 110, 110, 111, 111, 111, 111, + 111, 111, 111, 111, 111, 111, 111, 111, 111, 118, + 118, 217, 118, 118, 118, 216, 118, 118, 118, 118, + 118, 121, 121, 215, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 123, 123, 123, 214, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 125, 125, 213, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 129, 212, 129, 161, 187, 161, 186, 186, 186, 186, + + 186, 186, 186, 186, 186, 186, 186, 186, 186, 192, + 209, 192, 208, 207, 206, 205, 204, 175, 175, 203, + 202, 201, 200, 199, 198, 197, 196, 195, 194, 193, + 187, 185, 184, 144, 183, 182, 181, 180, 179, 178, + 177, 176, 172, 171, 170, 169, 168, 167, 166, 163, + 162, 120, 157, 156, 155, 154, 153, 152, 151, 150, + 149, 146, 145, 142, 141, 140, 139, 138, 137, 136, + 135, 134, 133, 130, 127, 127, 62, 267, 124, 122, + 109, 107, 106, 105, 104, 101, 100, 99, 96, 91, + 86, 85, 84, 75, 64, 62, 60, 267, 58, 58, + + 56, 56, 11, 267, 267, 267, 267, 267, 267, 267, + 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + 267, 267, 267, 267, 267, 267, 267, 267, 267, 267 } ; -static const flex_int16_t yy_chk[653] = +static const flex_int16_t yy_chk[661] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -815,81 +818,82 @@ static const flex_int16_t yy_chk[653] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 106, + 3, 4, 6, 20, 21, 20, 23, 23, 5, 108, 22, 6, 25, 25, 28, 35, 28, 34, 34, 35, 28, 28, 21, 21, 32, 3, 4, 5, 22, 22, - 6, 37, 32, 49, 92, 41, 32, 80, 21, 95, - - 37, 32, 41, 52, 22, 107, 21, 107, 92, 183, - 52, 183, 22, 95, 106, 80, 133, 276, 49, 70, - 70, 70, 70, 70, 70, 70, 142, 254, 142, 133, - 252, 49, 142, 186, 49, 186, 49, 206, 245, 206, - 49, 126, 126, 126, 126, 126, 126, 126, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - - 157, 157, 157, 157, 157, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, - 205, 205, 223, 223, 223, 225, 237, 225, 237, 223, - 223, 243, 223, 223, 223, 223, 223, 223, 223, 223, - 223, 223, 239, 241, 239, 241, 223, 223, 248, 249, - 242, 249, 248, 223, 223, 223, 223, 223, 223, 251, - - 240, 251, 238, 233, 232, 231, 230, 229, 228, 227, - 224, 220, 219, 217, 215, 212, 211, 223, 259, 259, - 259, 259, 259, 259, 259, 259, 259, 259, 259, 259, - 259, 260, 260, 260, 260, 260, 260, 260, 260, 260, - 260, 260, 260, 260, 261, 261, 261, 261, 261, 261, - 261, 261, 261, 261, 261, 261, 261, 262, 262, 262, - 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, - 263, 263, 263, 263, 263, 264, 210, 264, 264, 264, - 265, 209, 208, 265, 207, 265, 265, 265, 266, 204, - 266, 203, 202, 201, 266, 267, 200, 267, 267, 267, - - 268, 199, 268, 268, 268, 269, 269, 198, 197, 196, - 269, 269, 195, 269, 270, 270, 193, 192, 270, 270, - 270, 270, 270, 270, 270, 270, 271, 271, 271, 271, - 271, 271, 271, 271, 271, 271, 271, 271, 271, 272, - 272, 191, 272, 272, 272, 190, 272, 272, 272, 272, - 272, 273, 273, 182, 273, 273, 273, 273, 273, 273, - 273, 273, 273, 273, 274, 274, 274, 178, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 275, 275, 176, - 275, 275, 275, 275, 275, 275, 275, 275, 275, 275, - 277, 175, 277, 278, 173, 278, 279, 279, 279, 279, - - 279, 279, 279, 279, 279, 279, 279, 279, 279, 280, - 172, 280, 171, 170, 169, 168, 167, 166, 165, 164, - 163, 162, 161, 160, 159, 156, 153, 152, 151, 150, - 149, 148, 147, 145, 144, 143, 141, 140, 139, 138, - 136, 135, 134, 132, 131, 117, 105, 104, 103, 102, - 101, 100, 99, 98, 94, 93, 91, 90, 89, 88, - 87, 86, 85, 84, 83, 81, 79, 69, 68, 62, - 58, 57, 53, 45, 44, 43, 42, 40, 39, 38, - 36, 33, 31, 30, 29, 24, 19, 18, 15, 11, - 10, 9, 8, 7, 258, 258, 258, 258, 258, 258, - - 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - 258, 258, 258, 258, 258, 258, 258, 258, 258, 258, - 258, 258 + 6, 37, 32, 50, 93, 41, 32, 81, 21, 96, + + 37, 32, 41, 53, 22, 109, 21, 109, 93, 187, + 53, 187, 22, 96, 108, 81, 135, 285, 50, 71, + 71, 71, 71, 71, 71, 71, 144, 262, 144, 135, + 260, 50, 144, 190, 50, 190, 50, 211, 256, 211, + 50, 128, 128, 128, 128, 128, 128, 128, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + + 160, 160, 160, 160, 160, 210, 210, 210, 210, 210, + 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, + 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, + 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, + 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, + 210, 210, 210, 210, 210, 210, 210, 210, 210, 210, + 210, 210, 229, 229, 229, 231, 244, 231, 244, 229, + 229, 252, 229, 229, 229, 229, 229, 229, 229, 229, + 229, 229, 246, 248, 246, 248, 229, 229, 255, 257, + 250, 257, 255, 229, 229, 229, 229, 229, 229, 259, + + 249, 259, 247, 245, 243, 239, 238, 237, 236, 235, + 234, 233, 230, 226, 225, 224, 222, 229, 268, 268, + 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, + 268, 269, 269, 269, 269, 269, 269, 269, 269, 269, + 269, 269, 269, 269, 270, 270, 270, 270, 270, 270, + 270, 270, 270, 270, 270, 270, 270, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 272, 272, 272, 272, 272, 273, 220, 273, 273, 273, + 274, 217, 216, 274, 215, 274, 274, 274, 275, 214, + 275, 213, 212, 209, 275, 276, 208, 276, 276, 276, + + 277, 207, 277, 277, 277, 278, 278, 206, 205, 204, + 278, 278, 203, 278, 279, 279, 202, 201, 279, 279, + 279, 279, 279, 279, 279, 279, 280, 280, 280, 280, + 280, 280, 280, 280, 280, 280, 280, 280, 280, 281, + 281, 200, 281, 281, 281, 199, 281, 281, 281, 281, + 281, 282, 282, 197, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 283, 283, 283, 196, 283, 283, + 283, 283, 283, 283, 283, 283, 283, 284, 284, 195, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 286, 194, 286, 287, 186, 287, 288, 288, 288, 288, + + 288, 288, 288, 288, 288, 288, 288, 288, 288, 289, + 184, 289, 181, 179, 178, 176, 175, 174, 173, 172, + 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, + 159, 156, 155, 154, 153, 152, 151, 150, 149, 147, + 146, 145, 143, 142, 141, 140, 138, 137, 136, 134, + 133, 119, 107, 106, 105, 104, 103, 102, 101, 100, + 99, 95, 94, 92, 91, 90, 89, 88, 87, 86, + 85, 84, 82, 80, 70, 69, 63, 59, 58, 54, + 46, 45, 44, 43, 42, 40, 39, 38, 36, 33, + 31, 30, 29, 24, 19, 18, 15, 11, 10, 9, + + 8, 7, 267, 267, 267, 267, 267, 267, 267, 267, + 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + 267, 267, 267, 267, 267, 267, 267, 267, 267, 267, + 267, 267, 267, 267, 267, 267, 267, 267, 267, 267 } ; /* Table of booleans, true if rule could match eol. */ -static const flex_int32_t yy_rule_can_match_eol[79] = +static const flex_int32_t yy_rule_can_match_eol[80] = { 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, 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, + }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -1034,11 +1038,11 @@ static bool is_absolute_path( #endif } -#line 1037 "lexer.c" +#line 1041 "lexer.c" #define YY_NO_UNISTD_H 1 #define YY_NO_INPUT 1 -#line 1041 "lexer.c" +#line 1045 "lexer.c" #define INITIAL 0 #define str 1 @@ -1317,7 +1321,7 @@ YY_DECL #line 163 "lexer.l" -#line 1320 "lexer.c" +#line 1324 "lexer.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1344,13 +1348,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 >= 259 ) + if ( yy_current_state >= 268 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_current_state != 258 ); + while ( yy_current_state != 267 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -1450,172 +1454,177 @@ YY_RULE_SETUP case 14: YY_RULE_SETUP #line 178 "lexer.l" -{ return _STRINGS_; } +{ return _VARIABLES_; } YY_BREAK case 15: YY_RULE_SETUP #line 179 "lexer.l" -{ return _ASCII_; } +{ return _STRINGS_; } YY_BREAK case 16: YY_RULE_SETUP #line 180 "lexer.l" -{ return _WIDE_; } +{ return _ASCII_; } YY_BREAK case 17: YY_RULE_SETUP #line 181 "lexer.l" -{ return _XOR_; } +{ return _WIDE_; } YY_BREAK case 18: YY_RULE_SETUP #line 182 "lexer.l" -{ return _BASE64_; } +{ return _XOR_; } YY_BREAK case 19: YY_RULE_SETUP #line 183 "lexer.l" -{ return _BASE64_WIDE_; } +{ return _BASE64_; } YY_BREAK case 20: YY_RULE_SETUP #line 184 "lexer.l" -{ return _FULLWORD_; } +{ return _BASE64_WIDE_; } YY_BREAK case 21: YY_RULE_SETUP #line 185 "lexer.l" -{ return _NOCASE_; } +{ return _FULLWORD_; } YY_BREAK case 22: YY_RULE_SETUP #line 186 "lexer.l" -{ return _CONDITION_; } +{ return _NOCASE_; } YY_BREAK case 23: YY_RULE_SETUP #line 187 "lexer.l" -{ return _TRUE_; } +{ return _CONDITION_; } YY_BREAK case 24: YY_RULE_SETUP #line 188 "lexer.l" -{ return _FALSE_; } +{ return _TRUE_; } YY_BREAK case 25: YY_RULE_SETUP #line 189 "lexer.l" -{ return _NOT_; } +{ return _FALSE_; } YY_BREAK case 26: YY_RULE_SETUP #line 190 "lexer.l" -{ return _AND_; } +{ return _NOT_; } YY_BREAK case 27: YY_RULE_SETUP #line 191 "lexer.l" -{ return _OR_; } +{ return _AND_; } YY_BREAK case 28: YY_RULE_SETUP #line 192 "lexer.l" -{ return _AT_; } +{ return _OR_; } YY_BREAK case 29: YY_RULE_SETUP #line 193 "lexer.l" -{ return _IN_; } +{ return _AT_; } YY_BREAK case 30: YY_RULE_SETUP #line 194 "lexer.l" -{ return _OF_; } +{ return _IN_; } YY_BREAK case 31: YY_RULE_SETUP #line 195 "lexer.l" -{ return _THEM_; } +{ return _OF_; } YY_BREAK case 32: YY_RULE_SETUP #line 196 "lexer.l" -{ return _FOR_; } +{ return _THEM_; } YY_BREAK case 33: YY_RULE_SETUP #line 197 "lexer.l" -{ return _ALL_; } +{ return _FOR_; } YY_BREAK case 34: YY_RULE_SETUP #line 198 "lexer.l" -{ return _ANY_; } +{ return _ALL_; } YY_BREAK case 35: YY_RULE_SETUP #line 199 "lexer.l" -{ return _ENTRYPOINT_; } +{ return _ANY_; } YY_BREAK case 36: YY_RULE_SETUP #line 200 "lexer.l" -{ return _FILESIZE_; } +{ return _ENTRYPOINT_; } YY_BREAK case 37: YY_RULE_SETUP #line 201 "lexer.l" -{ return _MATCHES_; } +{ return _FILESIZE_; } YY_BREAK case 38: YY_RULE_SETUP #line 202 "lexer.l" -{ return _CONTAINS_; } +{ return _MATCHES_; } YY_BREAK case 39: YY_RULE_SETUP #line 203 "lexer.l" -{ return _IMPORT_; } +{ return _CONTAINS_; } YY_BREAK case 40: YY_RULE_SETUP -#line 206 "lexer.l" -{ BEGIN(comment); } +#line 204 "lexer.l" +{ return _IMPORT_; } YY_BREAK case 41: YY_RULE_SETUP #line 207 "lexer.l" -{ BEGIN(INITIAL); } +{ BEGIN(comment); } YY_BREAK case 42: -/* rule 42 can match eol */ YY_RULE_SETUP #line 208 "lexer.l" -{ /* skip comments */ } +{ BEGIN(INITIAL); } YY_BREAK case 43: +/* rule 43 can match eol */ YY_RULE_SETUP -#line 211 "lexer.l" -{ /* skip single-line comments */ } +#line 209 "lexer.l" +{ /* skip comments */ } YY_BREAK case 44: YY_RULE_SETUP -#line 214 "lexer.l" +#line 212 "lexer.l" +{ /* skip single-line comments */ } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 215 "lexer.l" { yyextra->lex_buf_ptr = yyextra->lex_buf; yyextra->lex_buf_len = 0; BEGIN(include); } YY_BREAK -case 45: -/* rule 45 can match eol */ +case 46: +/* rule 46 can match eol */ YY_RULE_SETUP -#line 221 "lexer.l" +#line 222 "lexer.l" { yytext_to_buffer; } YY_BREAK -case 46: +case 47: YY_RULE_SETUP -#line 224 "lexer.l" +#line 225 "lexer.l" { if (compiler->include_callback != NULL) @@ -1752,7 +1761,7 @@ case YY_STATE_EOF(str): case YY_STATE_EOF(regexp): case YY_STATE_EOF(include): case YY_STATE_EOF(comment): -#line 356 "lexer.l" +#line 357 "lexer.l" { yypop_buffer_state(yyscanner); @@ -1763,9 +1772,9 @@ case YY_STATE_EOF(comment): return _END_OF_INCLUDED_FILE_; } YY_BREAK -case 47: +case 48: YY_RULE_SETUP -#line 367 "lexer.l" +#line 368 "lexer.l" { yylval->c_string = yr_strdup(yytext); @@ -1776,9 +1785,9 @@ YY_RULE_SETUP return _STRING_IDENTIFIER_WITH_WILDCARD_; } YY_BREAK -case 48: +case 49: YY_RULE_SETUP -#line 378 "lexer.l" +#line 379 "lexer.l" { yylval->c_string = yr_strdup(yytext); @@ -1789,9 +1798,9 @@ YY_RULE_SETUP return _STRING_IDENTIFIER_; } YY_BREAK -case 49: +case 50: YY_RULE_SETUP -#line 389 "lexer.l" +#line 390 "lexer.l" { yylval->c_string = yr_strdup(yytext); @@ -1808,9 +1817,9 @@ YY_RULE_SETUP return _STRING_COUNT_; } YY_BREAK -case 50: +case 51: YY_RULE_SETUP -#line 406 "lexer.l" +#line 407 "lexer.l" { yylval->c_string = yr_strdup(yytext); @@ -1827,9 +1836,9 @@ YY_RULE_SETUP return _STRING_OFFSET_; } YY_BREAK -case 51: +case 52: YY_RULE_SETUP -#line 423 "lexer.l" +#line 424 "lexer.l" { yylval->c_string = yr_strdup(yytext); @@ -1846,9 +1855,9 @@ YY_RULE_SETUP return _STRING_LENGTH_; } YY_BREAK -case 52: +case 53: YY_RULE_SETUP -#line 440 "lexer.l" +#line 441 "lexer.l" { char* text = yytext; @@ -1887,9 +1896,9 @@ YY_RULE_SETUP return _INTEGER_FUNCTION_; } YY_BREAK -case 53: +case 54: YY_RULE_SETUP -#line 479 "lexer.l" +#line 480 "lexer.l" { if (strlen(yytext) > 128) @@ -1903,9 +1912,9 @@ YY_RULE_SETUP return _IDENTIFIER_; } YY_BREAK -case 54: +case 55: YY_RULE_SETUP -#line 493 "lexer.l" +#line 494 "lexer.l" { char *endptr; @@ -1946,17 +1955,17 @@ YY_RULE_SETUP return _NUMBER_; } YY_BREAK -case 55: +case 56: YY_RULE_SETUP -#line 533 "lexer.l" +#line 534 "lexer.l" { yylval->double_ = atof(yytext); return _DOUBLE_; } YY_BREAK -case 56: +case 57: YY_RULE_SETUP -#line 538 "lexer.l" +#line 539 "lexer.l" { char *endptr; @@ -1973,9 +1982,9 @@ YY_RULE_SETUP return _NUMBER_; } YY_BREAK -case 57: +case 58: YY_RULE_SETUP -#line 554 "lexer.l" +#line 555 "lexer.l" { char *endptr; @@ -1992,9 +2001,9 @@ YY_RULE_SETUP return _NUMBER_; } YY_BREAK -case 58: +case 59: YY_RULE_SETUP -#line 571 "lexer.l" +#line 572 "lexer.l" { /* saw closing quote - all done */ alloc_sized_string(s, yyextra->lex_buf_len); @@ -2008,9 +2017,9 @@ YY_RULE_SETUP return _TEXT_STRING_; } YY_BREAK -case 59: +case 60: YY_RULE_SETUP -#line 585 "lexer.l" +#line 586 "lexer.l" { lex_check_space_ok("\t", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); @@ -2018,9 +2027,9 @@ YY_RULE_SETUP yyextra->lex_buf_len++; } YY_BREAK -case 60: +case 61: YY_RULE_SETUP -#line 593 "lexer.l" +#line 594 "lexer.l" { lex_check_space_ok("\t", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); @@ -2028,9 +2037,9 @@ YY_RULE_SETUP yyextra->lex_buf_len++; } YY_BREAK -case 61: +case 62: YY_RULE_SETUP -#line 601 "lexer.l" +#line 602 "lexer.l" { lex_check_space_ok("\n", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); @@ -2038,9 +2047,9 @@ YY_RULE_SETUP yyextra->lex_buf_len++; } YY_BREAK -case 62: +case 63: YY_RULE_SETUP -#line 609 "lexer.l" +#line 610 "lexer.l" { lex_check_space_ok("\"", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); @@ -2048,9 +2057,9 @@ YY_RULE_SETUP yyextra->lex_buf_len++; } YY_BREAK -case 63: +case 64: YY_RULE_SETUP -#line 617 "lexer.l" +#line 618 "lexer.l" { lex_check_space_ok("\\", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); @@ -2058,9 +2067,9 @@ YY_RULE_SETUP yyextra->lex_buf_len++; } YY_BREAK -case 64: +case 65: YY_RULE_SETUP -#line 625 "lexer.l" +#line 626 "lexer.l" { int result; @@ -2071,30 +2080,30 @@ YY_RULE_SETUP yyextra->lex_buf_len++; } YY_BREAK -case 65: +case 66: YY_RULE_SETUP -#line 636 "lexer.l" +#line 637 "lexer.l" { yytext_to_buffer; } YY_BREAK -case 66: -/* rule 66 can match eol */ +case 67: +/* rule 67 can match eol */ YY_RULE_SETUP -#line 639 "lexer.l" +#line 640 "lexer.l" { syntax_error("unterminated string"); } YY_BREAK -case 67: -/* rule 67 can match eol */ +case 68: +/* rule 68 can match eol */ YY_RULE_SETUP -#line 644 "lexer.l" +#line 645 "lexer.l" { syntax_error("illegal escape sequence"); } YY_BREAK -case 68: +case 69: YY_RULE_SETUP -#line 649 "lexer.l" +#line 650 "lexer.l" { if (yyextra->lex_buf_len > 0) @@ -2120,9 +2129,9 @@ YY_RULE_SETUP return _REGEXP_; } YY_BREAK -case 69: +case 70: YY_RULE_SETUP -#line 675 "lexer.l" +#line 676 "lexer.l" { lex_check_space_ok("/", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); @@ -2130,9 +2139,9 @@ YY_RULE_SETUP yyextra->lex_buf_len++ ; } YY_BREAK -case 70: +case 71: YY_RULE_SETUP -#line 683 "lexer.l" +#line 684 "lexer.l" { lex_check_space_ok("\\.", yyextra->lex_buf_len, YR_LEX_BUF_SIZE); @@ -2145,22 +2154,22 @@ YY_RULE_SETUP yyextra->lex_buf_len += 2; } YY_BREAK -case 71: +case 72: YY_RULE_SETUP -#line 696 "lexer.l" +#line 697 "lexer.l" { yytext_to_buffer; } YY_BREAK -case 72: -/* rule 72 can match eol */ +case 73: +/* rule 73 can match eol */ YY_RULE_SETUP -#line 699 "lexer.l" +#line 700 "lexer.l" { syntax_error("unterminated regular expression"); } YY_BREAK -case 73: +case 74: YY_RULE_SETUP -#line 704 "lexer.l" +#line 705 "lexer.l" { yylval->sized_string = NULL; @@ -2169,9 +2178,9 @@ YY_RULE_SETUP BEGIN(str); } YY_BREAK -case 74: +case 75: YY_RULE_SETUP -#line 713 "lexer.l" +#line 714 "lexer.l" { yylval->sized_string = NULL; @@ -2180,10 +2189,10 @@ YY_RULE_SETUP BEGIN(regexp); } YY_BREAK -case 75: -/* rule 75 can match eol */ +case 76: +/* rule 76 can match eol */ YY_RULE_SETUP -#line 722 "lexer.l" +#line 723 "lexer.l" { // Match hex-digits with whitespace or comments. The latter are stripped // out by hex_lexer.l @@ -2200,15 +2209,15 @@ YY_RULE_SETUP return _HEX_STRING_; } YY_BREAK -case 76: -/* rule 76 can match eol */ +case 77: +/* rule 77 can match eol */ YY_RULE_SETUP -#line 739 "lexer.l" +#line 740 "lexer.l" /* skip whitespace */ YY_BREAK -case 77: +case 78: YY_RULE_SETUP -#line 741 "lexer.l" +#line 742 "lexer.l" { if (yytext[0] >= 32 && yytext[0] < 127) @@ -2221,12 +2230,12 @@ YY_RULE_SETUP } } YY_BREAK -case 78: +case 79: YY_RULE_SETUP -#line 753 "lexer.l" +#line 754 "lexer.l" ECHO; YY_BREAK -#line 2229 "lexer.c" +#line 2238 "lexer.c" case YY_END_OF_BUFFER: { @@ -2524,7 +2533,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 >= 259 ) + if ( yy_current_state >= 268 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -2553,11 +2562,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 >= 259 ) + if ( yy_current_state >= 268 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 258); + yy_is_jam = (yy_current_state == 267); (void)yyg; return yy_is_jam ? 0 : yy_current_state; @@ -3375,7 +3384,7 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 753 "lexer.l" +#line 754 "lexer.l" diff --git a/libyara/lexer.l b/libyara/lexer.l index 2512f44802..62728416d0 100644 --- a/libyara/lexer.l +++ b/libyara/lexer.l @@ -175,6 +175,7 @@ octdigit [0-7] "global" { return _GLOBAL_; } "rule" { return _RULE_; } "meta" { return _META_; } +"variables" { return _VARIABLES_; } "strings" { return _STRINGS_; } "ascii" { return _ASCII_; } "wide" { return _WIDE_; } diff --git a/libyara/object.c b/libyara/object.c index 75fb38ca00..9c3faf4fc4 100644 --- a/libyara/object.c +++ b/libyara/object.c @@ -1130,6 +1130,43 @@ int yr_object_set_string( return ERROR_SUCCESS; } +int yr_object_set_object( + YR_OBJECT* value, + YR_OBJECT* object, + const char* field, + ...) +{ + YR_OBJECT* custom_obj; + YR_OBJECT* copy; + + va_list args; + va_start(args, field); + + if (field != NULL) + custom_obj = _yr_object_lookup(object, OBJECT_CREATE, field, args); + else + custom_obj = object; + + va_end(args); + + if (custom_obj == NULL) + { + if (field != NULL) + return ERROR_INSUFFICIENT_MEMORY; + else + return ERROR_INVALID_ARGUMENT; + } + + assert(custom_obj->type == value->type); + + yr_object_copy(value, ©); + custom_obj->value.o = copy->value.o; + + yr_free((void*)copy->identifier); + yr_free((void*)copy); + + return ERROR_SUCCESS; +} YR_OBJECT* yr_object_get_root( YR_OBJECT* object) diff --git a/libyara/parser.c b/libyara/parser.c index 2dd437acee..576b88642f 100644 --- a/libyara/parser.c +++ b/libyara/parser.c @@ -938,6 +938,10 @@ int yr_parser_reduce_rule_declaration_phase_1( rule->flags = flags; rule->ns = ns; rule->num_atoms = 0; + + yr_hash_table_clean( + compiler->current_internal_variables_table, + (YR_HASH_TABLE_FREE_VALUE_FUNC) yr_object_destroy); YR_ARENA_REF jmp_offset_ref; diff --git a/libyara/rules.c b/libyara/rules.c index 63e26188e9..86c1de4f0b 100644 --- a/libyara/rules.c +++ b/libyara/rules.c @@ -41,7 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include - +#include YR_API int yr_rules_define_integer_variable( YR_RULES* rules, @@ -374,6 +374,9 @@ int yr_rules_from_arena( new_rules->externals_list_head = yr_arena_get_ptr( arena, YR_EXTERNAL_VARIABLES_TABLE, 0); + new_rules->internals_list_head = yr_arena_get_ptr( + arena, YR_INTERNAL_VARIABLES_TABLE, 0); + new_rules->ac_transition_table = yr_arena_get_ptr( arena, YR_AC_TRANSITION_TABLE, 0); diff --git a/libyara/scanner.c b/libyara/scanner.c index 3360d4ecf8..d75a488af7 100644 --- a/libyara/scanner.c +++ b/libyara/scanner.c @@ -165,6 +165,7 @@ YR_API int yr_scanner_create( YR_SCANNER** scanner) { YR_EXTERNAL_VARIABLE* external; + YR_INTERNAL_VARIABLE* internal; YR_SCANNER* new_scanner; new_scanner = (YR_SCANNER*) yr_calloc(1, sizeof(YR_SCANNER)); @@ -176,6 +177,28 @@ YR_API int yr_scanner_create( yr_hash_table_create(64, &new_scanner->objects_table), yr_free(new_scanner)); + new_scanner->internal_variable_tables = yr_malloc(sizeof(YR_HASH_TABLE*)*rules->num_rules); + + if(new_scanner->internal_variable_tables == NULL) { + yr_hash_table_destroy(new_scanner->objects_table, (YR_HASH_TABLE_FREE_VALUE_FUNC) yr_object_destroy); + yr_free(new_scanner); + + return ERROR_INSUFFICIENT_MEMORY; + } + + for(uint32_t rule_idx=0; rule_idxnum_rules; rule_idx++) { + FAIL_ON_ERROR_WITH_CLEANUP( + yr_hash_table_create(10, &new_scanner->internal_variable_tables[rule_idx]), + //CLEANUP + for(uint32_t cleanup_rule_idx = 0; cleanup_rule_idxinternal_variable_tables[cleanup_rule_idx], (YR_HASH_TABLE_FREE_VALUE_FUNC) yr_object_destroy); + }; + yr_free(new_scanner->internal_variable_tables); + yr_free(new_scanner->objects_table); + yr_free(new_scanner)); + } + new_scanner->rules = rules; new_scanner->entry_point = YR_UNDEFINED; new_scanner->canary = rand(); @@ -234,8 +257,37 @@ YR_API int yr_scanner_create( external++; } - *scanner = new_scanner; + internal = rules->internals_list_head; + + while (!INTERNAL_VARIABLE_IS_NULL(internal)) + { + YR_OBJECT* object; + + FAIL_ON_ERROR_WITH_CLEANUP( + yr_object_create( + internal->type, + internal->identifier, + NULL, + &object), + // cleanup + yr_scanner_destroy(new_scanner)); + + FAIL_ON_ERROR_WITH_CLEANUP( + yr_hash_table_add( + new_scanner->internal_variable_tables[internal->rule_idx], + internal->identifier, + NULL, + (void*) object), + // cleanup + yr_object_destroy(object); + yr_scanner_destroy(new_scanner)); + yr_object_set_canary(object, new_scanner->canary); + internal++; + } + + *scanner = new_scanner; + return ERROR_SUCCESS; } @@ -262,6 +314,16 @@ YR_API void yr_scanner_destroy( (YR_HASH_TABLE_FREE_VALUE_FUNC) yr_object_destroy); } + if(scanner->internal_variable_tables != NULL) { + for(uint32_t rule_idx=0; rule_idxrules->num_rules; rule_idx++) { + yr_hash_table_destroy( + scanner->internal_variable_tables[rule_idx], + (YR_HASH_TABLE_FREE_VALUE_FUNC)yr_object_destroy); + } + } + + yr_free(scanner->internal_variable_tables); + #ifdef YR_PROFILING_ENABLED yr_free(scanner->profiling_info); #endif diff --git a/tests/test-rules.c b/tests/test-rules.c index 3bbe1d52cf..d310befaf2 100644 --- a/tests/test-rules.c +++ b/tests/test-rules.c @@ -985,6 +985,102 @@ static void test_strings() }", "tests/data/base64"); } +static void test_internal_variables() { + asert_true_rule( + "rule test {\n\ + variables:\n\ + var = 2+2\n\ + condition:\n\ + var == 4\n\ + }"); + assert_false_rule( + "rule test {\n\ + variables:\n\ + var = 2+2\n\ + condition:\n\ + var < 4 or var > 4\n\ + }"); + asert_true_rule( + "rule test {\n\ + variables:\n\ + var = true\n\ + condition:\n\ + var\n\ + }"); + assert_false_rule( + "rule test{\n\ + variables:\n\ + var = false\n\ + condition:\n\ + var\n\ + }"); + assert_true_rule( + "rule test {\n\ + variables:\n\ + var = 1==1\n\ + condition:\n\ + var\n\ + }"); + assert_true_rule( + "rule test {\n\ + variables:\n\ + var = 2.5\n\ + condition:\n\ + var > 2.49 and var < 2.51\n\ + }"); + assert_false_rule( + "rule test {\n\ + variables:\n\ + var = 2.5\n\ + condition:\n\ + var < 2.49 or var > 2.51\n\ + }"); + assert_true_rule( + "rule test {\n\ + variables:\n\ + var = \"test\"\n\ + condition:\n\ + var == \"test\"\n\ + }"); + assert_false_rule( + "rule test {\n\ + variables:\n\ + var = \"test\"\n\ + condition:\n\ + var != \"test\"\n\ + }"); + assert_true_rule( + "rule test {\n\ + variables:\n\ + var1 = 1\n\ + var2 = 0\n\ + condition:\n\ + var1 == 1 and var2 == 0\n\ + }"); + assert_false_rule( + "rule test {\n\ + variables:\n\ + var1 = 1\n\ + var2 = 0\n\ + condition:\n\ + var1 != 1 or var2 != 0\n\ + }"); + assert_error( + "rule test {\n\ + variables:\n\ + var = true\n\ + var = false\n\ + condition:\n\ + var\n\ + }", + ERROR_DUPLICATED_IDENTIFIER_ERROR); + assert_error( + "rule test {\n\ + condition:\n\ + var\n\ + }", + ERROR_UNDEFINED_IDENTIFIER); +} static void test_wildcard_strings() { @@ -2821,6 +2917,7 @@ int main(int argc, char** argv) test_syntax(); test_anonymous_strings(); test_strings(); + test_internal_variables(); test_wildcard_strings(); test_hex_strings(); test_count();