From 87884c489c344db4bb2959bf6794ef1fe1b03235 Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Wed, 19 Aug 2020 16:54:55 +0200 Subject: [PATCH 01/17] read variable definitions --- libyara/grammar.y | 29 ++++++++++++++++++++++++++++- libyara/lexer.l | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/libyara/grammar.y b/libyara/grammar.y index 79f61fe6c5..59a33fdec4 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 @@ -343,7 +348,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 +411,16 @@ strings } ; +variables + : /* empty */ + { + $$.type = EXPRESSION_TYPE_UNKNOWN; + } + | _VARIABLES_ ':' variable_declarations + { + $$ = $3; + } + ; condition : _CONDITION_ ':' boolean_expression @@ -577,6 +592,18 @@ meta_declaration } ; +variable_declarations + : variable_declaration { $$ = $1; } + | variable_declarations variable_declaration { $$ = $1; } + ; + +variable_declaration + : _IDENTIFIER_ '=' expression + { + // variable value is on stack + $$ = $3; + } + ; string_declarations : string_declaration { $$ = $1; } 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_; } From c07bafe8dbf590b758820daaa614886589fb2e1a Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Tue, 1 Sep 2020 21:36:21 +0200 Subject: [PATCH 02/17] save variable to hashmap, pop value from stack --- libyara/exec.c | 20 ++++++++ libyara/grammar.y | 67 +++++++++++++++++++++++-- libyara/include/yara/exec.h | 97 +++++++++++++++++++------------------ 3 files changed, 133 insertions(+), 51 deletions(-) diff --git a/libyara/exec.c b/libyara/exec.c index 5ba8fde55c..f675fdeace 100644 --- a/libyara/exec.c +++ b/libyara/exec.c @@ -907,6 +907,26 @@ int yr_execute_code( 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->objects_table, + identifier, + NULL); + + assert(obj != NULL); + + obj->value = r1; + break; + case OP_OBJ_FIELD: identifier = *(char**)(ip); ip += sizeof(uint64_t); diff --git a/libyara/grammar.y b/libyara/grammar.y index 59a33fdec4..d9f363233a 100644 --- a/libyara/grammar.y +++ b/libyara/grammar.y @@ -598,10 +598,71 @@ variable_declarations ; variable_declaration - : _IDENTIFIER_ '=' expression + : _IDENTIFIER_ '=' { - // variable value is on stack - $$ = $3; + compiler->current_line = yyget_lineno(yyscanner); + } + expression + { + YR_OBJECT* object; + + object = (YR_OBJECT*)yr_hash_table_lookup( + compiler->objects_table, + $1, + NULL); + + if(object != NULL) { + fail_with_error(ERROR_DUPLICATED_IDENTIFIER); + } + + YR_EXTERNAL_VARIABLE* ext; + YR_ARENA_REF ext_ref; + YR_ARENA_REF identifier_ref; + + yr_arena_allocate_struct( + compiler->arena, + YR_EXTERNAL_VARIABLES_TABLE, + sizeof(YR_EXTERNAL_VARIABLE), + &ext_ref, + offsetof(YR_EXTERNAL_VARIABLE, identifier), + EOL); + //fprintf(stdout, "%d\n", offsetof(YR_EXTERNAL_VARIABLE, value)); + ext = yr_arena_ref_to_ptr(compiler->arena, &ext_ref); + + _yr_compiler_store_string( + compiler, + $1, + &identifier_ref); + + ext->identifier = yr_arena_ref_to_ptr( + compiler->arena, &identifier_ref); + ext->type = $4.type; + + switch(ext->type) { + case EXPRESSION_TYPE_BOOLEAN: + break; + case EXPRESSION_TYPE_INTEGER: + break; + case EXPRESSION_TYPE_FLOAT: + fprintf(stdout, "float hit\n"); + break; + default: assert(false); + } + + // Pop value on stack to variable + yr_parser_emit_with_arg_reloc(yyscanner, OP_OBJ_STORE, yr_arena_ref_to_ptr(compiler->arena, &identifier_ref), NULL, NULL); + + // get object from ext var + yr_object_from_external_variable(ext, &object); + + FAIL_ON_ERROR_WITH_CLEANUP(yr_hash_table_add( + compiler->objects_table, + $1, + NULL, + (void*) object), + yr_object_destroy(object)); + + yr_free($1); } ; 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 From 1e9d607b0c86316f183c2a8fbc6fe5121cf66515 Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Tue, 1 Sep 2020 21:51:22 +0200 Subject: [PATCH 03/17] fix ext variable type assignment --- libyara/grammar.y | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libyara/grammar.y b/libyara/grammar.y index d9f363233a..dc1cba547d 100644 --- a/libyara/grammar.y +++ b/libyara/grammar.y @@ -636,15 +636,19 @@ variable_declaration ext->identifier = yr_arena_ref_to_ptr( compiler->arena, &identifier_ref); - ext->type = $4.type; - switch(ext->type) { + switch($4.type) { case EXPRESSION_TYPE_BOOLEAN: + ext->type = EXTERNAL_VARIABLE_TYPE_BOOLEAN; break; case EXPRESSION_TYPE_INTEGER: + ext->type = EXTERNAL_VARIABLE_TYPE_INTEGER; break; case EXPRESSION_TYPE_FLOAT: - fprintf(stdout, "float hit\n"); + ext->type = EXTERNAL_VARIABLE_TYPE_FLOAT; + break; + case EXPRESSION_TYPE_STRING: + ext->type = EXTERNAL_VARIABLE_TYPE_STRING; break; default: assert(false); } From 64c3c0b6538666eae8a7a79fdda42ed0350578e6 Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Mon, 7 Sep 2020 02:07:08 +0200 Subject: [PATCH 04/17] internal var table independent of externals --- libyara/compiler.c | 12 +++++ libyara/grammar.y | 84 ++++++++++++++++++++------------- libyara/include/yara/compiler.h | 20 ++++---- libyara/include/yara/object.h | 1 + libyara/include/yara/types.h | 10 ++++ libyara/rules.c | 5 +- libyara/scanner.c | 32 ++++++++++++- 7 files changed, 121 insertions(+), 43 deletions(-) diff --git a/libyara/compiler.c b/libyara/compiler.c index 598817e1fe..faec6decc9 100644 --- a/libyara/compiler.c +++ b/libyara/compiler.c @@ -702,6 +702,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 +736,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/grammar.y b/libyara/grammar.y index dc1cba547d..b15c66021c 100644 --- a/libyara/grammar.y +++ b/libyara/grammar.y @@ -605,6 +605,11 @@ variable_declaration expression { YR_OBJECT* object; + YR_INTERNAL_VARIABLE* int_var; + YR_ARENA_REF int_ref; + YR_ARENA_REF identifier_ref; + uint8_t obj_type; + YR_NAMESPACE* ns; object = (YR_OBJECT*)yr_hash_table_lookup( compiler->objects_table, @@ -614,58 +619,71 @@ variable_declaration if(object != NULL) { fail_with_error(ERROR_DUPLICATED_IDENTIFIER); } - - YR_EXTERNAL_VARIABLE* ext; - YR_ARENA_REF ext_ref; - YR_ARENA_REF identifier_ref; - + yr_arena_allocate_struct( compiler->arena, - YR_EXTERNAL_VARIABLES_TABLE, - sizeof(YR_EXTERNAL_VARIABLE), - &ext_ref, - offsetof(YR_EXTERNAL_VARIABLE, identifier), + YR_INTERNAL_VARIABLES_TABLE, + sizeof(YR_INTERNAL_VARIABLE), + &int_ref, + offsetof(YR_INTERNAL_VARIABLE, identifier), EOL); - //fprintf(stdout, "%d\n", offsetof(YR_EXTERNAL_VARIABLE, value)); - ext = yr_arena_ref_to_ptr(compiler->arena, &ext_ref); + + int_var = yr_arena_ref_to_ptr(compiler->arena, &int_ref); _yr_compiler_store_string( compiler, $1, &identifier_ref); - ext->identifier = yr_arena_ref_to_ptr( - compiler->arena, &identifier_ref); - - switch($4.type) { - case EXPRESSION_TYPE_BOOLEAN: - ext->type = EXTERNAL_VARIABLE_TYPE_BOOLEAN; - break; - case EXPRESSION_TYPE_INTEGER: - ext->type = EXTERNAL_VARIABLE_TYPE_INTEGER; - break; - case EXPRESSION_TYPE_FLOAT: - ext->type = EXTERNAL_VARIABLE_TYPE_FLOAT; - break; - case EXPRESSION_TYPE_STRING: - ext->type = EXTERNAL_VARIABLE_TYPE_STRING; - break; - default: assert(false); + switch($4.type) { + case EXPRESSION_TYPE_BOOLEAN: + case EXPRESSION_TYPE_INTEGER: + obj_type = OBJECT_TYPE_INTEGER; + break; + case EXPRESSION_TYPE_FLOAT: + obj_type = OBJECT_TYPE_FLOAT; + break; + case EXPRESSION_TYPE_STRING: + obj_type = OBJECT_TYPE_STRING; + break; + default: assert(false); } - // Pop value on stack to variable - yr_parser_emit_with_arg_reloc(yyscanner, OP_OBJ_STORE, yr_arena_ref_to_ptr(compiler->arena, &identifier_ref), NULL, NULL); + int_var->identifier = yr_arena_ref_to_ptr( + compiler->arena, &identifier_ref); + int_var->type = obj_type; - // get object from ext var - yr_object_from_external_variable(ext, &object); + yr_object_create( + int_var->type, + int_var->identifier, + NULL, + &object); + + ns = (YR_NAMESPACE*) yr_arena_get_ptr( + compiler->arena, + YR_NAMESPACES_TABLE, + compiler->current_namespace_idx * sizeof(struct YR_NAMESPACE)); FAIL_ON_ERROR_WITH_CLEANUP(yr_hash_table_add( compiler->objects_table, $1, - NULL, + ns->name, (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); + /* + // get object from ext var + yr_object_from_external_variable(ext, &object); + */ + yr_free($1); } ; diff --git a/libyara/include/yara/compiler.h b/libyara/include/yara/compiler.h index c7d9e55d7d..5c5f3d6378 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 diff --git a/libyara/include/yara/object.h b/libyara/include/yara/object.h index f1d2a46f3b..bdaf022c0f 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 diff --git a/libyara/include/yara/types.h b/libyara/include/yara/types.h index 9570284ebe..2476741310 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,12 @@ struct YR_EXTERNAL_VARIABLE DECLARE_REFERENCE(const char*, identifier); }; +struct YR_INTERNAL_VARIABLE +{ + int32_t type; + + DECLARE_REFERENCE(const char*, identifier); +}; struct YR_AC_MATCH { @@ -574,6 +583,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; 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..f10009a84c 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)); @@ -234,8 +235,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->objects_table, + 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; } From ce0359f89597f192fa548b7631d7fef59aebd35a Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Mon, 7 Sep 2020 22:42:23 +0200 Subject: [PATCH 05/17] fix segfault for string variable object cleanup --- libyara/exec.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libyara/exec.c b/libyara/exec.c index f675fdeace..a5c9503c3f 100644 --- a/libyara/exec.c +++ b/libyara/exec.c @@ -923,8 +923,23 @@ int yr_execute_code( NULL); assert(obj != NULL); - - obj->value = r1; + + 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; + default: assert(false); + } break; case OP_OBJ_FIELD: From bcaed229e16316dc0f4571a8c7d87f0b37488e66 Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Mon, 14 Sep 2020 00:15:43 +0200 Subject: [PATCH 06/17] fix scope of internal variables --- libyara/exec.c | 10 +- libyara/grammar.c | 3028 ++++++++++++++++++---------------- libyara/grammar.h | 228 +-- libyara/grammar.y | 38 +- libyara/include/yara/types.h | 3 + libyara/lexer.c | 703 ++++---- libyara/parser.c | 2 + libyara/scanner.c | 2 +- 8 files changed, 2104 insertions(+), 1910 deletions(-) diff --git a/libyara/exec.c b/libyara/exec.c index a5c9503c3f..153081f755 100644 --- a/libyara/exec.c +++ b/libyara/exec.c @@ -899,10 +899,16 @@ int yr_execute_code( #endif r1.o = (YR_OBJECT*) yr_hash_table_lookup( - context->objects_table, + current_rule->internal_variables_table, 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; @@ -918,7 +924,7 @@ int yr_execute_code( pop(r1); YR_OBJECT* obj = (YR_OBJECT*) yr_hash_table_lookup( - context->objects_table, + current_rule->internal_variables_table, identifier, NULL); diff --git a/libyara/grammar.c b/libyara/grammar.c index 52dc22daff..90a1073e8d 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 302 "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,218 @@ 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_expression = 112, /* 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 */ +}; +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 +592,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 +627,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 +651,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 +670,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 + -#if ! defined yyoverflow || YYERROR_VERBOSE +#define YY_ASSERT(E) ((void) (0 && (E))) + +#if !defined yyoverflow /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -536,8 +750,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 +759,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 +782,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 +798,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 +815,44 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 387 +#define YYLAST 385 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 76 +#define YYNTOKENS 77 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 48 +#define YYNNTS 52 /* YYNRULES -- Number of rules. */ -#define YYNRULES 146 +#define YYNRULES 152 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 242 +#define YYNSTATES 252 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 311 +#define YYMAXUTOK 312 -#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 +871,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, 320, 320, 321, 322, 323, 324, 325, 326, 334, + 347, 352, 346, 379, 382, 398, 401, 416, 419, 426, + 431, 432, 437, 438, 444, 447, 463, 472, 514, 515, + 520, 537, 551, 565, 579, 596, 597, 602, 601, 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, 1090, 1138, 1199, 1246, 1247, 1251, 1286, 1339, + 1382, 1405, 1411, 1417, 1429, 1439, 1453, 1468, 1479, 1558, + 1596, 1498, 1756, 1755, 1845, 1851, 1858, 1857, 1903, 1902, + 1946, 1953, 1960, 1967, 1974, 1981, 1988, 1992, 2000, 2020, + 2048, 2122, 2150, 2158, 2167, 2191, 2206, 2226, 2225, 2231, + 2242, 2243, 2248, 2255, 2266, 2270, 2275, 2284, 2288, 2296, + 2308, 2322, 2329, 2336, 2361, 2373, 2385, 2400, 2412, 2427, + 2470, 2491, 2526, 2561, 2595, 2620, 2637, 2647, 2657, 2667, + 2677, 2697, 2717 }; #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", "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", 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 (-78) -#define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-74))) +#define yypact_value_is_default(Yyn) \ + ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF -119 +#define YYTABLE_NINF (-125) -#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 + -78, 178, -78, -37, -78, 19, -78, -78, 127, -78, + -78, -78, -78, 62, -78, -78, -78, -78, 7, 66, + 23, -78, 101, 115, -78, 67, 128, 129, 71, 133, + 74, 129, -78, 132, 78, -78, 131, -78, 94, 132, + -78, 136, 154, -78, -78, -78, -78, 151, 10, -78, + 97, 136, -78, 111, 114, -78, 166, 169, 171, -78, + -78, 48, -78, -78, -78, -78, 48, -78, -29, -78, + 120, 121, -78, -78, 125, -78, -78, -78, -78, -78, + -78, 82, -78, -78, 48, 106, 106, 48, 57, -78, + 42, -78, 177, 176, 216, 6, 209, 42, 61, 106, + 147, 106, 106, 106, 106, 2, 292, -78, -78, -78, + 195, 149, 48, 207, 106, -78, -78, -1, 200, 106, + 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, + 106, 106, 106, 106, 106, 106, -78, -78, -78, 198, + 199, 201, -78, -78, -78, -78, -78, -78, -78, -78, + -78, -78, -78, 292, 106, -78, 193, 203, 235, 254, + -78, -1, 259, -78, -78, 202, 197, 61, -78, 225, + 48, 48, -78, -78, -78, -78, 292, 292, 292, 292, + 292, 292, 292, -42, -42, 302, 312, 322, 110, 110, + -78, -78, -78, 257, 255, 256, 100, -78, -78, -78, + 230, -78, -35, -78, 48, -78, 258, -78, -2, -44, + 229, 231, 106, -78, -6, 290, 61, -78, -78, 3, + -78, 287, -78, -78, -78, 273, 247, 106, 57, 237, + -78, -78, -78, -78, -2, 248, -78, 48, 17, 100, + -78, -78, -78, 27, -78, 106, 250, -78, 292, 48, + 39, -78 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -778,51 +1010,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, 125, + 126, 0, 81, 82, 0, 0, 0, 0, 139, 152, + 19, 80, 0, 106, 42, 44, 46, 0, 38, 0, + 0, 0, 0, 0, 0, 0, 124, 95, 140, 149, + 80, 106, 75, 0, 0, 98, 96, 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 + 0, 0, 0, 0, 0, 0, 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, 107, 127, 0, 76, 77, 72, 0, + 0, 0, 119, 117, 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, 108, 0, 74, 0, 73, 99, 97, 0, 0, + 0, 0, 0, 92, 0, 0, 78, 122, 123, 0, + 120, 0, 55, 58, 60, 0, 0, 0, 110, 0, + 111, 113, 109, 118, 0, 0, 114, 0, 0, 115, + 90, 121, 56, 0, 112, 0, 0, 93, 116, 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 + -78, -78, 316, 319, -78, -78, -78, -78, -78, -78, + -78, -78, -78, -78, -78, 293, -78, 272, -78, -78, + 286, -78, -78, -78, -78, -78, -78, -78, -78, -78, + 123, -78, -78, 220, -61, -53, -78, -78, -78, -78, + -78, -78, -78, -78, 126, -78, 180, -78, -78, 105, + 261, -77 }; /* 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, 94, 144, 95, 150, 96, 152, + 88, 165, 166, 89, 97, 91, 162, 246, 226, 171, + 170, 202, 229, 230, 155, 238, 174, 208, 219, 220, + 92, 93 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -830,166 +1065,169 @@ 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, 214, 99, 160, 106, 5, 67, 100, 108, 109, + 111, 217, 145, 98, -89, 218, 221, 131, 132, 133, + 134, 135, 153, 107, 156, 157, 158, 159, 222, 9, + 146, 147, -45, -43, 110, 148, 149, 169, 172, 161, + 12, 215, 176, 177, 178, 179, 180, 181, 182, 183, + 184, 185, 186, 187, 188, 189, 190, 191, 192, 167, + 67, 68, 69, 70, 71, 227, 72, 73, 74, 75, + 173, 76, 115, 116, 17, 233, 19, 196, 21, 234, + 77, 78, 79, 80, 115, 116, 81, 115, 116, 244, + 23, 82, 83, 245, 67, 84, 69, 70, 71, 247, + 72, 73, 74, 75, 212, 76, -80, -80, 85, 206, + 207, 251, 86, 24, 77, 78, 79, 80, 67, 87, + 69, 70, 71, 25, 72, 73, 74, 75, 112, 76, + 113, 114, 13, 14, 15, 225, 27, 28, 77, 78, + 33, 30, 85, 34, 36, 38, 86, 41, 50, 43, + 239, 216, 44, 104, 126, 127, 128, 129, 130, 131, + 132, 133, 134, 135, 48, 53, 85, 59, 248, 55, + 86, 133, 134, 135, 45, 46, 243, 104, 2, 3, + 61, 4, 62, -20, -20, -20, -124, 63, 250, 118, + 119, 47, 64, 65, 101, 102, 103, 120, 121, 122, + 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, + 133, 134, 135, -124, 117, 151, 118, 119, 154, 168, + 5, 164, 136, 76, 120, 121, 122, 123, 124, 125, + 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, + 137, 138, 139, 140, 141, 142, 143, 126, 127, 128, + 129, 130, 131, 132, 133, 134, 135, 126, 127, 128, + 129, 130, 131, 132, 133, 134, 135, 163, 197, 193, + 194, 201, 195, 204, 203, 209, 210, 211, 198, 126, + 127, 128, 129, 130, 131, 132, 133, 134, 135, 126, + 127, 128, 129, 130, 131, 132, 133, 134, 135, 213, + 205, 223, 232, 224, 116, 235, 240, 199, 126, 127, + 128, 129, 130, 131, 132, 133, 134, 135, 237, 10, + 242, 249, 11, 60, 37, 49, 164, 126, 127, 128, + 129, 130, 131, 132, 133, 134, 135, 228, 175, 241, + 231, 200, 105, 0, 0, 236, 126, 127, 128, 129, + 130, 131, 132, 133, 134, 135, 126, 127, 0, 129, + 130, 131, 132, 133, 134, 135, 126, 127, 0, 0, + 130, 131, 132, 133, 134, 135, 126, 127, 0, 0, + 0, 131, 132, 133, 134, 135 }; 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, + 61, 36, 31, 1, 81, 42, 12, 36, 85, 86, + 87, 13, 6, 66, 12, 17, 60, 59, 60, 61, + 62, 63, 99, 84, 101, 102, 103, 104, 72, 66, + 24, 25, 22, 23, 87, 29, 30, 114, 39, 37, + 21, 76, 119, 120, 121, 122, 123, 124, 125, 126, + 127, 128, 129, 130, 131, 132, 133, 134, 135, 112, + 12, 13, 14, 15, 16, 71, 18, 19, 20, 21, + 71, 23, 45, 46, 12, 72, 69, 154, 12, 76, + 32, 33, 34, 35, 45, 46, 38, 45, 46, 72, + 67, 43, 44, 76, 12, 47, 14, 15, 16, 72, + 18, 19, 20, 21, 4, 23, 45, 46, 60, 170, + 171, 72, 64, 12, 32, 33, 34, 35, 12, 71, + 14, 15, 16, 8, 18, 19, 20, 21, 71, 23, + 73, 74, 5, 6, 7, 212, 69, 9, 32, 33, + 69, 12, 60, 10, 70, 13, 64, 69, 12, 18, + 227, 204, 21, 71, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 70, 11, 60, 70, 245, 18, + 64, 61, 62, 63, 43, 44, 237, 71, 0, 1, + 69, 3, 68, 5, 6, 7, 37, 21, 249, 40, + 41, 60, 23, 22, 74, 74, 71, 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, 62, 63, 37, 37, 6, 40, 41, 71, 12, + 42, 72, 6, 23, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 24, 25, 26, 27, 28, 29, 30, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 72, 75, 71, + 71, 12, 71, 76, 72, 18, 21, 21, 75, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 69, + 75, 72, 12, 72, 46, 18, 69, 72, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 71, 3, + 72, 71, 3, 51, 31, 39, 72, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 214, 118, 234, + 214, 161, 81, -1, -1, 72, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 54, 55, -1, 57, + 58, 59, 60, 61, 62, 63, 54, 55, -1, -1, + 58, 59, 60, 61, 62, 63, 54, 55, -1, -1, + -1, 59, 60, 61, 62, 63 }; /* 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, 101, 103, 105, 111, 112, 31, + 36, 74, 74, 71, 71, 127, 128, 111, 128, 128, + 112, 128, 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, 112, 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, 112, 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, 112, 118, 118, + 119, 119, 120, 120, 121, 122, 122, 124, 123, 123, + 125, 125, 126, 126, 127, 127, 127, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128 }; /* 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, 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 }; +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 +1236,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 +1273,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 +1335,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 +1358,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 +1387,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 +1411,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 272 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1440 "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 276 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1446 "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 273 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1452 "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 274 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1458 "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 275 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1464 "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 277 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1470 "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 278 "grammar.y" + { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } +#line 1476 "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 279 "grammar.y" + { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } +#line 1482 "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 280 "grammar.y" + { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } +#line 1488 "grammar.c" break; - case 96: /* string_modifiers */ -#line 288 "grammar.y" /* yacc.c:1258 */ - { + case 101: /* string_modifiers */ +#line 293 "grammar.y" + { if (((*yyvaluep).modifier).alphabet != NULL) { yr_free(((*yyvaluep).modifier).alphabet); ((*yyvaluep).modifier).alphabet = NULL; } } -#line 1477 "grammar.c" /* yacc.c:1258 */ +#line 1500 "grammar.c" break; - case 97: /* string_modifier */ -#line 280 "grammar.y" /* yacc.c:1258 */ - { + case 102: /* string_modifier */ +#line 285 "grammar.y" + { if (((*yyvaluep).modifier).alphabet != NULL) { yr_free(((*yyvaluep).modifier).alphabet); ((*yyvaluep).modifier).alphabet = NULL; } } -#line 1489 "grammar.c" /* yacc.c:1258 */ +#line 1512 "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 282 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1518 "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 283 "grammar.y" + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } +#line 1524 "grammar.c" break; - default: break; } @@ -1510,6 +1532,8 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *yyscanner, Y + + /*----------. | yyparse. | `----------*/ @@ -1530,7 +1554,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 +1565,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 +1595,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 +1666,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 +1679,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 +1713,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 +1763,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 +1784,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 +1804,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 327 "grammar.y" + { _yr_compiler_pop_file_name(compiler); } -#line 1771 "grammar.c" /* yacc.c:1663 */ +#line 1813 "grammar.c" break; case 9: -#line 330 "grammar.y" /* yacc.c:1663 */ - { +#line 335 "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 1825 "grammar.c" break; case 10: -#line 342 "grammar.y" /* yacc.c:1663 */ - { +#line 347 "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 1834 "grammar.c" break; case 11: -#line 347 "grammar.y" /* yacc.c:1663 */ - { +#line 352 "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 1852 "grammar.c" break; case 12: -#line 361 "grammar.y" /* yacc.c:1663 */ - { +#line 366 "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 1865 "grammar.c" break; case 13: -#line 374 "grammar.y" /* yacc.c:1663 */ - { +#line 379 "grammar.y" + { (yyval.meta) = YR_ARENA_NULL_REF; } -#line 1831 "grammar.c" /* yacc.c:1663 */ +#line 1873 "grammar.c" break; case 14: -#line 378 "grammar.y" /* yacc.c:1663 */ - { +#line 383 "grammar.y" + { YR_META* meta = yr_arena_get_ptr( compiler->arena, YR_METAS_TABLE, @@ -1842,20 +1884,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.meta) = (yyvsp[0].meta); } -#line 1846 "grammar.c" /* yacc.c:1663 */ +#line 1888 "grammar.c" break; case 15: -#line 393 "grammar.y" /* yacc.c:1663 */ - { +#line 398 "grammar.y" + { (yyval.string) = YR_ARENA_NULL_REF; } -#line 1854 "grammar.c" /* yacc.c:1663 */ +#line 1896 "grammar.c" break; case 16: -#line 397 "grammar.y" /* yacc.c:1663 */ - { +#line 402 "grammar.y" + { YR_STRING* string = (YR_STRING*) yr_arena_get_ptr( compiler->arena, YR_STRINGS_TABLE, @@ -1865,44 +1907,60 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.string) = (yyvsp[0].string); } -#line 1869 "grammar.c" /* yacc.c:1663 */ +#line 1911 "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 416 "grammar.y" + { + (yyval.expression).type = EXPRESSION_TYPE_UNKNOWN; + } +#line 1919 "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 420 "grammar.y" + { + (yyval.expression) = (yyvsp[0].expression); + } +#line 1927 "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 431 "grammar.y" + { (yyval.integer) = 0; } +#line 1933 "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 432 "grammar.y" + { (yyval.integer) = (yyvsp[-1].integer) | (yyvsp[0].integer); } +#line 1939 "grammar.c" break; case 22: -#line 429 "grammar.y" /* yacc.c:1663 */ - { +#line 437 "grammar.y" + { (yyval.integer) = RULE_FLAGS_PRIVATE; } +#line 1945 "grammar.c" + break; + + case 23: +#line 438 "grammar.y" + { (yyval.integer) = RULE_FLAGS_GLOBAL; } +#line 1951 "grammar.c" + break; + + case 24: +#line 444 "grammar.y" + { (yyval.tag) = YR_ARENA_NULL_REF; } -#line 1901 "grammar.c" /* yacc.c:1663 */ +#line 1959 "grammar.c" break; - case 23: -#line 433 "grammar.y" /* yacc.c:1663 */ - { + case 25: +#line 448 "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 +1971,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.tag) = (yyvsp[0].tag); } -#line 1917 "grammar.c" /* yacc.c:1663 */ +#line 1975 "grammar.c" break; - case 24: -#line 449 "grammar.y" /* yacc.c:1663 */ - { + case 26: +#line 464 "grammar.y" + { int result = yr_arena_write_string( yyget_extra(yyscanner)->arena, YR_SZ_POOL, (yyvsp[0].c_string), &(yyval.tag)); @@ -1926,12 +1984,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 1930 "grammar.c" /* yacc.c:1663 */ +#line 1988 "grammar.c" break; - case 25: -#line 458 "grammar.y" /* yacc.c:1663 */ - { + case 27: +#line 473 "grammar.y" + { YR_ARENA_REF ref; // Write the new tag identifier. @@ -1967,24 +2025,24 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.tag) = (yyvsp[-1].tag); } -#line 1971 "grammar.c" /* yacc.c:1663 */ +#line 2029 "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 514 "grammar.y" + { (yyval.meta) = (yyvsp[0].meta); } +#line 2035 "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 515 "grammar.y" + { (yyval.meta) = (yyvsp[-1].meta); } +#line 2041 "grammar.c" break; - case 28: -#line 506 "grammar.y" /* yacc.c:1663 */ - { + case 30: +#line 521 "grammar.y" + { SIZED_STRING* sized_string = (yyvsp[0].sized_string); int result = yr_parser_reduce_meta_declaration( @@ -2000,12 +2058,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2004 "grammar.c" /* yacc.c:1663 */ +#line 2062 "grammar.c" break; - case 29: -#line 523 "grammar.y" /* yacc.c:1663 */ - { + case 31: +#line 538 "grammar.y" + { int result = yr_parser_reduce_meta_declaration( yyscanner, META_TYPE_INTEGER, @@ -2018,12 +2076,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2022 "grammar.c" /* yacc.c:1663 */ +#line 2080 "grammar.c" break; - case 30: -#line 537 "grammar.y" /* yacc.c:1663 */ - { + case 32: +#line 552 "grammar.y" + { int result = yr_parser_reduce_meta_declaration( yyscanner, META_TYPE_INTEGER, @@ -2036,12 +2094,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2040 "grammar.c" /* yacc.c:1663 */ +#line 2098 "grammar.c" break; - case 31: -#line 551 "grammar.y" /* yacc.c:1663 */ - { + case 33: +#line 566 "grammar.y" + { int result = yr_parser_reduce_meta_declaration( yyscanner, META_TYPE_BOOLEAN, @@ -2054,12 +2112,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2058 "grammar.c" /* yacc.c:1663 */ +#line 2116 "grammar.c" break; - case 32: -#line 565 "grammar.y" /* yacc.c:1663 */ - { + case 34: +#line 580 "grammar.y" + { int result = yr_parser_reduce_meta_declaration( yyscanner, META_TYPE_BOOLEAN, @@ -2072,32 +2130,150 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2076 "grammar.c" /* yacc.c:1663 */ +#line 2134 "grammar.c" break; - case 33: -#line 582 "grammar.y" /* yacc.c:1663 */ - { (yyval.string) = (yyvsp[0].string); } -#line 2082 "grammar.c" /* yacc.c:1663 */ + case 35: +#line 596 "grammar.y" + { (yyval.expression) = (yyvsp[0].expression); } +#line 2140 "grammar.c" break; - case 34: -#line 583 "grammar.y" /* yacc.c:1663 */ - { (yyval.string) = (yyvsp[-1].string); } -#line 2088 "grammar.c" /* yacc.c:1663 */ + case 36: +#line 597 "grammar.y" + { (yyval.expression) = (yyvsp[-1].expression); } +#line 2146 "grammar.c" break; - case 35: -#line 589 "grammar.y" /* yacc.c:1663 */ - { + case 37: +#line 602 "grammar.y" + { compiler->current_line = yyget_lineno(yyscanner); } -#line 2096 "grammar.c" /* yacc.c:1663 */ +#line 2154 "grammar.c" break; - case 36: -#line 593 "grammar.y" /* yacc.c:1663 */ - { + case 38: +#line 606 "grammar.y" + { + YR_OBJECT* object; + YR_INTERNAL_VARIABLE* int_var; + YR_ARENA_REF int_ref; + YR_ARENA_REF identifier_ref; + uint8_t obj_type; + + YR_RULE* rule = _yr_compiler_get_rule_by_idx(compiler, + compiler->current_rule_idx); + + 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)); + } + + object = (YR_OBJECT*)yr_hash_table_lookup( + rule->internal_variables_table, + (yyvsp[-3].c_string), + 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), + offsetof(YR_INTERNAL_VARIABLE, rule), + EOL); + + int_var = yr_arena_ref_to_ptr(compiler->arena, &int_ref); + + _yr_compiler_store_string( + compiler, + (yyvsp[-3].c_string), + &identifier_ref); + + switch((yyvsp[0].expression).type) { + case EXPRESSION_TYPE_BOOLEAN: + case EXPRESSION_TYPE_INTEGER: + obj_type = OBJECT_TYPE_INTEGER; + break; + case EXPRESSION_TYPE_FLOAT: + obj_type = OBJECT_TYPE_FLOAT; + break; + case EXPRESSION_TYPE_STRING: + obj_type = OBJECT_TYPE_STRING; + break; + default: assert(false); + } + + int_var->identifier = yr_arena_ref_to_ptr( + compiler->arena, &identifier_ref); + int_var->rule = rule; + int_var->type = obj_type; + + yr_object_create( + int_var->type, + int_var->identifier, + NULL, + &object); + + FAIL_ON_ERROR_WITH_CLEANUP(yr_hash_table_add( + rule->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); + + /* + // get object from ext var + yr_object_from_external_variable(ext, &object); + */ + + yr_free((yyvsp[-3].c_string)); + } +#line 2252 "grammar.c" + break; + + case 39: +#line 702 "grammar.y" + { (yyval.string) = (yyvsp[0].string); } +#line 2258 "grammar.c" + break; + + case 40: +#line 703 "grammar.y" + { (yyval.string) = (yyvsp[-1].string); } +#line 2264 "grammar.c" + break; + + case 41: +#line 709 "grammar.y" + { + compiler->current_line = yyget_lineno(yyscanner); + } +#line 2272 "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)); @@ -2108,20 +2284,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); compiler->current_line = 0; } -#line 2112 "grammar.c" /* yacc.c:1663 */ +#line 2288 "grammar.c" break; - case 37: -#line 605 "grammar.y" /* yacc.c:1663 */ - { + case 43: +#line 725 "grammar.y" + { compiler->current_line = yyget_lineno(yyscanner); } -#line 2120 "grammar.c" /* yacc.c:1663 */ +#line 2296 "grammar.c" break; - case 38: -#line 609 "grammar.y" /* yacc.c:1663 */ - { + case 44: +#line 729 "grammar.y" + { int result; (yyvsp[0].modifier).flags |= STRING_FLAGS_REGEXP; @@ -2136,20 +2312,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->current_line = 0; } -#line 2140 "grammar.c" /* yacc.c:1663 */ +#line 2316 "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 2324 "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 +2340,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->current_line = 0; } -#line 2168 "grammar.c" /* yacc.c:1663 */ +#line 2344 "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 2355 "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 +2411,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 2415 "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 2421 "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 2427 "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 2433 "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 2439 "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 2445 "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 2455 "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 +2471,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 2475 "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 +2506,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 2510 "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 2519 "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 +2536,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 2540 "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 2549 "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 +2566,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 2570 "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 2576 "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 +2587,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 2591 "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 2597 "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 2603 "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 2609 "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 2615 "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 2621 "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 2627 "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 +2638,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 2642 "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 2648 "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; @@ -2498,8 +2674,16 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); // Search for identifier within the global namespace, where the // externals variables reside. - YR_OBJECT* object = (YR_OBJECT*) yr_hash_table_lookup( - compiler->objects_table, (yyvsp[0].c_string), NULL); + YR_OBJECT* object; + + YR_RULE* rule = _yr_compiler_get_rule_by_idx(compiler, compiler->current_rule_idx); + + object = yr_hash_table_lookup(rule->internal_variables_table, (yyvsp[0].c_string), NULL); + + if (object == NULL) { + 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 +2751,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2571 "grammar.c" /* yacc.c:1663 */ +#line 2755 "grammar.c" break; - case 66: -#line 963 "grammar.y" /* yacc.c:1663 */ - { + case 72: +#line 1091 "grammar.y" + { int result = ERROR_SUCCESS; YR_OBJECT* field = NULL; @@ -2619,12 +2803,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2623 "grammar.c" /* yacc.c:1663 */ +#line 2807 "grammar.c" break; - case 67: -#line 1011 "grammar.y" /* yacc.c:1663 */ - { + case 73: +#line 1139 "grammar.y" + { int result = ERROR_SUCCESS; YR_OBJECT_ARRAY* array; YR_OBJECT_DICTIONARY* dict; @@ -2683,12 +2867,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2687 "grammar.c" /* yacc.c:1663 */ +#line 2871 "grammar.c" break; - case 68: -#line 1072 "grammar.y" /* yacc.c:1663 */ - { + case 74: +#line 1200 "grammar.y" + { YR_ARENA_REF ref; int result = ERROR_SUCCESS; YR_OBJECT_FUNCTION* function; @@ -2730,24 +2914,24 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2734 "grammar.c" /* yacc.c:1663 */ +#line 2918 "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 1246 "grammar.y" + { (yyval.c_string) = yr_strdup(""); } +#line 2924 "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 1247 "grammar.y" + { (yyval.c_string) = (yyvsp[0].c_string); } +#line 2930 "grammar.c" break; - case 71: -#line 1124 "grammar.y" /* yacc.c:1663 */ - { + case 77: +#line 1252 "grammar.y" + { (yyval.c_string) = (char*) yr_malloc(YR_MAX_FUNCTION_ARGS + 1); if ((yyval.c_string) == NULL) @@ -2781,12 +2965,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); assert(compiler->last_error != ERROR_SUCCESS); } } -#line 2785 "grammar.c" /* yacc.c:1663 */ +#line 2969 "grammar.c" break; - case 72: -#line 1159 "grammar.y" /* yacc.c:1663 */ - { + case 78: +#line 1287 "grammar.y" + { int result = ERROR_SUCCESS; if (strlen((yyvsp[-2].c_string)) == YR_MAX_FUNCTION_ARGS) @@ -2834,12 +3018,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.c_string) = (yyvsp[-2].c_string); } -#line 2838 "grammar.c" /* yacc.c:1663 */ +#line 3022 "grammar.c" break; - case 73: -#line 1212 "grammar.y" /* yacc.c:1663 */ - { + case 79: +#line 1340 "grammar.y" + { SIZED_STRING* sized_string = (yyvsp[0].sized_string); YR_ARENA_REF re_ref; RE_ERROR error; @@ -2877,12 +3061,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_REGEXP; } -#line 2881 "grammar.c" /* yacc.c:1663 */ +#line 3065 "grammar.c" break; - case 74: -#line 1255 "grammar.y" /* yacc.c:1663 */ - { + case 80: +#line 1383 "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 +3085,32 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 2905 "grammar.c" /* yacc.c:1663 */ +#line 3089 "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 1406 "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 3099 "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 1412 "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 3109 "grammar.c" break; - case 77: -#line 1292 "grammar.y" /* yacc.c:1663 */ - { + case 83: +#line 1418 "grammar.y" + { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "matches"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_REGEXP, "matches"); @@ -2939,12 +3121,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 2943 "grammar.c" /* yacc.c:1663 */ +#line 3125 "grammar.c" break; - case 78: -#line 1304 "grammar.y" /* yacc.c:1663 */ - { + case 84: +#line 1430 "grammar.y" + { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "contains"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "contains"); @@ -2953,12 +3135,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 2957 "grammar.c" /* yacc.c:1663 */ +#line 3139 "grammar.c" break; - case 79: -#line 1314 "grammar.y" /* yacc.c:1663 */ - { + case 85: +#line 1440 "grammar.y" + { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[0].c_string), @@ -2971,12 +3153,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 2975 "grammar.c" /* yacc.c:1663 */ +#line 3157 "grammar.c" break; - case 80: -#line 1328 "grammar.y" /* yacc.c:1663 */ - { + case 86: +#line 1454 "grammar.y" + { int result; check_type_with_cleanup((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "at", yr_free((yyvsp[-2].c_string))); @@ -2990,12 +3172,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 2994 "grammar.c" /* yacc.c:1663 */ +#line 3176 "grammar.c" break; - case 81: -#line 1343 "grammar.y" /* yacc.c:1663 */ - { + case 87: +#line 1469 "grammar.y" + { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-2].c_string), OP_FOUND_IN, YR_UNDEFINED); @@ -3005,12 +3187,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3009 "grammar.c" /* yacc.c:1663 */ +#line 3191 "grammar.c" break; - case 82: -#line 1354 "grammar.y" /* yacc.c:1663 */ - { + case 88: +#line 1480 "grammar.y" + { int i; // Free all the loop variable identifiers, including the variables for @@ -3028,12 +3210,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->loop_index = -1; YYERROR; } -#line 3032 "grammar.c" /* yacc.c:1663 */ +#line 3214 "grammar.c" break; - case 83: -#line 1432 "grammar.y" /* yacc.c:1663 */ - { + case 89: +#line 1558 "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 +3252,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 3256 "grammar.c" break; - case 84: -#line 1470 "grammar.y" /* yacc.c:1663 */ - { + case 90: +#line 1596 "grammar.y" + { YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; YR_FIXUP* fixup; @@ -3124,12 +3306,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); loop_ctx->start_ref = loop_start_ref; } -#line 3128 "grammar.c" /* yacc.c:1663 */ +#line 3310 "grammar.c" break; - - case 85: -#line 1520 "grammar.y" /* yacc.c:1663 */ - { + + case 91: +#line 1646 "grammar.y" + { int32_t jmp_offset; YR_FIXUP* fixup; YR_ARENA_REF pop_ref; @@ -3238,12 +3420,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3242 "grammar.c" /* yacc.c:1663 */ +#line 3424 "grammar.c" break; - case 86: -#line 1630 "grammar.y" /* yacc.c:1663 */ - { + case 92: +#line 1756 "grammar.y" + { YR_ARENA_REF ref; int result = ERROR_SUCCESS; @@ -3277,12 +3459,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 3463 "grammar.c" break; - case 87: -#line 1665 "grammar.y" /* yacc.c:1663 */ - { + case 93: +#line 1791 "grammar.y" + { int var_frame = 0; compiler->loop_for_of_var_index = -1; @@ -3336,32 +3518,32 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3340 "grammar.c" /* yacc.c:1663 */ +#line 3522 "grammar.c" break; - case 88: -#line 1720 "grammar.y" /* yacc.c:1663 */ - { + case 94: +#line 1846 "grammar.y" + { yr_parser_emit(yyscanner, OP_OF, NULL); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3350 "grammar.c" /* yacc.c:1663 */ +#line 3532 "grammar.c" break; - case 89: -#line 1726 "grammar.y" /* yacc.c:1663 */ - { + case 95: +#line 1852 "grammar.y" + { yr_parser_emit(yyscanner, OP_NOT, NULL); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3360 "grammar.c" /* yacc.c:1663 */ +#line 3542 "grammar.c" break; - case 90: -#line 1732 "grammar.y" /* yacc.c:1663 */ - { + case 96: +#line 1858 "grammar.y" + { YR_FIXUP* fixup; YR_ARENA_REF jmp_offset_ref; @@ -3382,12 +3564,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 3568 "grammar.c" break; - case 91: -#line 1754 "grammar.y" /* yacc.c:1663 */ - { + case 97: +#line 1880 "grammar.y" + { YR_FIXUP* fixup; fail_if_error(yr_parser_emit(yyscanner, OP_AND, NULL)); @@ -3409,12 +3591,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3413 "grammar.c" /* yacc.c:1663 */ +#line 3595 "grammar.c" break; - case 92: -#line 1777 "grammar.y" /* yacc.c:1663 */ - { + case 98: +#line 1903 "grammar.y" + { YR_FIXUP* fixup; YR_ARENA_REF jmp_offset_ref; @@ -3434,12 +3616,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 3620 "grammar.c" break; - case 93: -#line 1798 "grammar.y" /* yacc.c:1663 */ - { + case 99: +#line 1924 "grammar.y" + { YR_FIXUP* fixup; fail_if_error(yr_parser_emit(yyscanner, OP_OR, NULL)); @@ -3461,94 +3643,94 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3465 "grammar.c" /* yacc.c:1663 */ +#line 3647 "grammar.c" break; - case 94: -#line 1821 "grammar.y" /* yacc.c:1663 */ - { + case 100: +#line 1947 "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 3658 "grammar.c" break; - case 95: -#line 1828 "grammar.y" /* yacc.c:1663 */ - { + case 101: +#line 1954 "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 3669 "grammar.c" break; - case 96: -#line 1835 "grammar.y" /* yacc.c:1663 */ - { + case 102: +#line 1961 "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 3680 "grammar.c" break; - case 97: -#line 1842 "grammar.y" /* yacc.c:1663 */ - { + case 103: +#line 1968 "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 3691 "grammar.c" break; - case 98: -#line 1849 "grammar.y" /* yacc.c:1663 */ - { + case 104: +#line 1975 "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 3702 "grammar.c" break; - case 99: -#line 1856 "grammar.y" /* yacc.c:1663 */ - { + case 105: +#line 1982 "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 */ +#line 3713 "grammar.c" break; - case 100: -#line 1863 "grammar.y" /* yacc.c:1663 */ - { + case 106: +#line 1989 "grammar.y" + { (yyval.expression) = (yyvsp[0].expression); } -#line 3539 "grammar.c" /* yacc.c:1663 */ +#line 3721 "grammar.c" break; - case 101: -#line 1867 "grammar.y" /* yacc.c:1663 */ - { + case 107: +#line 1993 "grammar.y" + { (yyval.expression) = (yyvsp[-1].expression); } -#line 3547 "grammar.c" /* yacc.c:1663 */ +#line 3729 "grammar.c" break; - case 102: -#line 1875 "grammar.y" /* yacc.c:1663 */ - { + case 108: +#line 2001 "grammar.y" + { int result = ERROR_SUCCESS; YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; @@ -3567,12 +3749,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 3753 "grammar.c" break; - case 103: -#line 1895 "grammar.y" /* yacc.c:1663 */ - { + case 109: +#line 2021 "grammar.y" + { int result = ERROR_SUCCESS; YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; @@ -3596,12 +3778,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 3782 "grammar.c" break; - case 104: -#line 1923 "grammar.y" /* yacc.c:1663 */ - { + case 110: +#line 2049 "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 +3856,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3678 "grammar.c" /* yacc.c:1663 */ +#line 3860 "grammar.c" break; - case 105: -#line 1997 "grammar.y" /* yacc.c:1663 */ - { + case 111: +#line 2123 "grammar.y" + { int result = ERROR_SUCCESS; YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; @@ -3702,34 +3884,33 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3706 "grammar.c" /* yacc.c:1663 */ +#line 3888 "grammar.c" break; - case 106: -#line 2025 "grammar.y" /* yacc.c:1663 */ - { + case 112: +#line 2151 "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 3900 "grammar.c" break; - case 107: -#line 2034 "grammar.y" /* yacc.c:1663 */ - { + case 113: +#line 2159 "grammar.y" + { fail_if_error(yr_parser_emit( yyscanner, OP_ITER_START_INT_RANGE, NULL)); } -#line 3728 "grammar.c" /* yacc.c:1663 */ +#line 3909 "grammar.c" break; - case 108: -#line 2043 "grammar.y" /* yacc.c:1663 */ - { + case 114: +#line 2168 "grammar.y" + { int result = ERROR_SUCCESS; if ((yyvsp[-3].expression).type != EXPRESSION_TYPE_INTEGER) @@ -3748,12 +3929,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3752 "grammar.c" /* yacc.c:1663 */ +#line 3933 "grammar.c" break; - case 109: -#line 2067 "grammar.y" /* yacc.c:1663 */ - { + case 115: +#line 2192 "grammar.y" + { int result = ERROR_SUCCESS; if ((yyvsp[0].expression).type != EXPRESSION_TYPE_INTEGER) @@ -3767,12 +3948,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = 1; } -#line 3771 "grammar.c" /* yacc.c:1663 */ +#line 3952 "grammar.c" break; - case 110: -#line 2082 "grammar.y" /* yacc.c:1663 */ - { + case 116: +#line 2207 "grammar.y" + { int result = ERROR_SUCCESS; if ((yyvsp[0].expression).type != EXPRESSION_TYPE_INTEGER) @@ -3786,101 +3967,100 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = (yyvsp[-2].integer) + 1; } -#line 3790 "grammar.c" /* yacc.c:1663 */ +#line 3971 "grammar.c" break; - case 111: -#line 2101 "grammar.y" /* yacc.c:1663 */ - { + case 117: +#line 2226 "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 3980 "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 119: +#line 2232 "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 3991 "grammar.c" break; - case 116: -#line 2125 "grammar.y" /* yacc.c:1663 */ - { + case 122: +#line 2249 "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 4002 "grammar.c" break; - case 117: -#line 2132 "grammar.y" /* yacc.c:1663 */ - { + case 123: +#line 2256 "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 4013 "grammar.c" break; - case 118: -#line 2143 "grammar.y" /* yacc.c:1663 */ - { + case 124: +#line 2267 "grammar.y" + { (yyval.integer) = FOR_EXPRESSION_ANY; } -#line 3841 "grammar.c" /* yacc.c:1663 */ +#line 4021 "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 125: +#line 2271 "grammar.y" + { + yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); (yyval.integer) = FOR_EXPRESSION_ALL; } -#line 3850 "grammar.c" /* yacc.c:1663 */ +#line 4030 "grammar.c" break; - case 120: -#line 2152 "grammar.y" /* yacc.c:1663 */ - { - yr_parser_emit_with_arg(yyscanner, OP_PUSH, 1, NULL, NULL); + case 126: +#line 2276 "grammar.y" + { + yr_parser_emit_push_const(yyscanner, 1); (yyval.integer) = FOR_EXPRESSION_ANY; } -#line 3859 "grammar.c" /* yacc.c:1663 */ +#line 4039 "grammar.c" break; - case 121: -#line 2161 "grammar.y" /* yacc.c:1663 */ - { + case 127: +#line 2285 "grammar.y" + { (yyval.expression) = (yyvsp[-1].expression); } -#line 3867 "grammar.c" /* yacc.c:1663 */ +#line 4047 "grammar.c" break; - case 122: -#line 2165 "grammar.y" /* yacc.c:1663 */ - { + case 128: +#line 2289 "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 4059 "grammar.c" break; - case 123: -#line 2173 "grammar.y" /* yacc.c:1663 */ - { + case 129: +#line 2297 "grammar.y" + { yywarning(yyscanner, "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " "function from PE module instead."); @@ -3891,12 +4071,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 4075 "grammar.c" break; - case 124: -#line 2185 "grammar.y" /* yacc.c:1663 */ - { + case 130: +#line 2309 "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 +4089,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 4093 "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 2323 "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 4104 "grammar.c" break; - case 126: -#line 2207 "grammar.y" /* yacc.c:1663 */ - { + case 132: +#line 2330 "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 4115 "grammar.c" break; - case 127: -#line 2214 "grammar.y" /* yacc.c:1663 */ - { + case 133: +#line 2337 "grammar.y" + { YR_ARENA_REF ref; int result = _yr_compiler_store_data( @@ -3961,12 +4140,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 4144 "grammar.c" break; - case 128: -#line 2239 "grammar.y" /* yacc.c:1663 */ - { + case 134: +#line 2362 "grammar.y" + { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[0].c_string), OP_COUNT, YR_UNDEFINED); @@ -3977,12 +4156,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 4160 "grammar.c" break; - case 129: -#line 2251 "grammar.y" /* yacc.c:1663 */ - { + case 135: +#line 2374 "grammar.y" + { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-3].c_string), OP_OFFSET, YR_UNDEFINED); @@ -3993,14 +4172,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 4176 "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 2386 "grammar.y" + { + int result = yr_parser_emit_push_const(yyscanner, 1); if (result == ERROR_SUCCESS) result = yr_parser_reduce_string_identifier( @@ -4013,12 +4191,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 4195 "grammar.c" break; - case 131: -#line 2279 "grammar.y" /* yacc.c:1663 */ - { + case 137: +#line 2401 "grammar.y" + { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-3].c_string), OP_LENGTH, YR_UNDEFINED); @@ -4029,14 +4207,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 4211 "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 2413 "grammar.y" + { + int result = yr_parser_emit_push_const(yyscanner, 1); if (result == ERROR_SUCCESS) result = yr_parser_reduce_string_identifier( @@ -4049,12 +4226,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 4230 "grammar.c" break; - case 133: -#line 2307 "grammar.y" /* yacc.c:1663 */ - { + case 139: +#line 2428 "grammar.y" + { int result = ERROR_SUCCESS; if ((yyvsp[0].expression).type == EXPRESSION_TYPE_OBJECT) @@ -4096,12 +4273,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4100 "grammar.c" /* yacc.c:1663 */ +#line 4277 "grammar.c" break; - case 134: -#line 2350 "grammar.y" /* yacc.c:1663 */ - { + case 140: +#line 2471 "grammar.y" + { int result = ERROR_SUCCESS; check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER | EXPRESSION_TYPE_FLOAT, "-"); @@ -4121,12 +4298,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4125 "grammar.c" /* yacc.c:1663 */ +#line 4302 "grammar.c" break; - case 135: -#line 2371 "grammar.y" /* yacc.c:1663 */ - { + case 141: +#line 2492 "grammar.y" + { int result = yr_parser_reduce_operation( yyscanner, "+", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4160,12 +4337,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4164 "grammar.c" /* yacc.c:1663 */ +#line 4341 "grammar.c" break; - case 136: -#line 2406 "grammar.y" /* yacc.c:1663 */ - { + case 142: +#line 2527 "grammar.y" + { int result = yr_parser_reduce_operation( yyscanner, "-", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4199,12 +4376,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4203 "grammar.c" /* yacc.c:1663 */ +#line 4380 "grammar.c" break; - case 137: -#line 2441 "grammar.y" /* yacc.c:1663 */ - { + case 143: +#line 2562 "grammar.y" + { int result = yr_parser_reduce_operation( yyscanner, "*", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4237,12 +4414,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4241 "grammar.c" /* yacc.c:1663 */ +#line 4418 "grammar.c" break; - case 138: -#line 2475 "grammar.y" /* yacc.c:1663 */ - { + case 144: +#line 2596 "grammar.y" + { int result = yr_parser_reduce_operation( yyscanner, "\\", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4266,12 +4443,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4270 "grammar.c" /* yacc.c:1663 */ +#line 4447 "grammar.c" break; - case 139: -#line 2500 "grammar.y" /* yacc.c:1663 */ - { + case 145: +#line 2621 "grammar.y" + { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "%"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "%"); @@ -4287,12 +4464,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(ERROR_DIVISION_BY_ZERO); } } -#line 4291 "grammar.c" /* yacc.c:1663 */ +#line 4468 "grammar.c" break; - case 140: -#line 2517 "grammar.y" /* yacc.c:1663 */ - { + case 146: +#line 2638 "grammar.y" + { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); @@ -4301,12 +4478,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 4482 "grammar.c" break; - case 141: -#line 2527 "grammar.y" /* yacc.c:1663 */ - { + case 147: +#line 2648 "grammar.y" + { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); @@ -4315,12 +4492,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 4496 "grammar.c" break; - case 142: -#line 2537 "grammar.y" /* yacc.c:1663 */ - { + case 148: +#line 2658 "grammar.y" + { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "|"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "|"); @@ -4329,12 +4506,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 4510 "grammar.c" break; - case 143: -#line 2547 "grammar.y" /* yacc.c:1663 */ - { + case 149: +#line 2668 "grammar.y" + { check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "~"); fail_if_error(yr_parser_emit(yyscanner, OP_BITWISE_NOT, NULL)); @@ -4343,12 +4520,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 4524 "grammar.c" break; - case 144: -#line 2557 "grammar.y" /* yacc.c:1663 */ - { + case 150: +#line 2678 "grammar.y" + { int result; check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "<<"); @@ -4367,12 +4544,12 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4371 "grammar.c" /* yacc.c:1663 */ +#line 4548 "grammar.c" break; - case 145: -#line 2577 "grammar.y" /* yacc.c:1663 */ - { + case 151: +#line 2698 "grammar.y" + { int result; check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, ">>"); @@ -4391,19 +4568,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4395 "grammar.c" /* yacc.c:1663 */ +#line 4572 "grammar.c" break; - case 146: -#line 2597 "grammar.y" /* yacc.c:1663 */ - { + case 152: +#line 2718 "grammar.y" + { (yyval.expression) = (yyvsp[0].expression); } -#line 4403 "grammar.c" /* yacc.c:1663 */ +#line 4580 "grammar.c" break; -#line 4407 "grammar.c" /* yacc.c:1663 */ +#line 4584 "grammar.c" + default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4417,25 +4595,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 +4622,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 +4658,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 +4678,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 +4699,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 +4711,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 +4724,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -4592,7 +4732,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 +4743,10 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); /* Fall through. */ #endif + +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -4618,17 +4763,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 2723 "grammar.y" + diff --git a/libyara/grammar.h b/libyara/grammar.h index 367434dd4f..dfe3662d64 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 302 "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 b15c66021c..2ee96d16b0 100644 --- a/libyara/grammar.y +++ b/libyara/grammar.y @@ -609,13 +609,26 @@ variable_declaration YR_ARENA_REF int_ref; YR_ARENA_REF identifier_ref; uint8_t obj_type; - YR_NAMESPACE* ns; + + YR_RULE* rule = _yr_compiler_get_rule_by_idx(compiler, + compiler->current_rule_idx); 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); + } + + object = (YR_OBJECT*)yr_hash_table_lookup( + rule->internal_variables_table, + $1, + NULL); + if(object != NULL) { fail_with_error(ERROR_DUPLICATED_IDENTIFIER); } @@ -626,6 +639,7 @@ variable_declaration sizeof(YR_INTERNAL_VARIABLE), &int_ref, offsetof(YR_INTERNAL_VARIABLE, identifier), + offsetof(YR_INTERNAL_VARIABLE, rule), EOL); int_var = yr_arena_ref_to_ptr(compiler->arena, &int_ref); @@ -651,6 +665,7 @@ variable_declaration int_var->identifier = yr_arena_ref_to_ptr( compiler->arena, &identifier_ref); + int_var->rule = rule; int_var->type = obj_type; yr_object_create( @@ -658,16 +673,11 @@ variable_declaration int_var->identifier, NULL, &object); - - ns = (YR_NAMESPACE*) yr_arena_get_ptr( - compiler->arena, - YR_NAMESPACES_TABLE, - compiler->current_namespace_idx * sizeof(struct YR_NAMESPACE)); FAIL_ON_ERROR_WITH_CLEANUP(yr_hash_table_add( - compiler->objects_table, + rule->internal_variables_table, $1, - ns->name, + NULL, (void*) object), yr_object_destroy(object)); @@ -1000,8 +1010,16 @@ identifier // Search for identifier within the global namespace, where the // externals variables reside. - YR_OBJECT* object = (YR_OBJECT*) yr_hash_table_lookup( - compiler->objects_table, $1, NULL); + YR_OBJECT* object; + + YR_RULE* rule = _yr_compiler_get_rule_by_idx(compiler, compiler->current_rule_idx); + + object = yr_hash_table_lookup(rule->internal_variables_table, $1, NULL); + + if (object == NULL) { + object = (YR_OBJECT*) yr_hash_table_lookup( + compiler->objects_table, $1, NULL); + } YR_NAMESPACE* ns = (YR_NAMESPACE*) yr_arena_get_ptr( compiler->arena, diff --git a/libyara/include/yara/types.h b/libyara/include/yara/types.h index 2476741310..f75b125495 100644 --- a/libyara/include/yara/types.h +++ b/libyara/include/yara/types.h @@ -327,6 +327,8 @@ struct YR_RULE // Number of atoms generated for this rule. int32_t num_atoms; + YR_HASH_TABLE* internal_variables_table; + DECLARE_REFERENCE(const char*, identifier); DECLARE_REFERENCE(const char*, tags); DECLARE_REFERENCE(YR_META*, metas); @@ -361,6 +363,7 @@ struct YR_INTERNAL_VARIABLE int32_t type; DECLARE_REFERENCE(const char*, identifier); + DECLARE_REFERENCE(YR_RULE*, rule); }; struct YR_AC_MATCH 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/parser.c b/libyara/parser.c index 2dd437acee..1a4af03a15 100644 --- a/libyara/parser.c +++ b/libyara/parser.c @@ -938,6 +938,8 @@ int yr_parser_reduce_rule_declaration_phase_1( rule->flags = flags; rule->ns = ns; rule->num_atoms = 0; + + yr_hash_table_create(10, &rule->internal_variables_table); YR_ARENA_REF jmp_offset_ref; diff --git a/libyara/scanner.c b/libyara/scanner.c index f10009a84c..5f96754f56 100644 --- a/libyara/scanner.c +++ b/libyara/scanner.c @@ -252,7 +252,7 @@ YR_API int yr_scanner_create( FAIL_ON_ERROR_WITH_CLEANUP( yr_hash_table_add( - new_scanner->objects_table, + internal->rule->internal_variables_table, internal->identifier, NULL, (void*) object), From 3175da44383a656958b911f709681475bb6aafed Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Mon, 14 Sep 2020 21:59:57 +0200 Subject: [PATCH 07/17] clean up code --- libyara/grammar.c | 486 +++++++++++++++++++++++----------------------- libyara/grammar.y | 10 +- 2 files changed, 244 insertions(+), 252 deletions(-) diff --git a/libyara/grammar.c b/libyara/grammar.c index 90a1073e8d..12dc85b6b3 100644 --- a/libyara/grammar.c +++ b/libyara/grammar.c @@ -881,19 +881,19 @@ static const yytype_int16 yyrline[] = 0, 320, 320, 321, 322, 323, 324, 325, 326, 334, 347, 352, 346, 379, 382, 398, 401, 416, 419, 426, 431, 432, 437, 438, 444, 447, 463, 472, 514, 515, - 520, 537, 551, 565, 579, 596, 597, 602, 601, 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, 1090, 1138, 1199, 1246, 1247, 1251, 1286, 1339, - 1382, 1405, 1411, 1417, 1429, 1439, 1453, 1468, 1479, 1558, - 1596, 1498, 1756, 1755, 1845, 1851, 1858, 1857, 1903, 1902, - 1946, 1953, 1960, 1967, 1974, 1981, 1988, 1992, 2000, 2020, - 2048, 2122, 2150, 2158, 2167, 2191, 2206, 2226, 2225, 2231, - 2242, 2243, 2248, 2255, 2266, 2270, 2275, 2284, 2288, 2296, - 2308, 2322, 2329, 2336, 2361, 2373, 2385, 2400, 2412, 2427, - 2470, 2491, 2526, 2561, 2595, 2620, 2637, 2647, 2657, 2667, - 2677, 2697, 2717 + 520, 537, 551, 565, 579, 596, 597, 602, 601, 698, + 699, 705, 704, 721, 720, 741, 740, 765, 771, 831, + 832, 833, 834, 835, 836, 842, 863, 894, 899, 916, + 921, 941, 942, 956, 957, 958, 959, 960, 964, 965, + 979, 983, 1086, 1134, 1195, 1242, 1243, 1247, 1282, 1335, + 1378, 1401, 1407, 1413, 1425, 1435, 1449, 1464, 1475, 1554, + 1592, 1494, 1752, 1751, 1841, 1847, 1854, 1853, 1899, 1898, + 1942, 1949, 1956, 1963, 1970, 1977, 1984, 1988, 1996, 2016, + 2044, 2118, 2146, 2154, 2163, 2187, 2202, 2222, 2221, 2227, + 2238, 2239, 2244, 2251, 2262, 2266, 2271, 2280, 2284, 2292, + 2304, 2318, 2325, 2332, 2357, 2369, 2381, 2396, 2408, 2423, + 2466, 2487, 2522, 2557, 2591, 2616, 2633, 2643, 2653, 2663, + 2673, 2693, 2713 }; #endif @@ -2156,7 +2156,6 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); case 38: #line 606 "grammar.y" { - YR_OBJECT* object; YR_INTERNAL_VARIABLE* int_var; YR_ARENA_REF int_ref; YR_ARENA_REF identifier_ref; @@ -2165,7 +2164,8 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); YR_RULE* rule = _yr_compiler_get_rule_by_idx(compiler, compiler->current_rule_idx); - object = (YR_OBJECT*)yr_hash_table_lookup( + // 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); @@ -2176,6 +2176,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyvsp[-3].c_string)); } + // Check for duplicated identifier in local rule scope object = (YR_OBJECT*)yr_hash_table_lookup( rule->internal_variables_table, (yyvsp[-3].c_string), @@ -2241,38 +2242,33 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); NULL, NULL); - /* - // get object from ext var - yr_object_from_external_variable(ext, &object); - */ - yr_free((yyvsp[-3].c_string)); } -#line 2252 "grammar.c" +#line 2248 "grammar.c" break; case 39: -#line 702 "grammar.y" +#line 698 "grammar.y" { (yyval.string) = (yyvsp[0].string); } -#line 2258 "grammar.c" +#line 2254 "grammar.c" break; case 40: -#line 703 "grammar.y" +#line 699 "grammar.y" { (yyval.string) = (yyvsp[-1].string); } -#line 2264 "grammar.c" +#line 2260 "grammar.c" break; case 41: -#line 709 "grammar.y" +#line 705 "grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2272 "grammar.c" +#line 2268 "grammar.c" break; case 42: -#line 713 "grammar.y" +#line 709 "grammar.y" { int result = yr_parser_reduce_string_declaration( yyscanner, (yyvsp[0].modifier), (yyvsp[-4].c_string), (yyvsp[-1].sized_string), &(yyval.string)); @@ -2284,19 +2280,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); compiler->current_line = 0; } -#line 2288 "grammar.c" +#line 2284 "grammar.c" break; case 43: -#line 725 "grammar.y" +#line 721 "grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2296 "grammar.c" +#line 2292 "grammar.c" break; case 44: -#line 729 "grammar.y" +#line 725 "grammar.y" { int result; @@ -2312,19 +2308,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->current_line = 0; } -#line 2316 "grammar.c" +#line 2312 "grammar.c" break; case 45: -#line 745 "grammar.y" +#line 741 "grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2324 "grammar.c" +#line 2320 "grammar.c" break; case 46: -#line 749 "grammar.y" +#line 745 "grammar.y" { int result; @@ -2340,22 +2336,22 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->current_line = 0; } -#line 2344 "grammar.c" +#line 2340 "grammar.c" break; case 47: -#line 769 "grammar.y" +#line 765 "grammar.y" { (yyval.modifier).flags = 0; (yyval.modifier).xor_min = 0; (yyval.modifier).xor_max = 0; (yyval.modifier).alphabet = NULL; } -#line 2355 "grammar.c" +#line 2351 "grammar.c" break; case 48: -#line 776 "grammar.y" +#line 772 "grammar.y" { (yyval.modifier) = (yyvsp[-1].modifier); @@ -2411,51 +2407,51 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyval.modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2415 "grammar.c" +#line 2411 "grammar.c" break; case 49: -#line 835 "grammar.y" +#line 831 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_WIDE; } -#line 2421 "grammar.c" +#line 2417 "grammar.c" break; case 50: -#line 836 "grammar.y" +#line 832 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_ASCII; } -#line 2427 "grammar.c" +#line 2423 "grammar.c" break; case 51: -#line 837 "grammar.y" +#line 833 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } -#line 2433 "grammar.c" +#line 2429 "grammar.c" break; case 52: -#line 838 "grammar.y" +#line 834 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } -#line 2439 "grammar.c" +#line 2435 "grammar.c" break; case 53: -#line 839 "grammar.y" +#line 835 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2445 "grammar.c" +#line 2441 "grammar.c" break; case 54: -#line 841 "grammar.y" +#line 837 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_XOR; (yyval.modifier).xor_min = 0; (yyval.modifier).xor_max = 255; } -#line 2455 "grammar.c" +#line 2451 "grammar.c" break; case 55: -#line 847 "grammar.y" +#line 843 "grammar.y" { int result = ERROR_SUCCESS; @@ -2471,11 +2467,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).xor_min = (yyvsp[-1].integer); (yyval.modifier).xor_max = (yyvsp[-1].integer); } -#line 2475 "grammar.c" +#line 2471 "grammar.c" break; case 56: -#line 868 "grammar.y" +#line 864 "grammar.y" { int result = ERROR_SUCCESS; @@ -2506,20 +2502,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).xor_min = (yyvsp[-3].integer); (yyval.modifier).xor_max = (yyvsp[-1].integer); } -#line 2510 "grammar.c" +#line 2506 "grammar.c" break; case 57: -#line 899 "grammar.y" +#line 895 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_BASE64; (yyval.modifier).alphabet = sized_string_new(DEFAULT_BASE64_ALPHABET); } -#line 2519 "grammar.c" +#line 2515 "grammar.c" break; case 58: -#line 904 "grammar.y" +#line 900 "grammar.y" { int result = ERROR_SUCCESS; @@ -2536,20 +2532,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = STRING_FLAGS_BASE64; (yyval.modifier).alphabet = (yyvsp[-1].sized_string); } -#line 2540 "grammar.c" +#line 2536 "grammar.c" break; case 59: -#line 921 "grammar.y" +#line 917 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; (yyval.modifier).alphabet = sized_string_new(DEFAULT_BASE64_ALPHABET); } -#line 2549 "grammar.c" +#line 2545 "grammar.c" break; case 60: -#line 926 "grammar.y" +#line 922 "grammar.y" { int result = ERROR_SUCCESS; @@ -2566,17 +2562,17 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; (yyval.modifier).alphabet = (yyvsp[-1].sized_string); } -#line 2570 "grammar.c" +#line 2566 "grammar.c" break; case 61: -#line 945 "grammar.y" +#line 941 "grammar.y" { (yyval.modifier).flags = 0; } -#line 2576 "grammar.c" +#line 2572 "grammar.c" break; case 62: -#line 947 "grammar.y" +#line 943 "grammar.y" { if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) { @@ -2587,47 +2583,47 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyvsp[-1].modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2591 "grammar.c" +#line 2587 "grammar.c" break; case 63: -#line 960 "grammar.y" +#line 956 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_WIDE; } -#line 2597 "grammar.c" +#line 2593 "grammar.c" break; case 64: -#line 961 "grammar.y" +#line 957 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_ASCII; } -#line 2603 "grammar.c" +#line 2599 "grammar.c" break; case 65: -#line 962 "grammar.y" +#line 958 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } -#line 2609 "grammar.c" +#line 2605 "grammar.c" break; case 66: -#line 963 "grammar.y" +#line 959 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } -#line 2615 "grammar.c" +#line 2611 "grammar.c" break; case 67: -#line 964 "grammar.y" +#line 960 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2621 "grammar.c" +#line 2617 "grammar.c" break; case 68: -#line 968 "grammar.y" +#line 964 "grammar.y" { (yyval.modifier).flags = 0; } -#line 2627 "grammar.c" +#line 2623 "grammar.c" break; case 69: -#line 970 "grammar.y" +#line 966 "grammar.y" { if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) { @@ -2638,17 +2634,17 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyvsp[-1].modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2642 "grammar.c" +#line 2638 "grammar.c" break; case 70: -#line 983 "grammar.y" +#line 979 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2648 "grammar.c" +#line 2644 "grammar.c" break; case 71: -#line 988 "grammar.y" +#line 984 "grammar.y" { YR_EXPRESSION expr; @@ -2751,11 +2747,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2755 "grammar.c" +#line 2751 "grammar.c" break; case 72: -#line 1091 "grammar.y" +#line 1087 "grammar.y" { int result = ERROR_SUCCESS; YR_OBJECT* field = NULL; @@ -2803,11 +2799,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2807 "grammar.c" +#line 2803 "grammar.c" break; case 73: -#line 1139 "grammar.y" +#line 1135 "grammar.y" { int result = ERROR_SUCCESS; YR_OBJECT_ARRAY* array; @@ -2867,11 +2863,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2871 "grammar.c" +#line 2867 "grammar.c" break; case 74: -#line 1200 "grammar.y" +#line 1196 "grammar.y" { YR_ARENA_REF ref; int result = ERROR_SUCCESS; @@ -2914,23 +2910,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2918 "grammar.c" +#line 2914 "grammar.c" break; case 75: -#line 1246 "grammar.y" +#line 1242 "grammar.y" { (yyval.c_string) = yr_strdup(""); } -#line 2924 "grammar.c" +#line 2920 "grammar.c" break; case 76: -#line 1247 "grammar.y" +#line 1243 "grammar.y" { (yyval.c_string) = (yyvsp[0].c_string); } -#line 2930 "grammar.c" +#line 2926 "grammar.c" break; case 77: -#line 1252 "grammar.y" +#line 1248 "grammar.y" { (yyval.c_string) = (char*) yr_malloc(YR_MAX_FUNCTION_ARGS + 1); @@ -2965,11 +2961,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); assert(compiler->last_error != ERROR_SUCCESS); } } -#line 2969 "grammar.c" +#line 2965 "grammar.c" break; case 78: -#line 1287 "grammar.y" +#line 1283 "grammar.y" { int result = ERROR_SUCCESS; @@ -3018,11 +3014,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.c_string) = (yyvsp[-2].c_string); } -#line 3022 "grammar.c" +#line 3018 "grammar.c" break; case 79: -#line 1340 "grammar.y" +#line 1336 "grammar.y" { SIZED_STRING* sized_string = (yyvsp[0].sized_string); YR_ARENA_REF re_ref; @@ -3061,11 +3057,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_REGEXP; } -#line 3065 "grammar.c" +#line 3061 "grammar.c" break; case 80: -#line 1383 "grammar.y" +#line 1379 "grammar.y" { if ((yyvsp[0].expression).type == EXPRESSION_TYPE_STRING) { @@ -3085,31 +3081,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3089 "grammar.c" +#line 3085 "grammar.c" break; case 81: -#line 1406 "grammar.y" +#line 1402 "grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, 1)); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3099 "grammar.c" +#line 3095 "grammar.c" break; case 82: -#line 1412 "grammar.y" +#line 1408 "grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, 0)); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3109 "grammar.c" +#line 3105 "grammar.c" break; case 83: -#line 1418 "grammar.y" +#line 1414 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "matches"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_REGEXP, "matches"); @@ -3121,11 +3117,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3125 "grammar.c" +#line 3121 "grammar.c" break; case 84: -#line 1430 "grammar.y" +#line 1426 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "contains"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "contains"); @@ -3135,11 +3131,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3139 "grammar.c" +#line 3135 "grammar.c" break; case 85: -#line 1440 "grammar.y" +#line 1436 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, @@ -3153,11 +3149,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3157 "grammar.c" +#line 3153 "grammar.c" break; case 86: -#line 1454 "grammar.y" +#line 1450 "grammar.y" { int result; @@ -3172,11 +3168,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3176 "grammar.c" +#line 3172 "grammar.c" break; case 87: -#line 1469 "grammar.y" +#line 1465 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-2].c_string), OP_FOUND_IN, YR_UNDEFINED); @@ -3187,11 +3183,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3191 "grammar.c" +#line 3187 "grammar.c" break; case 88: -#line 1480 "grammar.y" +#line 1476 "grammar.y" { int i; @@ -3210,11 +3206,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->loop_index = -1; YYERROR; } -#line 3214 "grammar.c" +#line 3210 "grammar.c" break; case 89: -#line 1558 "grammar.y" +#line 1554 "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, @@ -3252,11 +3248,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(yr_parser_emit_with_arg( yyscanner, OP_POP_M, var_frame + 2, NULL, NULL)); } -#line 3256 "grammar.c" +#line 3252 "grammar.c" break; case 90: -#line 1596 "grammar.y" +#line 1592 "grammar.y" { YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; YR_FIXUP* fixup; @@ -3306,11 +3302,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); loop_ctx->start_ref = loop_start_ref; } -#line 3310 "grammar.c" +#line 3306 "grammar.c" break; case 91: -#line 1646 "grammar.y" +#line 1642 "grammar.y" { int32_t jmp_offset; YR_FIXUP* fixup; @@ -3420,11 +3416,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3424 "grammar.c" +#line 3420 "grammar.c" break; case 92: -#line 1756 "grammar.y" +#line 1752 "grammar.y" { YR_ARENA_REF ref; @@ -3459,11 +3455,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->loop[compiler->loop_index].vars_internal_count = \ YR_INTERNAL_LOOP_VARS; } -#line 3463 "grammar.c" +#line 3459 "grammar.c" break; case 93: -#line 1791 "grammar.y" +#line 1787 "grammar.y" { int var_frame = 0; @@ -3518,31 +3514,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3522 "grammar.c" +#line 3518 "grammar.c" break; case 94: -#line 1846 "grammar.y" +#line 1842 "grammar.y" { yr_parser_emit(yyscanner, OP_OF, NULL); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3532 "grammar.c" +#line 3528 "grammar.c" break; case 95: -#line 1852 "grammar.y" +#line 1848 "grammar.y" { yr_parser_emit(yyscanner, OP_NOT, NULL); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3542 "grammar.c" +#line 3538 "grammar.c" break; case 96: -#line 1858 "grammar.y" +#line 1854 "grammar.y" { YR_FIXUP* fixup; YR_ARENA_REF jmp_offset_ref; @@ -3564,11 +3560,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fixup->next = compiler->fixup_stack_head; compiler->fixup_stack_head = fixup; } -#line 3568 "grammar.c" +#line 3564 "grammar.c" break; case 97: -#line 1880 "grammar.y" +#line 1876 "grammar.y" { YR_FIXUP* fixup; @@ -3591,11 +3587,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3595 "grammar.c" +#line 3591 "grammar.c" break; case 98: -#line 1903 "grammar.y" +#line 1899 "grammar.y" { YR_FIXUP* fixup; YR_ARENA_REF jmp_offset_ref; @@ -3616,11 +3612,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fixup->next = compiler->fixup_stack_head; compiler->fixup_stack_head = fixup; } -#line 3620 "grammar.c" +#line 3616 "grammar.c" break; case 99: -#line 1924 "grammar.y" +#line 1920 "grammar.y" { YR_FIXUP* fixup; @@ -3643,93 +3639,93 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3647 "grammar.c" +#line 3643 "grammar.c" break; case 100: -#line 1947 "grammar.y" +#line 1943 "grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, "<", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3658 "grammar.c" +#line 3654 "grammar.c" break; case 101: -#line 1954 "grammar.y" +#line 1950 "grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, ">", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3669 "grammar.c" +#line 3665 "grammar.c" break; case 102: -#line 1961 "grammar.y" +#line 1957 "grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, "<=", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3680 "grammar.c" +#line 3676 "grammar.c" break; case 103: -#line 1968 "grammar.y" +#line 1964 "grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, ">=", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3691 "grammar.c" +#line 3687 "grammar.c" break; case 104: -#line 1975 "grammar.y" +#line 1971 "grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, "==", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3702 "grammar.c" +#line 3698 "grammar.c" break; case 105: -#line 1982 "grammar.y" +#line 1978 "grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, "!=", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3713 "grammar.c" +#line 3709 "grammar.c" break; case 106: -#line 1989 "grammar.y" +#line 1985 "grammar.y" { (yyval.expression) = (yyvsp[0].expression); } -#line 3721 "grammar.c" +#line 3717 "grammar.c" break; case 107: -#line 1993 "grammar.y" +#line 1989 "grammar.y" { (yyval.expression) = (yyvsp[-1].expression); } -#line 3729 "grammar.c" +#line 3725 "grammar.c" break; case 108: -#line 2001 "grammar.y" +#line 1997 "grammar.y" { int result = ERROR_SUCCESS; @@ -3749,11 +3745,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); assert(loop_ctx->vars_count <= YR_MAX_LOOP_VARS); } -#line 3753 "grammar.c" +#line 3749 "grammar.c" break; case 109: -#line 2021 "grammar.y" +#line 2017 "grammar.y" { int result = ERROR_SUCCESS; @@ -3778,11 +3774,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); loop_ctx->vars[loop_ctx->vars_count++].identifier.ptr = (yyvsp[0].c_string); } -#line 3782 "grammar.c" +#line 3778 "grammar.c" break; case 110: -#line 2049 "grammar.y" +#line 2045 "grammar.y" { YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; @@ -3856,11 +3852,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3860 "grammar.c" +#line 3856 "grammar.c" break; case 111: -#line 2123 "grammar.y" +#line 2119 "grammar.y" { int result = ERROR_SUCCESS; @@ -3884,11 +3880,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3888 "grammar.c" +#line 3884 "grammar.c" break; case 112: -#line 2151 "grammar.y" +#line 2147 "grammar.y" { // $2 contains the number of integers in the enumeration fail_if_error(yr_parser_emit_push_const(yyscanner, (yyvsp[-1].integer))); @@ -3896,20 +3892,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(yr_parser_emit( yyscanner, OP_ITER_START_INT_ENUM, NULL)); } -#line 3900 "grammar.c" +#line 3896 "grammar.c" break; case 113: -#line 2159 "grammar.y" +#line 2155 "grammar.y" { fail_if_error(yr_parser_emit( yyscanner, OP_ITER_START_INT_RANGE, NULL)); } -#line 3909 "grammar.c" +#line 3905 "grammar.c" break; case 114: -#line 2168 "grammar.y" +#line 2164 "grammar.y" { int result = ERROR_SUCCESS; @@ -3929,11 +3925,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3933 "grammar.c" +#line 3929 "grammar.c" break; case 115: -#line 2192 "grammar.y" +#line 2188 "grammar.y" { int result = ERROR_SUCCESS; @@ -3948,11 +3944,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = 1; } -#line 3952 "grammar.c" +#line 3948 "grammar.c" break; case 116: -#line 2207 "grammar.y" +#line 2203 "grammar.y" { int result = ERROR_SUCCESS; @@ -3967,87 +3963,87 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = (yyvsp[-2].integer) + 1; } -#line 3971 "grammar.c" +#line 3967 "grammar.c" break; case 117: -#line 2226 "grammar.y" +#line 2222 "grammar.y" { // Push end-of-list marker yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); } -#line 3980 "grammar.c" +#line 3976 "grammar.c" break; case 119: -#line 2232 "grammar.y" +#line 2228 "grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, YR_UNDEFINED)); fail_if_error(yr_parser_emit_pushes_for_strings( yyscanner, "$*")); } -#line 3991 "grammar.c" +#line 3987 "grammar.c" break; case 122: -#line 2249 "grammar.y" +#line 2245 "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 4002 "grammar.c" +#line 3998 "grammar.c" break; case 123: -#line 2256 "grammar.y" +#line 2252 "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 4013 "grammar.c" +#line 4009 "grammar.c" break; case 124: -#line 2267 "grammar.y" +#line 2263 "grammar.y" { (yyval.integer) = FOR_EXPRESSION_ANY; } -#line 4021 "grammar.c" +#line 4017 "grammar.c" break; case 125: -#line 2271 "grammar.y" +#line 2267 "grammar.y" { yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); (yyval.integer) = FOR_EXPRESSION_ALL; } -#line 4030 "grammar.c" +#line 4026 "grammar.c" break; case 126: -#line 2276 "grammar.y" +#line 2272 "grammar.y" { yr_parser_emit_push_const(yyscanner, 1); (yyval.integer) = FOR_EXPRESSION_ANY; } -#line 4039 "grammar.c" +#line 4035 "grammar.c" break; case 127: -#line 2285 "grammar.y" +#line 2281 "grammar.y" { (yyval.expression) = (yyvsp[-1].expression); } -#line 4047 "grammar.c" +#line 4043 "grammar.c" break; case 128: -#line 2289 "grammar.y" +#line 2285 "grammar.y" { fail_if_error(yr_parser_emit( yyscanner, OP_FILESIZE, NULL)); @@ -4055,11 +4051,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4059 "grammar.c" +#line 4055 "grammar.c" break; case 129: -#line 2297 "grammar.y" +#line 2293 "grammar.y" { yywarning(yyscanner, "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " @@ -4071,11 +4067,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4075 "grammar.c" +#line 4071 "grammar.c" break; case 130: -#line 2309 "grammar.y" +#line 2305 "grammar.y" { check_type((yyvsp[-1].expression), EXPRESSION_TYPE_INTEGER, "intXXXX or uintXXXX"); @@ -4089,33 +4085,33 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4093 "grammar.c" +#line 4089 "grammar.c" break; case 131: -#line 2323 "grammar.y" +#line 2319 "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 4104 "grammar.c" +#line 4100 "grammar.c" break; case 132: -#line 2330 "grammar.y" +#line 2326 "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 4115 "grammar.c" +#line 4111 "grammar.c" break; case 133: -#line 2337 "grammar.y" +#line 2333 "grammar.y" { YR_ARENA_REF ref; @@ -4140,11 +4136,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_STRING; (yyval.expression).value.sized_string_ref = ref; } -#line 4144 "grammar.c" +#line 4140 "grammar.c" break; case 134: -#line 2362 "grammar.y" +#line 2358 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[0].c_string), OP_COUNT, YR_UNDEFINED); @@ -4156,11 +4152,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4160 "grammar.c" +#line 4156 "grammar.c" break; case 135: -#line 2374 "grammar.y" +#line 2370 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-3].c_string), OP_OFFSET, YR_UNDEFINED); @@ -4172,11 +4168,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4176 "grammar.c" +#line 4172 "grammar.c" break; case 136: -#line 2386 "grammar.y" +#line 2382 "grammar.y" { int result = yr_parser_emit_push_const(yyscanner, 1); @@ -4191,11 +4187,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4195 "grammar.c" +#line 4191 "grammar.c" break; case 137: -#line 2401 "grammar.y" +#line 2397 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-3].c_string), OP_LENGTH, YR_UNDEFINED); @@ -4207,11 +4203,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4211 "grammar.c" +#line 4207 "grammar.c" break; case 138: -#line 2413 "grammar.y" +#line 2409 "grammar.y" { int result = yr_parser_emit_push_const(yyscanner, 1); @@ -4226,11 +4222,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4230 "grammar.c" +#line 4226 "grammar.c" break; case 139: -#line 2428 "grammar.y" +#line 2424 "grammar.y" { int result = ERROR_SUCCESS; @@ -4273,11 +4269,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4277 "grammar.c" +#line 4273 "grammar.c" break; case 140: -#line 2471 "grammar.y" +#line 2467 "grammar.y" { int result = ERROR_SUCCESS; @@ -4298,11 +4294,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4302 "grammar.c" +#line 4298 "grammar.c" break; case 141: -#line 2492 "grammar.y" +#line 2488 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "+", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4337,11 +4333,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4341 "grammar.c" +#line 4337 "grammar.c" break; case 142: -#line 2527 "grammar.y" +#line 2523 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "-", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4376,11 +4372,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4380 "grammar.c" +#line 4376 "grammar.c" break; case 143: -#line 2562 "grammar.y" +#line 2558 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "*", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4414,11 +4410,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4418 "grammar.c" +#line 4414 "grammar.c" break; case 144: -#line 2596 "grammar.y" +#line 2592 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "\\", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4443,11 +4439,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4447 "grammar.c" +#line 4443 "grammar.c" break; case 145: -#line 2621 "grammar.y" +#line 2617 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "%"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "%"); @@ -4464,11 +4460,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(ERROR_DIVISION_BY_ZERO); } } -#line 4468 "grammar.c" +#line 4464 "grammar.c" break; case 146: -#line 2638 "grammar.y" +#line 2634 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); @@ -4478,11 +4474,11 @@ 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 4482 "grammar.c" +#line 4478 "grammar.c" break; case 147: -#line 2648 "grammar.y" +#line 2644 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); @@ -4492,11 +4488,11 @@ 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 4496 "grammar.c" +#line 4492 "grammar.c" break; case 148: -#line 2658 "grammar.y" +#line 2654 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "|"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "|"); @@ -4506,11 +4502,11 @@ 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 4510 "grammar.c" +#line 4506 "grammar.c" break; case 149: -#line 2668 "grammar.y" +#line 2664 "grammar.y" { check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "~"); @@ -4520,11 +4516,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).value.integer = ((yyvsp[0].expression).value.integer == YR_UNDEFINED) ? YR_UNDEFINED : ~((yyvsp[0].expression).value.integer); } -#line 4524 "grammar.c" +#line 4520 "grammar.c" break; case 150: -#line 2678 "grammar.y" +#line 2674 "grammar.y" { int result; @@ -4544,11 +4540,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4548 "grammar.c" +#line 4544 "grammar.c" break; case 151: -#line 2698 "grammar.y" +#line 2694 "grammar.y" { int result; @@ -4568,19 +4564,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4572 "grammar.c" +#line 4568 "grammar.c" break; case 152: -#line 2718 "grammar.y" +#line 2714 "grammar.y" { (yyval.expression) = (yyvsp[0].expression); } -#line 4580 "grammar.c" +#line 4576 "grammar.c" break; -#line 4584 "grammar.c" +#line 4580 "grammar.c" default: break; } @@ -4774,5 +4770,5 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); return yyresult; } -#line 2723 "grammar.y" +#line 2719 "grammar.y" diff --git a/libyara/grammar.y b/libyara/grammar.y index 2ee96d16b0..ec9179845d 100644 --- a/libyara/grammar.y +++ b/libyara/grammar.y @@ -604,7 +604,6 @@ variable_declaration } expression { - YR_OBJECT* object; YR_INTERNAL_VARIABLE* int_var; YR_ARENA_REF int_ref; YR_ARENA_REF identifier_ref; @@ -613,7 +612,8 @@ variable_declaration YR_RULE* rule = _yr_compiler_get_rule_by_idx(compiler, compiler->current_rule_idx); - object = (YR_OBJECT*)yr_hash_table_lookup( + // Check for duplicated identifier in scope with external variables + YR_OBJECT* object = (YR_OBJECT*)yr_hash_table_lookup( compiler->objects_table, $1, NULL); @@ -624,6 +624,7 @@ variable_declaration $1); } + // Check for duplicated identifier in local rule scope object = (YR_OBJECT*)yr_hash_table_lookup( rule->internal_variables_table, $1, @@ -689,11 +690,6 @@ variable_declaration NULL, NULL); - /* - // get object from ext var - yr_object_from_external_variable(ext, &object); - */ - yr_free($1); } ; From 1ed0cac60a99c3afe758e296f0b62edea2569fbe Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Tue, 15 Sep 2020 23:18:57 +0200 Subject: [PATCH 08/17] fix preference of external variable over internal --- libyara/grammar.c | 601 +++++++++++++++++++++++----------------------- libyara/grammar.y | 125 +++++----- 2 files changed, 364 insertions(+), 362 deletions(-) diff --git a/libyara/grammar.c b/libyara/grammar.c index 12dc85b6b3..bdcda603c0 100644 --- a/libyara/grammar.c +++ b/libyara/grammar.c @@ -881,19 +881,19 @@ static const yytype_int16 yyrline[] = 0, 320, 320, 321, 322, 323, 324, 325, 326, 334, 347, 352, 346, 379, 382, 398, 401, 416, 419, 426, 431, 432, 437, 438, 444, 447, 463, 472, 514, 515, - 520, 537, 551, 565, 579, 596, 597, 602, 601, 698, - 699, 705, 704, 721, 720, 741, 740, 765, 771, 831, - 832, 833, 834, 835, 836, 842, 863, 894, 899, 916, - 921, 941, 942, 956, 957, 958, 959, 960, 964, 965, - 979, 983, 1086, 1134, 1195, 1242, 1243, 1247, 1282, 1335, - 1378, 1401, 1407, 1413, 1425, 1435, 1449, 1464, 1475, 1554, - 1592, 1494, 1752, 1751, 1841, 1847, 1854, 1853, 1899, 1898, - 1942, 1949, 1956, 1963, 1970, 1977, 1984, 1988, 1996, 2016, - 2044, 2118, 2146, 2154, 2163, 2187, 2202, 2222, 2221, 2227, - 2238, 2239, 2244, 2251, 2262, 2266, 2271, 2280, 2284, 2292, - 2304, 2318, 2325, 2332, 2357, 2369, 2381, 2396, 2408, 2423, - 2466, 2487, 2522, 2557, 2591, 2616, 2633, 2643, 2653, 2663, - 2673, 2693, 2713 + 520, 537, 551, 565, 579, 596, 597, 602, 601, 699, + 700, 706, 705, 722, 721, 742, 741, 766, 772, 832, + 833, 834, 835, 836, 837, 843, 864, 895, 900, 917, + 922, 942, 943, 957, 958, 959, 960, 961, 965, 966, + 980, 984, 1087, 1135, 1196, 1243, 1244, 1248, 1283, 1336, + 1379, 1402, 1408, 1414, 1426, 1436, 1450, 1465, 1476, 1555, + 1593, 1495, 1753, 1752, 1842, 1848, 1855, 1854, 1900, 1899, + 1943, 1950, 1957, 1964, 1971, 1978, 1985, 1989, 1997, 2017, + 2045, 2119, 2147, 2155, 2164, 2188, 2203, 2223, 2222, 2228, + 2239, 2240, 2245, 2252, 2263, 2267, 2272, 2281, 2285, 2293, + 2305, 2319, 2326, 2333, 2358, 2370, 2382, 2397, 2409, 2424, + 2467, 2488, 2523, 2558, 2592, 2617, 2634, 2644, 2654, 2664, + 2674, 2694, 2714 }; #endif @@ -2174,101 +2174,102 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yywarning(yyscanner, "External variable overrides definition of internal variable \"%s\".", (yyvsp[-3].c_string)); - } - - // Check for duplicated identifier in local rule scope - object = (YR_OBJECT*)yr_hash_table_lookup( - rule->internal_variables_table, - (yyvsp[-3].c_string), - NULL); + yr_parser_emit(yyscanner, OP_POP, NULL); + } else { + // Check for duplicated identifier in local rule scope + object = (YR_OBJECT*)yr_hash_table_lookup( + rule->internal_variables_table, + (yyvsp[-3].c_string), + 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), - offsetof(YR_INTERNAL_VARIABLE, rule), - EOL); + if(object != NULL) { + fail_with_error(ERROR_DUPLICATED_IDENTIFIER); + } - int_var = yr_arena_ref_to_ptr(compiler->arena, &int_ref); + yr_arena_allocate_struct( + compiler->arena, + YR_INTERNAL_VARIABLES_TABLE, + sizeof(YR_INTERNAL_VARIABLE), + &int_ref, + offsetof(YR_INTERNAL_VARIABLE, identifier), + offsetof(YR_INTERNAL_VARIABLE, rule), + EOL); + + int_var = yr_arena_ref_to_ptr(compiler->arena, &int_ref); - _yr_compiler_store_string( - compiler, - (yyvsp[-3].c_string), - &identifier_ref); + _yr_compiler_store_string( + compiler, + (yyvsp[-3].c_string), + &identifier_ref); - switch((yyvsp[0].expression).type) { - case EXPRESSION_TYPE_BOOLEAN: - case EXPRESSION_TYPE_INTEGER: - obj_type = OBJECT_TYPE_INTEGER; - break; - case EXPRESSION_TYPE_FLOAT: - obj_type = OBJECT_TYPE_FLOAT; - break; - case EXPRESSION_TYPE_STRING: - obj_type = OBJECT_TYPE_STRING; - break; - default: assert(false); + switch((yyvsp[0].expression).type) { + case EXPRESSION_TYPE_BOOLEAN: + case EXPRESSION_TYPE_INTEGER: + obj_type = OBJECT_TYPE_INTEGER; + break; + case EXPRESSION_TYPE_FLOAT: + obj_type = OBJECT_TYPE_FLOAT; + break; + case EXPRESSION_TYPE_STRING: + obj_type = OBJECT_TYPE_STRING; + break; + default: assert(false); + } + + int_var->identifier = yr_arena_ref_to_ptr( + compiler->arena, &identifier_ref); + int_var->rule = rule; + int_var->type = obj_type; + + yr_object_create( + int_var->type, + int_var->identifier, + NULL, + &object); + + FAIL_ON_ERROR_WITH_CLEANUP(yr_hash_table_add( + rule->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); } - - int_var->identifier = yr_arena_ref_to_ptr( - compiler->arena, &identifier_ref); - int_var->rule = rule; - int_var->type = obj_type; - - yr_object_create( - int_var->type, - int_var->identifier, - NULL, - &object); - FAIL_ON_ERROR_WITH_CLEANUP(yr_hash_table_add( - rule->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 2248 "grammar.c" +#line 2249 "grammar.c" break; case 39: -#line 698 "grammar.y" +#line 699 "grammar.y" { (yyval.string) = (yyvsp[0].string); } -#line 2254 "grammar.c" +#line 2255 "grammar.c" break; case 40: -#line 699 "grammar.y" +#line 700 "grammar.y" { (yyval.string) = (yyvsp[-1].string); } -#line 2260 "grammar.c" +#line 2261 "grammar.c" break; case 41: -#line 705 "grammar.y" +#line 706 "grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2268 "grammar.c" +#line 2269 "grammar.c" break; case 42: -#line 709 "grammar.y" +#line 710 "grammar.y" { int result = yr_parser_reduce_string_declaration( yyscanner, (yyvsp[0].modifier), (yyvsp[-4].c_string), (yyvsp[-1].sized_string), &(yyval.string)); @@ -2280,19 +2281,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); compiler->current_line = 0; } -#line 2284 "grammar.c" +#line 2285 "grammar.c" break; case 43: -#line 721 "grammar.y" +#line 722 "grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2292 "grammar.c" +#line 2293 "grammar.c" break; case 44: -#line 725 "grammar.y" +#line 726 "grammar.y" { int result; @@ -2308,19 +2309,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->current_line = 0; } -#line 2312 "grammar.c" +#line 2313 "grammar.c" break; case 45: -#line 741 "grammar.y" +#line 742 "grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2320 "grammar.c" +#line 2321 "grammar.c" break; case 46: -#line 745 "grammar.y" +#line 746 "grammar.y" { int result; @@ -2336,22 +2337,22 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->current_line = 0; } -#line 2340 "grammar.c" +#line 2341 "grammar.c" break; case 47: -#line 765 "grammar.y" +#line 766 "grammar.y" { (yyval.modifier).flags = 0; (yyval.modifier).xor_min = 0; (yyval.modifier).xor_max = 0; (yyval.modifier).alphabet = NULL; } -#line 2351 "grammar.c" +#line 2352 "grammar.c" break; case 48: -#line 772 "grammar.y" +#line 773 "grammar.y" { (yyval.modifier) = (yyvsp[-1].modifier); @@ -2407,51 +2408,51 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyval.modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2411 "grammar.c" +#line 2412 "grammar.c" break; case 49: -#line 831 "grammar.y" +#line 832 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_WIDE; } -#line 2417 "grammar.c" +#line 2418 "grammar.c" break; case 50: -#line 832 "grammar.y" +#line 833 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_ASCII; } -#line 2423 "grammar.c" +#line 2424 "grammar.c" break; case 51: -#line 833 "grammar.y" +#line 834 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } -#line 2429 "grammar.c" +#line 2430 "grammar.c" break; case 52: -#line 834 "grammar.y" +#line 835 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } -#line 2435 "grammar.c" +#line 2436 "grammar.c" break; case 53: -#line 835 "grammar.y" +#line 836 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2441 "grammar.c" +#line 2442 "grammar.c" break; case 54: -#line 837 "grammar.y" +#line 838 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_XOR; (yyval.modifier).xor_min = 0; (yyval.modifier).xor_max = 255; } -#line 2451 "grammar.c" +#line 2452 "grammar.c" break; case 55: -#line 843 "grammar.y" +#line 844 "grammar.y" { int result = ERROR_SUCCESS; @@ -2467,11 +2468,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).xor_min = (yyvsp[-1].integer); (yyval.modifier).xor_max = (yyvsp[-1].integer); } -#line 2471 "grammar.c" +#line 2472 "grammar.c" break; case 56: -#line 864 "grammar.y" +#line 865 "grammar.y" { int result = ERROR_SUCCESS; @@ -2502,20 +2503,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).xor_min = (yyvsp[-3].integer); (yyval.modifier).xor_max = (yyvsp[-1].integer); } -#line 2506 "grammar.c" +#line 2507 "grammar.c" break; case 57: -#line 895 "grammar.y" +#line 896 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_BASE64; (yyval.modifier).alphabet = sized_string_new(DEFAULT_BASE64_ALPHABET); } -#line 2515 "grammar.c" +#line 2516 "grammar.c" break; case 58: -#line 900 "grammar.y" +#line 901 "grammar.y" { int result = ERROR_SUCCESS; @@ -2532,20 +2533,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = STRING_FLAGS_BASE64; (yyval.modifier).alphabet = (yyvsp[-1].sized_string); } -#line 2536 "grammar.c" +#line 2537 "grammar.c" break; case 59: -#line 917 "grammar.y" +#line 918 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; (yyval.modifier).alphabet = sized_string_new(DEFAULT_BASE64_ALPHABET); } -#line 2545 "grammar.c" +#line 2546 "grammar.c" break; case 60: -#line 922 "grammar.y" +#line 923 "grammar.y" { int result = ERROR_SUCCESS; @@ -2562,17 +2563,17 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; (yyval.modifier).alphabet = (yyvsp[-1].sized_string); } -#line 2566 "grammar.c" +#line 2567 "grammar.c" break; case 61: -#line 941 "grammar.y" +#line 942 "grammar.y" { (yyval.modifier).flags = 0; } -#line 2572 "grammar.c" +#line 2573 "grammar.c" break; case 62: -#line 943 "grammar.y" +#line 944 "grammar.y" { if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) { @@ -2583,47 +2584,47 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyvsp[-1].modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2587 "grammar.c" +#line 2588 "grammar.c" break; case 63: -#line 956 "grammar.y" +#line 957 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_WIDE; } -#line 2593 "grammar.c" +#line 2594 "grammar.c" break; case 64: -#line 957 "grammar.y" +#line 958 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_ASCII; } -#line 2599 "grammar.c" +#line 2600 "grammar.c" break; case 65: -#line 958 "grammar.y" +#line 959 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } -#line 2605 "grammar.c" +#line 2606 "grammar.c" break; case 66: -#line 959 "grammar.y" +#line 960 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } -#line 2611 "grammar.c" +#line 2612 "grammar.c" break; case 67: -#line 960 "grammar.y" +#line 961 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2617 "grammar.c" +#line 2618 "grammar.c" break; case 68: -#line 964 "grammar.y" +#line 965 "grammar.y" { (yyval.modifier).flags = 0; } -#line 2623 "grammar.c" +#line 2624 "grammar.c" break; case 69: -#line 966 "grammar.y" +#line 967 "grammar.y" { if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) { @@ -2634,17 +2635,17 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyvsp[-1].modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2638 "grammar.c" +#line 2639 "grammar.c" break; case 70: -#line 979 "grammar.y" +#line 980 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2644 "grammar.c" +#line 2645 "grammar.c" break; case 71: -#line 984 "grammar.y" +#line 985 "grammar.y" { YR_EXPRESSION expr; @@ -2747,11 +2748,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2751 "grammar.c" +#line 2752 "grammar.c" break; case 72: -#line 1087 "grammar.y" +#line 1088 "grammar.y" { int result = ERROR_SUCCESS; YR_OBJECT* field = NULL; @@ -2799,11 +2800,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2803 "grammar.c" +#line 2804 "grammar.c" break; case 73: -#line 1135 "grammar.y" +#line 1136 "grammar.y" { int result = ERROR_SUCCESS; YR_OBJECT_ARRAY* array; @@ -2863,11 +2864,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2867 "grammar.c" +#line 2868 "grammar.c" break; case 74: -#line 1196 "grammar.y" +#line 1197 "grammar.y" { YR_ARENA_REF ref; int result = ERROR_SUCCESS; @@ -2910,23 +2911,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2914 "grammar.c" +#line 2915 "grammar.c" break; case 75: -#line 1242 "grammar.y" +#line 1243 "grammar.y" { (yyval.c_string) = yr_strdup(""); } -#line 2920 "grammar.c" +#line 2921 "grammar.c" break; case 76: -#line 1243 "grammar.y" +#line 1244 "grammar.y" { (yyval.c_string) = (yyvsp[0].c_string); } -#line 2926 "grammar.c" +#line 2927 "grammar.c" break; case 77: -#line 1248 "grammar.y" +#line 1249 "grammar.y" { (yyval.c_string) = (char*) yr_malloc(YR_MAX_FUNCTION_ARGS + 1); @@ -2961,11 +2962,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); assert(compiler->last_error != ERROR_SUCCESS); } } -#line 2965 "grammar.c" +#line 2966 "grammar.c" break; case 78: -#line 1283 "grammar.y" +#line 1284 "grammar.y" { int result = ERROR_SUCCESS; @@ -3014,11 +3015,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.c_string) = (yyvsp[-2].c_string); } -#line 3018 "grammar.c" +#line 3019 "grammar.c" break; case 79: -#line 1336 "grammar.y" +#line 1337 "grammar.y" { SIZED_STRING* sized_string = (yyvsp[0].sized_string); YR_ARENA_REF re_ref; @@ -3057,11 +3058,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_REGEXP; } -#line 3061 "grammar.c" +#line 3062 "grammar.c" break; case 80: -#line 1379 "grammar.y" +#line 1380 "grammar.y" { if ((yyvsp[0].expression).type == EXPRESSION_TYPE_STRING) { @@ -3081,31 +3082,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3085 "grammar.c" +#line 3086 "grammar.c" break; case 81: -#line 1402 "grammar.y" +#line 1403 "grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, 1)); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3095 "grammar.c" +#line 3096 "grammar.c" break; case 82: -#line 1408 "grammar.y" +#line 1409 "grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, 0)); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3105 "grammar.c" +#line 3106 "grammar.c" break; case 83: -#line 1414 "grammar.y" +#line 1415 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "matches"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_REGEXP, "matches"); @@ -3117,11 +3118,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3121 "grammar.c" +#line 3122 "grammar.c" break; case 84: -#line 1426 "grammar.y" +#line 1427 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "contains"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "contains"); @@ -3131,11 +3132,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3135 "grammar.c" +#line 3136 "grammar.c" break; case 85: -#line 1436 "grammar.y" +#line 1437 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, @@ -3149,11 +3150,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3153 "grammar.c" +#line 3154 "grammar.c" break; case 86: -#line 1450 "grammar.y" +#line 1451 "grammar.y" { int result; @@ -3168,11 +3169,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3172 "grammar.c" +#line 3173 "grammar.c" break; case 87: -#line 1465 "grammar.y" +#line 1466 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-2].c_string), OP_FOUND_IN, YR_UNDEFINED); @@ -3183,11 +3184,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3187 "grammar.c" +#line 3188 "grammar.c" break; case 88: -#line 1476 "grammar.y" +#line 1477 "grammar.y" { int i; @@ -3206,11 +3207,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->loop_index = -1; YYERROR; } -#line 3210 "grammar.c" +#line 3211 "grammar.c" break; case 89: -#line 1554 "grammar.y" +#line 1555 "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, @@ -3248,11 +3249,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(yr_parser_emit_with_arg( yyscanner, OP_POP_M, var_frame + 2, NULL, NULL)); } -#line 3252 "grammar.c" +#line 3253 "grammar.c" break; case 90: -#line 1592 "grammar.y" +#line 1593 "grammar.y" { YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; YR_FIXUP* fixup; @@ -3302,11 +3303,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); loop_ctx->start_ref = loop_start_ref; } -#line 3306 "grammar.c" +#line 3307 "grammar.c" break; case 91: -#line 1642 "grammar.y" +#line 1643 "grammar.y" { int32_t jmp_offset; YR_FIXUP* fixup; @@ -3416,11 +3417,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3420 "grammar.c" +#line 3421 "grammar.c" break; case 92: -#line 1752 "grammar.y" +#line 1753 "grammar.y" { YR_ARENA_REF ref; @@ -3455,11 +3456,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->loop[compiler->loop_index].vars_internal_count = \ YR_INTERNAL_LOOP_VARS; } -#line 3459 "grammar.c" +#line 3460 "grammar.c" break; case 93: -#line 1787 "grammar.y" +#line 1788 "grammar.y" { int var_frame = 0; @@ -3514,31 +3515,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3518 "grammar.c" +#line 3519 "grammar.c" break; case 94: -#line 1842 "grammar.y" +#line 1843 "grammar.y" { yr_parser_emit(yyscanner, OP_OF, NULL); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3528 "grammar.c" +#line 3529 "grammar.c" break; case 95: -#line 1848 "grammar.y" +#line 1849 "grammar.y" { yr_parser_emit(yyscanner, OP_NOT, NULL); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3538 "grammar.c" +#line 3539 "grammar.c" break; case 96: -#line 1854 "grammar.y" +#line 1855 "grammar.y" { YR_FIXUP* fixup; YR_ARENA_REF jmp_offset_ref; @@ -3560,11 +3561,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fixup->next = compiler->fixup_stack_head; compiler->fixup_stack_head = fixup; } -#line 3564 "grammar.c" +#line 3565 "grammar.c" break; case 97: -#line 1876 "grammar.y" +#line 1877 "grammar.y" { YR_FIXUP* fixup; @@ -3587,11 +3588,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3591 "grammar.c" +#line 3592 "grammar.c" break; case 98: -#line 1899 "grammar.y" +#line 1900 "grammar.y" { YR_FIXUP* fixup; YR_ARENA_REF jmp_offset_ref; @@ -3612,11 +3613,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fixup->next = compiler->fixup_stack_head; compiler->fixup_stack_head = fixup; } -#line 3616 "grammar.c" +#line 3617 "grammar.c" break; case 99: -#line 1920 "grammar.y" +#line 1921 "grammar.y" { YR_FIXUP* fixup; @@ -3639,93 +3640,93 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3643 "grammar.c" +#line 3644 "grammar.c" break; case 100: -#line 1943 "grammar.y" +#line 1944 "grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, "<", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3654 "grammar.c" +#line 3655 "grammar.c" break; case 101: -#line 1950 "grammar.y" +#line 1951 "grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, ">", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3665 "grammar.c" +#line 3666 "grammar.c" break; case 102: -#line 1957 "grammar.y" +#line 1958 "grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, "<=", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3676 "grammar.c" +#line 3677 "grammar.c" break; case 103: -#line 1964 "grammar.y" +#line 1965 "grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, ">=", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3687 "grammar.c" +#line 3688 "grammar.c" break; case 104: -#line 1971 "grammar.y" +#line 1972 "grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, "==", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3698 "grammar.c" +#line 3699 "grammar.c" break; case 105: -#line 1978 "grammar.y" +#line 1979 "grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, "!=", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3709 "grammar.c" +#line 3710 "grammar.c" break; case 106: -#line 1985 "grammar.y" +#line 1986 "grammar.y" { (yyval.expression) = (yyvsp[0].expression); } -#line 3717 "grammar.c" +#line 3718 "grammar.c" break; case 107: -#line 1989 "grammar.y" +#line 1990 "grammar.y" { (yyval.expression) = (yyvsp[-1].expression); } -#line 3725 "grammar.c" +#line 3726 "grammar.c" break; case 108: -#line 1997 "grammar.y" +#line 1998 "grammar.y" { int result = ERROR_SUCCESS; @@ -3745,11 +3746,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); assert(loop_ctx->vars_count <= YR_MAX_LOOP_VARS); } -#line 3749 "grammar.c" +#line 3750 "grammar.c" break; case 109: -#line 2017 "grammar.y" +#line 2018 "grammar.y" { int result = ERROR_SUCCESS; @@ -3774,11 +3775,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); loop_ctx->vars[loop_ctx->vars_count++].identifier.ptr = (yyvsp[0].c_string); } -#line 3778 "grammar.c" +#line 3779 "grammar.c" break; case 110: -#line 2045 "grammar.y" +#line 2046 "grammar.y" { YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; @@ -3852,11 +3853,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3856 "grammar.c" +#line 3857 "grammar.c" break; case 111: -#line 2119 "grammar.y" +#line 2120 "grammar.y" { int result = ERROR_SUCCESS; @@ -3880,11 +3881,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3884 "grammar.c" +#line 3885 "grammar.c" break; case 112: -#line 2147 "grammar.y" +#line 2148 "grammar.y" { // $2 contains the number of integers in the enumeration fail_if_error(yr_parser_emit_push_const(yyscanner, (yyvsp[-1].integer))); @@ -3892,20 +3893,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(yr_parser_emit( yyscanner, OP_ITER_START_INT_ENUM, NULL)); } -#line 3896 "grammar.c" +#line 3897 "grammar.c" break; case 113: -#line 2155 "grammar.y" +#line 2156 "grammar.y" { fail_if_error(yr_parser_emit( yyscanner, OP_ITER_START_INT_RANGE, NULL)); } -#line 3905 "grammar.c" +#line 3906 "grammar.c" break; case 114: -#line 2164 "grammar.y" +#line 2165 "grammar.y" { int result = ERROR_SUCCESS; @@ -3925,11 +3926,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3929 "grammar.c" +#line 3930 "grammar.c" break; case 115: -#line 2188 "grammar.y" +#line 2189 "grammar.y" { int result = ERROR_SUCCESS; @@ -3944,11 +3945,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = 1; } -#line 3948 "grammar.c" +#line 3949 "grammar.c" break; case 116: -#line 2203 "grammar.y" +#line 2204 "grammar.y" { int result = ERROR_SUCCESS; @@ -3963,87 +3964,87 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = (yyvsp[-2].integer) + 1; } -#line 3967 "grammar.c" +#line 3968 "grammar.c" break; case 117: -#line 2222 "grammar.y" +#line 2223 "grammar.y" { // Push end-of-list marker yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); } -#line 3976 "grammar.c" +#line 3977 "grammar.c" break; case 119: -#line 2228 "grammar.y" +#line 2229 "grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, YR_UNDEFINED)); fail_if_error(yr_parser_emit_pushes_for_strings( yyscanner, "$*")); } -#line 3987 "grammar.c" +#line 3988 "grammar.c" break; case 122: -#line 2245 "grammar.y" +#line 2246 "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 3998 "grammar.c" +#line 3999 "grammar.c" break; case 123: -#line 2252 "grammar.y" +#line 2253 "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 4009 "grammar.c" +#line 4010 "grammar.c" break; case 124: -#line 2263 "grammar.y" +#line 2264 "grammar.y" { (yyval.integer) = FOR_EXPRESSION_ANY; } -#line 4017 "grammar.c" +#line 4018 "grammar.c" break; case 125: -#line 2267 "grammar.y" +#line 2268 "grammar.y" { yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); (yyval.integer) = FOR_EXPRESSION_ALL; } -#line 4026 "grammar.c" +#line 4027 "grammar.c" break; case 126: -#line 2272 "grammar.y" +#line 2273 "grammar.y" { yr_parser_emit_push_const(yyscanner, 1); (yyval.integer) = FOR_EXPRESSION_ANY; } -#line 4035 "grammar.c" +#line 4036 "grammar.c" break; case 127: -#line 2281 "grammar.y" +#line 2282 "grammar.y" { (yyval.expression) = (yyvsp[-1].expression); } -#line 4043 "grammar.c" +#line 4044 "grammar.c" break; case 128: -#line 2285 "grammar.y" +#line 2286 "grammar.y" { fail_if_error(yr_parser_emit( yyscanner, OP_FILESIZE, NULL)); @@ -4051,11 +4052,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4055 "grammar.c" +#line 4056 "grammar.c" break; case 129: -#line 2293 "grammar.y" +#line 2294 "grammar.y" { yywarning(yyscanner, "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " @@ -4067,11 +4068,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4071 "grammar.c" +#line 4072 "grammar.c" break; case 130: -#line 2305 "grammar.y" +#line 2306 "grammar.y" { check_type((yyvsp[-1].expression), EXPRESSION_TYPE_INTEGER, "intXXXX or uintXXXX"); @@ -4085,33 +4086,33 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4089 "grammar.c" +#line 4090 "grammar.c" break; case 131: -#line 2319 "grammar.y" +#line 2320 "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 4100 "grammar.c" +#line 4101 "grammar.c" break; case 132: -#line 2326 "grammar.y" +#line 2327 "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 4111 "grammar.c" +#line 4112 "grammar.c" break; case 133: -#line 2333 "grammar.y" +#line 2334 "grammar.y" { YR_ARENA_REF ref; @@ -4136,11 +4137,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_STRING; (yyval.expression).value.sized_string_ref = ref; } -#line 4140 "grammar.c" +#line 4141 "grammar.c" break; case 134: -#line 2358 "grammar.y" +#line 2359 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[0].c_string), OP_COUNT, YR_UNDEFINED); @@ -4152,11 +4153,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4156 "grammar.c" +#line 4157 "grammar.c" break; case 135: -#line 2370 "grammar.y" +#line 2371 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-3].c_string), OP_OFFSET, YR_UNDEFINED); @@ -4168,11 +4169,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4172 "grammar.c" +#line 4173 "grammar.c" break; case 136: -#line 2382 "grammar.y" +#line 2383 "grammar.y" { int result = yr_parser_emit_push_const(yyscanner, 1); @@ -4187,11 +4188,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4191 "grammar.c" +#line 4192 "grammar.c" break; case 137: -#line 2397 "grammar.y" +#line 2398 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-3].c_string), OP_LENGTH, YR_UNDEFINED); @@ -4203,11 +4204,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4207 "grammar.c" +#line 4208 "grammar.c" break; case 138: -#line 2409 "grammar.y" +#line 2410 "grammar.y" { int result = yr_parser_emit_push_const(yyscanner, 1); @@ -4222,11 +4223,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4226 "grammar.c" +#line 4227 "grammar.c" break; case 139: -#line 2424 "grammar.y" +#line 2425 "grammar.y" { int result = ERROR_SUCCESS; @@ -4269,11 +4270,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4273 "grammar.c" +#line 4274 "grammar.c" break; case 140: -#line 2467 "grammar.y" +#line 2468 "grammar.y" { int result = ERROR_SUCCESS; @@ -4294,11 +4295,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4298 "grammar.c" +#line 4299 "grammar.c" break; case 141: -#line 2488 "grammar.y" +#line 2489 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "+", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4333,11 +4334,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4337 "grammar.c" +#line 4338 "grammar.c" break; case 142: -#line 2523 "grammar.y" +#line 2524 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "-", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4372,11 +4373,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4376 "grammar.c" +#line 4377 "grammar.c" break; case 143: -#line 2558 "grammar.y" +#line 2559 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "*", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4410,11 +4411,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4414 "grammar.c" +#line 4415 "grammar.c" break; case 144: -#line 2592 "grammar.y" +#line 2593 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "\\", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4439,11 +4440,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4443 "grammar.c" +#line 4444 "grammar.c" break; case 145: -#line 2617 "grammar.y" +#line 2618 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "%"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "%"); @@ -4460,11 +4461,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(ERROR_DIVISION_BY_ZERO); } } -#line 4464 "grammar.c" +#line 4465 "grammar.c" break; case 146: -#line 2634 "grammar.y" +#line 2635 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); @@ -4474,11 +4475,11 @@ 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 4478 "grammar.c" +#line 4479 "grammar.c" break; case 147: -#line 2644 "grammar.y" +#line 2645 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); @@ -4488,11 +4489,11 @@ 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 4492 "grammar.c" +#line 4493 "grammar.c" break; case 148: -#line 2654 "grammar.y" +#line 2655 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "|"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "|"); @@ -4502,11 +4503,11 @@ 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 4506 "grammar.c" +#line 4507 "grammar.c" break; case 149: -#line 2664 "grammar.y" +#line 2665 "grammar.y" { check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "~"); @@ -4516,11 +4517,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).value.integer = ((yyvsp[0].expression).value.integer == YR_UNDEFINED) ? YR_UNDEFINED : ~((yyvsp[0].expression).value.integer); } -#line 4520 "grammar.c" +#line 4521 "grammar.c" break; case 150: -#line 2674 "grammar.y" +#line 2675 "grammar.y" { int result; @@ -4540,11 +4541,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4544 "grammar.c" +#line 4545 "grammar.c" break; case 151: -#line 2694 "grammar.y" +#line 2695 "grammar.y" { int result; @@ -4564,19 +4565,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4568 "grammar.c" +#line 4569 "grammar.c" break; case 152: -#line 2714 "grammar.y" +#line 2715 "grammar.y" { (yyval.expression) = (yyvsp[0].expression); } -#line 4576 "grammar.c" +#line 4577 "grammar.c" break; -#line 4580 "grammar.c" +#line 4581 "grammar.c" default: break; } @@ -4770,5 +4771,5 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); return yyresult; } -#line 2719 "grammar.y" +#line 2720 "grammar.y" diff --git a/libyara/grammar.y b/libyara/grammar.y index ec9179845d..713428adfb 100644 --- a/libyara/grammar.y +++ b/libyara/grammar.y @@ -622,74 +622,75 @@ variable_declaration yywarning(yyscanner, "External variable overrides definition of internal variable \"%s\".", $1); - } - - // Check for duplicated identifier in local rule scope - object = (YR_OBJECT*)yr_hash_table_lookup( - rule->internal_variables_table, - $1, - NULL); + yr_parser_emit(yyscanner, OP_POP, NULL); + } else { + // Check for duplicated identifier in local rule scope + object = (YR_OBJECT*)yr_hash_table_lookup( + rule->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), - offsetof(YR_INTERNAL_VARIABLE, rule), - EOL); + if(object != NULL) { + fail_with_error(ERROR_DUPLICATED_IDENTIFIER); + } - int_var = yr_arena_ref_to_ptr(compiler->arena, &int_ref); + yr_arena_allocate_struct( + compiler->arena, + YR_INTERNAL_VARIABLES_TABLE, + sizeof(YR_INTERNAL_VARIABLE), + &int_ref, + offsetof(YR_INTERNAL_VARIABLE, identifier), + offsetof(YR_INTERNAL_VARIABLE, rule), + EOL); + + int_var = yr_arena_ref_to_ptr(compiler->arena, &int_ref); - _yr_compiler_store_string( - compiler, - $1, - &identifier_ref); + _yr_compiler_store_string( + compiler, + $1, + &identifier_ref); - switch($4.type) { - case EXPRESSION_TYPE_BOOLEAN: - case EXPRESSION_TYPE_INTEGER: - obj_type = OBJECT_TYPE_INTEGER; - break; - case EXPRESSION_TYPE_FLOAT: - obj_type = OBJECT_TYPE_FLOAT; - break; - case EXPRESSION_TYPE_STRING: - obj_type = OBJECT_TYPE_STRING; - break; - default: assert(false); + switch($4.type) { + case EXPRESSION_TYPE_BOOLEAN: + case EXPRESSION_TYPE_INTEGER: + obj_type = OBJECT_TYPE_INTEGER; + break; + case EXPRESSION_TYPE_FLOAT: + obj_type = OBJECT_TYPE_FLOAT; + break; + case EXPRESSION_TYPE_STRING: + obj_type = OBJECT_TYPE_STRING; + break; + default: assert(false); + } + + int_var->identifier = yr_arena_ref_to_ptr( + compiler->arena, &identifier_ref); + int_var->rule = rule; + int_var->type = obj_type; + + yr_object_create( + int_var->type, + int_var->identifier, + NULL, + &object); + + FAIL_ON_ERROR_WITH_CLEANUP(yr_hash_table_add( + rule->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); } - - int_var->identifier = yr_arena_ref_to_ptr( - compiler->arena, &identifier_ref); - int_var->rule = rule; - int_var->type = obj_type; - - yr_object_create( - int_var->type, - int_var->identifier, - NULL, - &object); - FAIL_ON_ERROR_WITH_CLEANUP(yr_hash_table_add( - rule->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); } ; From 38cd3a8b226731c9b0eabe57891c25b376779e2e Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Sat, 19 Sep 2020 17:37:56 +0200 Subject: [PATCH 09/17] clear allocated memory for internal variables after scanning --- libyara/scanner.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libyara/scanner.c b/libyara/scanner.c index 5f96754f56..e1b95a937e 100644 --- a/libyara/scanner.c +++ b/libyara/scanner.c @@ -275,6 +275,7 @@ YR_API void yr_scanner_destroy( { RE_FIBER* fiber; RE_FIBER* next_fiber; + YR_RULE* rule; fiber = scanner->re_fiber_pool.fibers.head; @@ -292,6 +293,15 @@ YR_API void yr_scanner_destroy( (YR_HASH_TABLE_FREE_VALUE_FUNC) yr_object_destroy); } + rule = (YR_RULE*)scanner->rules->rules_list_head; + while(!RULE_IS_NULL(rule)) { + yr_hash_table_destroy( + rule->internal_variables_table, + (YR_HASH_TABLE_FREE_VALUE_FUNC)yr_object_destroy); + + rule++; + } + #ifdef YR_PROFILING_ENABLED yr_free(scanner->profiling_info); #endif From c69175b9415fff5a17383cb79c1e4766cb926ca4 Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Sat, 19 Sep 2020 21:52:37 +0200 Subject: [PATCH 10/17] destroy internal tables after all scanners are done --- libyara/rules.c | 10 ++++++++++ libyara/scanner.c | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libyara/rules.c b/libyara/rules.c index 86c1de4f0b..c5ffcbe6c8 100644 --- a/libyara/rules.c +++ b/libyara/rules.c @@ -559,6 +559,7 @@ YR_API int yr_rules_destroy( YR_RULES* rules) { YR_EXTERNAL_VARIABLE* external = rules->externals_list_head; + YR_RULE* rule = rules->rules_list_head; while (!EXTERNAL_VARIABLE_IS_NULL(external)) { @@ -568,6 +569,15 @@ YR_API int yr_rules_destroy( external++; } + while(!RULE_IS_NULL(rule)) + { + yr_hash_table_destroy( + rule->internal_variables_table, + (YR_HASH_TABLE_FREE_VALUE_FUNC)yr_object_destroy); + + rule++; + } + yr_arena_release(rules->arena); yr_free(rules); diff --git a/libyara/scanner.c b/libyara/scanner.c index e1b95a937e..5f96754f56 100644 --- a/libyara/scanner.c +++ b/libyara/scanner.c @@ -275,7 +275,6 @@ YR_API void yr_scanner_destroy( { RE_FIBER* fiber; RE_FIBER* next_fiber; - YR_RULE* rule; fiber = scanner->re_fiber_pool.fibers.head; @@ -293,15 +292,6 @@ YR_API void yr_scanner_destroy( (YR_HASH_TABLE_FREE_VALUE_FUNC) yr_object_destroy); } - rule = (YR_RULE*)scanner->rules->rules_list_head; - while(!RULE_IS_NULL(rule)) { - yr_hash_table_destroy( - rule->internal_variables_table, - (YR_HASH_TABLE_FREE_VALUE_FUNC)yr_object_destroy); - - rule++; - } - #ifdef YR_PROFILING_ENABLED yr_free(scanner->profiling_info); #endif From c91a983348e6fa0a10996d3ef2e2aeab494226e5 Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Sun, 20 Sep 2020 19:17:28 +0200 Subject: [PATCH 11/17] separate alloc and dealloc of hashtable in compiler and scanner --- libyara/compiler.c | 11 +++++++++++ libyara/rules.c | 10 ---------- libyara/scanner.c | 26 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/libyara/compiler.c b/libyara/compiler.c index faec6decc9..32a10bd773 100644 --- a/libyara/compiler.c +++ b/libyara/compiler.c @@ -301,6 +301,8 @@ YR_API int yr_compiler_create( YR_API void yr_compiler_destroy( YR_COMPILER* compiler) { + YR_RULE* rule; + yr_arena_release(compiler->arena); if (compiler->automaton != NULL) @@ -322,6 +324,15 @@ YR_API void yr_compiler_destroy( compiler->objects_table, (YR_HASH_TABLE_FREE_VALUE_FUNC) yr_object_destroy); + rule = compiler->rules->rules_list_head; + while(!RULE_IS_NULL(rule)) { + yr_hash_table_destroy( + rule->internal_variables_table, + (YR_HASH_TABLE_FREE_VALUE_FUNC) yr_object_destroy); + + rule++; + } + if (compiler->atoms_config.free_quality_table) yr_free(compiler->atoms_config.quality_table); diff --git a/libyara/rules.c b/libyara/rules.c index c5ffcbe6c8..86c1de4f0b 100644 --- a/libyara/rules.c +++ b/libyara/rules.c @@ -559,7 +559,6 @@ YR_API int yr_rules_destroy( YR_RULES* rules) { YR_EXTERNAL_VARIABLE* external = rules->externals_list_head; - YR_RULE* rule = rules->rules_list_head; while (!EXTERNAL_VARIABLE_IS_NULL(external)) { @@ -569,15 +568,6 @@ YR_API int yr_rules_destroy( external++; } - while(!RULE_IS_NULL(rule)) - { - yr_hash_table_destroy( - rule->internal_variables_table, - (YR_HASH_TABLE_FREE_VALUE_FUNC)yr_object_destroy); - - rule++; - } - yr_arena_release(rules->arena); yr_free(rules); diff --git a/libyara/scanner.c b/libyara/scanner.c index 5f96754f56..b1bb8412b0 100644 --- a/libyara/scanner.c +++ b/libyara/scanner.c @@ -164,6 +164,7 @@ YR_API int yr_scanner_create( YR_RULES* rules, YR_SCANNER** scanner) { + YR_RULE* rule; YR_EXTERNAL_VARIABLE* external; YR_INTERNAL_VARIABLE* internal; YR_SCANNER* new_scanner; @@ -177,6 +178,21 @@ YR_API int yr_scanner_create( yr_hash_table_create(64, &new_scanner->objects_table), yr_free(new_scanner)); + rule = rules->rules_list_head; + while(!RULE_IS_NULL(rule)) { + FAIL_ON_ERROR_WITH_CLEANUP( + yr_hash_table_create(10, &rule->internal_variables_table), + //CLEANUP + for(YR_RULE* r=rules->rules_list_head; rinternal_variables_table, NULL); + }; + yr_free(new_scanner->objects_table); + yr_free(new_scanner)); + + rule++; + } + new_scanner->rules = rules; new_scanner->entry_point = YR_UNDEFINED; new_scanner->canary = rand(); @@ -275,6 +291,7 @@ YR_API void yr_scanner_destroy( { RE_FIBER* fiber; RE_FIBER* next_fiber; + YR_RULE* rule; fiber = scanner->re_fiber_pool.fibers.head; @@ -292,6 +309,15 @@ YR_API void yr_scanner_destroy( (YR_HASH_TABLE_FREE_VALUE_FUNC) yr_object_destroy); } + rule = (YR_RULE*)scanner->rules->rules_list_head; + while(!RULE_IS_NULL(rule)) { + yr_hash_table_destroy( + rule->internal_variables_table, + (YR_HASH_TABLE_FREE_VALUE_FUNC)yr_object_destroy); + + rule++; + } + #ifdef YR_PROFILING_ENABLED yr_free(scanner->profiling_info); #endif From a0a40667a0e9e3af06a6aea99406e8688c968ee5 Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Sun, 20 Sep 2020 19:26:51 +0200 Subject: [PATCH 12/17] dealloc rules after internal variables are dealloced --- libyara/compiler.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libyara/compiler.c b/libyara/compiler.c index 32a10bd773..c9d9ffbe38 100644 --- a/libyara/compiler.c +++ b/libyara/compiler.c @@ -308,10 +308,6 @@ YR_API void yr_compiler_destroy( if (compiler->automaton != NULL) yr_ac_automaton_destroy(compiler->automaton); - yr_hash_table_destroy( - compiler->rules_table, - NULL); - yr_hash_table_destroy( compiler->strings_table, NULL); @@ -333,6 +329,10 @@ YR_API void yr_compiler_destroy( rule++; } + yr_hash_table_destroy( + compiler->rules_table, + NULL); + if (compiler->atoms_config.free_quality_table) yr_free(compiler->atoms_config.quality_table); From 3b18bf16c132e782b1e6035c86ce98bc36ed6775 Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Mon, 21 Sep 2020 02:07:23 +0200 Subject: [PATCH 13/17] internal variable hashtables moved out of rules --- libyara/compiler.c | 22 +- libyara/exec.c | 4 +- libyara/grammar.c | 499 ++++++++++++++++---------------- libyara/grammar.y | 23 +- libyara/include/yara/compiler.h | 1 + libyara/include/yara/types.h | 9 +- libyara/parser.c | 4 +- libyara/scanner.c | 38 ++- 8 files changed, 299 insertions(+), 301 deletions(-) diff --git a/libyara/compiler.c b/libyara/compiler.c index c9d9ffbe38..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); @@ -301,13 +304,15 @@ YR_API int yr_compiler_create( YR_API void yr_compiler_destroy( YR_COMPILER* compiler) { - YR_RULE* rule; - yr_arena_release(compiler->arena); if (compiler->automaton != NULL) yr_ac_automaton_destroy(compiler->automaton); + yr_hash_table_destroy( + compiler->rules_table, + NULL); + yr_hash_table_destroy( compiler->strings_table, NULL); @@ -320,18 +325,9 @@ YR_API void yr_compiler_destroy( compiler->objects_table, (YR_HASH_TABLE_FREE_VALUE_FUNC) yr_object_destroy); - rule = compiler->rules->rules_list_head; - while(!RULE_IS_NULL(rule)) { - yr_hash_table_destroy( - rule->internal_variables_table, - (YR_HASH_TABLE_FREE_VALUE_FUNC) yr_object_destroy); - - rule++; - } - yr_hash_table_destroy( - compiler->rules_table, - NULL); + 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); diff --git a/libyara/exec.c b/libyara/exec.c index 153081f755..6200a9e31c 100644 --- a/libyara/exec.c +++ b/libyara/exec.c @@ -899,7 +899,7 @@ int yr_execute_code( #endif r1.o = (YR_OBJECT*) yr_hash_table_lookup( - current_rule->internal_variables_table, + context->internal_variable_tables[current_rule_idx], identifier, NULL); @@ -924,7 +924,7 @@ int yr_execute_code( pop(r1); YR_OBJECT* obj = (YR_OBJECT*) yr_hash_table_lookup( - current_rule->internal_variables_table, + context->internal_variable_tables[current_rule_idx], identifier, NULL); diff --git a/libyara/grammar.c b/libyara/grammar.c index bdcda603c0..2cd6780262 100644 --- a/libyara/grammar.c +++ b/libyara/grammar.c @@ -881,19 +881,19 @@ static const yytype_int16 yyrline[] = 0, 320, 320, 321, 322, 323, 324, 325, 326, 334, 347, 352, 346, 379, 382, 398, 401, 416, 419, 426, 431, 432, 437, 438, 444, 447, 463, 472, 514, 515, - 520, 537, 551, 565, 579, 596, 597, 602, 601, 699, - 700, 706, 705, 722, 721, 742, 741, 766, 772, 832, - 833, 834, 835, 836, 837, 843, 864, 895, 900, 917, - 922, 942, 943, 957, 958, 959, 960, 961, 965, 966, - 980, 984, 1087, 1135, 1196, 1243, 1244, 1248, 1283, 1336, - 1379, 1402, 1408, 1414, 1426, 1436, 1450, 1465, 1476, 1555, - 1593, 1495, 1753, 1752, 1842, 1848, 1855, 1854, 1900, 1899, - 1943, 1950, 1957, 1964, 1971, 1978, 1985, 1989, 1997, 2017, - 2045, 2119, 2147, 2155, 2164, 2188, 2203, 2223, 2222, 2228, - 2239, 2240, 2245, 2252, 2263, 2267, 2272, 2281, 2285, 2293, - 2305, 2319, 2326, 2333, 2358, 2370, 2382, 2397, 2409, 2424, - 2467, 2488, 2523, 2558, 2592, 2617, 2634, 2644, 2654, 2664, - 2674, 2694, 2714 + 520, 537, 551, 565, 579, 596, 597, 602, 601, 695, + 696, 702, 701, 718, 717, 738, 737, 762, 768, 828, + 829, 830, 831, 832, 833, 839, 860, 891, 896, 913, + 918, 938, 939, 953, 954, 955, 956, 957, 961, 962, + 976, 980, 1082, 1130, 1191, 1238, 1239, 1243, 1278, 1331, + 1374, 1397, 1403, 1409, 1421, 1431, 1445, 1460, 1471, 1550, + 1588, 1490, 1748, 1747, 1837, 1843, 1850, 1849, 1895, 1894, + 1938, 1945, 1952, 1959, 1966, 1973, 1980, 1984, 1992, 2012, + 2040, 2114, 2142, 2150, 2159, 2183, 2198, 2218, 2217, 2223, + 2234, 2235, 2240, 2247, 2258, 2262, 2267, 2276, 2280, 2288, + 2300, 2314, 2321, 2328, 2353, 2365, 2377, 2392, 2404, 2419, + 2462, 2483, 2518, 2553, 2587, 2612, 2629, 2639, 2649, 2659, + 2669, 2689, 2709 }; #endif @@ -2161,9 +2161,6 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); YR_ARENA_REF identifier_ref; uint8_t obj_type; - YR_RULE* rule = _yr_compiler_get_rule_by_idx(compiler, - compiler->current_rule_idx); - // Check for duplicated identifier in scope with external variables YR_OBJECT* object = (YR_OBJECT*)yr_hash_table_lookup( compiler->objects_table, @@ -2178,7 +2175,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); } else { // Check for duplicated identifier in local rule scope object = (YR_OBJECT*)yr_hash_table_lookup( - rule->internal_variables_table, + compiler->current_internal_variables_table, (yyvsp[-3].c_string), NULL); @@ -2192,7 +2189,6 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); sizeof(YR_INTERNAL_VARIABLE), &int_ref, offsetof(YR_INTERNAL_VARIABLE, identifier), - offsetof(YR_INTERNAL_VARIABLE, rule), EOL); int_var = yr_arena_ref_to_ptr(compiler->arena, &int_ref); @@ -2218,7 +2214,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); int_var->identifier = yr_arena_ref_to_ptr( compiler->arena, &identifier_ref); - int_var->rule = rule; + int_var->rule_idx = compiler->current_rule_idx; int_var->type = obj_type; yr_object_create( @@ -2228,7 +2224,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); &object); FAIL_ON_ERROR_WITH_CLEANUP(yr_hash_table_add( - rule->internal_variables_table, + compiler->current_internal_variables_table, (yyvsp[-3].c_string), NULL, (void*) object), @@ -2245,31 +2241,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yr_free((yyvsp[-3].c_string)); } -#line 2249 "grammar.c" +#line 2245 "grammar.c" break; case 39: -#line 699 "grammar.y" +#line 695 "grammar.y" { (yyval.string) = (yyvsp[0].string); } -#line 2255 "grammar.c" +#line 2251 "grammar.c" break; case 40: -#line 700 "grammar.y" +#line 696 "grammar.y" { (yyval.string) = (yyvsp[-1].string); } -#line 2261 "grammar.c" +#line 2257 "grammar.c" break; case 41: -#line 706 "grammar.y" +#line 702 "grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2269 "grammar.c" +#line 2265 "grammar.c" break; case 42: -#line 710 "grammar.y" +#line 706 "grammar.y" { int result = yr_parser_reduce_string_declaration( yyscanner, (yyvsp[0].modifier), (yyvsp[-4].c_string), (yyvsp[-1].sized_string), &(yyval.string)); @@ -2281,19 +2277,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); compiler->current_line = 0; } -#line 2285 "grammar.c" +#line 2281 "grammar.c" break; case 43: -#line 722 "grammar.y" +#line 718 "grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2293 "grammar.c" +#line 2289 "grammar.c" break; case 44: -#line 726 "grammar.y" +#line 722 "grammar.y" { int result; @@ -2309,19 +2305,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->current_line = 0; } -#line 2313 "grammar.c" +#line 2309 "grammar.c" break; case 45: -#line 742 "grammar.y" +#line 738 "grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2321 "grammar.c" +#line 2317 "grammar.c" break; case 46: -#line 746 "grammar.y" +#line 742 "grammar.y" { int result; @@ -2337,22 +2333,22 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->current_line = 0; } -#line 2341 "grammar.c" +#line 2337 "grammar.c" break; case 47: -#line 766 "grammar.y" +#line 762 "grammar.y" { (yyval.modifier).flags = 0; (yyval.modifier).xor_min = 0; (yyval.modifier).xor_max = 0; (yyval.modifier).alphabet = NULL; } -#line 2352 "grammar.c" +#line 2348 "grammar.c" break; case 48: -#line 773 "grammar.y" +#line 769 "grammar.y" { (yyval.modifier) = (yyvsp[-1].modifier); @@ -2408,51 +2404,51 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyval.modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2412 "grammar.c" +#line 2408 "grammar.c" break; case 49: -#line 832 "grammar.y" +#line 828 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_WIDE; } -#line 2418 "grammar.c" +#line 2414 "grammar.c" break; case 50: -#line 833 "grammar.y" +#line 829 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_ASCII; } -#line 2424 "grammar.c" +#line 2420 "grammar.c" break; case 51: -#line 834 "grammar.y" +#line 830 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } -#line 2430 "grammar.c" +#line 2426 "grammar.c" break; case 52: -#line 835 "grammar.y" +#line 831 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } -#line 2436 "grammar.c" +#line 2432 "grammar.c" break; case 53: -#line 836 "grammar.y" +#line 832 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2442 "grammar.c" +#line 2438 "grammar.c" break; case 54: -#line 838 "grammar.y" +#line 834 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_XOR; (yyval.modifier).xor_min = 0; (yyval.modifier).xor_max = 255; } -#line 2452 "grammar.c" +#line 2448 "grammar.c" break; case 55: -#line 844 "grammar.y" +#line 840 "grammar.y" { int result = ERROR_SUCCESS; @@ -2468,11 +2464,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).xor_min = (yyvsp[-1].integer); (yyval.modifier).xor_max = (yyvsp[-1].integer); } -#line 2472 "grammar.c" +#line 2468 "grammar.c" break; case 56: -#line 865 "grammar.y" +#line 861 "grammar.y" { int result = ERROR_SUCCESS; @@ -2503,20 +2499,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).xor_min = (yyvsp[-3].integer); (yyval.modifier).xor_max = (yyvsp[-1].integer); } -#line 2507 "grammar.c" +#line 2503 "grammar.c" break; case 57: -#line 896 "grammar.y" +#line 892 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_BASE64; (yyval.modifier).alphabet = sized_string_new(DEFAULT_BASE64_ALPHABET); } -#line 2516 "grammar.c" +#line 2512 "grammar.c" break; case 58: -#line 901 "grammar.y" +#line 897 "grammar.y" { int result = ERROR_SUCCESS; @@ -2533,20 +2529,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = STRING_FLAGS_BASE64; (yyval.modifier).alphabet = (yyvsp[-1].sized_string); } -#line 2537 "grammar.c" +#line 2533 "grammar.c" break; case 59: -#line 918 "grammar.y" +#line 914 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; (yyval.modifier).alphabet = sized_string_new(DEFAULT_BASE64_ALPHABET); } -#line 2546 "grammar.c" +#line 2542 "grammar.c" break; case 60: -#line 923 "grammar.y" +#line 919 "grammar.y" { int result = ERROR_SUCCESS; @@ -2563,17 +2559,17 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; (yyval.modifier).alphabet = (yyvsp[-1].sized_string); } -#line 2567 "grammar.c" +#line 2563 "grammar.c" break; case 61: -#line 942 "grammar.y" +#line 938 "grammar.y" { (yyval.modifier).flags = 0; } -#line 2573 "grammar.c" +#line 2569 "grammar.c" break; case 62: -#line 944 "grammar.y" +#line 940 "grammar.y" { if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) { @@ -2584,47 +2580,47 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyvsp[-1].modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2588 "grammar.c" +#line 2584 "grammar.c" break; case 63: -#line 957 "grammar.y" +#line 953 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_WIDE; } -#line 2594 "grammar.c" +#line 2590 "grammar.c" break; case 64: -#line 958 "grammar.y" +#line 954 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_ASCII; } -#line 2600 "grammar.c" +#line 2596 "grammar.c" break; case 65: -#line 959 "grammar.y" +#line 955 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } -#line 2606 "grammar.c" +#line 2602 "grammar.c" break; case 66: -#line 960 "grammar.y" +#line 956 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } -#line 2612 "grammar.c" +#line 2608 "grammar.c" break; case 67: -#line 961 "grammar.y" +#line 957 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2618 "grammar.c" +#line 2614 "grammar.c" break; case 68: -#line 965 "grammar.y" +#line 961 "grammar.y" { (yyval.modifier).flags = 0; } -#line 2624 "grammar.c" +#line 2620 "grammar.c" break; case 69: -#line 967 "grammar.y" +#line 963 "grammar.y" { if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) { @@ -2635,17 +2631,17 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyvsp[-1].modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2639 "grammar.c" +#line 2635 "grammar.c" break; case 70: -#line 980 "grammar.y" +#line 976 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2645 "grammar.c" +#line 2641 "grammar.c" break; case 71: -#line 985 "grammar.y" +#line 981 "grammar.y" { YR_EXPRESSION expr; @@ -2668,15 +2664,14 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); } else { + // Search for identifier in current rule scope. + YR_OBJECT* object = yr_hash_table_lookup( + compiler->current_internal_variables_table, + (yyvsp[0].c_string), + NULL); + // Search for identifier within the global namespace, where the // externals variables reside. - - YR_OBJECT* object; - - YR_RULE* rule = _yr_compiler_get_rule_by_idx(compiler, compiler->current_rule_idx); - - object = yr_hash_table_lookup(rule->internal_variables_table, (yyvsp[0].c_string), NULL); - if (object == NULL) { object = (YR_OBJECT*) yr_hash_table_lookup( compiler->objects_table, (yyvsp[0].c_string), NULL); @@ -2748,11 +2743,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2752 "grammar.c" +#line 2747 "grammar.c" break; case 72: -#line 1088 "grammar.y" +#line 1083 "grammar.y" { int result = ERROR_SUCCESS; YR_OBJECT* field = NULL; @@ -2800,11 +2795,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2804 "grammar.c" +#line 2799 "grammar.c" break; case 73: -#line 1136 "grammar.y" +#line 1131 "grammar.y" { int result = ERROR_SUCCESS; YR_OBJECT_ARRAY* array; @@ -2864,11 +2859,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2868 "grammar.c" +#line 2863 "grammar.c" break; case 74: -#line 1197 "grammar.y" +#line 1192 "grammar.y" { YR_ARENA_REF ref; int result = ERROR_SUCCESS; @@ -2911,23 +2906,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2915 "grammar.c" +#line 2910 "grammar.c" break; case 75: -#line 1243 "grammar.y" +#line 1238 "grammar.y" { (yyval.c_string) = yr_strdup(""); } -#line 2921 "grammar.c" +#line 2916 "grammar.c" break; case 76: -#line 1244 "grammar.y" +#line 1239 "grammar.y" { (yyval.c_string) = (yyvsp[0].c_string); } -#line 2927 "grammar.c" +#line 2922 "grammar.c" break; case 77: -#line 1249 "grammar.y" +#line 1244 "grammar.y" { (yyval.c_string) = (char*) yr_malloc(YR_MAX_FUNCTION_ARGS + 1); @@ -2962,11 +2957,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); assert(compiler->last_error != ERROR_SUCCESS); } } -#line 2966 "grammar.c" +#line 2961 "grammar.c" break; case 78: -#line 1284 "grammar.y" +#line 1279 "grammar.y" { int result = ERROR_SUCCESS; @@ -3015,11 +3010,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.c_string) = (yyvsp[-2].c_string); } -#line 3019 "grammar.c" +#line 3014 "grammar.c" break; case 79: -#line 1337 "grammar.y" +#line 1332 "grammar.y" { SIZED_STRING* sized_string = (yyvsp[0].sized_string); YR_ARENA_REF re_ref; @@ -3058,11 +3053,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_REGEXP; } -#line 3062 "grammar.c" +#line 3057 "grammar.c" break; case 80: -#line 1380 "grammar.y" +#line 1375 "grammar.y" { if ((yyvsp[0].expression).type == EXPRESSION_TYPE_STRING) { @@ -3082,31 +3077,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3086 "grammar.c" +#line 3081 "grammar.c" break; case 81: -#line 1403 "grammar.y" +#line 1398 "grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, 1)); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3096 "grammar.c" +#line 3091 "grammar.c" break; case 82: -#line 1409 "grammar.y" +#line 1404 "grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, 0)); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3106 "grammar.c" +#line 3101 "grammar.c" break; case 83: -#line 1415 "grammar.y" +#line 1410 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "matches"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_REGEXP, "matches"); @@ -3118,11 +3113,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3122 "grammar.c" +#line 3117 "grammar.c" break; case 84: -#line 1427 "grammar.y" +#line 1422 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "contains"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "contains"); @@ -3132,11 +3127,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3136 "grammar.c" +#line 3131 "grammar.c" break; case 85: -#line 1437 "grammar.y" +#line 1432 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, @@ -3150,11 +3145,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3154 "grammar.c" +#line 3149 "grammar.c" break; case 86: -#line 1451 "grammar.y" +#line 1446 "grammar.y" { int result; @@ -3169,11 +3164,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3173 "grammar.c" +#line 3168 "grammar.c" break; case 87: -#line 1466 "grammar.y" +#line 1461 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-2].c_string), OP_FOUND_IN, YR_UNDEFINED); @@ -3184,11 +3179,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3188 "grammar.c" +#line 3183 "grammar.c" break; case 88: -#line 1477 "grammar.y" +#line 1472 "grammar.y" { int i; @@ -3207,11 +3202,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->loop_index = -1; YYERROR; } -#line 3211 "grammar.c" +#line 3206 "grammar.c" break; case 89: -#line 1555 "grammar.y" +#line 1550 "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, @@ -3249,11 +3244,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(yr_parser_emit_with_arg( yyscanner, OP_POP_M, var_frame + 2, NULL, NULL)); } -#line 3253 "grammar.c" +#line 3248 "grammar.c" break; case 90: -#line 1593 "grammar.y" +#line 1588 "grammar.y" { YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; YR_FIXUP* fixup; @@ -3303,11 +3298,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); loop_ctx->start_ref = loop_start_ref; } -#line 3307 "grammar.c" +#line 3302 "grammar.c" break; case 91: -#line 1643 "grammar.y" +#line 1638 "grammar.y" { int32_t jmp_offset; YR_FIXUP* fixup; @@ -3417,11 +3412,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3421 "grammar.c" +#line 3416 "grammar.c" break; case 92: -#line 1753 "grammar.y" +#line 1748 "grammar.y" { YR_ARENA_REF ref; @@ -3456,11 +3451,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->loop[compiler->loop_index].vars_internal_count = \ YR_INTERNAL_LOOP_VARS; } -#line 3460 "grammar.c" +#line 3455 "grammar.c" break; case 93: -#line 1788 "grammar.y" +#line 1783 "grammar.y" { int var_frame = 0; @@ -3515,31 +3510,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3519 "grammar.c" +#line 3514 "grammar.c" break; case 94: -#line 1843 "grammar.y" +#line 1838 "grammar.y" { yr_parser_emit(yyscanner, OP_OF, NULL); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3529 "grammar.c" +#line 3524 "grammar.c" break; case 95: -#line 1849 "grammar.y" +#line 1844 "grammar.y" { yr_parser_emit(yyscanner, OP_NOT, NULL); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3539 "grammar.c" +#line 3534 "grammar.c" break; case 96: -#line 1855 "grammar.y" +#line 1850 "grammar.y" { YR_FIXUP* fixup; YR_ARENA_REF jmp_offset_ref; @@ -3561,11 +3556,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fixup->next = compiler->fixup_stack_head; compiler->fixup_stack_head = fixup; } -#line 3565 "grammar.c" +#line 3560 "grammar.c" break; case 97: -#line 1877 "grammar.y" +#line 1872 "grammar.y" { YR_FIXUP* fixup; @@ -3588,11 +3583,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3592 "grammar.c" +#line 3587 "grammar.c" break; case 98: -#line 1900 "grammar.y" +#line 1895 "grammar.y" { YR_FIXUP* fixup; YR_ARENA_REF jmp_offset_ref; @@ -3613,11 +3608,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fixup->next = compiler->fixup_stack_head; compiler->fixup_stack_head = fixup; } -#line 3617 "grammar.c" +#line 3612 "grammar.c" break; case 99: -#line 1921 "grammar.y" +#line 1916 "grammar.y" { YR_FIXUP* fixup; @@ -3640,93 +3635,93 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3644 "grammar.c" +#line 3639 "grammar.c" break; case 100: -#line 1944 "grammar.y" +#line 1939 "grammar.y" { fail_if_error(yr_parser_reduce_operation( yyscanner, "<", (yyvsp[-2].expression), (yyvsp[0].expression))); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3655 "grammar.c" +#line 3650 "grammar.c" break; case 101: -#line 1951 "grammar.y" +#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 3666 "grammar.c" +#line 3661 "grammar.c" break; case 102: -#line 1958 "grammar.y" +#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 3677 "grammar.c" +#line 3672 "grammar.c" break; case 103: -#line 1965 "grammar.y" +#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 3688 "grammar.c" +#line 3683 "grammar.c" break; case 104: -#line 1972 "grammar.y" +#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 3699 "grammar.c" +#line 3694 "grammar.c" break; case 105: -#line 1979 "grammar.y" +#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 3710 "grammar.c" +#line 3705 "grammar.c" break; case 106: -#line 1986 "grammar.y" +#line 1981 "grammar.y" { (yyval.expression) = (yyvsp[0].expression); } -#line 3718 "grammar.c" +#line 3713 "grammar.c" break; case 107: -#line 1990 "grammar.y" +#line 1985 "grammar.y" { (yyval.expression) = (yyvsp[-1].expression); } -#line 3726 "grammar.c" +#line 3721 "grammar.c" break; case 108: -#line 1998 "grammar.y" +#line 1993 "grammar.y" { int result = ERROR_SUCCESS; @@ -3746,11 +3741,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); assert(loop_ctx->vars_count <= YR_MAX_LOOP_VARS); } -#line 3750 "grammar.c" +#line 3745 "grammar.c" break; case 109: -#line 2018 "grammar.y" +#line 2013 "grammar.y" { int result = ERROR_SUCCESS; @@ -3775,11 +3770,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); loop_ctx->vars[loop_ctx->vars_count++].identifier.ptr = (yyvsp[0].c_string); } -#line 3779 "grammar.c" +#line 3774 "grammar.c" break; case 110: -#line 2046 "grammar.y" +#line 2041 "grammar.y" { YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; @@ -3853,11 +3848,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3857 "grammar.c" +#line 3852 "grammar.c" break; case 111: -#line 2120 "grammar.y" +#line 2115 "grammar.y" { int result = ERROR_SUCCESS; @@ -3881,11 +3876,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3885 "grammar.c" +#line 3880 "grammar.c" break; case 112: -#line 2148 "grammar.y" +#line 2143 "grammar.y" { // $2 contains the number of integers in the enumeration fail_if_error(yr_parser_emit_push_const(yyscanner, (yyvsp[-1].integer))); @@ -3893,20 +3888,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(yr_parser_emit( yyscanner, OP_ITER_START_INT_ENUM, NULL)); } -#line 3897 "grammar.c" +#line 3892 "grammar.c" break; case 113: -#line 2156 "grammar.y" +#line 2151 "grammar.y" { fail_if_error(yr_parser_emit( yyscanner, OP_ITER_START_INT_RANGE, NULL)); } -#line 3906 "grammar.c" +#line 3901 "grammar.c" break; case 114: -#line 2165 "grammar.y" +#line 2160 "grammar.y" { int result = ERROR_SUCCESS; @@ -3926,11 +3921,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3930 "grammar.c" +#line 3925 "grammar.c" break; case 115: -#line 2189 "grammar.y" +#line 2184 "grammar.y" { int result = ERROR_SUCCESS; @@ -3945,11 +3940,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = 1; } -#line 3949 "grammar.c" +#line 3944 "grammar.c" break; case 116: -#line 2204 "grammar.y" +#line 2199 "grammar.y" { int result = ERROR_SUCCESS; @@ -3964,87 +3959,87 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = (yyvsp[-2].integer) + 1; } -#line 3968 "grammar.c" +#line 3963 "grammar.c" break; case 117: -#line 2223 "grammar.y" +#line 2218 "grammar.y" { // Push end-of-list marker yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); } -#line 3977 "grammar.c" +#line 3972 "grammar.c" break; case 119: -#line 2229 "grammar.y" +#line 2224 "grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, YR_UNDEFINED)); fail_if_error(yr_parser_emit_pushes_for_strings( yyscanner, "$*")); } -#line 3988 "grammar.c" +#line 3983 "grammar.c" break; case 122: -#line 2246 "grammar.y" +#line 2241 "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 3999 "grammar.c" +#line 3994 "grammar.c" break; case 123: -#line 2253 "grammar.y" +#line 2248 "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 4010 "grammar.c" +#line 4005 "grammar.c" break; case 124: -#line 2264 "grammar.y" +#line 2259 "grammar.y" { (yyval.integer) = FOR_EXPRESSION_ANY; } -#line 4018 "grammar.c" +#line 4013 "grammar.c" break; case 125: -#line 2268 "grammar.y" +#line 2263 "grammar.y" { yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); (yyval.integer) = FOR_EXPRESSION_ALL; } -#line 4027 "grammar.c" +#line 4022 "grammar.c" break; case 126: -#line 2273 "grammar.y" +#line 2268 "grammar.y" { yr_parser_emit_push_const(yyscanner, 1); (yyval.integer) = FOR_EXPRESSION_ANY; } -#line 4036 "grammar.c" +#line 4031 "grammar.c" break; case 127: -#line 2282 "grammar.y" +#line 2277 "grammar.y" { (yyval.expression) = (yyvsp[-1].expression); } -#line 4044 "grammar.c" +#line 4039 "grammar.c" break; case 128: -#line 2286 "grammar.y" +#line 2281 "grammar.y" { fail_if_error(yr_parser_emit( yyscanner, OP_FILESIZE, NULL)); @@ -4052,11 +4047,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4056 "grammar.c" +#line 4051 "grammar.c" break; case 129: -#line 2294 "grammar.y" +#line 2289 "grammar.y" { yywarning(yyscanner, "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " @@ -4068,11 +4063,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4072 "grammar.c" +#line 4067 "grammar.c" break; case 130: -#line 2306 "grammar.y" +#line 2301 "grammar.y" { check_type((yyvsp[-1].expression), EXPRESSION_TYPE_INTEGER, "intXXXX or uintXXXX"); @@ -4086,33 +4081,33 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4090 "grammar.c" +#line 4085 "grammar.c" break; case 131: -#line 2320 "grammar.y" +#line 2315 "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 4101 "grammar.c" +#line 4096 "grammar.c" break; case 132: -#line 2327 "grammar.y" +#line 2322 "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 4112 "grammar.c" +#line 4107 "grammar.c" break; case 133: -#line 2334 "grammar.y" +#line 2329 "grammar.y" { YR_ARENA_REF ref; @@ -4137,11 +4132,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_STRING; (yyval.expression).value.sized_string_ref = ref; } -#line 4141 "grammar.c" +#line 4136 "grammar.c" break; case 134: -#line 2359 "grammar.y" +#line 2354 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[0].c_string), OP_COUNT, YR_UNDEFINED); @@ -4153,11 +4148,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4157 "grammar.c" +#line 4152 "grammar.c" break; case 135: -#line 2371 "grammar.y" +#line 2366 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-3].c_string), OP_OFFSET, YR_UNDEFINED); @@ -4169,11 +4164,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4173 "grammar.c" +#line 4168 "grammar.c" break; case 136: -#line 2383 "grammar.y" +#line 2378 "grammar.y" { int result = yr_parser_emit_push_const(yyscanner, 1); @@ -4188,11 +4183,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4192 "grammar.c" +#line 4187 "grammar.c" break; case 137: -#line 2398 "grammar.y" +#line 2393 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-3].c_string), OP_LENGTH, YR_UNDEFINED); @@ -4204,11 +4199,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4208 "grammar.c" +#line 4203 "grammar.c" break; case 138: -#line 2410 "grammar.y" +#line 2405 "grammar.y" { int result = yr_parser_emit_push_const(yyscanner, 1); @@ -4223,11 +4218,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4227 "grammar.c" +#line 4222 "grammar.c" break; case 139: -#line 2425 "grammar.y" +#line 2420 "grammar.y" { int result = ERROR_SUCCESS; @@ -4270,11 +4265,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4274 "grammar.c" +#line 4269 "grammar.c" break; case 140: -#line 2468 "grammar.y" +#line 2463 "grammar.y" { int result = ERROR_SUCCESS; @@ -4295,11 +4290,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4299 "grammar.c" +#line 4294 "grammar.c" break; case 141: -#line 2489 "grammar.y" +#line 2484 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "+", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4334,11 +4329,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4338 "grammar.c" +#line 4333 "grammar.c" break; case 142: -#line 2524 "grammar.y" +#line 2519 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "-", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4373,11 +4368,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4377 "grammar.c" +#line 4372 "grammar.c" break; case 143: -#line 2559 "grammar.y" +#line 2554 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "*", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4411,11 +4406,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4415 "grammar.c" +#line 4410 "grammar.c" break; case 144: -#line 2593 "grammar.y" +#line 2588 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "\\", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4440,11 +4435,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4444 "grammar.c" +#line 4439 "grammar.c" break; case 145: -#line 2618 "grammar.y" +#line 2613 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "%"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "%"); @@ -4461,11 +4456,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(ERROR_DIVISION_BY_ZERO); } } -#line 4465 "grammar.c" +#line 4460 "grammar.c" break; case 146: -#line 2635 "grammar.y" +#line 2630 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); @@ -4475,11 +4470,11 @@ 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 4479 "grammar.c" +#line 4474 "grammar.c" break; case 147: -#line 2645 "grammar.y" +#line 2640 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); @@ -4489,11 +4484,11 @@ 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 4493 "grammar.c" +#line 4488 "grammar.c" break; case 148: -#line 2655 "grammar.y" +#line 2650 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "|"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "|"); @@ -4503,11 +4498,11 @@ 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 4507 "grammar.c" +#line 4502 "grammar.c" break; case 149: -#line 2665 "grammar.y" +#line 2660 "grammar.y" { check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "~"); @@ -4517,11 +4512,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).value.integer = ((yyvsp[0].expression).value.integer == YR_UNDEFINED) ? YR_UNDEFINED : ~((yyvsp[0].expression).value.integer); } -#line 4521 "grammar.c" +#line 4516 "grammar.c" break; case 150: -#line 2675 "grammar.y" +#line 2670 "grammar.y" { int result; @@ -4541,11 +4536,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4545 "grammar.c" +#line 4540 "grammar.c" break; case 151: -#line 2695 "grammar.y" +#line 2690 "grammar.y" { int result; @@ -4565,19 +4560,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4569 "grammar.c" +#line 4564 "grammar.c" break; case 152: -#line 2715 "grammar.y" +#line 2710 "grammar.y" { (yyval.expression) = (yyvsp[0].expression); } -#line 4577 "grammar.c" +#line 4572 "grammar.c" break; -#line 4581 "grammar.c" +#line 4576 "grammar.c" default: break; } @@ -4771,5 +4766,5 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); return yyresult; } -#line 2720 "grammar.y" +#line 2715 "grammar.y" diff --git a/libyara/grammar.y b/libyara/grammar.y index 713428adfb..151515937e 100644 --- a/libyara/grammar.y +++ b/libyara/grammar.y @@ -609,9 +609,6 @@ variable_declaration YR_ARENA_REF identifier_ref; uint8_t obj_type; - YR_RULE* rule = _yr_compiler_get_rule_by_idx(compiler, - compiler->current_rule_idx); - // Check for duplicated identifier in scope with external variables YR_OBJECT* object = (YR_OBJECT*)yr_hash_table_lookup( compiler->objects_table, @@ -626,7 +623,7 @@ variable_declaration } else { // Check for duplicated identifier in local rule scope object = (YR_OBJECT*)yr_hash_table_lookup( - rule->internal_variables_table, + compiler->current_internal_variables_table, $1, NULL); @@ -640,7 +637,6 @@ variable_declaration sizeof(YR_INTERNAL_VARIABLE), &int_ref, offsetof(YR_INTERNAL_VARIABLE, identifier), - offsetof(YR_INTERNAL_VARIABLE, rule), EOL); int_var = yr_arena_ref_to_ptr(compiler->arena, &int_ref); @@ -666,7 +662,7 @@ variable_declaration int_var->identifier = yr_arena_ref_to_ptr( compiler->arena, &identifier_ref); - int_var->rule = rule; + int_var->rule_idx = compiler->current_rule_idx; int_var->type = obj_type; yr_object_create( @@ -676,7 +672,7 @@ variable_declaration &object); FAIL_ON_ERROR_WITH_CLEANUP(yr_hash_table_add( - rule->internal_variables_table, + compiler->current_internal_variables_table, $1, NULL, (void*) object), @@ -1004,15 +1000,14 @@ identifier } else { + // Search for identifier in current rule scope. + YR_OBJECT* object = yr_hash_table_lookup( + compiler->current_internal_variables_table, + $1, + NULL); + // Search for identifier within the global namespace, where the // externals variables reside. - - YR_OBJECT* object; - - YR_RULE* rule = _yr_compiler_get_rule_by_idx(compiler, compiler->current_rule_idx); - - object = yr_hash_table_lookup(rule->internal_variables_table, $1, NULL); - if (object == NULL) { object = (YR_OBJECT*) yr_hash_table_lookup( compiler->objects_table, $1, NULL); diff --git a/libyara/include/yara/compiler.h b/libyara/include/yara/compiler.h index 5c5f3d6378..0ea93a2652 100644 --- a/libyara/include/yara/compiler.h +++ b/libyara/include/yara/compiler.h @@ -246,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/types.h b/libyara/include/yara/types.h index f75b125495..ecf47b36d8 100644 --- a/libyara/include/yara/types.h +++ b/libyara/include/yara/types.h @@ -327,8 +327,6 @@ struct YR_RULE // Number of atoms generated for this rule. int32_t num_atoms; - YR_HASH_TABLE* internal_variables_table; - DECLARE_REFERENCE(const char*, identifier); DECLARE_REFERENCE(const char*, tags); DECLARE_REFERENCE(YR_META*, metas); @@ -360,10 +358,10 @@ struct YR_EXTERNAL_VARIABLE struct YR_INTERNAL_VARIABLE { - int32_t type; + int32_t type; + uint32_t rule_idx; DECLARE_REFERENCE(const char*, identifier); - DECLARE_REFERENCE(YR_RULE*, rule); }; struct YR_AC_MATCH @@ -744,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/parser.c b/libyara/parser.c index 1a4af03a15..576b88642f 100644 --- a/libyara/parser.c +++ b/libyara/parser.c @@ -939,7 +939,9 @@ int yr_parser_reduce_rule_declaration_phase_1( rule->ns = ns; rule->num_atoms = 0; - yr_hash_table_create(10, &rule->internal_variables_table); + 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/scanner.c b/libyara/scanner.c index b1bb8412b0..c20e99426f 100644 --- a/libyara/scanner.c +++ b/libyara/scanner.c @@ -164,7 +164,6 @@ YR_API int yr_scanner_create( YR_RULES* rules, YR_SCANNER** scanner) { - YR_RULE* rule; YR_EXTERNAL_VARIABLE* external; YR_INTERNAL_VARIABLE* internal; YR_SCANNER* new_scanner; @@ -178,19 +177,26 @@ YR_API int yr_scanner_create( yr_hash_table_create(64, &new_scanner->objects_table), yr_free(new_scanner)); - rule = rules->rules_list_head; - while(!RULE_IS_NULL(rule)) { + 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, &rule->internal_variables_table), + yr_hash_table_create(10, &new_scanner->internal_variable_tables[rule_idx]), //CLEANUP - for(YR_RULE* r=rules->rules_list_head; rinternal_variables_table, NULL); + yr_hash_table_destroy(new_scanner->internal_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)); - - rule++; } new_scanner->rules = rules; @@ -268,7 +274,7 @@ YR_API int yr_scanner_create( FAIL_ON_ERROR_WITH_CLEANUP( yr_hash_table_add( - internal->rule->internal_variables_table, + new_scanner->internal_variable_tables[internal->rule_idx], internal->identifier, NULL, (void*) object), @@ -291,7 +297,6 @@ YR_API void yr_scanner_destroy( { RE_FIBER* fiber; RE_FIBER* next_fiber; - YR_RULE* rule; fiber = scanner->re_fiber_pool.fibers.head; @@ -309,15 +314,18 @@ YR_API void yr_scanner_destroy( (YR_HASH_TABLE_FREE_VALUE_FUNC) yr_object_destroy); } - rule = (YR_RULE*)scanner->rules->rules_list_head; - while(!RULE_IS_NULL(rule)) { - yr_hash_table_destroy( - rule->internal_variables_table, + 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); - rule++; + rule_idx++; + } } + yr_free(scanner->internal_variable_tables); + #ifdef YR_PROFILING_ENABLED yr_free(scanner->profiling_info); #endif From 0e59ad2257d10b00bcb6461110e4f8809dba5df2 Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Mon, 21 Sep 2020 07:47:05 +0200 Subject: [PATCH 14/17] add tests --- tests/test-rules.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/tests/test-rules.c b/tests/test-rules.c index 3bbe1d52cf..234c2a681b 100644 --- a/tests/test-rules.c +++ b/tests/test-rules.c @@ -985,6 +985,100 @@ 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\ + }"); + assert_error( + "rule test {\n\ + condition:\n\ + var\n\ + }"); +} static void test_wildcard_strings() { @@ -2821,6 +2915,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(); From 3b514a71c68dd522317e01916f105165b10d1ce6 Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Mon, 21 Sep 2020 07:54:09 +0200 Subject: [PATCH 15/17] add expected exit code for errors in tests --- tests/test-rules.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test-rules.c b/tests/test-rules.c index 234c2a681b..d310befaf2 100644 --- a/tests/test-rules.c +++ b/tests/test-rules.c @@ -1072,12 +1072,14 @@ static void test_internal_variables() { 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() From bbcf19544994e8978bb4a2ca28a47e305728e976 Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Mon, 21 Sep 2020 08:44:35 +0200 Subject: [PATCH 16/17] fix memory leak when multiple rules are being scanned --- libyara/scanner.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libyara/scanner.c b/libyara/scanner.c index c20e99426f..d75a488af7 100644 --- a/libyara/scanner.c +++ b/libyara/scanner.c @@ -319,8 +319,6 @@ YR_API void yr_scanner_destroy( yr_hash_table_destroy( scanner->internal_variable_tables[rule_idx], (YR_HASH_TABLE_FREE_VALUE_FUNC)yr_object_destroy); - - rule_idx++; } } From 6aac65636814f0e9fb042db45bf577804612a689 Mon Sep 17 00:00:00 2001 From: Tomas Kender Date: Sun, 4 Oct 2020 19:24:40 +0200 Subject: [PATCH 17/17] make variables to support structs --- libyara/exec.c | 13 +- libyara/grammar.c | 1139 +++++++++++++++++---------------- libyara/grammar.h | 2 +- libyara/grammar.y | 114 +++- libyara/include/yara/object.h | 6 + libyara/object.c | 37 ++ 6 files changed, 745 insertions(+), 566 deletions(-) diff --git a/libyara/exec.c b/libyara/exec.c index 6200a9e31c..5cad04794a 100644 --- a/libyara/exec.c +++ b/libyara/exec.c @@ -944,7 +944,11 @@ int yr_execute_code( obj, NULL); break; - default: assert(false); + case OBJECT_TYPE_STRUCTURE: + yr_object_set_object(r1.o, obj, NULL); + break; + default: + assert(false); } break; @@ -998,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 2cd6780262..cb6f1183cd 100644 --- a/libyara/grammar.c +++ b/libyara/grammar.c @@ -346,7 +346,7 @@ extern int yara_yydebug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { -#line 302 "grammar.y" +#line 305 "grammar.y" YR_EXPRESSION expression; SIZED_STRING* sized_string; @@ -489,7 +489,7 @@ enum yysymbol_kind_t YYSYMBOL_arguments_list = 109, /* arguments_list */ YYSYMBOL_regexp = 110, /* regexp */ YYSYMBOL_boolean_expression = 111, /* boolean_expression */ - YYSYMBOL_expression = 112, /* expression */ + YYSYMBOL_complex_expression = 112, /* complex_expression */ YYSYMBOL_113_7 = 113, /* $@7 */ YYSYMBOL_114_8 = 114, /* $@8 */ YYSYMBOL_115_9 = 115, /* $@9 */ @@ -505,7 +505,10 @@ enum yysymbol_kind_t 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_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; @@ -815,16 +818,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 385 +#define YYLAST 354 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 77 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 52 +#define YYNNTS 55 /* YYNRULES -- Number of rules. */ -#define YYNRULES 152 +#define YYNRULES 156 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 252 +#define YYNSTATES 256 #define YYMAXUTOK 312 @@ -878,22 +881,22 @@ static const yytype_int8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_int16 yyrline[] = { - 0, 320, 320, 321, 322, 323, 324, 325, 326, 334, - 347, 352, 346, 379, 382, 398, 401, 416, 419, 426, - 431, 432, 437, 438, 444, 447, 463, 472, 514, 515, - 520, 537, 551, 565, 579, 596, 597, 602, 601, 695, - 696, 702, 701, 718, 717, 738, 737, 762, 768, 828, - 829, 830, 831, 832, 833, 839, 860, 891, 896, 913, - 918, 938, 939, 953, 954, 955, 956, 957, 961, 962, - 976, 980, 1082, 1130, 1191, 1238, 1239, 1243, 1278, 1331, - 1374, 1397, 1403, 1409, 1421, 1431, 1445, 1460, 1471, 1550, - 1588, 1490, 1748, 1747, 1837, 1843, 1850, 1849, 1895, 1894, - 1938, 1945, 1952, 1959, 1966, 1973, 1980, 1984, 1992, 2012, - 2040, 2114, 2142, 2150, 2159, 2183, 2198, 2218, 2217, 2223, - 2234, 2235, 2240, 2247, 2258, 2262, 2267, 2276, 2280, 2288, - 2300, 2314, 2321, 2328, 2353, 2365, 2377, 2392, 2404, 2419, - 2462, 2483, 2518, 2553, 2587, 2612, 2629, 2639, 2649, 2659, - 2669, 2689, 2709 + 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 @@ -933,11 +936,11 @@ static const char *const yytname[] = "string_declaration", "$@4", "$@5", "$@6", "string_modifiers", "string_modifier", "regexp_modifiers", "regexp_modifier", "hex_modifiers", "hex_modifier", "identifier", "arguments", - "arguments_list", "regexp", "boolean_expression", "expression", "$@7", - "$@8", "$@9", "$@10", "$@11", "for_variables", "iterator", "integer_set", - "range", "integer_enumeration", "string_set", "$@12", + "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", YY_NULLPTR + "primary_expression", "nonprimary_expression", "expression", "object", YY_NULLPTR }; static const char * @@ -963,12 +966,12 @@ static const yytype_int16 yytoknum[] = }; #endif -#define YYPACT_NINF (-78) +#define YYPACT_NINF (-87) #define yypact_value_is_default(Yyn) \ ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF (-125) +#define YYTABLE_NINF (-157) #define yytable_value_is_error(Yyn) \ 0 @@ -977,32 +980,32 @@ static const yytype_int16 yytoknum[] = STATE-NUM. */ static const yytype_int16 yypact[] = { - -78, 178, -78, -37, -78, 19, -78, -78, 127, -78, - -78, -78, -78, 62, -78, -78, -78, -78, 7, 66, - 23, -78, 101, 115, -78, 67, 128, 129, 71, 133, - 74, 129, -78, 132, 78, -78, 131, -78, 94, 132, - -78, 136, 154, -78, -78, -78, -78, 151, 10, -78, - 97, 136, -78, 111, 114, -78, 166, 169, 171, -78, - -78, 48, -78, -78, -78, -78, 48, -78, -29, -78, - 120, 121, -78, -78, 125, -78, -78, -78, -78, -78, - -78, 82, -78, -78, 48, 106, 106, 48, 57, -78, - 42, -78, 177, 176, 216, 6, 209, 42, 61, 106, - 147, 106, 106, 106, 106, 2, 292, -78, -78, -78, - 195, 149, 48, 207, 106, -78, -78, -1, 200, 106, - 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, - 106, 106, 106, 106, 106, 106, -78, -78, -78, 198, - 199, 201, -78, -78, -78, -78, -78, -78, -78, -78, - -78, -78, -78, 292, 106, -78, 193, 203, 235, 254, - -78, -1, 259, -78, -78, 202, 197, 61, -78, 225, - 48, 48, -78, -78, -78, -78, 292, 292, 292, 292, - 292, 292, 292, -42, -42, 302, 312, 322, 110, 110, - -78, -78, -78, 257, 255, 256, 100, -78, -78, -78, - 230, -78, -35, -78, 48, -78, 258, -78, -2, -44, - 229, 231, 106, -78, -6, 290, 61, -78, -78, 3, - -78, 287, -78, -78, -78, 273, 247, 106, 57, 237, - -78, -78, -78, -78, -2, 248, -78, 48, 17, 100, - -78, -78, -78, 27, -78, 106, 250, -78, 292, 48, - 39, -78 + -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. @@ -1017,36 +1020,36 @@ static const yytype_uint8 yydefact[] = 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, 125, - 126, 0, 81, 82, 0, 0, 0, 0, 139, 152, - 19, 80, 0, 106, 42, 44, 46, 0, 38, 0, - 0, 0, 0, 0, 0, 0, 124, 95, 140, 149, - 80, 106, 75, 0, 0, 98, 96, 0, 0, 0, + 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, 0, 0, 0, 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, 107, 127, 0, 76, 77, 72, 0, - 0, 0, 119, 117, 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, 108, 0, 74, 0, 73, 99, 97, 0, 0, - 0, 0, 0, 92, 0, 0, 78, 122, 123, 0, - 120, 0, 55, 58, 60, 0, 0, 0, 110, 0, - 111, 113, 109, 118, 0, 0, 114, 0, 0, 115, - 90, 121, 56, 0, 112, 0, 0, 93, 116, 0, - 0, 91 + 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[] = { - -78, -78, 316, 319, -78, -78, -78, -78, -78, -78, - -78, -78, -78, -78, -78, 293, -78, 272, -78, -78, - 286, -78, -78, -78, -78, -78, -78, -78, -78, -78, - 123, -78, -78, 220, -61, -53, -78, -78, -78, -78, - -78, -78, -78, -78, 126, -78, 180, -78, -78, 105, - 261, -77 + -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]. */ @@ -1054,10 +1057,10 @@ static const yytype_int16 yydefgoto[] = { -1, 1, 6, 7, 18, 42, 26, 29, 35, 54, 8, 16, 20, 22, 31, 32, 51, 52, 66, 39, - 40, 56, 57, 58, 94, 144, 95, 150, 96, 152, - 88, 165, 166, 89, 97, 91, 162, 246, 226, 171, - 170, 202, 229, 230, 155, 238, 174, 208, 219, 220, - 92, 93 + 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 @@ -1065,88 +1068,82 @@ static const yytype_int16 yydefgoto[] = number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = { - 90, 214, 99, 160, 106, 5, 67, 100, 108, 109, - 111, 217, 145, 98, -89, 218, 221, 131, 132, 133, - 134, 135, 153, 107, 156, 157, 158, 159, 222, 9, - 146, 147, -45, -43, 110, 148, 149, 169, 172, 161, - 12, 215, 176, 177, 178, 179, 180, 181, 182, 183, - 184, 185, 186, 187, 188, 189, 190, 191, 192, 167, - 67, 68, 69, 70, 71, 227, 72, 73, 74, 75, - 173, 76, 115, 116, 17, 233, 19, 196, 21, 234, - 77, 78, 79, 80, 115, 116, 81, 115, 116, 244, - 23, 82, 83, 245, 67, 84, 69, 70, 71, 247, - 72, 73, 74, 75, 212, 76, -80, -80, 85, 206, - 207, 251, 86, 24, 77, 78, 79, 80, 67, 87, - 69, 70, 71, 25, 72, 73, 74, 75, 112, 76, - 113, 114, 13, 14, 15, 225, 27, 28, 77, 78, - 33, 30, 85, 34, 36, 38, 86, 41, 50, 43, - 239, 216, 44, 104, 126, 127, 128, 129, 130, 131, - 132, 133, 134, 135, 48, 53, 85, 59, 248, 55, - 86, 133, 134, 135, 45, 46, 243, 104, 2, 3, - 61, 4, 62, -20, -20, -20, -124, 63, 250, 118, - 119, 47, 64, 65, 101, 102, 103, 120, 121, 122, - 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, - 133, 134, 135, -124, 117, 151, 118, 119, 154, 168, - 5, 164, 136, 76, 120, 121, 122, 123, 124, 125, - 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, - 137, 138, 139, 140, 141, 142, 143, 126, 127, 128, - 129, 130, 131, 132, 133, 134, 135, 126, 127, 128, - 129, 130, 131, 132, 133, 134, 135, 163, 197, 193, - 194, 201, 195, 204, 203, 209, 210, 211, 198, 126, - 127, 128, 129, 130, 131, 132, 133, 134, 135, 126, - 127, 128, 129, 130, 131, 132, 133, 134, 135, 213, - 205, 223, 232, 224, 116, 235, 240, 199, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, 237, 10, - 242, 249, 11, 60, 37, 49, 164, 126, 127, 128, - 129, 130, 131, 132, 133, 134, 135, 228, 175, 241, - 231, 200, 105, 0, 0, 236, 126, 127, 128, 129, - 130, 131, 132, 133, 134, 135, 126, 127, 0, 129, - 130, 131, 132, 133, 134, 135, 126, 127, 0, 0, - 130, 131, 132, 133, 134, 135, 126, 127, 0, 0, - 0, 131, 132, 133, 134, 135 + 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[] = { - 61, 36, 31, 1, 81, 42, 12, 36, 85, 86, - 87, 13, 6, 66, 12, 17, 60, 59, 60, 61, - 62, 63, 99, 84, 101, 102, 103, 104, 72, 66, - 24, 25, 22, 23, 87, 29, 30, 114, 39, 37, - 21, 76, 119, 120, 121, 122, 123, 124, 125, 126, - 127, 128, 129, 130, 131, 132, 133, 134, 135, 112, - 12, 13, 14, 15, 16, 71, 18, 19, 20, 21, - 71, 23, 45, 46, 12, 72, 69, 154, 12, 76, - 32, 33, 34, 35, 45, 46, 38, 45, 46, 72, - 67, 43, 44, 76, 12, 47, 14, 15, 16, 72, - 18, 19, 20, 21, 4, 23, 45, 46, 60, 170, - 171, 72, 64, 12, 32, 33, 34, 35, 12, 71, - 14, 15, 16, 8, 18, 19, 20, 21, 71, 23, - 73, 74, 5, 6, 7, 212, 69, 9, 32, 33, - 69, 12, 60, 10, 70, 13, 64, 69, 12, 18, - 227, 204, 21, 71, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 70, 11, 60, 70, 245, 18, - 64, 61, 62, 63, 43, 44, 237, 71, 0, 1, - 69, 3, 68, 5, 6, 7, 37, 21, 249, 40, - 41, 60, 23, 22, 74, 74, 71, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 37, 37, 6, 40, 41, 71, 12, - 42, 72, 6, 23, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 24, 25, 26, 27, 28, 29, 30, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 72, 75, 71, - 71, 12, 71, 76, 72, 18, 21, 21, 75, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 69, - 75, 72, 12, 72, 46, 18, 69, 72, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 71, 3, - 72, 71, 3, 51, 31, 39, 72, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 214, 118, 234, - 214, 161, 81, -1, -1, 72, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 54, 55, -1, 57, - 58, 59, 60, 61, 62, 63, 54, 55, -1, -1, - 58, 59, 60, 61, 62, 63, 54, 55, -1, -1, - -1, 59, 60, 61, 62, 63 + 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 @@ -1162,23 +1159,23 @@ static const yytype_uint8 yystos[] = 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, 101, 103, 105, 111, 112, 31, - 36, 74, 74, 71, 71, 127, 128, 111, 128, 128, - 112, 128, 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, 112, 12, 128, - 117, 116, 39, 71, 123, 110, 128, 128, 128, 128, + 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, 71, 71, 71, 128, 75, 75, 72, - 123, 12, 118, 72, 76, 75, 111, 111, 124, 18, - 21, 21, 4, 69, 36, 76, 112, 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 + 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. */ @@ -1194,12 +1191,12 @@ static const yytype_uint8 yyr1[] = 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, 112, 118, 118, - 119, 119, 120, 120, 121, 122, 122, 124, 123, 123, - 125, 125, 126, 126, 127, 127, 127, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128 + 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. */ @@ -1215,12 +1212,12 @@ static const yytype_int8 yyr2[] = 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, + 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 + 3, 3, 1, 1, 1, 1, 1 }; @@ -1434,61 +1431,61 @@ yydestruct (const char *yymsg, switch (yykind) { case 12: /* "identifier" */ -#line 272 "grammar.y" +#line 275 "grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1440 "grammar.c" +#line 1437 "grammar.c" break; case 13: /* "string identifier" */ -#line 276 "grammar.y" +#line 279 "grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1446 "grammar.c" +#line 1443 "grammar.c" break; case 14: /* "string count" */ -#line 273 "grammar.y" +#line 276 "grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1452 "grammar.c" +#line 1449 "grammar.c" break; case 15: /* "string offset" */ -#line 274 "grammar.y" +#line 277 "grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1458 "grammar.c" +#line 1455 "grammar.c" break; case 16: /* "string length" */ -#line 275 "grammar.y" +#line 278 "grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1464 "grammar.c" +#line 1461 "grammar.c" break; case 17: /* "string identifier with wildcard" */ -#line 277 "grammar.y" +#line 280 "grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1470 "grammar.c" +#line 1467 "grammar.c" break; case 21: /* "text string" */ -#line 278 "grammar.y" +#line 281 "grammar.y" { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } -#line 1476 "grammar.c" +#line 1473 "grammar.c" break; case 22: /* "hex string" */ -#line 279 "grammar.y" +#line 282 "grammar.y" { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } -#line 1482 "grammar.c" +#line 1479 "grammar.c" break; case 23: /* "regular expression" */ -#line 280 "grammar.y" +#line 283 "grammar.y" { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } -#line 1488 "grammar.c" +#line 1485 "grammar.c" break; case 101: /* string_modifiers */ -#line 293 "grammar.y" +#line 296 "grammar.y" { if (((*yyvaluep).modifier).alphabet != NULL) { @@ -1496,11 +1493,11 @@ yydestruct (const char *yymsg, ((*yyvaluep).modifier).alphabet = NULL; } } -#line 1500 "grammar.c" +#line 1497 "grammar.c" break; case 102: /* string_modifier */ -#line 285 "grammar.y" +#line 288 "grammar.y" { if (((*yyvaluep).modifier).alphabet != NULL) { @@ -1508,19 +1505,19 @@ yydestruct (const char *yymsg, ((*yyvaluep).modifier).alphabet = NULL; } } -#line 1512 "grammar.c" +#line 1509 "grammar.c" break; case 108: /* arguments */ -#line 282 "grammar.y" +#line 285 "grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1518 "grammar.c" +#line 1515 "grammar.c" break; case 109: /* arguments_list */ -#line 283 "grammar.y" +#line 286 "grammar.y" { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } -#line 1524 "grammar.c" +#line 1521 "grammar.c" break; default: @@ -1805,15 +1802,15 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); switch (yyn) { case 8: -#line 327 "grammar.y" +#line 330 "grammar.y" { _yr_compiler_pop_file_name(compiler); } -#line 1813 "grammar.c" +#line 1810 "grammar.c" break; case 9: -#line 335 "grammar.y" +#line 338 "grammar.y" { int result = yr_parser_reduce_import(yyscanner, (yyvsp[0].sized_string)); @@ -1821,20 +1818,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 1825 "grammar.c" +#line 1822 "grammar.c" break; case 10: -#line 347 "grammar.y" +#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 1834 "grammar.c" +#line 1831 "grammar.c" break; case 11: -#line 352 "grammar.y" +#line 355 "grammar.y" { YR_RULE* rule = (YR_RULE*) yr_arena_ref_to_ptr( compiler->arena, &(yyvsp[-5].rule)); @@ -1848,11 +1845,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); rule->strings = (YR_STRING*) yr_arena_ref_to_ptr( compiler->arena, &(yyvsp[-1].string)); } -#line 1852 "grammar.c" +#line 1849 "grammar.c" break; case 12: -#line 366 "grammar.y" +#line 369 "grammar.y" { int result = yr_parser_reduce_rule_declaration_phase_2( yyscanner, &(yyvsp[-8].rule)); // rule created in phase 1 @@ -1861,19 +1858,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 1865 "grammar.c" +#line 1862 "grammar.c" break; case 13: -#line 379 "grammar.y" +#line 382 "grammar.y" { (yyval.meta) = YR_ARENA_NULL_REF; } -#line 1873 "grammar.c" +#line 1870 "grammar.c" break; case 14: -#line 383 "grammar.y" +#line 386 "grammar.y" { YR_META* meta = yr_arena_get_ptr( compiler->arena, @@ -1884,19 +1881,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.meta) = (yyvsp[0].meta); } -#line 1888 "grammar.c" +#line 1885 "grammar.c" break; case 15: -#line 398 "grammar.y" +#line 401 "grammar.y" { (yyval.string) = YR_ARENA_NULL_REF; } -#line 1896 "grammar.c" +#line 1893 "grammar.c" break; case 16: -#line 402 "grammar.y" +#line 405 "grammar.y" { YR_STRING* string = (YR_STRING*) yr_arena_get_ptr( compiler->arena, @@ -1907,59 +1904,59 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.string) = (yyvsp[0].string); } -#line 1911 "grammar.c" +#line 1908 "grammar.c" break; case 17: -#line 416 "grammar.y" +#line 419 "grammar.y" { (yyval.expression).type = EXPRESSION_TYPE_UNKNOWN; } -#line 1919 "grammar.c" +#line 1916 "grammar.c" break; case 18: -#line 420 "grammar.y" +#line 423 "grammar.y" { (yyval.expression) = (yyvsp[0].expression); } -#line 1927 "grammar.c" +#line 1924 "grammar.c" break; case 20: -#line 431 "grammar.y" +#line 434 "grammar.y" { (yyval.integer) = 0; } -#line 1933 "grammar.c" +#line 1930 "grammar.c" break; case 21: -#line 432 "grammar.y" +#line 435 "grammar.y" { (yyval.integer) = (yyvsp[-1].integer) | (yyvsp[0].integer); } -#line 1939 "grammar.c" +#line 1936 "grammar.c" break; case 22: -#line 437 "grammar.y" +#line 440 "grammar.y" { (yyval.integer) = RULE_FLAGS_PRIVATE; } -#line 1945 "grammar.c" +#line 1942 "grammar.c" break; case 23: -#line 438 "grammar.y" +#line 441 "grammar.y" { (yyval.integer) = RULE_FLAGS_GLOBAL; } -#line 1951 "grammar.c" +#line 1948 "grammar.c" break; case 24: -#line 444 "grammar.y" +#line 447 "grammar.y" { (yyval.tag) = YR_ARENA_NULL_REF; } -#line 1959 "grammar.c" +#line 1956 "grammar.c" break; case 25: -#line 448 "grammar.y" +#line 451 "grammar.y" { // Tags list is represented in the arena as a sequence // of null-terminated strings, the sequence ends with an @@ -1971,11 +1968,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.tag) = (yyvsp[0].tag); } -#line 1975 "grammar.c" +#line 1972 "grammar.c" break; case 26: -#line 464 "grammar.y" +#line 467 "grammar.y" { int result = yr_arena_write_string( yyget_extra(yyscanner)->arena, YR_SZ_POOL, (yyvsp[0].c_string), &(yyval.tag)); @@ -1984,11 +1981,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 1988 "grammar.c" +#line 1985 "grammar.c" break; case 27: -#line 473 "grammar.y" +#line 476 "grammar.y" { YR_ARENA_REF ref; @@ -2025,23 +2022,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.tag) = (yyvsp[-1].tag); } -#line 2029 "grammar.c" +#line 2026 "grammar.c" break; case 28: -#line 514 "grammar.y" +#line 517 "grammar.y" { (yyval.meta) = (yyvsp[0].meta); } -#line 2035 "grammar.c" +#line 2032 "grammar.c" break; case 29: -#line 515 "grammar.y" +#line 518 "grammar.y" { (yyval.meta) = (yyvsp[-1].meta); } -#line 2041 "grammar.c" +#line 2038 "grammar.c" break; case 30: -#line 521 "grammar.y" +#line 524 "grammar.y" { SIZED_STRING* sized_string = (yyvsp[0].sized_string); @@ -2058,11 +2055,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2062 "grammar.c" +#line 2059 "grammar.c" break; case 31: -#line 538 "grammar.y" +#line 541 "grammar.y" { int result = yr_parser_reduce_meta_declaration( yyscanner, @@ -2076,11 +2073,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2080 "grammar.c" +#line 2077 "grammar.c" break; case 32: -#line 552 "grammar.y" +#line 555 "grammar.y" { int result = yr_parser_reduce_meta_declaration( yyscanner, @@ -2094,11 +2091,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2098 "grammar.c" +#line 2095 "grammar.c" break; case 33: -#line 566 "grammar.y" +#line 569 "grammar.y" { int result = yr_parser_reduce_meta_declaration( yyscanner, @@ -2112,11 +2109,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2116 "grammar.c" +#line 2113 "grammar.c" break; case 34: -#line 580 "grammar.y" +#line 583 "grammar.y" { int result = yr_parser_reduce_meta_declaration( yyscanner, @@ -2130,36 +2127,35 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2134 "grammar.c" +#line 2131 "grammar.c" break; case 35: -#line 596 "grammar.y" +#line 599 "grammar.y" { (yyval.expression) = (yyvsp[0].expression); } -#line 2140 "grammar.c" +#line 2137 "grammar.c" break; case 36: -#line 597 "grammar.y" +#line 600 "grammar.y" { (yyval.expression) = (yyvsp[-1].expression); } -#line 2146 "grammar.c" +#line 2143 "grammar.c" break; case 37: -#line 602 "grammar.y" +#line 605 "grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2154 "grammar.c" +#line 2151 "grammar.c" break; case 38: -#line 606 "grammar.y" +#line 609 "grammar.y" { YR_INTERNAL_VARIABLE* int_var; YR_ARENA_REF int_ref; YR_ARENA_REF identifier_ref; - uint8_t obj_type; // Check for duplicated identifier in scope with external variables YR_OBJECT* object = (YR_OBJECT*)yr_hash_table_lookup( @@ -2198,30 +2194,35 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (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: - obj_type = OBJECT_TYPE_INTEGER; + int_var->type = OBJECT_TYPE_INTEGER; break; case EXPRESSION_TYPE_FLOAT: - obj_type = OBJECT_TYPE_FLOAT; + int_var->type = OBJECT_TYPE_FLOAT; break; case EXPRESSION_TYPE_STRING: - obj_type = OBJECT_TYPE_STRING; + int_var->type = OBJECT_TYPE_STRING; + break; + case EXPRESSION_TYPE_OBJECT: + int_var->type = (yyvsp[0].expression).value.object->type; break; - default: assert(false); } - int_var->identifier = yr_arena_ref_to_ptr( - compiler->arena, &identifier_ref); - int_var->rule_idx = compiler->current_rule_idx; - int_var->type = obj_type; - - yr_object_create( + 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, @@ -2241,31 +2242,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yr_free((yyvsp[-3].c_string)); } -#line 2245 "grammar.c" +#line 2246 "grammar.c" break; case 39: -#line 695 "grammar.y" +#line 702 "grammar.y" { (yyval.string) = (yyvsp[0].string); } -#line 2251 "grammar.c" +#line 2252 "grammar.c" break; case 40: -#line 696 "grammar.y" +#line 703 "grammar.y" { (yyval.string) = (yyvsp[-1].string); } -#line 2257 "grammar.c" +#line 2258 "grammar.c" break; case 41: -#line 702 "grammar.y" +#line 709 "grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2265 "grammar.c" +#line 2266 "grammar.c" break; case 42: -#line 706 "grammar.y" +#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)); @@ -2277,19 +2278,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); compiler->current_line = 0; } -#line 2281 "grammar.c" +#line 2282 "grammar.c" break; case 43: -#line 718 "grammar.y" +#line 725 "grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2289 "grammar.c" +#line 2290 "grammar.c" break; case 44: -#line 722 "grammar.y" +#line 729 "grammar.y" { int result; @@ -2305,19 +2306,19 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->current_line = 0; } -#line 2309 "grammar.c" +#line 2310 "grammar.c" break; case 45: -#line 738 "grammar.y" +#line 745 "grammar.y" { compiler->current_line = yyget_lineno(yyscanner); } -#line 2317 "grammar.c" +#line 2318 "grammar.c" break; case 46: -#line 742 "grammar.y" +#line 749 "grammar.y" { int result; @@ -2333,22 +2334,22 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->current_line = 0; } -#line 2337 "grammar.c" +#line 2338 "grammar.c" break; case 47: -#line 762 "grammar.y" +#line 769 "grammar.y" { (yyval.modifier).flags = 0; (yyval.modifier).xor_min = 0; (yyval.modifier).xor_max = 0; (yyval.modifier).alphabet = NULL; } -#line 2348 "grammar.c" +#line 2349 "grammar.c" break; case 48: -#line 769 "grammar.y" +#line 776 "grammar.y" { (yyval.modifier) = (yyvsp[-1].modifier); @@ -2404,51 +2405,51 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyval.modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2408 "grammar.c" +#line 2409 "grammar.c" break; case 49: -#line 828 "grammar.y" +#line 835 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_WIDE; } -#line 2414 "grammar.c" +#line 2415 "grammar.c" break; case 50: -#line 829 "grammar.y" +#line 836 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_ASCII; } -#line 2420 "grammar.c" +#line 2421 "grammar.c" break; case 51: -#line 830 "grammar.y" +#line 837 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } -#line 2426 "grammar.c" +#line 2427 "grammar.c" break; case 52: -#line 831 "grammar.y" +#line 838 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } -#line 2432 "grammar.c" +#line 2433 "grammar.c" break; case 53: -#line 832 "grammar.y" +#line 839 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2438 "grammar.c" +#line 2439 "grammar.c" break; case 54: -#line 834 "grammar.y" +#line 841 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_XOR; (yyval.modifier).xor_min = 0; (yyval.modifier).xor_max = 255; } -#line 2448 "grammar.c" +#line 2449 "grammar.c" break; case 55: -#line 840 "grammar.y" +#line 847 "grammar.y" { int result = ERROR_SUCCESS; @@ -2464,11 +2465,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).xor_min = (yyvsp[-1].integer); (yyval.modifier).xor_max = (yyvsp[-1].integer); } -#line 2468 "grammar.c" +#line 2469 "grammar.c" break; case 56: -#line 861 "grammar.y" +#line 868 "grammar.y" { int result = ERROR_SUCCESS; @@ -2499,20 +2500,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).xor_min = (yyvsp[-3].integer); (yyval.modifier).xor_max = (yyvsp[-1].integer); } -#line 2503 "grammar.c" +#line 2504 "grammar.c" break; case 57: -#line 892 "grammar.y" +#line 899 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_BASE64; (yyval.modifier).alphabet = sized_string_new(DEFAULT_BASE64_ALPHABET); } -#line 2512 "grammar.c" +#line 2513 "grammar.c" break; case 58: -#line 897 "grammar.y" +#line 904 "grammar.y" { int result = ERROR_SUCCESS; @@ -2529,20 +2530,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = STRING_FLAGS_BASE64; (yyval.modifier).alphabet = (yyvsp[-1].sized_string); } -#line 2533 "grammar.c" +#line 2534 "grammar.c" break; case 59: -#line 914 "grammar.y" +#line 921 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; (yyval.modifier).alphabet = sized_string_new(DEFAULT_BASE64_ALPHABET); } -#line 2542 "grammar.c" +#line 2543 "grammar.c" break; case 60: -#line 919 "grammar.y" +#line 926 "grammar.y" { int result = ERROR_SUCCESS; @@ -2559,17 +2560,17 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; (yyval.modifier).alphabet = (yyvsp[-1].sized_string); } -#line 2563 "grammar.c" +#line 2564 "grammar.c" break; case 61: -#line 938 "grammar.y" +#line 945 "grammar.y" { (yyval.modifier).flags = 0; } -#line 2569 "grammar.c" +#line 2570 "grammar.c" break; case 62: -#line 940 "grammar.y" +#line 947 "grammar.y" { if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) { @@ -2580,47 +2581,47 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyvsp[-1].modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2584 "grammar.c" +#line 2585 "grammar.c" break; case 63: -#line 953 "grammar.y" +#line 960 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_WIDE; } -#line 2590 "grammar.c" +#line 2591 "grammar.c" break; case 64: -#line 954 "grammar.y" +#line 961 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_ASCII; } -#line 2596 "grammar.c" +#line 2597 "grammar.c" break; case 65: -#line 955 "grammar.y" +#line 962 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } -#line 2602 "grammar.c" +#line 2603 "grammar.c" break; case 66: -#line 956 "grammar.y" +#line 963 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } -#line 2608 "grammar.c" +#line 2609 "grammar.c" break; case 67: -#line 957 "grammar.y" +#line 964 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2614 "grammar.c" +#line 2615 "grammar.c" break; case 68: -#line 961 "grammar.y" +#line 968 "grammar.y" { (yyval.modifier).flags = 0; } -#line 2620 "grammar.c" +#line 2621 "grammar.c" break; case 69: -#line 963 "grammar.y" +#line 970 "grammar.y" { if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) { @@ -2631,17 +2632,17 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.modifier).flags = (yyvsp[-1].modifier).flags | (yyvsp[0].modifier).flags; } } -#line 2635 "grammar.c" +#line 2636 "grammar.c" break; case 70: -#line 976 "grammar.y" +#line 983 "grammar.y" { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } -#line 2641 "grammar.c" +#line 2642 "grammar.c" break; case 71: -#line 981 "grammar.y" +#line 988 "grammar.y" { YR_EXPRESSION expr; @@ -2670,9 +2671,9 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyvsp[0].c_string), NULL); - // Search for identifier within the global namespace, where the - // externals variables reside. 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); } @@ -2743,11 +2744,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2747 "grammar.c" +#line 2748 "grammar.c" break; case 72: -#line 1083 "grammar.y" +#line 1090 "grammar.y" { int result = ERROR_SUCCESS; YR_OBJECT* field = NULL; @@ -2795,11 +2796,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2799 "grammar.c" +#line 2800 "grammar.c" break; case 73: -#line 1131 "grammar.y" +#line 1138 "grammar.y" { int result = ERROR_SUCCESS; YR_OBJECT_ARRAY* array; @@ -2859,11 +2860,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2863 "grammar.c" +#line 2864 "grammar.c" break; case 74: -#line 1192 "grammar.y" +#line 1199 "grammar.y" { YR_ARENA_REF ref; int result = ERROR_SUCCESS; @@ -2906,23 +2907,23 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 2910 "grammar.c" +#line 2911 "grammar.c" break; case 75: -#line 1238 "grammar.y" +#line 1245 "grammar.y" { (yyval.c_string) = yr_strdup(""); } -#line 2916 "grammar.c" +#line 2917 "grammar.c" break; case 76: -#line 1239 "grammar.y" +#line 1246 "grammar.y" { (yyval.c_string) = (yyvsp[0].c_string); } -#line 2922 "grammar.c" +#line 2923 "grammar.c" break; case 77: -#line 1244 "grammar.y" +#line 1251 "grammar.y" { (yyval.c_string) = (char*) yr_malloc(YR_MAX_FUNCTION_ARGS + 1); @@ -2957,11 +2958,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); assert(compiler->last_error != ERROR_SUCCESS); } } -#line 2961 "grammar.c" +#line 2962 "grammar.c" break; case 78: -#line 1279 "grammar.y" +#line 1286 "grammar.y" { int result = ERROR_SUCCESS; @@ -3010,11 +3011,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.c_string) = (yyvsp[-2].c_string); } -#line 3014 "grammar.c" +#line 3015 "grammar.c" break; case 79: -#line 1332 "grammar.y" +#line 1339 "grammar.y" { SIZED_STRING* sized_string = (yyvsp[0].sized_string); YR_ARENA_REF re_ref; @@ -3053,11 +3054,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_REGEXP; } -#line 3057 "grammar.c" +#line 3058 "grammar.c" break; case 80: -#line 1375 "grammar.y" +#line 1382 "grammar.y" { if ((yyvsp[0].expression).type == EXPRESSION_TYPE_STRING) { @@ -3077,31 +3078,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3081 "grammar.c" +#line 3082 "grammar.c" break; case 81: -#line 1398 "grammar.y" +#line 1405 "grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, 1)); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3091 "grammar.c" +#line 3092 "grammar.c" break; case 82: -#line 1404 "grammar.y" +#line 1411 "grammar.y" { fail_if_error(yr_parser_emit_push_const(yyscanner, 0)); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3101 "grammar.c" +#line 3102 "grammar.c" break; case 83: -#line 1410 "grammar.y" +#line 1417 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "matches"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_REGEXP, "matches"); @@ -3113,11 +3114,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3117 "grammar.c" +#line 3118 "grammar.c" break; case 84: -#line 1422 "grammar.y" +#line 1429 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "contains"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "contains"); @@ -3127,11 +3128,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3131 "grammar.c" +#line 3132 "grammar.c" break; case 85: -#line 1432 "grammar.y" +#line 1439 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, @@ -3145,11 +3146,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3149 "grammar.c" +#line 3150 "grammar.c" break; case 86: -#line 1446 "grammar.y" +#line 1453 "grammar.y" { int result; @@ -3164,11 +3165,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3168 "grammar.c" +#line 3169 "grammar.c" break; case 87: -#line 1461 "grammar.y" +#line 1468 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-2].c_string), OP_FOUND_IN, YR_UNDEFINED); @@ -3179,11 +3180,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3183 "grammar.c" +#line 3184 "grammar.c" break; case 88: -#line 1472 "grammar.y" +#line 1479 "grammar.y" { int i; @@ -3202,11 +3203,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->loop_index = -1; YYERROR; } -#line 3206 "grammar.c" +#line 3207 "grammar.c" break; case 89: -#line 1550 "grammar.y" +#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, @@ -3244,11 +3245,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(yr_parser_emit_with_arg( yyscanner, OP_POP_M, var_frame + 2, NULL, NULL)); } -#line 3248 "grammar.c" +#line 3249 "grammar.c" break; case 90: -#line 1588 "grammar.y" +#line 1595 "grammar.y" { YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; YR_FIXUP* fixup; @@ -3298,11 +3299,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); loop_ctx->start_ref = loop_start_ref; } -#line 3302 "grammar.c" +#line 3303 "grammar.c" break; case 91: -#line 1638 "grammar.y" +#line 1645 "grammar.y" { int32_t jmp_offset; YR_FIXUP* fixup; @@ -3412,11 +3413,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3416 "grammar.c" +#line 3417 "grammar.c" break; case 92: -#line 1748 "grammar.y" +#line 1755 "grammar.y" { YR_ARENA_REF ref; @@ -3451,11 +3452,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); compiler->loop[compiler->loop_index].vars_internal_count = \ YR_INTERNAL_LOOP_VARS; } -#line 3455 "grammar.c" +#line 3456 "grammar.c" break; case 93: -#line 1783 "grammar.y" +#line 1790 "grammar.y" { int var_frame = 0; @@ -3510,31 +3511,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3514 "grammar.c" +#line 3515 "grammar.c" break; case 94: -#line 1838 "grammar.y" +#line 1845 "grammar.y" { yr_parser_emit(yyscanner, OP_OF, NULL); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3524 "grammar.c" +#line 3525 "grammar.c" break; case 95: -#line 1844 "grammar.y" +#line 1851 "grammar.y" { yr_parser_emit(yyscanner, OP_NOT, NULL); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3534 "grammar.c" +#line 3535 "grammar.c" break; case 96: -#line 1850 "grammar.y" +#line 1857 "grammar.y" { YR_FIXUP* fixup; YR_ARENA_REF jmp_offset_ref; @@ -3556,11 +3557,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fixup->next = compiler->fixup_stack_head; compiler->fixup_stack_head = fixup; } -#line 3560 "grammar.c" +#line 3561 "grammar.c" break; case 97: -#line 1872 "grammar.y" +#line 1879 "grammar.y" { YR_FIXUP* fixup; @@ -3583,11 +3584,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3587 "grammar.c" +#line 3588 "grammar.c" break; case 98: -#line 1895 "grammar.y" +#line 1902 "grammar.y" { YR_FIXUP* fixup; YR_ARENA_REF jmp_offset_ref; @@ -3608,11 +3609,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fixup->next = compiler->fixup_stack_head; compiler->fixup_stack_head = fixup; } -#line 3612 "grammar.c" +#line 3613 "grammar.c" break; case 99: -#line 1916 "grammar.y" +#line 1923 "grammar.y" { YR_FIXUP* fixup; @@ -3635,93 +3636,85 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } -#line 3639 "grammar.c" +#line 3640 "grammar.c" break; case 100: -#line 1939 "grammar.y" +#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 3650 "grammar.c" +#line 3651 "grammar.c" break; case 101: -#line 1946 "grammar.y" +#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 3661 "grammar.c" +#line 3662 "grammar.c" break; case 102: -#line 1953 "grammar.y" +#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 3672 "grammar.c" +#line 3673 "grammar.c" break; case 103: -#line 1960 "grammar.y" +#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 3683 "grammar.c" +#line 3684 "grammar.c" break; case 104: -#line 1967 "grammar.y" +#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 3694 "grammar.c" +#line 3695 "grammar.c" break; case 105: -#line 1974 "grammar.y" +#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 3705 "grammar.c" +#line 3706 "grammar.c" break; case 106: -#line 1981 "grammar.y" - { - (yyval.expression) = (yyvsp[0].expression); - } -#line 3713 "grammar.c" - break; - - case 107: -#line 1985 "grammar.y" +#line 1988 "grammar.y" { (yyval.expression) = (yyvsp[-1].expression); } -#line 3721 "grammar.c" +#line 3714 "grammar.c" break; - case 108: -#line 1993 "grammar.y" + case 107: +#line 1996 "grammar.y" { int result = ERROR_SUCCESS; @@ -3741,11 +3734,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); assert(loop_ctx->vars_count <= YR_MAX_LOOP_VARS); } -#line 3745 "grammar.c" +#line 3738 "grammar.c" break; - case 109: -#line 2013 "grammar.y" + case 108: +#line 2016 "grammar.y" { int result = ERROR_SUCCESS; @@ -3770,11 +3763,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); loop_ctx->vars[loop_ctx->vars_count++].identifier.ptr = (yyvsp[0].c_string); } -#line 3774 "grammar.c" +#line 3767 "grammar.c" break; - case 110: -#line 2041 "grammar.y" + case 109: +#line 2044 "grammar.y" { YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; @@ -3848,11 +3841,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3852 "grammar.c" +#line 3845 "grammar.c" break; - case 111: -#line 2115 "grammar.y" + case 110: +#line 2118 "grammar.y" { int result = ERROR_SUCCESS; @@ -3876,11 +3869,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3880 "grammar.c" +#line 3873 "grammar.c" break; - case 112: -#line 2143 "grammar.y" + case 111: +#line 2146 "grammar.y" { // $2 contains the number of integers in the enumeration fail_if_error(yr_parser_emit_push_const(yyscanner, (yyvsp[-1].integer))); @@ -3888,20 +3881,20 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(yr_parser_emit( yyscanner, OP_ITER_START_INT_ENUM, NULL)); } -#line 3892 "grammar.c" +#line 3885 "grammar.c" break; - case 113: -#line 2151 "grammar.y" + case 112: +#line 2154 "grammar.y" { fail_if_error(yr_parser_emit( yyscanner, OP_ITER_START_INT_RANGE, NULL)); } -#line 3901 "grammar.c" +#line 3894 "grammar.c" break; - case 114: -#line 2160 "grammar.y" + case 113: +#line 2163 "grammar.y" { int result = ERROR_SUCCESS; @@ -3921,11 +3914,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 3925 "grammar.c" +#line 3918 "grammar.c" break; - case 115: -#line 2184 "grammar.y" + case 114: +#line 2187 "grammar.y" { int result = ERROR_SUCCESS; @@ -3940,11 +3933,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = 1; } -#line 3944 "grammar.c" +#line 3937 "grammar.c" break; - case 116: -#line 2199 "grammar.y" + case 115: +#line 2202 "grammar.y" { int result = ERROR_SUCCESS; @@ -3959,87 +3952,128 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.integer) = (yyvsp[-2].integer) + 1; } -#line 3963 "grammar.c" +#line 3956 "grammar.c" break; - case 117: -#line 2218 "grammar.y" + case 116: +#line 2221 "grammar.y" { // Push end-of-list marker yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); } -#line 3972 "grammar.c" +#line 3965 "grammar.c" break; - case 119: -#line 2224 "grammar.y" + 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 3983 "grammar.c" +#line 3976 "grammar.c" break; - case 122: -#line 2241 "grammar.y" + 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 3994 "grammar.c" +#line 3987 "grammar.c" break; - case 123: -#line 2248 "grammar.y" + 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 4005 "grammar.c" +#line 3998 "grammar.c" break; - case 124: -#line 2259 "grammar.y" + case 123: +#line 2262 "grammar.y" { (yyval.integer) = FOR_EXPRESSION_ANY; } -#line 4013 "grammar.c" +#line 4006 "grammar.c" break; - case 125: -#line 2263 "grammar.y" + case 124: +#line 2266 "grammar.y" { yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); (yyval.integer) = FOR_EXPRESSION_ALL; } -#line 4022 "grammar.c" +#line 4015 "grammar.c" break; - case 126: -#line 2268 "grammar.y" + case 125: +#line 2271 "grammar.y" { yr_parser_emit_push_const(yyscanner, 1); (yyval.integer) = FOR_EXPRESSION_ANY; } -#line 4031 "grammar.c" +#line 4024 "grammar.c" + break; + + 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 2277 "grammar.y" +#line 2318 "grammar.y" { (yyval.expression) = (yyvsp[-1].expression); } -#line 4039 "grammar.c" +#line 4073 "grammar.c" break; case 128: -#line 2281 "grammar.y" +#line 2322 "grammar.y" { fail_if_error(yr_parser_emit( yyscanner, OP_FILESIZE, NULL)); @@ -4047,11 +4081,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4051 "grammar.c" +#line 4085 "grammar.c" break; case 129: -#line 2289 "grammar.y" +#line 2330 "grammar.y" { yywarning(yyscanner, "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " @@ -4063,11 +4097,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4067 "grammar.c" +#line 4101 "grammar.c" break; case 130: -#line 2301 "grammar.y" +#line 2342 "grammar.y" { check_type((yyvsp[-1].expression), EXPRESSION_TYPE_INTEGER, "intXXXX or uintXXXX"); @@ -4081,33 +4115,33 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4085 "grammar.c" +#line 4119 "grammar.c" break; case 131: -#line 2315 "grammar.y" +#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 4096 "grammar.c" +#line 4130 "grammar.c" break; case 132: -#line 2322 "grammar.y" +#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 4107 "grammar.c" +#line 4141 "grammar.c" break; case 133: -#line 2329 "grammar.y" +#line 2370 "grammar.y" { YR_ARENA_REF ref; @@ -4132,11 +4166,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_STRING; (yyval.expression).value.sized_string_ref = ref; } -#line 4136 "grammar.c" +#line 4170 "grammar.c" break; case 134: -#line 2354 "grammar.y" +#line 2395 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[0].c_string), OP_COUNT, YR_UNDEFINED); @@ -4148,11 +4182,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4152 "grammar.c" +#line 4186 "grammar.c" break; case 135: -#line 2366 "grammar.y" +#line 2407 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-3].c_string), OP_OFFSET, YR_UNDEFINED); @@ -4164,11 +4198,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4168 "grammar.c" +#line 4202 "grammar.c" break; case 136: -#line 2378 "grammar.y" +#line 2419 "grammar.y" { int result = yr_parser_emit_push_const(yyscanner, 1); @@ -4183,11 +4217,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4187 "grammar.c" +#line 4221 "grammar.c" break; case 137: -#line 2393 "grammar.y" +#line 2434 "grammar.y" { int result = yr_parser_reduce_string_identifier( yyscanner, (yyvsp[-3].c_string), OP_LENGTH, YR_UNDEFINED); @@ -4199,11 +4233,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4203 "grammar.c" +#line 4237 "grammar.c" break; case 138: -#line 2405 "grammar.y" +#line 2446 "grammar.y" { int result = yr_parser_emit_push_const(yyscanner, 1); @@ -4218,11 +4252,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).type = EXPRESSION_TYPE_INTEGER; (yyval.expression).value.integer = YR_UNDEFINED; } -#line 4222 "grammar.c" +#line 4256 "grammar.c" break; case 139: -#line 2420 "grammar.y" +#line 2461 "grammar.y" { int result = ERROR_SUCCESS; @@ -4244,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\"", @@ -4265,11 +4298,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4269 "grammar.c" +#line 4302 "grammar.c" break; case 140: -#line 2463 "grammar.y" +#line 2503 "grammar.y" { int result = ERROR_SUCCESS; @@ -4290,11 +4323,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4294 "grammar.c" +#line 4327 "grammar.c" break; case 141: -#line 2484 "grammar.y" +#line 2524 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "+", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4329,11 +4362,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4333 "grammar.c" +#line 4366 "grammar.c" break; case 142: -#line 2519 "grammar.y" +#line 2559 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "-", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4368,11 +4401,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4372 "grammar.c" +#line 4405 "grammar.c" break; case 143: -#line 2554 "grammar.y" +#line 2594 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "*", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4406,11 +4439,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4410 "grammar.c" +#line 4443 "grammar.c" break; case 144: -#line 2588 "grammar.y" +#line 2628 "grammar.y" { int result = yr_parser_reduce_operation( yyscanner, "\\", (yyvsp[-2].expression), (yyvsp[0].expression)); @@ -4435,11 +4468,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4439 "grammar.c" +#line 4472 "grammar.c" break; case 145: -#line 2613 "grammar.y" +#line 2653 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "%"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "%"); @@ -4456,11 +4489,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(ERROR_DIVISION_BY_ZERO); } } -#line 4460 "grammar.c" +#line 4493 "grammar.c" break; case 146: -#line 2630 "grammar.y" +#line 2670 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); @@ -4470,11 +4503,11 @@ 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 4474 "grammar.c" +#line 4507 "grammar.c" break; case 147: -#line 2640 "grammar.y" +#line 2680 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); @@ -4484,11 +4517,11 @@ 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 4488 "grammar.c" +#line 4521 "grammar.c" break; case 148: -#line 2650 "grammar.y" +#line 2690 "grammar.y" { check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "|"); check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "|"); @@ -4498,11 +4531,11 @@ 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 4502 "grammar.c" +#line 4535 "grammar.c" break; case 149: -#line 2660 "grammar.y" +#line 2700 "grammar.y" { check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "~"); @@ -4512,11 +4545,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); (yyval.expression).value.integer = ((yyvsp[0].expression).value.integer == YR_UNDEFINED) ? YR_UNDEFINED : ~((yyvsp[0].expression).value.integer); } -#line 4516 "grammar.c" +#line 4549 "grammar.c" break; case 150: -#line 2670 "grammar.y" +#line 2710 "grammar.y" { int result; @@ -4536,11 +4569,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4540 "grammar.c" +#line 4573 "grammar.c" break; case 151: -#line 2690 "grammar.y" +#line 2730 "grammar.y" { int result; @@ -4560,19 +4593,51 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); fail_if_error(result); } -#line 4564 "grammar.c" +#line 4597 "grammar.c" break; case 152: -#line 2710 "grammar.y" +#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 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 4572 "grammar.c" +#line 4637 "grammar.c" break; -#line 4576 "grammar.c" +#line 4641 "grammar.c" default: break; } @@ -4766,5 +4831,5 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); return yyresult; } -#line 2715 "grammar.y" +#line 2777 "grammar.y" diff --git a/libyara/grammar.h b/libyara/grammar.h index dfe3662d64..ba49ea9edf 100644 --- a/libyara/grammar.h +++ b/libyara/grammar.h @@ -174,7 +174,7 @@ extern int yara_yydebug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { -#line 302 "grammar.y" +#line 305 "grammar.y" YR_EXPRESSION expression; SIZED_STRING* sized_string; diff --git a/libyara/grammar.y b/libyara/grammar.y index 151515937e..f89b9cbc1a 100644 --- a/libyara/grammar.y +++ b/libyara/grammar.y @@ -261,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 @@ -602,12 +605,11 @@ variable_declaration { compiler->current_line = yyget_lineno(yyscanner); } - expression + object { YR_INTERNAL_VARIABLE* int_var; YR_ARENA_REF int_ref; YR_ARENA_REF identifier_ref; - uint8_t obj_type; // Check for duplicated identifier in scope with external variables YR_OBJECT* object = (YR_OBJECT*)yr_hash_table_lookup( @@ -646,30 +648,35 @@ variable_declaration $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: - obj_type = OBJECT_TYPE_INTEGER; + int_var->type = OBJECT_TYPE_INTEGER; break; case EXPRESSION_TYPE_FLOAT: - obj_type = OBJECT_TYPE_FLOAT; + int_var->type = OBJECT_TYPE_FLOAT; break; case EXPRESSION_TYPE_STRING: - obj_type = OBJECT_TYPE_STRING; + int_var->type = OBJECT_TYPE_STRING; + break; + case EXPRESSION_TYPE_OBJECT: + int_var->type = $4.value.object->type; break; - default: assert(false); } - int_var->identifier = yr_arena_ref_to_ptr( - compiler->arena, &identifier_ref); - int_var->rule_idx = compiler->current_rule_idx; - int_var->type = obj_type; - - yr_object_create( + 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, @@ -1006,9 +1013,9 @@ identifier $1, NULL); - // Search for identifier within the global namespace, where the - // externals variables reside. 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); } @@ -1393,7 +1400,7 @@ boolean_expression } ; -expression +complex_expression : _TRUE_ { fail_if_error(yr_parser_emit_push_const(yyscanner, 1)); @@ -1977,10 +1984,6 @@ expression $$.type = EXPRESSION_TYPE_BOOLEAN; } - | primary_expression - { - $$ = $1; - } |'(' expression ')' { $$ = $2; @@ -2271,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; } @@ -2438,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\"", @@ -2712,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/object.h b/libyara/include/yara/object.h index bdaf022c0f..18311e2a42 100644 --- a/libyara/include/yara/object.h +++ b/libyara/include/yara/object.h @@ -154,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/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)