diff --git a/libyara/grammar.c b/libyara/grammar.c index 0284fb64..11ee6319 100644 --- a/libyara/grammar.c +++ b/libyara/grammar.c @@ -60,35 +60,37 @@ /* Substitute the variable and function names. */ -#define yyparse yara_yyparse -#define yylex yara_yylex -#define yyerror yara_yyerror -#define yydebug yara_yydebug -#define yynerrs yara_yynerrs +#define yyparse yara_yyparse +#define yylex yara_yylex +#define yyerror yara_yyerror +#define yydebug yara_yydebug +#define yynerrs yara_yynerrs /* Copy the first part of user declarations. */ #line 30 "grammar.y" /* yacc.c:339 */ + #include -#include -#include #include -#include #include +#include +#include +#include + #include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #if defined(_MSC_VER) #define llabs _abs64 @@ -97,111 +99,110 @@ #define YYERROR_VERBOSE #define YYMALLOC yr_malloc -#define YYFREE yr_free +#define YYFREE yr_free #define FOR_EXPRESSION_ALL 1 #define FOR_EXPRESSION_ANY 2 -#define fail_with_error(e) \ - { \ - compiler->last_error = e; \ - yyerror(yyscanner, compiler, NULL); \ - YYERROR; \ - } +#define fail_with_error(e) \ + { \ + compiler->last_error = e; \ + yyerror(yyscanner, compiler, NULL); \ + YYERROR; \ + } -#define fail_if_error(e) \ - if (e != ERROR_SUCCESS) \ - { \ - fail_with_error(e); \ - } +#define fail_if_error(e) \ + if (e != ERROR_SUCCESS) \ + { \ + fail_with_error(e); \ + } \ #define check_type_with_cleanup(expression, expected_type, op, cleanup) \ - if (((expression.type) & (expected_type)) == 0) \ - { \ - switch (expression.type) \ - { \ - case EXPRESSION_TYPE_INTEGER: \ - yr_compiler_set_error_extra_info( \ - compiler, "wrong type \"integer\" for " op " operator"); \ - break; \ - case EXPRESSION_TYPE_FLOAT: \ - yr_compiler_set_error_extra_info( \ - compiler, "wrong type \"float\" for " op " operator"); \ - break; \ - case EXPRESSION_TYPE_STRING: \ - yr_compiler_set_error_extra_info( \ - compiler, "wrong type \"string\" for " op " operator"); \ - break; \ - case EXPRESSION_TYPE_BOOLEAN: \ - yr_compiler_set_error_extra_info( \ - compiler, "wrong type \"boolean\" for " op " operator"); \ - break; \ - } \ - cleanup; \ - compiler->last_error = ERROR_WRONG_TYPE; \ - yyerror(yyscanner, compiler, NULL); \ - YYERROR; \ - } + if (((expression.type) & (expected_type)) == 0) \ + { \ + switch(expression.type) \ + { \ + case EXPRESSION_TYPE_INTEGER: \ + yr_compiler_set_error_extra_info( \ + compiler, "wrong type \"integer\" for " op " operator"); \ + break; \ + case EXPRESSION_TYPE_FLOAT: \ + yr_compiler_set_error_extra_info( \ + compiler, "wrong type \"float\" for " op " operator"); \ + break; \ + case EXPRESSION_TYPE_STRING: \ + yr_compiler_set_error_extra_info( \ + compiler, "wrong type \"string\" for " op " operator"); \ + break; \ + case EXPRESSION_TYPE_BOOLEAN: \ + yr_compiler_set_error_extra_info( \ + compiler, "wrong type \"boolean\" for " op " operator"); \ + break; \ + } \ + cleanup; \ + compiler->last_error = ERROR_WRONG_TYPE; \ + yyerror(yyscanner, compiler, NULL); \ + YYERROR; \ + } // check_type(expression, EXPRESSION_TYPE_INTEGER | EXPRESSION_TYPE_FLOAT) is // used to ensure that the type of "expression" is either integer or float. #define check_type(expression, expected_type, op) \ - check_type_with_cleanup(expression, expected_type, op, ) + check_type_with_cleanup(expression, expected_type, op, ) -#define loop_vars_cleanup(loop_index) \ - { \ - YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[loop_index]; \ - for (int i = 0; i < loop_ctx->vars_count; i++) \ - { \ - yr_free((void*) loop_ctx->vars[i].identifier.ptr); \ - loop_ctx->vars[i].identifier.ptr = NULL; \ - loop_ctx->vars[i].identifier.ref = YR_ARENA_NULL_REF; \ - } \ - loop_ctx->vars_count = 0; \ - } +#define loop_vars_cleanup(loop_index) \ + { \ + YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[loop_index]; \ + for (int i = 0; i < loop_ctx->vars_count; i++) \ + { \ + yr_free((void*) loop_ctx->vars[i].identifier.ptr); \ + loop_ctx->vars[i].identifier.ptr = NULL; \ + loop_ctx->vars[i].identifier.ref = YR_ARENA_NULL_REF; \ + } \ + loop_ctx->vars_count = 0; \ + } \ // Given a YR_EXPRESSION returns its identifier. It returns identifier.ptr if // not NULL and relies on identifier.ref if otherwise. -#define expression_identifier(expr) \ - ((expr).identifier.ptr != NULL \ - ? (expr).identifier.ptr \ - : (const char*) yr_arena_ref_to_ptr( \ - compiler->arena, &(expr).identifier.ref)) +#define expression_identifier(expr) \ + ((expr).identifier.ptr != NULL ? \ + (expr).identifier.ptr : \ + (const char*) yr_arena_ref_to_ptr(compiler->arena, &(expr).identifier.ref)) #define DEFAULT_BASE64_ALPHABET \ - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" #line 182 "grammar.c" /* yacc.c:339 */ -#ifndef YY_NULLPTR -#if defined __cplusplus && 201103L <= __cplusplus -#define YY_NULLPTR nullptr -#else -#define YY_NULLPTR 0 -#endif -#endif +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE -#undef YYERROR_VERBOSE -#define YYERROR_VERBOSE 1 +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 #else -#define YYERROR_VERBOSE 0 +# define YYERROR_VERBOSE 0 #endif /* In a future release of Bison, this section will be replaced by #include "y.tab.h". */ #ifndef YY_YARA_YY_GRAMMAR_H_INCLUDED -#define YY_YARA_YY_GRAMMAR_H_INCLUDED +# define YY_YARA_YY_GRAMMAR_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG -#define YYDEBUG 0 +# define YYDEBUG 0 #endif #if YYDEBUG extern int yara_yydebug; @@ -209,144 +210,144 @@ extern int yara_yydebug; /* Token type. */ #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, - _STARTSWITH_ = 296, - _ENDSWITH_ = 297, - _ICONTAINS_ = 298, - _ISTARTSWITH_ = 299, - _IENDSWITH_ = 300, - _IMPORT_ = 301, - _TRUE_ = 302, - _FALSE_ = 303, - _OR_ = 304, - _AND_ = 305, - _NOT_ = 306, - _EQ_ = 307, - _NEQ_ = 308, - _LT_ = 309, - _LE_ = 310, - _GT_ = 311, - _GE_ = 312, - _SHIFT_LEFT_ = 313, - _SHIFT_RIGHT_ = 314, - UNARY_MINUS = 315 -}; +# 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, + _STARTSWITH_ = 296, + _ENDSWITH_ = 297, + _ICONTAINS_ = 298, + _ISTARTSWITH_ = 299, + _IENDSWITH_ = 300, + _IMPORT_ = 301, + _TRUE_ = 302, + _FALSE_ = 303, + _OR_ = 304, + _AND_ = 305, + _NOT_ = 306, + _EQ_ = 307, + _NEQ_ = 308, + _LT_ = 309, + _LE_ = 310, + _GT_ = 311, + _GE_ = 312, + _SHIFT_LEFT_ = 313, + _SHIFT_RIGHT_ = 314, + UNARY_MINUS = 315 + }; #endif /* Tokens. */ -#define _END_OF_FILE_ 0 -#define _END_OF_INCLUDED_FILE_ 258 -#define _DOT_DOT_ 259 -#define _RULE_ 260 -#define _PRIVATE_ 261 -#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 _END_OF_FILE_ 0 +#define _END_OF_INCLUDED_FILE_ 258 +#define _DOT_DOT_ 259 +#define _RULE_ 260 +#define _PRIVATE_ 261 +#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 _STARTSWITH_ 296 -#define _ENDSWITH_ 297 -#define _ICONTAINS_ 298 -#define _ISTARTSWITH_ 299 -#define _IENDSWITH_ 300 -#define _IMPORT_ 301 -#define _TRUE_ 302 -#define _FALSE_ 303 -#define _OR_ 304 -#define _AND_ 305 -#define _NOT_ 306 -#define _EQ_ 307 -#define _NEQ_ 308 -#define _LT_ 309 -#define _LE_ 310 -#define _GT_ 311 -#define _GE_ 312 -#define _SHIFT_LEFT_ 313 -#define _SHIFT_RIGHT_ 314 -#define UNARY_MINUS 315 +#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 _STARTSWITH_ 296 +#define _ENDSWITH_ 297 +#define _ICONTAINS_ 298 +#define _ISTARTSWITH_ 299 +#define _IENDSWITH_ 300 +#define _IMPORT_ 301 +#define _TRUE_ 302 +#define _FALSE_ 303 +#define _OR_ 304 +#define _AND_ 305 +#define _NOT_ 306 +#define _EQ_ 307 +#define _NEQ_ 308 +#define _LT_ 309 +#define _LE_ 310 +#define _GT_ 311 +#define _GE_ 312 +#define _SHIFT_LEFT_ 313 +#define _SHIFT_RIGHT_ 314 +#define UNARY_MINUS 315 /* Value type. */ -#if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { #line 302 "grammar.y" /* yacc.c:355 */ - YR_EXPRESSION expression; - SIZED_STRING* sized_string; - char* c_string; - int64_t integer; - double double_; - YR_MODIFIER modifier; + YR_EXPRESSION expression; + SIZED_STRING* sized_string; + char* c_string; + int64_t integer; + double double_; + YR_MODIFIER modifier; YR_ARENA_REF tag; YR_ARENA_REF rule; @@ -357,12 +358,13 @@ union YYSTYPE }; typedef union YYSTYPE YYSTYPE; -#define YYSTYPE_IS_TRIVIAL 1 -#define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 #endif -int yara_yyparse(void* yyscanner, YR_COMPILER* compiler); + +int yara_yyparse (void *yyscanner, YR_COMPILER* compiler); #endif /* !YY_YARA_YY_GRAMMAR_H_INCLUDED */ @@ -371,7 +373,7 @@ int yara_yyparse(void* yyscanner, YR_COMPILER* compiler); #line 374 "grammar.c" /* yacc.c:358 */ #ifdef short -#undef short +# undef short #endif #ifdef YYTYPE_UINT8 @@ -399,163 +401,157 @@ typedef short int yytype_int16; #endif #ifndef YYSIZE_T -#ifdef __SIZE_TYPE__ -#define YYSIZE_T __SIZE_TYPE__ -#elif defined size_t -#define YYSIZE_T size_t -#elif !defined YYSIZE_T -#include /* INFRINGES ON USER NAME SPACE */ -#define YYSIZE_T size_t -#else -#define YYSIZE_T unsigned int -#endif +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -#if defined YYENABLE_NLS && YYENABLE_NLS -#if ENABLE_NLS -#include /* INFRINGES ON USER NAME SPACE */ -#define YY_(Msgid) dgettext("bison-runtime", Msgid) -#endif -#endif -#ifndef YY_ -#define YY_(Msgid) Msgid -#endif +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# 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 +# 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__)) +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) #endif #ifndef YY_ATTRIBUTE_UNUSED -#define YY_ATTRIBUTE_UNUSED 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) -#else -#define _Noreturn YY_ATTRIBUTE((__noreturn__)) -#endif +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif #endif /* Suppress unused-variable warnings by "using" E. */ -#if !defined lint || defined __GNUC__ -#define YYUSE(E) ((void) (E)) +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) #else -#define YYUSE(E) /* empty */ +# define YYUSE(E) /* empty */ #endif #if defined __GNUC__ && 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\"") \ - _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") -#define YY_IGNORE_MAYBE_UNINITIALIZED_END _Pragma("GCC diagnostic pop") +# 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 \ + _Pragma ("GCC diagnostic pop") #else -#define YY_INITIAL_VALUE(Value) Value +# define YY_INITIAL_VALUE(Value) Value #endif #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN -#define YY_IGNORE_MAYBE_UNINITIALIZED_END +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END #endif #ifndef YY_INITIAL_VALUE -#define YY_INITIAL_VALUE(Value) /* Nothing. */ +# define YY_INITIAL_VALUE(Value) /* Nothing. */ #endif -#if !defined yyoverflow || YYERROR_VERBOSE +#if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ -#ifdef YYSTACK_USE_ALLOCA -#if YYSTACK_USE_ALLOCA -#ifdef __GNUC__ -#define YYSTACK_ALLOC __builtin_alloca -#elif defined __BUILTIN_VA_ARG_INCR -#include /* INFRINGES ON USER NAME SPACE */ -#elif defined _AIX -#define YYSTACK_ALLOC __alloca -#elif defined _MSC_VER -#include /* INFRINGES ON USER NAME SPACE */ -#define alloca _alloca -#else -#define YYSTACK_ALLOC alloca -#if !defined _ALLOCA_H && !defined EXIT_SUCCESS -#include /* INFRINGES ON USER NAME SPACE */ -/* Use EXIT_SUCCESS as a witness for stdlib.h. */ -#ifndef EXIT_SUCCESS -#define EXIT_SUCCESS 0 -#endif -#endif -#endif -#endif -#endif +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif -#ifdef YYSTACK_ALLOC -/* Pacify GCC's 'empty if-body' warning. */ -#define YYSTACK_FREE(Ptr) \ - do \ - { /* empty */ \ - ; \ - } while (0) -#ifndef YYSTACK_ALLOC_MAXIMUM -/* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -#define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -#endif -#else -#define YYSTACK_ALLOC YYMALLOC -#define YYSTACK_FREE YYFREE -#ifndef YYSTACK_ALLOC_MAXIMUM -#define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -#endif -#if ( \ - defined __cplusplus && !defined EXIT_SUCCESS && \ - !((defined YYMALLOC || defined malloc) && \ - (defined YYFREE || defined free))) -#include /* INFRINGES ON USER NAME SPACE */ -#ifndef EXIT_SUCCESS -#define EXIT_SUCCESS 0 -#endif -#endif -#ifndef YYMALLOC -#define YYMALLOC malloc -#if !defined malloc && !defined EXIT_SUCCESS -void* malloc(YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -#endif -#endif -#ifndef YYFREE -#define YYFREE free -#if !defined free && !defined EXIT_SUCCESS -void free(void*); /* INFRINGES ON USER NAME SPACE */ -#endif -#endif -#endif +# ifdef YYSTACK_ALLOC + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ -#if ( \ - !defined yyoverflow && \ - (!defined __cplusplus || \ - (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc @@ -565,520 +561,536 @@ union yyalloc }; /* 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 (sizeof (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)) + YYSTACK_GAP_MAXIMUM) +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) -#define YYCOPY_NEEDED 1 +# define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -#define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY(&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof(*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof(*yyptr); \ - } while (0) +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from SRC to DST. The source and destination do not overlap. */ -#ifndef YYCOPY -#if defined __GNUC__ && 1 < __GNUC__ -#define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy(Dst, Src, (Count) * sizeof(*(Src))) -#else -#define YYCOPY(Dst, Src, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) (Dst)[yyi] = (Src)[yyi]; \ - } while (0) -#endif -#endif +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 2 +#define YYFINAL 2 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 396 +#define YYLAST 396 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 81 +#define YYNTOKENS 81 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 48 +#define YYNNTS 48 /* YYNRULES -- Number of rules. */ -#define YYNRULES 151 +#define YYNRULES 151 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 252 +#define YYNSTATES 252 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 316 +#define YYUNDEFTOK 2 +#define YYMAXUTOK 316 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex, without out-of-bounds checking. */ -static const yytype_uint8 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, 67, - 62, 2, 75, 76, 65, 63, 80, 64, 77, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 73, 2, 2, 74, 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, 78, 66, 79, 61, - 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, 71, 60, 72, 68, 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, 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, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 69, 70}; +static const yytype_uint8 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, 67, 62, 2, + 75, 76, 65, 63, 80, 64, 77, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 73, 2, + 2, 74, 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, 78, 66, 79, 61, 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, 71, 60, 72, 68, 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, 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, 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, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 69, 70 +}; #if YYDEBUG -/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = { - 0, 319, 319, 321, 322, 323, 324, 325, 326, 334, 347, 352, - 346, 379, 382, 398, 401, 416, 421, 422, 427, 428, 434, 437, - 453, 462, 504, 505, 510, 527, 541, 555, 569, 587, 588, 594, - 593, 610, 609, 630, 629, 654, 660, 720, 721, 722, 723, 724, - 725, 731, 752, 783, 788, 805, 810, 830, 831, 845, 846, 847, - 848, 849, 853, 854, 868, 872, 967, 1015, 1076, 1123, 1124, 1128, - 1163, 1216, 1259, 1282, 1288, 1294, 1306, 1316, 1326, 1336, 1346, 1356, - 1366, 1380, 1395, 1406, 1485, 1523, 1425, 1683, 1682, 1772, 1778, 1785, - 1784, 1830, 1829, 1873, 1880, 1887, 1894, 1901, 1908, 1915, 1919, 1927, - 1947, 1975, 2049, 2077, 2085, 2094, 2118, 2133, 2153, 2152, 2158, 2169, - 2170, 2175, 2182, 2193, 2197, 2202, 2211, 2215, 2223, 2235, 2249, 2256, - 2263, 2288, 2300, 2312, 2327, 2339, 2354, 2397, 2418, 2453, 2488, 2522, - 2547, 2564, 2574, 2584, 2594, 2604, 2624, 2644}; + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 319, 319, 321, 322, 323, 324, 325, 326, 334, + 347, 352, 346, 379, 382, 398, 401, 416, 421, 422, + 427, 428, 434, 437, 453, 462, 504, 505, 510, 527, + 541, 555, 569, 587, 588, 594, 593, 610, 609, 630, + 629, 654, 660, 720, 721, 722, 723, 724, 725, 731, + 752, 783, 788, 805, 810, 830, 831, 845, 846, 847, + 848, 849, 853, 854, 868, 872, 967, 1015, 1076, 1123, + 1124, 1128, 1163, 1216, 1259, 1282, 1288, 1294, 1306, 1316, + 1326, 1336, 1346, 1356, 1366, 1380, 1395, 1406, 1483, 1521, + 1423, 1680, 1679, 1769, 1775, 1782, 1781, 1827, 1826, 1870, + 1877, 1884, 1891, 1898, 1905, 1912, 1916, 1924, 1944, 1972, + 2046, 2074, 2082, 2091, 2115, 2130, 2150, 2149, 2155, 2166, + 2167, 2172, 2179, 2190, 2194, 2199, 2208, 2212, 2220, 2232, + 2246, 2253, 2260, 2285, 2297, 2309, 2324, 2336, 2351, 2394, + 2415, 2450, 2485, 2519, 2544, 2561, 2571, 2581, 2591, 2601, + 2621, 2641 +}; #endif #if YYDEBUG || YYERROR_VERBOSE || 0 /* 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}; +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 +}; #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[] = { - 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, 310, - 311, 312, 313, 314, 124, 94, 38, 43, 45, 42, 92, 37, 126, 315, - 316, 123, 125, 58, 61, 40, 41, 46, 91, 93, 44}; -#endif +static const yytype_uint16 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, 310, 311, 312, 313, 314, + 124, 94, 38, 43, 45, 42, 92, 37, 126, 315, + 316, 123, 125, 58, 61, 40, 41, 46, 91, 93, + 44 +}; +# endif #define YYPACT_NINF -74 -#define yypact_value_is_default(Yystate) (!!((Yystate) == (-74))) +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-74))) #define YYTABLE_NINF -124 -#define yytable_value_is_error(Yytable_value) 0 +#define yytable_value_is_error(Yytable_value) \ + 0 -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -static const yytype_int16 yypact[] = { - -74, 153, -74, -34, -74, -4, -74, -74, 114, -74, -74, -74, -74, 7, -74, - -74, -74, -74, -36, 16, -8, -74, 73, 62, -74, 30, 107, 98, 50, -74, - 56, 98, -74, 124, 122, 14, -74, 70, 124, -74, 94, 117, -74, -74, -74, - -74, 152, 59, -74, 54, -74, -74, 176, 190, 177, -74, -6, -74, 119, 135, - -74, -74, 151, -74, -74, -74, -74, -74, -74, 93, -74, -74, 54, 120, 120, - 54, 68, -74, 100, -74, 207, 213, -74, -74, -74, 120, 169, 120, 120, 120, - 120, 81, 329, -74, -74, -74, 100, 170, 175, 54, 234, 120, -74, -74, 39, - 225, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, - 120, 120, 120, 120, 120, 120, 120, 120, 258, 142, 242, 329, 120, -74, 230, - 240, 272, 291, -74, 39, 239, -74, -74, 183, 180, 123, -74, 262, 54, 54, - -74, -74, -74, -74, 329, 329, 329, 329, 329, 329, 329, 329, 329, 329, 329, - 329, 158, 158, 116, 31, 127, 97, 97, -74, -74, -74, -74, -74, -74, 186, - 187, 188, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, -74, 143, -74, - -74, -74, 235, -74, -20, -74, 54, -74, 260, -74, -2, 294, 292, 293, 120, - -74, 0, 303, 123, -74, -74, -48, -74, -51, 241, 264, 310, 243, 120, 68, - 269, -74, -74, -74, -74, -2, 298, -74, -74, -74, -74, 54, 3, 143, -74, - -74, 267, -46, -74, 120, 270, -74, -74, 329, 54, -41, -74}; + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int16 yypact[] = +{ + -74, 153, -74, -34, -74, -4, -74, -74, 114, -74, + -74, -74, -74, 7, -74, -74, -74, -74, -36, 16, + -8, -74, 73, 62, -74, 30, 107, 98, 50, -74, + 56, 98, -74, 124, 122, 14, -74, 70, 124, -74, + 94, 117, -74, -74, -74, -74, 152, 59, -74, 54, + -74, -74, 176, 190, 177, -74, -6, -74, 119, 135, + -74, -74, 151, -74, -74, -74, -74, -74, -74, 93, + -74, -74, 54, 120, 120, 54, 68, -74, 100, -74, + 207, 213, -74, -74, -74, 120, 169, 120, 120, 120, + 120, 81, 329, -74, -74, -74, 100, 170, 175, 54, + 234, 120, -74, -74, 39, 225, 120, 120, 120, 120, + 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, + 120, 120, 120, 120, 120, 120, 120, 120, 258, 142, + 242, 329, 120, -74, 230, 240, 272, 291, -74, 39, + 239, -74, -74, 183, 180, 123, -74, 262, 54, 54, + -74, -74, -74, -74, 329, 329, 329, 329, 329, 329, + 329, 329, 329, 329, 329, 329, 158, 158, 116, 31, + 127, 97, 97, -74, -74, -74, -74, -74, -74, 186, + 187, 188, -74, -74, -74, -74, -74, -74, -74, -74, + -74, -74, -74, 143, -74, -74, -74, 235, -74, -20, + -74, 54, -74, 260, -74, -2, 294, 292, 293, 120, + -74, 0, 303, 123, -74, -74, -48, -74, -51, 241, + 264, 310, 243, 120, 68, 269, -74, -74, -74, -74, + -2, 298, -74, -74, -74, -74, 54, 3, 143, -74, + -74, 267, -46, -74, 120, 270, -74, -74, 329, 54, + -41, -74 +}; -/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE does not specify something else to do. Zero - 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, 84, 133, 135, 137, - 130, 131, 0, 132, 73, 127, 128, 124, 125, 0, 75, 76, 0, 0, 0, - 0, 138, 151, 17, 74, 0, 105, 41, 55, 62, 0, 0, 0, 0, 0, - 0, 0, 123, 94, 139, 148, 0, 74, 105, 69, 0, 0, 97, 95, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 36, 38, 40, 85, 0, 86, 0, - 0, 0, 0, 87, 0, 0, 106, 126, 0, 70, 71, 66, 0, 0, 0, - 118, 116, 93, 77, 78, 80, 82, 79, 81, 83, 103, 104, 99, 101, 100, - 102, 149, 150, 147, 145, 146, 140, 141, 142, 143, 144, 47, 44, 43, 48, - 51, 53, 45, 46, 42, 61, 58, 57, 59, 60, 56, 64, 63, 0, 134, - 136, 129, 0, 107, 0, 68, 0, 67, 98, 96, 0, 0, 0, 0, 0, - 91, 0, 0, 72, 121, 122, 0, 119, 0, 0, 0, 0, 0, 0, 109, - 0, 110, 112, 108, 117, 0, 0, 49, 52, 54, 113, 0, 0, 114, 89, - 120, 0, 0, 111, 0, 0, 50, 92, 115, 0, 0, 90}; + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + 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, 84, 133, 135, 137, + 130, 131, 0, 132, 73, 127, 128, 124, 125, 0, + 75, 76, 0, 0, 0, 0, 138, 151, 17, 74, + 0, 105, 41, 55, 62, 0, 0, 0, 0, 0, + 0, 0, 123, 94, 139, 148, 0, 74, 105, 69, + 0, 0, 97, 95, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 36, 38, + 40, 85, 0, 86, 0, 0, 0, 0, 87, 0, + 0, 106, 126, 0, 70, 71, 66, 0, 0, 0, + 118, 116, 93, 77, 78, 80, 82, 79, 81, 83, + 103, 104, 99, 101, 100, 102, 149, 150, 147, 145, + 146, 140, 141, 142, 143, 144, 47, 44, 43, 48, + 51, 53, 45, 46, 42, 61, 58, 57, 59, 60, + 56, 64, 63, 0, 134, 136, 129, 0, 107, 0, + 68, 0, 67, 98, 96, 0, 0, 0, 0, 0, + 91, 0, 0, 72, 121, 122, 0, 119, 0, 0, + 0, 0, 0, 0, 109, 0, 110, 112, 108, 117, + 0, 0, 49, 52, 54, 113, 0, 0, 114, 89, + 120, 0, 0, 111, 0, 0, 50, 92, 115, 0, + 0, 90 +}; -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = { - -74, -74, 313, 341, -74, -74, -74, -74, -74, -74, -74, -74, - -74, -74, 315, -74, 309, -74, -74, -74, -74, -74, -74, -74, - -74, -74, 148, -74, -74, 255, -49, -73, -74, -74, -74, -74, - -74, -74, -74, -74, 150, -74, 223, -74, -74, 133, 295, -68}; + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -74, -74, 313, 341, -74, -74, -74, -74, -74, -74, + -74, -74, -74, -74, 315, -74, 309, -74, -74, -74, + -74, -74, -74, -74, -74, -74, 148, -74, -74, 255, + -49, -73, -74, -74, -74, -74, -74, -74, -74, -74, + 150, -74, 223, -74, -74, 133, 295, -68 +}; -/* 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, 128, 184, 129, 190, - 130, 192, 76, 143, 144, 77, 96, 79, 140, 245, 222, 149, - 148, 199, 225, 226, 133, 237, 152, 205, 216, 217, 80, 81}; + /* 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, + 128, 184, 129, 190, 130, 192, 76, 143, 144, 77, + 96, 79, 140, 245, 222, 149, 148, 199, 225, 226, + 133, 237, 152, 205, 216, 217, 80, 81 +}; -/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule whose - number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_int16 yytable[] = { - 78, 92, 97, 102, 103, 94, 95, 98, 102, 103, 214, 55, 5, 231, 215, - 211, 12, 131, 17, 134, 135, 136, 137, 93, 85, 232, 145, 21, 229, 86, - 247, 42, 230, 147, 43, 251, 9, 19, 154, 155, 156, 157, 158, 159, 160, - 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, - 212, 44, 45, 23, 193, 55, 56, 57, 58, 59, 25, 60, 61, 62, 63, - 223, 64, 150, 46, 243, -39, -37, 138, 244, 24, 65, 66, 67, 68, 118, - 119, 69, -88, 122, 123, 124, 125, 126, 127, 203, 204, 70, 71, 27, 55, - 72, 57, 58, 59, 30, 60, 61, 62, 63, 151, 64, 28, 139, 73, 13, - 14, 15, 74, 33, 65, 66, 67, 68, 213, 75, 35, 55, 40, 57, 58, - 59, 37, 60, 61, 62, 63, 221, 64, 99, 47, 100, 101, 209, 185, 102, - 103, 65, 66, 2, 3, 238, 4, 73, -18, -18, -18, 74, 125, 126, 127, - 186, 187, 49, 90, 51, 188, 189, -74, -74, 118, 119, 248, 121, 122, 123, - 124, 125, 126, 127, 73, 118, 119, 242, 74, 50, 123, 124, 125, 126, 127, - 90, 82, 87, 84, 5, 250, 118, 119, 120, 121, 122, 123, 124, 125, 126, - 127, -123, 83, 88, 105, 106, 107, 108, 109, 110, 111, 123, 124, 125, 126, - 127, 89, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, - 125, 126, 127, 104, 132, 146, 141, 64, 191, -123, 198, 142, 105, 106, 107, - 108, 109, 110, 111, 200, 201, 206, 207, 208, 176, 112, 113, 114, 115, 116, - 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 177, 178, 179, 180, - 181, 182, 183, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, 210, 194, 103, 218, 219, 220, 228, - 241, 10, 233, 236, 195, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 234, 202, 239, 246, 11, - 249, 36, 48, 196, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 224, - 153, 227, 197, 240, 91, 0, 0, 142, 118, 119, 120, 121, 122, 123, 124, - 125, 126, 127, 0, 0, 0, 0, 0, 0, 0, 0, 235, 118, 119, 120, - 121, 122, 123, 124, 125, 126, 127}; + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_int16 yytable[] = +{ + 78, 92, 97, 102, 103, 94, 95, 98, 102, 103, + 214, 55, 5, 231, 215, 211, 12, 131, 17, 134, + 135, 136, 137, 93, 85, 232, 145, 21, 229, 86, + 247, 42, 230, 147, 43, 251, 9, 19, 154, 155, + 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, + 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, + 212, 44, 45, 23, 193, 55, 56, 57, 58, 59, + 25, 60, 61, 62, 63, 223, 64, 150, 46, 243, + -39, -37, 138, 244, 24, 65, 66, 67, 68, 118, + 119, 69, -88, 122, 123, 124, 125, 126, 127, 203, + 204, 70, 71, 27, 55, 72, 57, 58, 59, 30, + 60, 61, 62, 63, 151, 64, 28, 139, 73, 13, + 14, 15, 74, 33, 65, 66, 67, 68, 213, 75, + 35, 55, 40, 57, 58, 59, 37, 60, 61, 62, + 63, 221, 64, 99, 47, 100, 101, 209, 185, 102, + 103, 65, 66, 2, 3, 238, 4, 73, -18, -18, + -18, 74, 125, 126, 127, 186, 187, 49, 90, 51, + 188, 189, -74, -74, 118, 119, 248, 121, 122, 123, + 124, 125, 126, 127, 73, 118, 119, 242, 74, 50, + 123, 124, 125, 126, 127, 90, 82, 87, 84, 5, + 250, 118, 119, 120, 121, 122, 123, 124, 125, 126, + 127, -123, 83, 88, 105, 106, 107, 108, 109, 110, + 111, 123, 124, 125, 126, 127, 89, 112, 113, 114, + 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, + 125, 126, 127, 104, 132, 146, 141, 64, 191, -123, + 198, 142, 105, 106, 107, 108, 109, 110, 111, 200, + 201, 206, 207, 208, 176, 112, 113, 114, 115, 116, + 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, + 127, 177, 178, 179, 180, 181, 182, 183, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 127, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 127, 210, 194, + 103, 218, 219, 220, 228, 241, 10, 233, 236, 195, + 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, + 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, + 234, 202, 239, 246, 11, 249, 36, 48, 196, 118, + 119, 120, 121, 122, 123, 124, 125, 126, 127, 224, + 153, 227, 197, 240, 91, 0, 0, 142, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 127, 0, 0, + 0, 0, 0, 0, 0, 0, 235, 118, 119, 120, + 121, 122, 123, 124, 125, 126, 127 +}; -static const yytype_int16 yycheck[] = { - 49, 69, 75, 49, 50, 73, 74, 75, 49, 50, 12, 11, 46, 64, 16, - 35, 20, 85, 11, 87, 88, 89, 90, 72, 30, 76, 99, 11, 76, 35, - 76, 17, 80, 101, 20, 76, 70, 73, 106, 107, 108, 109, 110, 111, 112, - 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - 80, 47, 48, 71, 132, 11, 12, 13, 14, 15, 8, 17, 18, 19, 20, - 75, 22, 38, 64, 76, 21, 22, 1, 80, 11, 31, 32, 33, 34, 58, - 59, 37, 11, 62, 63, 64, 65, 66, 67, 148, 149, 47, 48, 73, 11, - 51, 13, 14, 15, 11, 17, 18, 19, 20, 75, 22, 9, 36, 64, 5, - 6, 7, 68, 73, 31, 32, 33, 34, 201, 75, 74, 11, 10, 13, 14, - 15, 12, 17, 18, 19, 20, 209, 22, 75, 74, 77, 78, 4, 6, 49, - 50, 31, 32, 0, 1, 223, 3, 64, 5, 6, 7, 68, 65, 66, 67, - 23, 24, 73, 75, 17, 28, 29, 49, 50, 58, 59, 244, 61, 62, 63, - 64, 65, 66, 67, 64, 58, 59, 236, 68, 72, 63, 64, 65, 66, 67, - 75, 20, 78, 21, 46, 249, 58, 59, 60, 61, 62, 63, 64, 65, 66, - 67, 36, 22, 78, 39, 40, 41, 42, 43, 44, 45, 63, 64, 65, 66, - 67, 75, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 36, 75, 11, 76, 22, 6, 36, 11, 76, 39, 40, 41, - 42, 43, 44, 45, 76, 80, 75, 75, 75, 6, 52, 53, 54, 55, 56, - 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 23, 24, 25, 26, - 27, 28, 29, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 73, 79, 50, 17, 20, 20, 11, - 17, 3, 76, 75, 79, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, - 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 76, 79, 73, 76, 3, - 75, 31, 38, 76, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 211, - 105, 211, 139, 230, 69, -1, -1, 76, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, -1, -1, -1, -1, -1, -1, -1, -1, 76, 58, 59, 60, - 61, 62, 63, 64, 65, 66, 67}; +static const yytype_int16 yycheck[] = +{ + 49, 69, 75, 49, 50, 73, 74, 75, 49, 50, + 12, 11, 46, 64, 16, 35, 20, 85, 11, 87, + 88, 89, 90, 72, 30, 76, 99, 11, 76, 35, + 76, 17, 80, 101, 20, 76, 70, 73, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, + 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, + 80, 47, 48, 71, 132, 11, 12, 13, 14, 15, + 8, 17, 18, 19, 20, 75, 22, 38, 64, 76, + 21, 22, 1, 80, 11, 31, 32, 33, 34, 58, + 59, 37, 11, 62, 63, 64, 65, 66, 67, 148, + 149, 47, 48, 73, 11, 51, 13, 14, 15, 11, + 17, 18, 19, 20, 75, 22, 9, 36, 64, 5, + 6, 7, 68, 73, 31, 32, 33, 34, 201, 75, + 74, 11, 10, 13, 14, 15, 12, 17, 18, 19, + 20, 209, 22, 75, 74, 77, 78, 4, 6, 49, + 50, 31, 32, 0, 1, 223, 3, 64, 5, 6, + 7, 68, 65, 66, 67, 23, 24, 73, 75, 17, + 28, 29, 49, 50, 58, 59, 244, 61, 62, 63, + 64, 65, 66, 67, 64, 58, 59, 236, 68, 72, + 63, 64, 65, 66, 67, 75, 20, 78, 21, 46, + 249, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 36, 22, 78, 39, 40, 41, 42, 43, 44, + 45, 63, 64, 65, 66, 67, 75, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 67, 36, 75, 11, 76, 22, 6, 36, + 11, 76, 39, 40, 41, 42, 43, 44, 45, 76, + 80, 75, 75, 75, 6, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 23, 24, 25, 26, 27, 28, 29, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 73, 79, + 50, 17, 20, 20, 11, 17, 3, 76, 75, 79, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, + 76, 79, 73, 76, 3, 75, 31, 38, 76, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 67, 211, + 105, 211, 139, 230, 69, -1, -1, 76, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, -1, -1, + -1, -1, -1, -1, -1, -1, 76, 58, 59, 60, + 61, 62, 63, 64, 65, 66, 67 +}; -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = { - 0, 82, 0, 1, 3, 46, 83, 84, 90, 70, 83, 84, 20, 5, 6, - 7, 91, 11, 85, 73, 92, 11, 93, 71, 11, 8, 87, 73, 9, 88, - 11, 94, 95, 73, 86, 74, 95, 12, 96, 97, 10, 89, 17, 20, 47, - 48, 64, 74, 97, 73, 72, 17, 98, 99, 100, 11, 12, 13, 14, 15, - 17, 18, 19, 20, 22, 31, 32, 33, 34, 37, 47, 48, 51, 64, 68, - 75, 107, 110, 111, 112, 127, 128, 20, 22, 21, 30, 35, 78, 78, 75, - 75, 127, 128, 111, 128, 128, 111, 112, 128, 75, 77, 78, 49, 50, 36, - 39, 40, 41, 42, 43, 44, 45, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 101, 103, 105, 128, 75, 121, 128, - 128, 128, 128, 1, 36, 113, 76, 76, 108, 109, 112, 11, 128, 117, 116, - 38, 75, 123, 110, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 6, 23, 24, 25, - 26, 27, 28, 29, 102, 6, 23, 24, 28, 29, 104, 6, 106, 128, 79, - 79, 76, 123, 11, 118, 76, 80, 79, 111, 111, 124, 75, 75, 75, 4, - 73, 35, 80, 112, 12, 16, 125, 126, 17, 20, 20, 128, 115, 75, 107, - 119, 120, 121, 11, 76, 80, 64, 76, 76, 76, 76, 75, 122, 128, 73, - 126, 17, 111, 76, 80, 114, 76, 76, 128, 75, 111, 76}; + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 82, 0, 1, 3, 46, 83, 84, 90, 70, + 83, 84, 20, 5, 6, 7, 91, 11, 85, 73, + 92, 11, 93, 71, 11, 8, 87, 73, 9, 88, + 11, 94, 95, 73, 86, 74, 95, 12, 96, 97, + 10, 89, 17, 20, 47, 48, 64, 74, 97, 73, + 72, 17, 98, 99, 100, 11, 12, 13, 14, 15, + 17, 18, 19, 20, 22, 31, 32, 33, 34, 37, + 47, 48, 51, 64, 68, 75, 107, 110, 111, 112, + 127, 128, 20, 22, 21, 30, 35, 78, 78, 75, + 75, 127, 128, 111, 128, 128, 111, 112, 128, 75, + 77, 78, 49, 50, 36, 39, 40, 41, 42, 43, + 44, 45, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 101, 103, + 105, 128, 75, 121, 128, 128, 128, 128, 1, 36, + 113, 76, 76, 108, 109, 112, 11, 128, 117, 116, + 38, 75, 123, 110, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 6, 23, 24, 25, + 26, 27, 28, 29, 102, 6, 23, 24, 28, 29, + 104, 6, 106, 128, 79, 79, 76, 123, 11, 118, + 76, 80, 79, 111, 111, 124, 75, 75, 75, 4, + 73, 35, 80, 112, 12, 16, 125, 126, 17, 20, + 20, 128, 115, 75, 107, 119, 120, 121, 11, 76, + 80, 64, 76, 76, 76, 76, 75, 122, 128, 73, + 126, 17, 111, 76, 80, 114, 76, 76, 128, 75, + 111, 76 +}; -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = { - 0, 81, 82, 82, 82, 82, 82, 82, 82, 83, 85, 86, 84, 87, - 87, 88, 88, 89, 90, 90, 91, 91, 92, 92, 93, 93, 94, 94, - 95, 95, 95, 95, 95, 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, 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}; + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 81, 82, 82, 82, 82, 82, 82, 82, 83, + 85, 86, 84, 87, 87, 88, 88, 89, 90, 90, + 91, 91, 92, 92, 93, 93, 94, 94, 95, 95, + 95, 95, 95, 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, 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[] = { - 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, 3, 3, 3, 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}; + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 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, 3, + 3, 3, 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 +}; -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab -#define YYRECOVERING() (!!yyerrstatus) +#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) +#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 YYTERROR 1 +#define YYERRCODE 256 + /* Enable debugging if requested. */ #if YYDEBUG -#ifndef YYFPRINTF -#include /* INFRINGES ON USER NAME SPACE */ -#define YYFPRINTF fprintf -#endif +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif -#define YYDPRINTF(Args) \ - do \ - { \ - if (yydebug) \ - YYFPRINTF Args; \ - } while (0) +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) /* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT -#define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif -#define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ - do \ - { \ - if (yydebug) \ - { \ - YYFPRINTF(stderr, "%s ", Title); \ - yy_symbol_print(stderr, Type, Value, yyscanner, compiler); \ - YYFPRINTF(stderr, "\n"); \ - } \ - } while (0) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, yyscanner, compiler); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) /*----------------------------------------. | Print this symbol's value on YYOUTPUT. | `----------------------------------------*/ -static void yy_symbol_value_print( - FILE* yyoutput, - int yytype, - YYSTYPE const* const yyvaluep, - void* yyscanner, - YR_COMPILER* compiler) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *yyscanner, YR_COMPILER* compiler) { - FILE* yyo = yyoutput; - YYUSE(yyo); - YYUSE(yyscanner); - YYUSE(compiler); + FILE *yyo = yyoutput; + YYUSE (yyo); + YYUSE (yyscanner); + YYUSE (compiler); if (!yyvaluep) return; -#ifdef YYPRINT +# ifdef YYPRINT if (yytype < YYNTOKENS) - YYPRINT(yyoutput, yytoknum[yytype], *yyvaluep); -#endif - YYUSE(yytype); + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + YYUSE (yytype); } @@ -1086,21 +1098,14 @@ static void yy_symbol_value_print( | Print this symbol on YYOUTPUT. | `--------------------------------*/ -static void yy_symbol_print( - FILE* yyoutput, - int yytype, - YYSTYPE const* const yyvaluep, - void* yyscanner, - YR_COMPILER* compiler) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *yyscanner, YR_COMPILER* compiler) { - YYFPRINTF( - yyoutput, - "%s %s (", - yytype < YYNTOKENS ? "token" : "nterm", - yytname[yytype]); + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - yy_symbol_value_print(yyoutput, yytype, yyvaluep, yyscanner, compiler); - YYFPRINTF(yyoutput, ")"); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner, compiler); + YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. @@ -1108,76 +1113,69 @@ static void yy_symbol_print( | TOP (included). | `------------------------------------------------------------------*/ -static void yy_stack_print(yytype_int16* yybottom, yytype_int16* yytop) +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) { - YYFPRINTF(stderr, "Stack now"); + YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF(stderr, " %d", yybot); - } - YYFPRINTF(stderr, "\n"); + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); } -#define YY_STACK_PRINT(Bottom, Top) \ - do \ - { \ - if (yydebug) \ - yy_stack_print((Bottom), (Top)); \ - } while (0) +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -static void yy_reduce_print( - yytype_int16* yyssp, - YYSTYPE* yyvsp, - int yyrule, - void* yyscanner, - YR_COMPILER* compiler) +static void +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, void *yyscanner, YR_COMPILER* compiler) { unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - YYFPRINTF( - stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\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); - YYFPRINTF(stderr, "\n"); - } + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , yyscanner, compiler); + YYFPRINTF (stderr, "\n"); + } } -#define YY_REDUCE_PRINT(Rule) \ - do \ - { \ - if (yydebug) \ - yy_reduce_print(yyssp, yyvsp, Rule, yyscanner, compiler); \ - } while (0) +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule, yyscanner, compiler); \ +} while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ -#define YYDPRINTF(Args) -#define YY_SYMBOL_PRINT(Title, Type, Value, Location) -#define YY_STACK_PRINT(Bottom, Top) -#define YY_REDUCE_PRINT(Rule) +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH -#define YYINITDEPTH 200 +# define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only @@ -1188,45 +1186,49 @@ int yydebug; evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 +# define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE -#ifndef yystrlen -#if defined __GLIBC__ && defined _STRING_H -#define yystrlen strlen -#else +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else /* Return the length of YYSTR. */ -static YYSIZE_T yystrlen(const char* yystr) +static YYSIZE_T +yystrlen (const char *yystr) { YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) continue; + for (yylen = 0; yystr[yylen]; yylen++) + continue; return yylen; } -#endif -#endif +# endif +# endif -#ifndef yystpcpy -#if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -#define yystpcpy stpcpy -#else +# 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) +static char * +yystpcpy (char *yydest, const char *yysrc) { - char* yyd = yydest; - const char* yys = yysrc; + char *yyd = yydest; + const char *yys = yysrc; - while ((*yyd++ = *yys++) != '\0') continue; + while ((*yyd++ = *yys++) != '\0') + continue; return yyd - 1; } -#endif -#endif +# endif +# endif -#ifndef yytnamerr +# 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 @@ -1234,43 +1236,45 @@ static char* yystpcpy(char* yydest, const char* yysrc) 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) +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const* yyp = yystr; + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; - for (;;) switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; + 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 (*++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:; - } + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } - if (!yyres) - return yystrlen(yystr); + if (! yyres) + return yystrlen (yystr); - return yystpcpy(yyres, yystr) - yyres; + return yystpcpy (yyres, yystr) - yyres; } -#endif +# 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 @@ -1280,22 +1284,17 @@ static YYSIZE_T yytnamerr(char* yyres, const char* yystr) 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) +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 yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; - enum - { - YYERROR_VERBOSE_ARGS_MAXIMUM = 5 - }; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char* yyformat = YY_NULLPTR; + const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ - char const* yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per "expected"). */ int yycount = 0; @@ -1324,90 +1323,91 @@ static int yysyntax_error( 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])) + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (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; - } + /* 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_ - } + { +# 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)) + 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; - } + { + *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; + char *yyp = *yymsg; int yyi = 0; while ((*yyp = *yyformat) != '\0') if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr(yyp, yyarg[yyi++]); - yyformat += 2; - } + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } else - { - yyp++; - yyformat++; - } + { + yyp++; + yyformat++; + } } return 0; } @@ -1417,195 +1417,161 @@ static int yysyntax_error( | Release the memory associated to this symbol. | `-----------------------------------------------*/ -static void yydestruct( - const char* yymsg, - int yytype, - YYSTYPE* yyvaluep, - void* yyscanner, - YR_COMPILER* compiler) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *yyscanner, YR_COMPILER* compiler) { - YYUSE(yyvaluep); - YYUSE(yyscanner); - YYUSE(compiler); + YYUSE (yyvaluep); + YYUSE (yyscanner); + YYUSE (compiler); if (!yymsg) yymsg = "Deleting"; - YY_SYMBOL_PRINT(yymsg, yytype, yyvaluep, yylocationp); + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN switch (yytype) - { - case 11: /* "identifier" */ + { + case 11: /* "identifier" */ #line 272 "grammar.y" /* yacc.c:1258 */ - { - yr_free(((*yyvaluep).c_string)); - ((*yyvaluep).c_string) = NULL; - } + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } #line 1437 "grammar.c" /* yacc.c:1258 */ - break; + break; - case 12: /* "string identifier" */ + case 12: /* "string identifier" */ #line 276 "grammar.y" /* yacc.c:1258 */ - { - yr_free(((*yyvaluep).c_string)); - ((*yyvaluep).c_string) = NULL; - } + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } #line 1443 "grammar.c" /* yacc.c:1258 */ - break; + break; - case 13: /* "string count" */ + case 13: /* "string count" */ #line 273 "grammar.y" /* yacc.c:1258 */ - { - yr_free(((*yyvaluep).c_string)); - ((*yyvaluep).c_string) = NULL; - } + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } #line 1449 "grammar.c" /* yacc.c:1258 */ - break; + break; - case 14: /* "string offset" */ + case 14: /* "string offset" */ #line 274 "grammar.y" /* yacc.c:1258 */ - { - yr_free(((*yyvaluep).c_string)); - ((*yyvaluep).c_string) = NULL; - } + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } #line 1455 "grammar.c" /* yacc.c:1258 */ - break; + break; - case 15: /* "string length" */ + case 15: /* "string length" */ #line 275 "grammar.y" /* yacc.c:1258 */ - { - yr_free(((*yyvaluep).c_string)); - ((*yyvaluep).c_string) = NULL; - } + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } #line 1461 "grammar.c" /* yacc.c:1258 */ - break; + break; - case 16: /* "string identifier with wildcard" */ + case 16: /* "string identifier with wildcard" */ #line 277 "grammar.y" /* yacc.c:1258 */ - { - yr_free(((*yyvaluep).c_string)); - ((*yyvaluep).c_string) = NULL; - } + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } #line 1467 "grammar.c" /* yacc.c:1258 */ - break; + break; - case 20: /* "text string" */ + case 20: /* "text string" */ #line 278 "grammar.y" /* yacc.c:1258 */ - { - yr_free(((*yyvaluep).sized_string)); - ((*yyvaluep).sized_string) = NULL; - } + { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } #line 1473 "grammar.c" /* yacc.c:1258 */ - break; + break; - case 21: /* "hex string" */ + case 21: /* "hex string" */ #line 279 "grammar.y" /* yacc.c:1258 */ - { - yr_free(((*yyvaluep).sized_string)); - ((*yyvaluep).sized_string) = NULL; - } + { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } #line 1479 "grammar.c" /* yacc.c:1258 */ - break; + break; - case 22: /* "regular expression" */ + case 22: /* "regular expression" */ #line 280 "grammar.y" /* yacc.c:1258 */ - { - yr_free(((*yyvaluep).sized_string)); - ((*yyvaluep).sized_string) = NULL; - } + { yr_free(((*yyvaluep).sized_string)); ((*yyvaluep).sized_string) = NULL; } #line 1485 "grammar.c" /* yacc.c:1258 */ - break; + break; - case 101: /* string_modifiers */ + case 101: /* string_modifiers */ #line 293 "grammar.y" /* yacc.c:1258 */ + { + if (((*yyvaluep).modifier).alphabet != NULL) { - if (((*yyvaluep).modifier).alphabet != NULL) - { - yr_free(((*yyvaluep).modifier).alphabet); - ((*yyvaluep).modifier).alphabet = NULL; - } + yr_free(((*yyvaluep).modifier).alphabet); + ((*yyvaluep).modifier).alphabet = NULL; } +} #line 1497 "grammar.c" /* yacc.c:1258 */ - break; + break; - case 102: /* string_modifier */ + case 102: /* string_modifier */ #line 285 "grammar.y" /* yacc.c:1258 */ + { + if (((*yyvaluep).modifier).alphabet != NULL) { - if (((*yyvaluep).modifier).alphabet != NULL) - { - yr_free(((*yyvaluep).modifier).alphabet); - ((*yyvaluep).modifier).alphabet = NULL; - } + yr_free(((*yyvaluep).modifier).alphabet); + ((*yyvaluep).modifier).alphabet = NULL; } +} #line 1509 "grammar.c" /* yacc.c:1258 */ - break; + break; - case 108: /* arguments */ + case 108: /* arguments */ #line 282 "grammar.y" /* yacc.c:1258 */ - { - yr_free(((*yyvaluep).c_string)); - ((*yyvaluep).c_string) = NULL; - } + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } #line 1515 "grammar.c" /* yacc.c:1258 */ - break; + break; - case 109: /* arguments_list */ + case 109: /* arguments_list */ #line 283 "grammar.y" /* yacc.c:1258 */ - { - yr_free(((*yyvaluep).c_string)); - ((*yyvaluep).c_string) = NULL; - } + { yr_free(((*yyvaluep).c_string)); ((*yyvaluep).c_string) = NULL; } #line 1521 "grammar.c" /* yacc.c:1258 */ - break; + break; - default: - break; - } + default: + break; + } YY_IGNORE_MAYBE_UNINITIALIZED_END } + + /*----------. | yyparse. | `----------*/ -int yyparse(void* yyscanner, YR_COMPILER* compiler) +int +yyparse (void *yyscanner, YR_COMPILER* compiler) { - /* The lookahead symbol. */ - int yychar; +/* The lookahead symbol. */ +int yychar; - /* The semantic value of the lookahead symbol. */ - /* Default value used for initialization, for pacifying older GCCs - or non-GCC compilers. */ - YY_INITIAL_VALUE(static YYSTYPE yyval_default;) - YYSTYPE yylval YY_INITIAL_VALUE(= yyval_default); +/* The semantic value of the lookahead symbol. */ +/* Default value used for initialization, for pacifying older GCCs + or non-GCC compilers. */ +YY_INITIAL_VALUE (static YYSTYPE yyval_default;) +YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); - /* Number of syntax errors so far. */ - int yynerrs; + /* Number of syntax errors so far. */ + int yynerrs; - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; - /* The stacks and their tools: - 'yyss': related to states. - 'yyvs': related to semantic values. + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. - Refer to the stacks through separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16* yyss; - yytype_int16* yyssp; + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE* yyvs; - YYSTYPE* yyvsp; + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; - YYSIZE_T yystacksize; + YYSIZE_T yystacksize; int yyn; int yyresult; @@ -1618,11 +1584,11 @@ int yyparse(void* yyscanner, YR_COMPILER* compiler) #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; - char* yymsg = yymsgbuf; + char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ @@ -1632,7 +1598,7 @@ int yyparse(void* yyscanner, YR_COMPILER* compiler) yyvsp = yyvs = yyvsa; yystacksize = YYINITDEPTH; - YYDPRINTF((stderr, "Starting parse\n")); + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; @@ -1640,84 +1606,79 @@ int yyparse(void* yyscanner, YR_COMPILER* compiler) yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; - /*------------------------------------------------------------. - | yynewstate -- Push a new state, which is found in yystate. | - `------------------------------------------------------------*/ -yynewstate: +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + 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: + yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; #ifdef 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. */ - YYSTYPE* yyvs1 = yyvs; - yytype_int16* yyss1 = yyss; + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + 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), - &yystacksize); + /* 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), + &yystacksize); - yyss = yyss1; - yyvs = yyvs1; - } + yyss = yyss1; + yyvs = yyvs1; + } #else /* no yyoverflow */ -#ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -#else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) +# ifndef YYSTACK_RELOCATE goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yytype_int16* yyss1 = yyss; - union yyalloc* yyptr = (union yyalloc*) YYSTACK_ALLOC( - YYSTACK_BYTES(yystacksize)); - if (!yyptr) +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; - YYSTACK_RELOCATE(yyss_alloc, yyss); - YYSTACK_RELOCATE(yyvs_alloc, yyvs); -#undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE(yyss1); - } -#endif + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif #endif /* no yyoverflow */ - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; - YYDPRINTF( - (stderr, - "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } - YYDPRINTF((stderr, "Entering state %d\n", yystate)); + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; @@ -1734,28 +1695,28 @@ yybackup: /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yypact_value_is_default(yyn)) + if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) - { - YYDPRINTF((stderr, "Reading a token: ")); - yychar = yylex(&yylval, yyscanner, compiler); - } + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = yylex (&yylval, yyscanner, compiler); + } if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF((stderr, "Now at end of input.\n")); - } + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } else - { - yytoken = YYTRANSLATE(yychar); - YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc); - } + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ @@ -1764,12 +1725,12 @@ yybackup: goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) - { - if (yytable_value_is_error(yyn)) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } /* Count tokens shifted since error; after three, turn off error status. */ @@ -1777,7 +1738,7 @@ yybackup: yyerrstatus--; /* Shift the lookahead token. */ - YY_SYMBOL_PRINT("Shifting", yytoken, &yylval, &yylloc); + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token. */ yychar = YYEMPTY; @@ -1815,2774 +1776,2716 @@ yyreduce: users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1 - yylen]; + yyval = yyvsp[1-yylen]; - YY_REDUCE_PRINT(yyn); + YY_REDUCE_PRINT (yyn); switch (yyn) - { - case 8: + { + case 8: #line 327 "grammar.y" /* yacc.c:1663 */ - { - _yr_compiler_pop_file_name(compiler); - } + { + _yr_compiler_pop_file_name(compiler); + } #line 1791 "grammar.c" /* yacc.c:1663 */ - break; + break; case 9: #line 335 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_import(yyscanner, (yyvsp[0].sized_string)); + { + int result = yr_parser_reduce_import(yyscanner, (yyvsp[0].sized_string)); - yr_free((yyvsp[0].sized_string)); + yr_free((yyvsp[0].sized_string)); - fail_if_error(result); - } + fail_if_error(result); + } #line 1803 "grammar.c" /* yacc.c:1663 */ - break; + break; case 10: #line 347 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_reduce_rule_declaration_phase_1( - yyscanner, - (int32_t)(yyvsp[-2].integer), - (yyvsp[0].c_string), - &(yyval.rule))); - } + { + fail_if_error(yr_parser_reduce_rule_declaration_phase_1( + yyscanner, (int32_t) (yyvsp[-2].integer), (yyvsp[0].c_string), &(yyval.rule))); + } #line 1812 "grammar.c" /* yacc.c:1663 */ - break; + break; case 11: #line 352 "grammar.y" /* yacc.c:1663 */ - { - YR_RULE* rule = (YR_RULE*) yr_arena_ref_to_ptr( - compiler->arena, &(yyvsp[-4].rule)); + { + YR_RULE* rule = (YR_RULE*) yr_arena_ref_to_ptr( + compiler->arena, &(yyvsp[-4].rule)); - rule->tags = (char*) yr_arena_ref_to_ptr(compiler->arena, &(yyvsp[-3].tag)); + rule->tags = (char*) yr_arena_ref_to_ptr( + compiler->arena, &(yyvsp[-3].tag)); - rule->metas = (YR_META*) yr_arena_ref_to_ptr( - compiler->arena, &(yyvsp[-1].meta)); + rule->metas = (YR_META*) yr_arena_ref_to_ptr( + compiler->arena, &(yyvsp[-1].meta)); - rule->strings = (YR_STRING*) yr_arena_ref_to_ptr( - compiler->arena, &(yyvsp[0].string)); - } + rule->strings = (YR_STRING*) yr_arena_ref_to_ptr( + compiler->arena, &(yyvsp[0].string)); + } #line 1830 "grammar.c" /* yacc.c:1663 */ - break; + break; case 12: #line 366 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_rule_declaration_phase_2( - yyscanner, &(yyvsp[-7].rule)); // rule created in phase 1 + { + int result = yr_parser_reduce_rule_declaration_phase_2( + yyscanner, &(yyvsp[-7].rule)); // rule created in phase 1 - yr_free((yyvsp[-8].c_string)); + yr_free((yyvsp[-8].c_string)); - fail_if_error(result); - } + fail_if_error(result); + } #line 1843 "grammar.c" /* yacc.c:1663 */ - break; + break; case 13: #line 379 "grammar.y" /* yacc.c:1663 */ - { - (yyval.meta) = YR_ARENA_NULL_REF; - } + { + (yyval.meta) = YR_ARENA_NULL_REF; + } #line 1851 "grammar.c" /* yacc.c:1663 */ - break; + break; case 14: #line 383 "grammar.y" /* yacc.c:1663 */ - { - YR_META* meta = yr_arena_get_ptr( - compiler->arena, - YR_METAS_TABLE, - (compiler->current_meta_idx - 1) * sizeof(YR_META)); + { + YR_META* meta = yr_arena_get_ptr( + compiler->arena, + YR_METAS_TABLE, + (compiler->current_meta_idx - 1) * sizeof(YR_META)); - meta->flags |= META_FLAGS_LAST_IN_RULE; + meta->flags |= META_FLAGS_LAST_IN_RULE; - (yyval.meta) = (yyvsp[0].meta); - } + (yyval.meta) = (yyvsp[0].meta); + } #line 1866 "grammar.c" /* yacc.c:1663 */ - break; + break; case 15: #line 398 "grammar.y" /* yacc.c:1663 */ - { - (yyval.string) = YR_ARENA_NULL_REF; - } + { + (yyval.string) = YR_ARENA_NULL_REF; + } #line 1874 "grammar.c" /* yacc.c:1663 */ - break; + break; case 16: #line 402 "grammar.y" /* yacc.c:1663 */ - { - YR_STRING* string = (YR_STRING*) yr_arena_get_ptr( - compiler->arena, - YR_STRINGS_TABLE, - (compiler->current_string_idx - 1) * sizeof(YR_STRING)); + { + YR_STRING* string = (YR_STRING*) yr_arena_get_ptr( + compiler->arena, + YR_STRINGS_TABLE, + (compiler->current_string_idx - 1) * sizeof(YR_STRING)); - string->flags |= STRING_FLAGS_LAST_IN_RULE; + string->flags |= STRING_FLAGS_LAST_IN_RULE; - (yyval.string) = (yyvsp[0].string); - } + (yyval.string) = (yyvsp[0].string); + } #line 1889 "grammar.c" /* yacc.c:1663 */ - break; + break; case 18: #line 421 "grammar.y" /* yacc.c:1663 */ - { - (yyval.integer) = 0; - } + { (yyval.integer) = 0; } #line 1895 "grammar.c" /* yacc.c:1663 */ - break; + break; case 19: #line 422 "grammar.y" /* yacc.c:1663 */ - { - (yyval.integer) = (yyvsp[-1].integer) | (yyvsp[0].integer); - } + { (yyval.integer) = (yyvsp[-1].integer) | (yyvsp[0].integer); } #line 1901 "grammar.c" /* yacc.c:1663 */ - break; + break; case 20: #line 427 "grammar.y" /* yacc.c:1663 */ - { - (yyval.integer) = RULE_FLAGS_PRIVATE; - } + { (yyval.integer) = RULE_FLAGS_PRIVATE; } #line 1907 "grammar.c" /* yacc.c:1663 */ - break; + break; case 21: #line 428 "grammar.y" /* yacc.c:1663 */ - { - (yyval.integer) = RULE_FLAGS_GLOBAL; - } + { (yyval.integer) = RULE_FLAGS_GLOBAL; } #line 1913 "grammar.c" /* yacc.c:1663 */ - break; + break; case 22: #line 434 "grammar.y" /* yacc.c:1663 */ - { - (yyval.tag) = YR_ARENA_NULL_REF; - } + { + (yyval.tag) = YR_ARENA_NULL_REF; + } #line 1921 "grammar.c" /* yacc.c:1663 */ - break; + break; case 23: #line 438 "grammar.y" /* yacc.c:1663 */ - { - // 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 - // character. Example: tag1\0tag2\0tag3\0\0 + { + // 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 + //character. Example: tag1\0tag2\0tag3\0\0 - fail_if_error(yr_arena_write_string( - yyget_extra(yyscanner)->arena, YR_SZ_POOL, "", NULL)); + fail_if_error(yr_arena_write_string( + yyget_extra(yyscanner)->arena, YR_SZ_POOL, "", NULL)); - (yyval.tag) = (yyvsp[0].tag); - } + (yyval.tag) = (yyvsp[0].tag); + } #line 1937 "grammar.c" /* yacc.c:1663 */ - break; + break; case 24: #line 454 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_arena_write_string( - yyget_extra(yyscanner)->arena, - YR_SZ_POOL, - (yyvsp[0].c_string), - &(yyval.tag)); + { + int result = yr_arena_write_string( + yyget_extra(yyscanner)->arena, YR_SZ_POOL, (yyvsp[0].c_string), &(yyval.tag)); - yr_free((yyvsp[0].c_string)); + yr_free((yyvsp[0].c_string)); - fail_if_error(result); - } + fail_if_error(result); + } #line 1950 "grammar.c" /* yacc.c:1663 */ - break; + break; case 25: #line 463 "grammar.y" /* yacc.c:1663 */ - { - YR_ARENA_REF ref; - - // Write the new tag identifier. - int result = yr_arena_write_string( - yyget_extra(yyscanner)->arena, YR_SZ_POOL, (yyvsp[0].c_string), &ref); - - yr_free((yyvsp[0].c_string)); - - fail_if_error(result); - - // Get the address for the tag identifier just written. - char* new_tag = (char*) yr_arena_ref_to_ptr(compiler->arena, &ref); - - // Take the address of first tag's identifier in the list. - char* tag = (char*) yr_arena_ref_to_ptr(compiler->arena, &(yyval.tag)); - - // Search for duplicated tags. Tags are written one after - // the other, with zeroes in between (i.e: tag1/0tag2/0tag3) - // that's why can use tag < new_tag as the condition for the - // loop. - while (tag < new_tag) { - if (strcmp(tag, new_tag) == 0) - { - yr_compiler_set_error_extra_info(compiler, tag); - fail_with_error(ERROR_DUPLICATED_TAG_IDENTIFIER); + YR_ARENA_REF ref; + + // Write the new tag identifier. + int result = yr_arena_write_string( + yyget_extra(yyscanner)->arena, YR_SZ_POOL, (yyvsp[0].c_string), &ref); + + yr_free((yyvsp[0].c_string)); + + fail_if_error(result); + + // Get the address for the tag identifier just written. + char* new_tag = (char*) yr_arena_ref_to_ptr( + compiler->arena, &ref); + + // Take the address of first tag's identifier in the list. + char* tag = (char*) yr_arena_ref_to_ptr( + compiler->arena, &(yyval.tag)); + + // Search for duplicated tags. Tags are written one after + // the other, with zeroes in between (i.e: tag1/0tag2/0tag3) + // that's why can use tag < new_tag as the condition for the + // loop. + while (tag < new_tag) + { + if (strcmp(tag, new_tag) == 0) + { + yr_compiler_set_error_extra_info(compiler, tag); + fail_with_error(ERROR_DUPLICATED_TAG_IDENTIFIER); + } + + tag += strlen(tag) + 1; + } + + (yyval.tag) = (yyvsp[-1].tag); } - - tag += strlen(tag) + 1; - } - - (yyval.tag) = (yyvsp[-1].tag); - } #line 1991 "grammar.c" /* yacc.c:1663 */ - break; + break; case 26: #line 504 "grammar.y" /* yacc.c:1663 */ - { - (yyval.meta) = (yyvsp[0].meta); - } + { (yyval.meta) = (yyvsp[0].meta); } #line 1997 "grammar.c" /* yacc.c:1663 */ - break; + break; case 27: #line 505 "grammar.y" /* yacc.c:1663 */ - { - (yyval.meta) = (yyvsp[-1].meta); - } + { (yyval.meta) = (yyvsp[-1].meta); } #line 2003 "grammar.c" /* yacc.c:1663 */ - break; + break; case 28: #line 511 "grammar.y" /* yacc.c:1663 */ - { - SIZED_STRING* sized_string = (yyvsp[0].sized_string); + { + SIZED_STRING* sized_string = (yyvsp[0].sized_string); - int result = yr_parser_reduce_meta_declaration( - yyscanner, - META_TYPE_STRING, - (yyvsp[-2].c_string), - sized_string->c_string, - 0, - &(yyval.meta)); + int result = yr_parser_reduce_meta_declaration( + yyscanner, + META_TYPE_STRING, + (yyvsp[-2].c_string), + sized_string->c_string, + 0, + &(yyval.meta)); - yr_free((yyvsp[-2].c_string)); - yr_free((yyvsp[0].sized_string)); + yr_free((yyvsp[-2].c_string)); + yr_free((yyvsp[0].sized_string)); - fail_if_error(result); - } + fail_if_error(result); + } #line 2024 "grammar.c" /* yacc.c:1663 */ - break; + break; case 29: #line 528 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_meta_declaration( - yyscanner, - META_TYPE_INTEGER, - (yyvsp[-2].c_string), - NULL, - (yyvsp[0].integer), - &(yyval.meta)); + { + int result = yr_parser_reduce_meta_declaration( + yyscanner, + META_TYPE_INTEGER, + (yyvsp[-2].c_string), + NULL, + (yyvsp[0].integer), + &(yyval.meta)); - yr_free((yyvsp[-2].c_string)); + yr_free((yyvsp[-2].c_string)); - fail_if_error(result); - } + fail_if_error(result); + } #line 2042 "grammar.c" /* yacc.c:1663 */ - break; + break; case 30: #line 542 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_meta_declaration( - yyscanner, - META_TYPE_INTEGER, - (yyvsp[-3].c_string), - NULL, - -(yyvsp[0].integer), - &(yyval.meta)); + { + int result = yr_parser_reduce_meta_declaration( + yyscanner, + META_TYPE_INTEGER, + (yyvsp[-3].c_string), + NULL, + -(yyvsp[0].integer), + &(yyval.meta)); - yr_free((yyvsp[-3].c_string)); + yr_free((yyvsp[-3].c_string)); - fail_if_error(result); - } + fail_if_error(result); + } #line 2060 "grammar.c" /* yacc.c:1663 */ - break; + break; case 31: #line 556 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_meta_declaration( - yyscanner, - META_TYPE_BOOLEAN, - (yyvsp[-2].c_string), - NULL, - true, - &(yyval.meta)); + { + int result = yr_parser_reduce_meta_declaration( + yyscanner, + META_TYPE_BOOLEAN, + (yyvsp[-2].c_string), + NULL, + true, + &(yyval.meta)); - yr_free((yyvsp[-2].c_string)); + yr_free((yyvsp[-2].c_string)); - fail_if_error(result); - } + fail_if_error(result); + } #line 2078 "grammar.c" /* yacc.c:1663 */ - break; + break; case 32: #line 570 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_meta_declaration( - yyscanner, - META_TYPE_BOOLEAN, - (yyvsp[-2].c_string), - NULL, - false, - &(yyval.meta)); + { + int result = yr_parser_reduce_meta_declaration( + yyscanner, + META_TYPE_BOOLEAN, + (yyvsp[-2].c_string), + NULL, + false, + &(yyval.meta)); - yr_free((yyvsp[-2].c_string)); + yr_free((yyvsp[-2].c_string)); - fail_if_error(result); - } + fail_if_error(result); + } #line 2096 "grammar.c" /* yacc.c:1663 */ - break; + break; case 33: #line 587 "grammar.y" /* yacc.c:1663 */ - { - (yyval.string) = (yyvsp[0].string); - } + { (yyval.string) = (yyvsp[0].string); } #line 2102 "grammar.c" /* yacc.c:1663 */ - break; + break; case 34: #line 588 "grammar.y" /* yacc.c:1663 */ - { - (yyval.string) = (yyvsp[-1].string); - } + { (yyval.string) = (yyvsp[-1].string); } #line 2108 "grammar.c" /* yacc.c:1663 */ - break; + break; case 35: #line 594 "grammar.y" /* yacc.c:1663 */ - { - compiler->current_line = yyget_lineno(yyscanner); - } + { + compiler->current_line = yyget_lineno(yyscanner); + } #line 2116 "grammar.c" /* yacc.c:1663 */ - break; + break; case 36: #line 598 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_string_declaration( - yyscanner, - (yyvsp[0].modifier), - (yyvsp[-4].c_string), - (yyvsp[-1].sized_string), - &(yyval.string)); + { + int result = yr_parser_reduce_string_declaration( + yyscanner, (yyvsp[0].modifier), (yyvsp[-4].c_string), (yyvsp[-1].sized_string), &(yyval.string)); - yr_free((yyvsp[-4].c_string)); - yr_free((yyvsp[-1].sized_string)); - yr_free((yyvsp[0].modifier).alphabet); + yr_free((yyvsp[-4].c_string)); + yr_free((yyvsp[-1].sized_string)); + yr_free((yyvsp[0].modifier).alphabet); - fail_if_error(result); - compiler->current_line = 0; - } + fail_if_error(result); + compiler->current_line = 0; + } #line 2132 "grammar.c" /* yacc.c:1663 */ - break; + break; case 37: #line 610 "grammar.y" /* yacc.c:1663 */ - { - compiler->current_line = yyget_lineno(yyscanner); - } + { + compiler->current_line = yyget_lineno(yyscanner); + } #line 2140 "grammar.c" /* yacc.c:1663 */ - break; + break; case 38: #line 614 "grammar.y" /* yacc.c:1663 */ - { - int result; + { + int result; - (yyvsp[0].modifier).flags |= STRING_FLAGS_REGEXP; + (yyvsp[0].modifier).flags |= STRING_FLAGS_REGEXP; - result = yr_parser_reduce_string_declaration( - yyscanner, - (yyvsp[0].modifier), - (yyvsp[-4].c_string), - (yyvsp[-1].sized_string), - &(yyval.string)); + result = yr_parser_reduce_string_declaration( + yyscanner, (yyvsp[0].modifier), (yyvsp[-4].c_string), (yyvsp[-1].sized_string), &(yyval.string)); - yr_free((yyvsp[-4].c_string)); - yr_free((yyvsp[-1].sized_string)); + yr_free((yyvsp[-4].c_string)); + yr_free((yyvsp[-1].sized_string)); - fail_if_error(result); + fail_if_error(result); - compiler->current_line = 0; - } + compiler->current_line = 0; + } #line 2160 "grammar.c" /* yacc.c:1663 */ - break; + break; case 39: #line 630 "grammar.y" /* yacc.c:1663 */ - { - compiler->current_line = yyget_lineno(yyscanner); - } + { + compiler->current_line = yyget_lineno(yyscanner); + } #line 2168 "grammar.c" /* yacc.c:1663 */ - break; + break; case 40: #line 634 "grammar.y" /* yacc.c:1663 */ - { - int result; + { + int result; - (yyvsp[0].modifier).flags |= STRING_FLAGS_HEXADECIMAL; + (yyvsp[0].modifier).flags |= STRING_FLAGS_HEXADECIMAL; - result = yr_parser_reduce_string_declaration( - yyscanner, - (yyvsp[0].modifier), - (yyvsp[-4].c_string), - (yyvsp[-1].sized_string), - &(yyval.string)); + result = yr_parser_reduce_string_declaration( + yyscanner, (yyvsp[0].modifier), (yyvsp[-4].c_string), (yyvsp[-1].sized_string), &(yyval.string)); - yr_free((yyvsp[-4].c_string)); - yr_free((yyvsp[-1].sized_string)); + yr_free((yyvsp[-4].c_string)); + yr_free((yyvsp[-1].sized_string)); - fail_if_error(result); + fail_if_error(result); - compiler->current_line = 0; - } + compiler->current_line = 0; + } #line 2188 "grammar.c" /* yacc.c:1663 */ - break; + break; case 41: #line 654 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = 0; - (yyval.modifier).xor_min = 0; - (yyval.modifier).xor_max = 0; - (yyval.modifier).alphabet = NULL; - } + { + (yyval.modifier).flags = 0; + (yyval.modifier).xor_min = 0; + (yyval.modifier).xor_max = 0; + (yyval.modifier).alphabet = NULL; + } #line 2199 "grammar.c" /* yacc.c:1663 */ - break; + break; case 42: #line 661 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier) = (yyvsp[-1].modifier); - - // Only set the xor minimum and maximum if we are dealing with the - // xor modifier. If we don't check for this then we can end up with - // "xor wide" resulting in whatever is on the stack for "wide" - // overwriting the values for xor. - if ((yyvsp[0].modifier).flags & STRING_FLAGS_XOR) { - (yyval.modifier).xor_min = (yyvsp[0].modifier).xor_min; - (yyval.modifier).xor_max = (yyvsp[0].modifier).xor_max; - } + (yyval.modifier) = (yyvsp[-1].modifier); - // Only set the base64 alphabet if we are dealing with the base64 - // modifier. If we don't check for this then we can end up with - // "base64 ascii" resulting in whatever is on the stack for "ascii" - // overwriting the values for base64. - if (((yyvsp[0].modifier).flags & STRING_FLAGS_BASE64) || - ((yyvsp[0].modifier).flags & STRING_FLAGS_BASE64_WIDE)) - { - if ((yyval.modifier).alphabet != NULL) - { - if (ss_compare( - (yyval.modifier).alphabet, (yyvsp[0].modifier).alphabet) != 0) + // Only set the xor minimum and maximum if we are dealing with the + // xor modifier. If we don't check for this then we can end up with + // "xor wide" resulting in whatever is on the stack for "wide" + // overwriting the values for xor. + if ((yyvsp[0].modifier).flags & STRING_FLAGS_XOR) { - yr_compiler_set_error_extra_info( - compiler, "can not specify multiple alphabets"); + (yyval.modifier).xor_min = (yyvsp[0].modifier).xor_min; + (yyval.modifier).xor_max = (yyvsp[0].modifier).xor_max; + } - yr_free((yyvsp[0].modifier).alphabet); - yr_free((yyval.modifier).alphabet); + // Only set the base64 alphabet if we are dealing with the base64 + // modifier. If we don't check for this then we can end up with + // "base64 ascii" resulting in whatever is on the stack for "ascii" + // overwriting the values for base64. + if (((yyvsp[0].modifier).flags & STRING_FLAGS_BASE64) || + ((yyvsp[0].modifier).flags & STRING_FLAGS_BASE64_WIDE)) + { + if ((yyval.modifier).alphabet != NULL) + { + if (ss_compare((yyval.modifier).alphabet, (yyvsp[0].modifier).alphabet) != 0) + { + yr_compiler_set_error_extra_info( + compiler, "can not specify multiple alphabets"); - fail_with_error(ERROR_INVALID_MODIFIER); + yr_free((yyvsp[0].modifier).alphabet); + yr_free((yyval.modifier).alphabet); + + fail_with_error(ERROR_INVALID_MODIFIER); + } + else + { + yr_free((yyvsp[0].modifier).alphabet); + } + } + else + { + (yyval.modifier).alphabet = (yyvsp[0].modifier).alphabet; + } + } + + if ((yyval.modifier).flags & (yyvsp[0].modifier).flags) + { + if ((yyval.modifier).alphabet != NULL) + yr_free((yyval.modifier).alphabet); + + fail_with_error(ERROR_DUPLICATED_MODIFIER); } else { - yr_free((yyvsp[0].modifier).alphabet); + (yyval.modifier).flags = (yyval.modifier).flags | (yyvsp[0].modifier).flags; } } - else - { - (yyval.modifier).alphabet = (yyvsp[0].modifier).alphabet; - } - } - - if ((yyval.modifier).flags & (yyvsp[0].modifier).flags) - { - if ((yyval.modifier).alphabet != NULL) - yr_free((yyval.modifier).alphabet); - - fail_with_error(ERROR_DUPLICATED_MODIFIER); - } - else - { - (yyval.modifier).flags = (yyval.modifier).flags | - (yyvsp[0].modifier).flags; - } - } #line 2259 "grammar.c" /* yacc.c:1663 */ - break; + break; case 43: #line 720 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = STRING_FLAGS_WIDE; - } + { (yyval.modifier).flags = STRING_FLAGS_WIDE; } #line 2265 "grammar.c" /* yacc.c:1663 */ - break; + break; case 44: #line 721 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = STRING_FLAGS_ASCII; - } + { (yyval.modifier).flags = STRING_FLAGS_ASCII; } #line 2271 "grammar.c" /* yacc.c:1663 */ - break; + break; case 45: #line 722 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = STRING_FLAGS_NO_CASE; - } + { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } #line 2277 "grammar.c" /* yacc.c:1663 */ - break; + break; case 46: #line 723 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; - } + { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } #line 2283 "grammar.c" /* yacc.c:1663 */ - break; + break; case 47: #line 724 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = STRING_FLAGS_PRIVATE; - } + { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } #line 2289 "grammar.c" /* yacc.c:1663 */ - break; + break; case 48: #line 726 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = STRING_FLAGS_XOR; - (yyval.modifier).xor_min = 0; - (yyval.modifier).xor_max = 255; - } + { + (yyval.modifier).flags = STRING_FLAGS_XOR; + (yyval.modifier).xor_min = 0; + (yyval.modifier).xor_max = 255; + } #line 2299 "grammar.c" /* yacc.c:1663 */ - break; + break; case 49: #line 732 "grammar.y" /* yacc.c:1663 */ - { - int result = ERROR_SUCCESS; - - if ((yyvsp[-1].integer) < 0 || (yyvsp[-1].integer) > 255) { - yr_compiler_set_error_extra_info(compiler, "invalid xor range"); - result = ERROR_INVALID_MODIFIER; - } + int result = ERROR_SUCCESS; - fail_if_error(result); + if ((yyvsp[-1].integer) < 0 || (yyvsp[-1].integer) > 255) + { + yr_compiler_set_error_extra_info(compiler, "invalid xor range"); + result = ERROR_INVALID_MODIFIER; + } - (yyval.modifier).flags = STRING_FLAGS_XOR; - (yyval.modifier).xor_min = (yyvsp[-1].integer); - (yyval.modifier).xor_max = (yyvsp[-1].integer); - } + fail_if_error(result); + + (yyval.modifier).flags = STRING_FLAGS_XOR; + (yyval.modifier).xor_min = (yyvsp[-1].integer); + (yyval.modifier).xor_max = (yyvsp[-1].integer); + } #line 2319 "grammar.c" /* yacc.c:1663 */ - break; + break; case 50: #line 753 "grammar.y" /* yacc.c:1663 */ - { - int result = ERROR_SUCCESS; - - if ((yyvsp[-3].integer) < 0) { - yr_compiler_set_error_extra_info( - compiler, "lower bound for xor range exceeded (min: 0)"); - result = ERROR_INVALID_MODIFIER; - } + int result = ERROR_SUCCESS; - if ((yyvsp[-1].integer) > 255) - { - yr_compiler_set_error_extra_info( - compiler, "upper bound for xor range exceeded (max: 255)"); - result = ERROR_INVALID_MODIFIER; - } + if ((yyvsp[-3].integer) < 0) + { + yr_compiler_set_error_extra_info( + compiler, "lower bound for xor range exceeded (min: 0)"); + result = ERROR_INVALID_MODIFIER; + } - if ((yyvsp[-3].integer) > (yyvsp[-1].integer)) - { - yr_compiler_set_error_extra_info( - compiler, "xor lower bound exceeds upper bound"); - result = ERROR_INVALID_MODIFIER; - } + if ((yyvsp[-1].integer) > 255) + { + yr_compiler_set_error_extra_info( + compiler, "upper bound for xor range exceeded (max: 255)"); + result = ERROR_INVALID_MODIFIER; + } - fail_if_error(result); + if ((yyvsp[-3].integer) > (yyvsp[-1].integer)) + { + yr_compiler_set_error_extra_info( + compiler, "xor lower bound exceeds upper bound"); + result = ERROR_INVALID_MODIFIER; + } - (yyval.modifier).flags = STRING_FLAGS_XOR; - (yyval.modifier).xor_min = (yyvsp[-3].integer); - (yyval.modifier).xor_max = (yyvsp[-1].integer); - } + fail_if_error(result); + + (yyval.modifier).flags = STRING_FLAGS_XOR; + (yyval.modifier).xor_min = (yyvsp[-3].integer); + (yyval.modifier).xor_max = (yyvsp[-1].integer); + } #line 2354 "grammar.c" /* yacc.c:1663 */ - break; + break; case 51: #line 784 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = STRING_FLAGS_BASE64; - (yyval.modifier).alphabet = ss_new(DEFAULT_BASE64_ALPHABET); - } + { + (yyval.modifier).flags = STRING_FLAGS_BASE64; + (yyval.modifier).alphabet = ss_new(DEFAULT_BASE64_ALPHABET); + } #line 2363 "grammar.c" /* yacc.c:1663 */ - break; + break; case 52: #line 789 "grammar.y" /* yacc.c:1663 */ - { - int result = ERROR_SUCCESS; - - if ((yyvsp[-1].sized_string)->length != 64) { - yr_free((yyvsp[-1].sized_string)); - result = yr_compiler_set_error_extra_info( - compiler, "length of base64 alphabet must be 64"); - result = ERROR_INVALID_MODIFIER; - } + int result = ERROR_SUCCESS; - fail_if_error(result); + if ((yyvsp[-1].sized_string)->length != 64) + { + yr_free((yyvsp[-1].sized_string)); + result = yr_compiler_set_error_extra_info( + compiler, "length of base64 alphabet must be 64"); + result = ERROR_INVALID_MODIFIER; + } - (yyval.modifier).flags = STRING_FLAGS_BASE64; - (yyval.modifier).alphabet = (yyvsp[-1].sized_string); - } + fail_if_error(result); + + (yyval.modifier).flags = STRING_FLAGS_BASE64; + (yyval.modifier).alphabet = (yyvsp[-1].sized_string); + } #line 2384 "grammar.c" /* yacc.c:1663 */ - break; + break; case 53: #line 806 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; - (yyval.modifier).alphabet = ss_new(DEFAULT_BASE64_ALPHABET); - } + { + (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; + (yyval.modifier).alphabet = ss_new(DEFAULT_BASE64_ALPHABET); + } #line 2393 "grammar.c" /* yacc.c:1663 */ - break; + break; case 54: #line 811 "grammar.y" /* yacc.c:1663 */ - { - int result = ERROR_SUCCESS; - - if ((yyvsp[-1].sized_string)->length != 64) { - yr_free((yyvsp[-1].sized_string)); - result = yr_compiler_set_error_extra_info( - compiler, "length of base64 alphabet must be 64"); - result = ERROR_INVALID_MODIFIER; - } + int result = ERROR_SUCCESS; - fail_if_error(result); + if ((yyvsp[-1].sized_string)->length != 64) + { + yr_free((yyvsp[-1].sized_string)); + result = yr_compiler_set_error_extra_info( + compiler, "length of base64 alphabet must be 64"); + result = ERROR_INVALID_MODIFIER; + } - (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; - (yyval.modifier).alphabet = (yyvsp[-1].sized_string); - } + fail_if_error(result); + + (yyval.modifier).flags = STRING_FLAGS_BASE64_WIDE; + (yyval.modifier).alphabet = (yyvsp[-1].sized_string); + } #line 2414 "grammar.c" /* yacc.c:1663 */ - break; + break; case 55: #line 830 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = 0; - } + { (yyval.modifier).flags = 0; } #line 2420 "grammar.c" /* yacc.c:1663 */ - break; + break; case 56: #line 832 "grammar.y" /* yacc.c:1663 */ - { - if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) { - fail_with_error(ERROR_DUPLICATED_MODIFIER); - } - else - { - (yyval.modifier).flags = (yyvsp[-1].modifier).flags | - (yyvsp[0].modifier).flags; - } - } + if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) + { + fail_with_error(ERROR_DUPLICATED_MODIFIER); + } + else + { + (yyval.modifier).flags = (yyvsp[-1].modifier).flags | (yyvsp[0].modifier).flags; + } + } #line 2435 "grammar.c" /* yacc.c:1663 */ - break; + break; case 57: #line 845 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = STRING_FLAGS_WIDE; - } + { (yyval.modifier).flags = STRING_FLAGS_WIDE; } #line 2441 "grammar.c" /* yacc.c:1663 */ - break; + break; case 58: #line 846 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = STRING_FLAGS_ASCII; - } + { (yyval.modifier).flags = STRING_FLAGS_ASCII; } #line 2447 "grammar.c" /* yacc.c:1663 */ - break; + break; case 59: #line 847 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = STRING_FLAGS_NO_CASE; - } + { (yyval.modifier).flags = STRING_FLAGS_NO_CASE; } #line 2453 "grammar.c" /* yacc.c:1663 */ - break; + break; case 60: #line 848 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; - } + { (yyval.modifier).flags = STRING_FLAGS_FULL_WORD; } #line 2459 "grammar.c" /* yacc.c:1663 */ - break; + break; case 61: #line 849 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = STRING_FLAGS_PRIVATE; - } + { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } #line 2465 "grammar.c" /* yacc.c:1663 */ - break; + break; case 62: #line 853 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = 0; - } + { (yyval.modifier).flags = 0; } #line 2471 "grammar.c" /* yacc.c:1663 */ - break; + break; case 63: #line 855 "grammar.y" /* yacc.c:1663 */ - { - if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) { - fail_with_error(ERROR_DUPLICATED_MODIFIER); - } - else - { - (yyval.modifier).flags = (yyvsp[-1].modifier).flags | - (yyvsp[0].modifier).flags; - } - } + if ((yyvsp[-1].modifier).flags & (yyvsp[0].modifier).flags) + { + fail_with_error(ERROR_DUPLICATED_MODIFIER); + } + else + { + (yyval.modifier).flags = (yyvsp[-1].modifier).flags | (yyvsp[0].modifier).flags; + } + } #line 2486 "grammar.c" /* yacc.c:1663 */ - break; + break; case 64: #line 868 "grammar.y" /* yacc.c:1663 */ - { - (yyval.modifier).flags = STRING_FLAGS_PRIVATE; - } + { (yyval.modifier).flags = STRING_FLAGS_PRIVATE; } #line 2492 "grammar.c" /* yacc.c:1663 */ - break; + break; case 65: #line 873 "grammar.y" /* yacc.c:1663 */ - { - YR_EXPRESSION expr; - - int result = ERROR_SUCCESS; - int var_index = yr_parser_lookup_loop_variable( - yyscanner, (yyvsp[0].c_string), &expr); - - if (var_index >= 0) { - // The identifier corresponds to a loop variable. - result = yr_parser_emit_with_arg( - yyscanner, OP_PUSH_M, var_index, NULL, NULL); + YR_EXPRESSION expr; - // The expression associated to this identifier is the same one - // associated to the loop variable. - (yyval.expression) = expr; - } - else - { - // Search for identifier within the global namespace, where the - // externals variables reside. + int result = ERROR_SUCCESS; + int var_index = yr_parser_lookup_loop_variable(yyscanner, (yyvsp[0].c_string), &expr); - YR_OBJECT* 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, - YR_NAMESPACES_TABLE, - compiler->current_namespace_idx * sizeof(struct YR_NAMESPACE)); - - if (object == NULL) - { - // If not found, search within the current namespace. - object = (YR_OBJECT*) yr_hash_table_lookup( - compiler->objects_table, (yyvsp[0].c_string), ns->name); - } - - if (object != NULL) - { - YR_ARENA_REF ref; - - result = _yr_compiler_store_string(compiler, (yyvsp[0].c_string), &ref); - - if (result == ERROR_SUCCESS) - result = yr_parser_emit_with_arg_reloc( + if (var_index >= 0) + { + // The identifier corresponds to a loop variable. + result = yr_parser_emit_with_arg( yyscanner, - OP_OBJ_LOAD, - yr_arena_ref_to_ptr(compiler->arena, &ref), + OP_PUSH_M, + var_index, NULL, NULL); - (yyval.expression).type = EXPRESSION_TYPE_OBJECT; - (yyval.expression).value.object = object; - (yyval.expression).identifier.ptr = NULL; - (yyval.expression).identifier.ref = ref; - } - else - { - uint32_t rule_idx = yr_hash_table_lookup_uint32( - compiler->rules_table, (yyvsp[0].c_string), ns->name); - - if (rule_idx != UINT32_MAX) + // The expression associated to this identifier is the same one + // associated to the loop variable. + (yyval.expression) = expr; + } + else { - result = yr_parser_emit_with_arg( - yyscanner, OP_PUSH_RULE, rule_idx, NULL, NULL); + // Search for identifier within the global namespace, where the + // externals variables reside. - YR_RULE* rule = _yr_compiler_get_rule_by_idx(compiler, rule_idx); + YR_OBJECT* object = (YR_OBJECT*) yr_hash_table_lookup( + compiler->objects_table, (yyvsp[0].c_string), NULL); - yr_arena_ptr_to_ref( + YR_NAMESPACE* ns = (YR_NAMESPACE*) yr_arena_get_ptr( compiler->arena, - rule->identifier, - &(yyval.expression).identifier.ref); + YR_NAMESPACES_TABLE, + compiler->current_namespace_idx * sizeof(struct YR_NAMESPACE)); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - (yyval.expression).value.integer = YR_UNDEFINED; + if (object == NULL) + { + // If not found, search within the current namespace. + object = (YR_OBJECT*) yr_hash_table_lookup( + compiler->objects_table, (yyvsp[0].c_string), ns->name); + } + + if (object != NULL) + { + YR_ARENA_REF ref; + + result = _yr_compiler_store_string( + compiler, (yyvsp[0].c_string), &ref); + + if (result == ERROR_SUCCESS) + result = yr_parser_emit_with_arg_reloc( + yyscanner, + OP_OBJ_LOAD, + yr_arena_ref_to_ptr(compiler->arena, &ref), + NULL, + NULL); + + (yyval.expression).type = EXPRESSION_TYPE_OBJECT; + (yyval.expression).value.object = object; + (yyval.expression).identifier.ptr = NULL; + (yyval.expression).identifier.ref = ref; + } + else + { + uint32_t rule_idx = yr_hash_table_lookup_uint32( + compiler->rules_table, (yyvsp[0].c_string), ns->name); + + if (rule_idx != UINT32_MAX) + { + result = yr_parser_emit_with_arg( + yyscanner, + OP_PUSH_RULE, + rule_idx, + NULL, + NULL); + + YR_RULE* rule = _yr_compiler_get_rule_by_idx(compiler, rule_idx); + + yr_arena_ptr_to_ref(compiler->arena, rule->identifier, &(yyval.expression).identifier.ref); + + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + (yyval.expression).value.integer = YR_UNDEFINED; + (yyval.expression).identifier.ptr = NULL; + } + else + { + yr_compiler_set_error_extra_info(compiler, (yyvsp[0].c_string)); + result = ERROR_UNDEFINED_IDENTIFIER; + } + } + } + + yr_free((yyvsp[0].c_string)); + + fail_if_error(result); + } +#line 2591 "grammar.c" /* yacc.c:1663 */ + break; + + case 66: +#line 968 "grammar.y" /* yacc.c:1663 */ + { + int result = ERROR_SUCCESS; + YR_OBJECT* field = NULL; + + if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_OBJECT && + (yyvsp[-2].expression).value.object->type == OBJECT_TYPE_STRUCTURE) + { + field = yr_object_lookup_field((yyvsp[-2].expression).value.object, (yyvsp[0].c_string)); + + if (field != NULL) + { + YR_ARENA_REF ref; + + result = _yr_compiler_store_string( + compiler, (yyvsp[0].c_string), &ref); + + if (result == ERROR_SUCCESS) + result = yr_parser_emit_with_arg_reloc( + yyscanner, + OP_OBJ_FIELD, + yr_arena_ref_to_ptr(compiler->arena, &ref), + NULL, + NULL); + + (yyval.expression).type = EXPRESSION_TYPE_OBJECT; + (yyval.expression).value.object = field; + (yyval.expression).identifier.ref = ref; + (yyval.expression).identifier.ptr = NULL; + } + else + { + yr_compiler_set_error_extra_info(compiler, (yyvsp[0].c_string)); + result = ERROR_INVALID_FIELD_NAME; + } + } + else + { + yr_compiler_set_error_extra_info( + compiler, expression_identifier((yyvsp[-2].expression))); + + result = ERROR_NOT_A_STRUCTURE; + } + + yr_free((yyvsp[0].c_string)); + + fail_if_error(result); + } +#line 2643 "grammar.c" /* yacc.c:1663 */ + break; + + case 67: +#line 1016 "grammar.y" /* yacc.c:1663 */ + { + int result = ERROR_SUCCESS; + YR_OBJECT_ARRAY* array; + YR_OBJECT_DICTIONARY* dict; + + if ((yyvsp[-3].expression).type == EXPRESSION_TYPE_OBJECT && + (yyvsp[-3].expression).value.object->type == OBJECT_TYPE_ARRAY) + { + if ((yyvsp[-1].expression).type != EXPRESSION_TYPE_INTEGER) + { + yr_compiler_set_error_extra_info( + compiler, "array indexes must be of integer type"); + result = ERROR_WRONG_TYPE; + } + + fail_if_error(result); + + result = yr_parser_emit( + yyscanner, OP_INDEX_ARRAY, NULL); + + array = object_as_array((yyvsp[-3].expression).value.object); + + (yyval.expression).type = EXPRESSION_TYPE_OBJECT; + (yyval.expression).value.object = array->prototype_item; + (yyval.expression).identifier.ptr = array->identifier; + (yyval.expression).identifier.ref = YR_ARENA_NULL_REF; + } + else if ((yyvsp[-3].expression).type == EXPRESSION_TYPE_OBJECT && + (yyvsp[-3].expression).value.object->type == OBJECT_TYPE_DICTIONARY) + { + if ((yyvsp[-1].expression).type != EXPRESSION_TYPE_STRING) + { + yr_compiler_set_error_extra_info( + compiler, "dictionary keys must be of string type"); + result = ERROR_WRONG_TYPE; + } + + fail_if_error(result); + + result = yr_parser_emit( + yyscanner, OP_LOOKUP_DICT, NULL); + + dict = object_as_dictionary((yyvsp[-3].expression).value.object); + + (yyval.expression).type = EXPRESSION_TYPE_OBJECT; + (yyval.expression).value.object = dict->prototype_item; + (yyval.expression).identifier.ptr = dict->identifier; + (yyval.expression).identifier.ref = YR_ARENA_NULL_REF; + } + else + { + yr_compiler_set_error_extra_info( + compiler, expression_identifier((yyvsp[-3].expression))); + + result = ERROR_NOT_INDEXABLE; + } + + fail_if_error(result); + } +#line 2707 "grammar.c" /* yacc.c:1663 */ + break; + + case 68: +#line 1077 "grammar.y" /* yacc.c:1663 */ + { + YR_ARENA_REF ref; + int result = ERROR_SUCCESS; + YR_OBJECT_FUNCTION* function; + + if ((yyvsp[-3].expression).type == EXPRESSION_TYPE_OBJECT && + (yyvsp[-3].expression).value.object->type == OBJECT_TYPE_FUNCTION) + { + result = yr_parser_check_types( + compiler, object_as_function((yyvsp[-3].expression).value.object), (yyvsp[-1].c_string)); + + if (result == ERROR_SUCCESS) + result = _yr_compiler_store_string( + compiler, (yyvsp[-1].c_string), &ref); + + if (result == ERROR_SUCCESS) + result = yr_parser_emit_with_arg_reloc( + yyscanner, + OP_CALL, + yr_arena_ref_to_ptr(compiler->arena, &ref), + NULL, + NULL); + + function = object_as_function((yyvsp[-3].expression).value.object); + + (yyval.expression).type = EXPRESSION_TYPE_OBJECT; + (yyval.expression).value.object = function->return_obj; + (yyval.expression).identifier.ref = ref; (yyval.expression).identifier.ptr = NULL; } else { - yr_compiler_set_error_extra_info(compiler, (yyvsp[0].c_string)); - result = ERROR_UNDEFINED_IDENTIFIER; + yr_compiler_set_error_extra_info( + compiler, expression_identifier((yyvsp[-3].expression))); + + result = ERROR_NOT_A_FUNCTION; + } + + yr_free((yyvsp[-1].c_string)); + + fail_if_error(result); + } +#line 2754 "grammar.c" /* yacc.c:1663 */ + break; + + case 69: +#line 1123 "grammar.y" /* yacc.c:1663 */ + { (yyval.c_string) = yr_strdup(""); } +#line 2760 "grammar.c" /* yacc.c:1663 */ + break; + + case 70: +#line 1124 "grammar.y" /* yacc.c:1663 */ + { (yyval.c_string) = (yyvsp[0].c_string); } +#line 2766 "grammar.c" /* yacc.c:1663 */ + break; + + case 71: +#line 1129 "grammar.y" /* yacc.c:1663 */ + { + (yyval.c_string) = (char*) yr_malloc(YR_MAX_FUNCTION_ARGS + 1); + + if ((yyval.c_string) == NULL) + fail_with_error(ERROR_INSUFFICIENT_MEMORY); + + switch((yyvsp[0].expression).type) + { + case EXPRESSION_TYPE_INTEGER: + strlcpy((yyval.c_string), "i", YR_MAX_FUNCTION_ARGS); + break; + case EXPRESSION_TYPE_FLOAT: + strlcpy((yyval.c_string), "f", YR_MAX_FUNCTION_ARGS); + break; + case EXPRESSION_TYPE_BOOLEAN: + strlcpy((yyval.c_string), "b", YR_MAX_FUNCTION_ARGS); + break; + case EXPRESSION_TYPE_STRING: + strlcpy((yyval.c_string), "s", YR_MAX_FUNCTION_ARGS); + break; + case EXPRESSION_TYPE_REGEXP: + strlcpy((yyval.c_string), "r", YR_MAX_FUNCTION_ARGS); + break; + case EXPRESSION_TYPE_UNKNOWN: + yr_free((yyval.c_string)); + yr_compiler_set_error_extra_info( + compiler, "unknown type for argument 1 in function call"); + fail_with_error(ERROR_WRONG_TYPE); + break; + default: + // An unknown expression type is OK iff an error ocurred. + assert(compiler->last_error != ERROR_SUCCESS); } } - } +#line 2805 "grammar.c" /* yacc.c:1663 */ + break; - yr_free((yyvsp[0].c_string)); - - fail_if_error(result); - } -#line 2591 "grammar.c" /* yacc.c:1663 */ - break; - - case 66: -#line 968 "grammar.y" /* yacc.c:1663 */ - { - int result = ERROR_SUCCESS; - YR_OBJECT* field = NULL; - - if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_OBJECT && - (yyvsp[-2].expression).value.object->type == OBJECT_TYPE_STRUCTURE) + case 72: +#line 1164 "grammar.y" /* yacc.c:1663 */ { - field = yr_object_lookup_field( - (yyvsp[-2].expression).value.object, (yyvsp[0].c_string)); + int result = ERROR_SUCCESS; - if (field != NULL) - { - YR_ARENA_REF ref; + if (strlen((yyvsp[-2].c_string)) == YR_MAX_FUNCTION_ARGS) + { + result = ERROR_TOO_MANY_ARGUMENTS; + } + else + { + switch((yyvsp[0].expression).type) + { + case EXPRESSION_TYPE_INTEGER: + strlcat((yyvsp[-2].c_string), "i", YR_MAX_FUNCTION_ARGS); + break; + case EXPRESSION_TYPE_FLOAT: + strlcat((yyvsp[-2].c_string), "f", YR_MAX_FUNCTION_ARGS); + break; + case EXPRESSION_TYPE_BOOLEAN: + strlcat((yyvsp[-2].c_string), "b", YR_MAX_FUNCTION_ARGS); + break; + case EXPRESSION_TYPE_STRING: + strlcat((yyvsp[-2].c_string), "s", YR_MAX_FUNCTION_ARGS); + break; + case EXPRESSION_TYPE_REGEXP: + strlcat((yyvsp[-2].c_string), "r", YR_MAX_FUNCTION_ARGS); + break; + case EXPRESSION_TYPE_UNKNOWN: + result = ERROR_WRONG_TYPE; + yr_compiler_set_error_extra_info_fmt( + compiler, "unknown type for argument %zu in function call", + // As we add one character per argument, the length of $1 is + // the number of arguments parsed so far, and the argument + // represented by is length of $1 plus one. + strlen((yyvsp[-2].c_string)) + 1); + break; + default: + // An unknown expression type is OK iff an error ocurred. + assert(compiler->last_error != ERROR_SUCCESS); + } + } - result = _yr_compiler_store_string(compiler, (yyvsp[0].c_string), &ref); + if (result != ERROR_SUCCESS) + yr_free((yyvsp[-2].c_string)); + + fail_if_error(result); + + (yyval.c_string) = (yyvsp[-2].c_string); + } +#line 2858 "grammar.c" /* yacc.c:1663 */ + break; + + case 73: +#line 1217 "grammar.y" /* yacc.c:1663 */ + { + SIZED_STRING* sized_string = (yyvsp[0].sized_string); + YR_ARENA_REF re_ref; + RE_ERROR error; + + int result = ERROR_SUCCESS; + int re_flags = 0; + + if (sized_string->flags & SIZED_STRING_FLAGS_NO_CASE) + re_flags |= RE_FLAGS_NO_CASE; + + if (sized_string->flags & SIZED_STRING_FLAGS_DOT_ALL) + re_flags |= RE_FLAGS_DOT_ALL; + + result = yr_re_compile( + sized_string->c_string, + re_flags, + compiler->arena, + &re_ref, + &error); + + yr_free((yyvsp[0].sized_string)); + + if (result == ERROR_INVALID_REGULAR_EXPRESSION) + yr_compiler_set_error_extra_info(compiler, error.message); if (result == ERROR_SUCCESS) result = yr_parser_emit_with_arg_reloc( yyscanner, - OP_OBJ_FIELD, - yr_arena_ref_to_ptr(compiler->arena, &ref), + OP_PUSH, + yr_arena_ref_to_ptr(compiler->arena, &re_ref), NULL, NULL); - (yyval.expression).type = EXPRESSION_TYPE_OBJECT; - (yyval.expression).value.object = field; - (yyval.expression).identifier.ref = ref; - (yyval.expression).identifier.ptr = NULL; + fail_if_error(result); + + (yyval.expression).type = EXPRESSION_TYPE_REGEXP; } - else - { - yr_compiler_set_error_extra_info(compiler, (yyvsp[0].c_string)); - result = ERROR_INVALID_FIELD_NAME; - } - } - else - { - yr_compiler_set_error_extra_info( - compiler, expression_identifier((yyvsp[-2].expression))); - - result = ERROR_NOT_A_STRUCTURE; - } - - yr_free((yyvsp[0].c_string)); - - fail_if_error(result); - } -#line 2643 "grammar.c" /* yacc.c:1663 */ - break; - - case 67: -#line 1016 "grammar.y" /* yacc.c:1663 */ - { - int result = ERROR_SUCCESS; - YR_OBJECT_ARRAY* array; - YR_OBJECT_DICTIONARY* dict; - - if ((yyvsp[-3].expression).type == EXPRESSION_TYPE_OBJECT && - (yyvsp[-3].expression).value.object->type == OBJECT_TYPE_ARRAY) - { - if ((yyvsp[-1].expression).type != EXPRESSION_TYPE_INTEGER) - { - yr_compiler_set_error_extra_info( - compiler, "array indexes must be of integer type"); - result = ERROR_WRONG_TYPE; - } - - fail_if_error(result); - - result = yr_parser_emit(yyscanner, OP_INDEX_ARRAY, NULL); - - array = object_as_array((yyvsp[-3].expression).value.object); - - (yyval.expression).type = EXPRESSION_TYPE_OBJECT; - (yyval.expression).value.object = array->prototype_item; - (yyval.expression).identifier.ptr = array->identifier; - (yyval.expression).identifier.ref = YR_ARENA_NULL_REF; - } - else if ( - (yyvsp[-3].expression).type == EXPRESSION_TYPE_OBJECT && - (yyvsp[-3].expression).value.object->type == OBJECT_TYPE_DICTIONARY) - { - if ((yyvsp[-1].expression).type != EXPRESSION_TYPE_STRING) - { - yr_compiler_set_error_extra_info( - compiler, "dictionary keys must be of string type"); - result = ERROR_WRONG_TYPE; - } - - fail_if_error(result); - - result = yr_parser_emit(yyscanner, OP_LOOKUP_DICT, NULL); - - dict = object_as_dictionary((yyvsp[-3].expression).value.object); - - (yyval.expression).type = EXPRESSION_TYPE_OBJECT; - (yyval.expression).value.object = dict->prototype_item; - (yyval.expression).identifier.ptr = dict->identifier; - (yyval.expression).identifier.ref = YR_ARENA_NULL_REF; - } - else - { - yr_compiler_set_error_extra_info( - compiler, expression_identifier((yyvsp[-3].expression))); - - result = ERROR_NOT_INDEXABLE; - } - - fail_if_error(result); - } -#line 2707 "grammar.c" /* yacc.c:1663 */ - break; - - case 68: -#line 1077 "grammar.y" /* yacc.c:1663 */ - { - YR_ARENA_REF ref; - int result = ERROR_SUCCESS; - YR_OBJECT_FUNCTION* function; - - if ((yyvsp[-3].expression).type == EXPRESSION_TYPE_OBJECT && - (yyvsp[-3].expression).value.object->type == OBJECT_TYPE_FUNCTION) - { - result = yr_parser_check_types( - compiler, - object_as_function((yyvsp[-3].expression).value.object), - (yyvsp[-1].c_string)); - - if (result == ERROR_SUCCESS) - result = _yr_compiler_store_string( - compiler, (yyvsp[-1].c_string), &ref); - - if (result == ERROR_SUCCESS) - result = yr_parser_emit_with_arg_reloc( - yyscanner, - OP_CALL, - yr_arena_ref_to_ptr(compiler->arena, &ref), - NULL, - NULL); - - function = object_as_function((yyvsp[-3].expression).value.object); - - (yyval.expression).type = EXPRESSION_TYPE_OBJECT; - (yyval.expression).value.object = function->return_obj; - (yyval.expression).identifier.ref = ref; - (yyval.expression).identifier.ptr = NULL; - } - else - { - yr_compiler_set_error_extra_info( - compiler, expression_identifier((yyvsp[-3].expression))); - - result = ERROR_NOT_A_FUNCTION; - } - - yr_free((yyvsp[-1].c_string)); - - fail_if_error(result); - } -#line 2754 "grammar.c" /* yacc.c:1663 */ - break; - - case 69: -#line 1123 "grammar.y" /* yacc.c:1663 */ - { - (yyval.c_string) = yr_strdup(""); - } -#line 2760 "grammar.c" /* yacc.c:1663 */ - break; - - case 70: -#line 1124 "grammar.y" /* yacc.c:1663 */ - { - (yyval.c_string) = (yyvsp[0].c_string); - } -#line 2766 "grammar.c" /* yacc.c:1663 */ - break; - - case 71: -#line 1129 "grammar.y" /* yacc.c:1663 */ - { - (yyval.c_string) = (char*) yr_malloc(YR_MAX_FUNCTION_ARGS + 1); - - if ((yyval.c_string) == NULL) - fail_with_error(ERROR_INSUFFICIENT_MEMORY); - - switch ((yyvsp[0].expression).type) - { - case EXPRESSION_TYPE_INTEGER: - strlcpy((yyval.c_string), "i", YR_MAX_FUNCTION_ARGS); - break; - case EXPRESSION_TYPE_FLOAT: - strlcpy((yyval.c_string), "f", YR_MAX_FUNCTION_ARGS); - break; - case EXPRESSION_TYPE_BOOLEAN: - strlcpy((yyval.c_string), "b", YR_MAX_FUNCTION_ARGS); - break; - case EXPRESSION_TYPE_STRING: - strlcpy((yyval.c_string), "s", YR_MAX_FUNCTION_ARGS); - break; - case EXPRESSION_TYPE_REGEXP: - strlcpy((yyval.c_string), "r", YR_MAX_FUNCTION_ARGS); - break; - case EXPRESSION_TYPE_UNKNOWN: - yr_free((yyval.c_string)); - yr_compiler_set_error_extra_info( - compiler, "unknown type for argument 1 in function call"); - fail_with_error(ERROR_WRONG_TYPE); - break; - default: - // An unknown expression type is OK iff an error ocurred. - assert(compiler->last_error != ERROR_SUCCESS); - } - } -#line 2805 "grammar.c" /* yacc.c:1663 */ - break; - - case 72: -#line 1164 "grammar.y" /* yacc.c:1663 */ - { - int result = ERROR_SUCCESS; - - if (strlen((yyvsp[-2].c_string)) == YR_MAX_FUNCTION_ARGS) - { - result = ERROR_TOO_MANY_ARGUMENTS; - } - else - { - switch ((yyvsp[0].expression).type) - { - case EXPRESSION_TYPE_INTEGER: - strlcat((yyvsp[-2].c_string), "i", YR_MAX_FUNCTION_ARGS); - break; - case EXPRESSION_TYPE_FLOAT: - strlcat((yyvsp[-2].c_string), "f", YR_MAX_FUNCTION_ARGS); - break; - case EXPRESSION_TYPE_BOOLEAN: - strlcat((yyvsp[-2].c_string), "b", YR_MAX_FUNCTION_ARGS); - break; - case EXPRESSION_TYPE_STRING: - strlcat((yyvsp[-2].c_string), "s", YR_MAX_FUNCTION_ARGS); - break; - case EXPRESSION_TYPE_REGEXP: - strlcat((yyvsp[-2].c_string), "r", YR_MAX_FUNCTION_ARGS); - break; - case EXPRESSION_TYPE_UNKNOWN: - result = ERROR_WRONG_TYPE; - yr_compiler_set_error_extra_info_fmt( - compiler, - "unknown type for argument %zu in function call", - // As we add one character per argument, the length of $1 is - // the number of arguments parsed so far, and the argument - // represented by is length of $1 plus one. - strlen((yyvsp[-2].c_string)) + 1); - break; - default: - // An unknown expression type is OK iff an error ocurred. - assert(compiler->last_error != ERROR_SUCCESS); - } - } - - if (result != ERROR_SUCCESS) - yr_free((yyvsp[-2].c_string)); - - fail_if_error(result); - - (yyval.c_string) = (yyvsp[-2].c_string); - } -#line 2858 "grammar.c" /* yacc.c:1663 */ - break; - - case 73: -#line 1217 "grammar.y" /* yacc.c:1663 */ - { - SIZED_STRING* sized_string = (yyvsp[0].sized_string); - YR_ARENA_REF re_ref; - RE_ERROR error; - - int result = ERROR_SUCCESS; - int re_flags = 0; - - if (sized_string->flags & SIZED_STRING_FLAGS_NO_CASE) - re_flags |= RE_FLAGS_NO_CASE; - - if (sized_string->flags & SIZED_STRING_FLAGS_DOT_ALL) - re_flags |= RE_FLAGS_DOT_ALL; - - result = yr_re_compile( - sized_string->c_string, re_flags, compiler->arena, &re_ref, &error); - - yr_free((yyvsp[0].sized_string)); - - if (result == ERROR_INVALID_REGULAR_EXPRESSION) - yr_compiler_set_error_extra_info(compiler, error.message); - - if (result == ERROR_SUCCESS) - result = yr_parser_emit_with_arg_reloc( - yyscanner, - OP_PUSH, - yr_arena_ref_to_ptr(compiler->arena, &re_ref), - NULL, - NULL); - - fail_if_error(result); - - (yyval.expression).type = EXPRESSION_TYPE_REGEXP; - } #line 2901 "grammar.c" /* yacc.c:1663 */ - break; + break; case 74: #line 1260 "grammar.y" /* yacc.c:1663 */ - { - if ((yyvsp[0].expression).type == EXPRESSION_TYPE_STRING) { - if (!YR_ARENA_IS_NULL_REF((yyvsp[0].expression).value.sized_string_ref)) - { - SIZED_STRING* sized_string = yr_arena_ref_to_ptr( - compiler->arena, &(yyvsp[0].expression).value.sized_string_ref); + if ((yyvsp[0].expression).type == EXPRESSION_TYPE_STRING) + { + if (!YR_ARENA_IS_NULL_REF((yyvsp[0].expression).value.sized_string_ref)) + { + SIZED_STRING* sized_string = yr_arena_ref_to_ptr( + compiler->arena, &(yyvsp[0].expression).value.sized_string_ref); - yywarning( - yyscanner, - "Using literal string \"%s\" in a boolean operation.", - sized_string->c_string); + yywarning(yyscanner, + "Using literal string \"%s\" in a boolean operation.", + sized_string->c_string); + } + + fail_if_error(yr_parser_emit( + yyscanner, OP_STR_TO_BOOL, NULL)); + } + + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; } - - fail_if_error(yr_parser_emit(yyscanner, OP_STR_TO_BOOL, NULL)); - } - - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } #line 2925 "grammar.c" /* yacc.c:1663 */ - break; + break; case 75: #line 1283 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_emit_push_const(yyscanner, 1)); + { + fail_if_error(yr_parser_emit_push_const(yyscanner, 1)); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } #line 2935 "grammar.c" /* yacc.c:1663 */ - break; + break; case 76: #line 1289 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_emit_push_const(yyscanner, 0)); + { + fail_if_error(yr_parser_emit_push_const(yyscanner, 0)); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } #line 2945 "grammar.c" /* yacc.c:1663 */ - break; + break; case 77: #line 1295 "grammar.y" /* yacc.c:1663 */ - { - check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "matches"); - check_type((yyvsp[0].expression), EXPRESSION_TYPE_REGEXP, "matches"); + { + check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "matches"); + check_type((yyvsp[0].expression), EXPRESSION_TYPE_REGEXP, "matches"); - fail_if_error(yr_parser_emit(yyscanner, OP_MATCHES, NULL)); + fail_if_error(yr_parser_emit( + yyscanner, + OP_MATCHES, + NULL)); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } #line 2961 "grammar.c" /* yacc.c:1663 */ - break; + break; case 78: #line 1307 "grammar.y" /* yacc.c:1663 */ - { - check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "contains"); - check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "contains"); + { + check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "contains"); + check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "contains"); - fail_if_error(yr_parser_emit(yyscanner, OP_CONTAINS, NULL)); + fail_if_error(yr_parser_emit( + yyscanner, OP_CONTAINS, NULL)); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } #line 2975 "grammar.c" /* yacc.c:1663 */ - break; + break; case 79: #line 1317 "grammar.y" /* yacc.c:1663 */ - { - check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "icontains"); - check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "icontains"); + { + check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "icontains"); + check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "icontains"); - fail_if_error(yr_parser_emit(yyscanner, OP_ICONTAINS, NULL)); + fail_if_error(yr_parser_emit( + yyscanner, OP_ICONTAINS, NULL)); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } #line 2989 "grammar.c" /* yacc.c:1663 */ - break; + break; case 80: #line 1327 "grammar.y" /* yacc.c:1663 */ - { - check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "startswith"); - check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "startswith"); + { + check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "startswith"); + check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "startswith"); - fail_if_error(yr_parser_emit(yyscanner, OP_STARTSWITH, NULL)); + fail_if_error(yr_parser_emit( + yyscanner, OP_STARTSWITH, NULL)); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } #line 3003 "grammar.c" /* yacc.c:1663 */ - break; + break; case 81: #line 1337 "grammar.y" /* yacc.c:1663 */ - { - check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "istartswith"); - check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "istartswith"); + { + check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "istartswith"); + check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "istartswith"); - fail_if_error(yr_parser_emit(yyscanner, OP_ISTARTSWITH, NULL)); + fail_if_error(yr_parser_emit( + yyscanner, OP_ISTARTSWITH, NULL)); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } #line 3017 "grammar.c" /* yacc.c:1663 */ - break; + break; case 82: #line 1347 "grammar.y" /* yacc.c:1663 */ - { - check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "endswith"); - check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "endswith"); + { + check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "endswith"); + check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "endswith"); - fail_if_error(yr_parser_emit(yyscanner, OP_ENDSWITH, NULL)); + fail_if_error(yr_parser_emit( + yyscanner, OP_ENDSWITH, NULL)); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } #line 3031 "grammar.c" /* yacc.c:1663 */ - break; + break; case 83: #line 1357 "grammar.y" /* yacc.c:1663 */ - { - check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "iendswith"); - check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "iendswith"); + { + check_type((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "iendswith"); + check_type((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "iendswith"); - fail_if_error(yr_parser_emit(yyscanner, OP_IENDSWITH, NULL)); + fail_if_error(yr_parser_emit( + yyscanner, OP_IENDSWITH, NULL)); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } #line 3045 "grammar.c" /* yacc.c:1663 */ - break; + break; case 84: #line 1367 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_string_identifier( - yyscanner, (yyvsp[0].c_string), OP_FOUND, YR_UNDEFINED); + { + int result = yr_parser_reduce_string_identifier( + yyscanner, + (yyvsp[0].c_string), + OP_FOUND, + YR_UNDEFINED); - yr_free((yyvsp[0].c_string)); + yr_free((yyvsp[0].c_string)); - fail_if_error(result); + fail_if_error(result); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } #line 3063 "grammar.c" /* yacc.c:1663 */ - break; + break; case 85: #line 1381 "grammar.y" /* yacc.c:1663 */ - { - int result; + { + int result; - check_type_with_cleanup( - (yyvsp[0].expression), - EXPRESSION_TYPE_INTEGER, - "at", - yr_free((yyvsp[-2].c_string))); + check_type_with_cleanup((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "at", yr_free((yyvsp[-2].c_string))); - result = yr_parser_reduce_string_identifier( - yyscanner, - (yyvsp[-2].c_string), - OP_FOUND_AT, - (yyvsp[0].expression).value.integer); + result = yr_parser_reduce_string_identifier( + yyscanner, (yyvsp[-2].c_string), OP_FOUND_AT, (yyvsp[0].expression).value.integer); - yr_free((yyvsp[-2].c_string)); + yr_free((yyvsp[-2].c_string)); - fail_if_error(result); + fail_if_error(result); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } #line 3082 "grammar.c" /* yacc.c:1663 */ - break; + break; case 86: #line 1396 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_string_identifier( - yyscanner, (yyvsp[-2].c_string), OP_FOUND_IN, YR_UNDEFINED); + { + int result = yr_parser_reduce_string_identifier( + yyscanner, (yyvsp[-2].c_string), OP_FOUND_IN, YR_UNDEFINED); - yr_free((yyvsp[-2].c_string)); + yr_free((yyvsp[-2].c_string)); - fail_if_error(result); + fail_if_error(result); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } #line 3097 "grammar.c" /* yacc.c:1663 */ - break; + break; case 87: #line 1407 "grammar.y" /* yacc.c:1663 */ - { - int i; - - // Free all the loop variable identifiers, including the variables for - // the current loop (represented by loop_index), and set loop_index to - // -1. This is OK even if we have nested loops. If an error occurs while - // parsing the inner loop, it will be propagated to the outer loop - // anyways, so it's safe to do this cleanup while processing the error - // for the inner loop. - - for (i = 0; i <= compiler->loop_index; i++) { - loop_vars_cleanup(i); - } + // Free all the loop variable identifiers, including the variables for + // the current loop (represented by loop_index), and set loop_index to + // -1. This is OK even if we have nested loops. If an error occurs while + // parsing the inner loop, it will be propagated to the outer loop + // anyways, so it's safe to do this cleanup while processing the error + // for the inner loop. - compiler->loop_index = -1; - YYERROR; - } -#line 3120 "grammar.c" /* yacc.c:1663 */ - break; + for (int i = 0; i <= compiler->loop_index; i++) + { + loop_vars_cleanup(i); + } + + compiler->loop_index = -1; + YYERROR; + } +#line 3118 "grammar.c" /* yacc.c:1663 */ + break; case 88: -#line 1485 "grammar.y" /* yacc.c:1663 */ - { - // 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 - // with the correct value, which depends on the number of variables - // defined by any outer loops. +#line 1483 "grammar.y" /* yacc.c:1663 */ + { + // 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 + // with the correct value, which depends on the number of variables + // defined by any outer loops. - int var_frame; - int result = ERROR_SUCCESS; + int var_frame; + int result = ERROR_SUCCESS; - if (compiler->loop_index + 1 == YR_MAX_LOOP_NESTING) - result = ERROR_LOOP_NESTING_LIMIT_EXCEEDED; + if (compiler->loop_index + 1 == YR_MAX_LOOP_NESTING) + result = ERROR_LOOP_NESTING_LIMIT_EXCEEDED; - fail_if_error(result); + fail_if_error(result); - compiler->loop_index++; + compiler->loop_index++; - // This loop uses internal variables besides the ones explicitly - // defined by the user. - compiler->loop[compiler->loop_index].vars_internal_count = - YR_INTERNAL_LOOP_VARS; + // This loop uses internal variables besides the ones explicitly + // defined by the user. + compiler->loop[compiler->loop_index].vars_internal_count = \ + YR_INTERNAL_LOOP_VARS; - // Initialize the number of variables, this number will be incremented - // as variable declaration are processed by for_variables. - compiler->loop[compiler->loop_index].vars_count = 0; + // Initialize the number of variables, this number will be incremented + // as variable declaration are processed by for_variables. + compiler->loop[compiler->loop_index].vars_count = 0; - var_frame = _yr_compiler_get_var_frame(compiler); + var_frame = _yr_compiler_get_var_frame(compiler); - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_CLEAR_M, var_frame + 0, NULL, NULL)); + fail_if_error(yr_parser_emit_with_arg( + yyscanner, OP_CLEAR_M, var_frame + 0, NULL, NULL)); - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_CLEAR_M, var_frame + 1, NULL, NULL)); + fail_if_error(yr_parser_emit_with_arg( + yyscanner, OP_CLEAR_M, var_frame + 1, NULL, NULL)); - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_POP_M, var_frame + 2, NULL, NULL)); - } -#line 3162 "grammar.c" /* yacc.c:1663 */ - break; + fail_if_error(yr_parser_emit_with_arg( + yyscanner, OP_POP_M, var_frame + 2, NULL, NULL)); + } +#line 3160 "grammar.c" /* yacc.c:1663 */ + break; case 89: -#line 1523 "grammar.y" /* yacc.c:1663 */ - { - YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; - YR_FIXUP* fixup; - - YR_ARENA_REF loop_start_ref; - YR_ARENA_REF jmp_offset_ref; - - int var_frame = _yr_compiler_get_var_frame(compiler); - int i; - - fail_if_error(yr_parser_emit(yyscanner, OP_ITER_NEXT, &loop_start_ref)); - - // For each variable generate an instruction that pops the value from - // the stack and store it into one memory slot starting at var_frame + - // YR_INTERNAL_LOOP_VARS because the first YR_INTERNAL_LOOP_VARS slots - // in the frame are for the internal variables. - - for (i = 0; i < loop_ctx->vars_count; i++) +#line 1521 "grammar.y" /* yacc.c:1663 */ { - fail_if_error(yr_parser_emit_with_arg( - yyscanner, - OP_POP_M, - var_frame + YR_INTERNAL_LOOP_VARS + i, - NULL, - NULL)); - } + YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; + YR_FIXUP* fixup; - fail_if_error(yr_parser_emit_with_arg_int32( - yyscanner, - OP_JTRUE_P, - 0, // still don't know the jump offset, use 0 for now. - NULL, - &jmp_offset_ref)); + YR_ARENA_REF loop_start_ref; + YR_ARENA_REF jmp_offset_ref; - // We still don't know the jump's target, so we push a fixup entry - // in the stack, so that the jump's offset can be set once we know it. + int var_frame = _yr_compiler_get_var_frame(compiler); - fixup = (YR_FIXUP*) yr_malloc(sizeof(YR_FIXUP)); + fail_if_error(yr_parser_emit( + yyscanner, OP_ITER_NEXT, &loop_start_ref)); - if (fixup == NULL) - fail_with_error(ERROR_INSUFFICIENT_MEMORY); + // For each variable generate an instruction that pops the value from + // the stack and store it into one memory slot starting at var_frame + + // YR_INTERNAL_LOOP_VARS because the first YR_INTERNAL_LOOP_VARS slots + // in the frame are for the internal variables. - fixup->ref = jmp_offset_ref; - fixup->next = compiler->fixup_stack_head; - compiler->fixup_stack_head = fixup; + for (int i = 0; i < loop_ctx->vars_count; i++) + { + fail_if_error(yr_parser_emit_with_arg( + yyscanner, + OP_POP_M, + var_frame + YR_INTERNAL_LOOP_VARS + i, + NULL, + NULL)); + } - loop_ctx->start_ref = loop_start_ref; - } -#line 3216 "grammar.c" /* yacc.c:1663 */ - break; + fail_if_error(yr_parser_emit_with_arg_int32( + yyscanner, + OP_JTRUE_P, + 0, // still don't know the jump offset, use 0 for now. + NULL, + &jmp_offset_ref)); + + // We still don't know the jump's target, so we push a fixup entry + // in the stack, so that the jump's offset can be set once we know it. + + fixup = (YR_FIXUP*) yr_malloc(sizeof(YR_FIXUP)); + + if (fixup == NULL) + fail_with_error(ERROR_INSUFFICIENT_MEMORY); + + fixup->ref = jmp_offset_ref; + fixup->next = compiler->fixup_stack_head; + compiler->fixup_stack_head = fixup; + + loop_ctx->start_ref = loop_start_ref; + } +#line 3213 "grammar.c" /* yacc.c:1663 */ + break; case 90: -#line 1573 "grammar.y" /* yacc.c:1663 */ - { - int32_t jmp_offset; - YR_FIXUP* fixup; - YR_ARENA_REF pop_ref; - YR_ARENA_REF jmp_offset_ref; +#line 1570 "grammar.y" /* yacc.c:1663 */ + { + int32_t jmp_offset; + YR_FIXUP* fixup; + YR_ARENA_REF pop_ref; + YR_ARENA_REF jmp_offset_ref; - int var_frame = _yr_compiler_get_var_frame(compiler); + int var_frame = _yr_compiler_get_var_frame(compiler); - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_ADD_M, var_frame + 0, NULL, NULL)); + fail_if_error(yr_parser_emit_with_arg( + yyscanner, OP_ADD_M, var_frame + 0, NULL, NULL)); - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_INCR_M, var_frame + 1, NULL, NULL)); + fail_if_error(yr_parser_emit_with_arg( + yyscanner, OP_INCR_M, var_frame + 1, NULL, NULL)); - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_PUSH_M, var_frame + 2, NULL, NULL)); + fail_if_error(yr_parser_emit_with_arg( + yyscanner, OP_PUSH_M, var_frame + 2, NULL, NULL)); - jmp_offset = compiler->loop[compiler->loop_index].start_ref.offset - - yr_arena_get_current_offset(compiler->arena, YR_CODE_SECTION); + jmp_offset = \ + compiler->loop[compiler->loop_index].start_ref.offset - + yr_arena_get_current_offset(compiler->arena, YR_CODE_SECTION); - fail_if_error(yr_parser_emit_with_arg_int32( - yyscanner, OP_JUNDEF_P, jmp_offset, NULL, NULL)); + fail_if_error(yr_parser_emit_with_arg_int32( + yyscanner, + OP_JUNDEF_P, + jmp_offset, + NULL, + NULL)); - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_PUSH_M, var_frame + 0, NULL, NULL)); + fail_if_error(yr_parser_emit_with_arg( + yyscanner, OP_PUSH_M, var_frame + 0, NULL, NULL)); - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_PUSH_M, var_frame + 2, NULL, NULL)); + fail_if_error(yr_parser_emit_with_arg( + yyscanner, OP_PUSH_M, var_frame + 2, NULL, NULL)); - jmp_offset = compiler->loop[compiler->loop_index].start_ref.offset - - yr_arena_get_current_offset(compiler->arena, YR_CODE_SECTION); + jmp_offset = \ + compiler->loop[compiler->loop_index].start_ref.offset - + yr_arena_get_current_offset(compiler->arena, YR_CODE_SECTION); - fail_if_error(yr_parser_emit_with_arg_int32( - yyscanner, OP_JL_P, jmp_offset, NULL, NULL)); + fail_if_error(yr_parser_emit_with_arg_int32( + yyscanner, + OP_JL_P, + jmp_offset, + NULL, + NULL)); - fail_if_error(yr_parser_emit(yyscanner, OP_POP, &pop_ref)); + fail_if_error(yr_parser_emit( + yyscanner, OP_POP, &pop_ref)); - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_PUSH_M, var_frame + 1, NULL, NULL)); + fail_if_error(yr_parser_emit_with_arg( + yyscanner, OP_PUSH_M, var_frame + 1, NULL, NULL)); - fail_if_error(yr_parser_emit_with_arg_int32( - yyscanner, - OP_JZ, - 0, // still don't know the jump offset, use 0 for now. - NULL, - &jmp_offset_ref)); + fail_if_error(yr_parser_emit_with_arg_int32( + yyscanner, + OP_JZ, + 0, // still don't know the jump offset, use 0 for now. + NULL, + &jmp_offset_ref)); - fail_if_error(yr_parser_emit(yyscanner, OP_POP, NULL)); + fail_if_error(yr_parser_emit( + yyscanner, OP_POP, NULL)); - // Pop from the stack the fixup entry containing the reference to - // the jump offset that needs to be fixed. + // Pop from the stack the fixup entry containing the reference to + // the jump offset that needs to be fixed. - fixup = compiler->fixup_stack_head; - compiler->fixup_stack_head = fixup->next; + fixup = compiler->fixup_stack_head; + compiler->fixup_stack_head = fixup->next; - // The fixup entry has a reference to the jump offset that need - // to be fixed, convert the address into a pointer. - int32_t* jmp_offset_addr = (int32_t*) yr_arena_ref_to_ptr( - compiler->arena, &fixup->ref); + // The fixup entry has a reference to the jump offset that need + // to be fixed, convert the address into a pointer. + int32_t* jmp_offset_addr = (int32_t*) yr_arena_ref_to_ptr( + compiler->arena, &fixup->ref); - // The reference in the fixup entry points to the jump's offset - // but the jump instruction is one byte before, that's why we add - // one to the offset. - jmp_offset = pop_ref.offset - fixup->ref.offset + 1; + // The reference in the fixup entry points to the jump's offset + // but the jump instruction is one byte before, that's why we add + // one to the offset. + jmp_offset = pop_ref.offset - fixup->ref.offset + 1; - // Fix the jump's offset. - *jmp_offset_addr = jmp_offset; + // Fix the jump's offset. + *jmp_offset_addr = jmp_offset; - yr_free(fixup); + yr_free(fixup); - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_PUSH_M, var_frame + 0, NULL, NULL)); + fail_if_error(yr_parser_emit_with_arg( + yyscanner, OP_PUSH_M, var_frame + 0, NULL, NULL)); - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_PUSH_M, var_frame + 2, NULL, NULL)); + fail_if_error(yr_parser_emit_with_arg( + yyscanner, OP_PUSH_M, var_frame + 2, NULL, NULL)); - fail_if_error(yr_parser_emit_with_arg( - yyscanner, OP_SWAPUNDEF, var_frame + 1, NULL, NULL)); + fail_if_error(yr_parser_emit_with_arg( + yyscanner, OP_SWAPUNDEF, var_frame + 1, NULL, NULL)); - fail_if_error(yr_parser_emit(yyscanner, OP_INT_GE, NULL)); + fail_if_error(yr_parser_emit( + yyscanner, OP_INT_GE, NULL)); - jmp_offset = yr_arena_get_current_offset(compiler->arena, YR_CODE_SECTION) - - jmp_offset_ref.offset + 1; + jmp_offset = \ + yr_arena_get_current_offset(compiler->arena, YR_CODE_SECTION) - + jmp_offset_ref.offset + 1; - jmp_offset_addr = (int32_t*) yr_arena_ref_to_ptr( - compiler->arena, &jmp_offset_ref); + jmp_offset_addr = (int32_t*) yr_arena_ref_to_ptr( + compiler->arena, &jmp_offset_ref); - *jmp_offset_addr = jmp_offset; + *jmp_offset_addr = jmp_offset; - loop_vars_cleanup(compiler->loop_index); + loop_vars_cleanup(compiler->loop_index); - compiler->loop_index--; + compiler->loop_index--; - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } -#line 3330 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } +#line 3327 "grammar.c" /* yacc.c:1663 */ + break; case 91: -#line 1683 "grammar.y" /* yacc.c:1663 */ - { - YR_ARENA_REF ref; +#line 1680 "grammar.y" /* yacc.c:1663 */ + { + YR_ARENA_REF ref; - int result = ERROR_SUCCESS; - int var_frame; + int result = ERROR_SUCCESS; + int var_frame; - if (compiler->loop_index + 1 == YR_MAX_LOOP_NESTING) - result = ERROR_LOOP_NESTING_LIMIT_EXCEEDED; + if (compiler->loop_index + 1 == YR_MAX_LOOP_NESTING) + result = ERROR_LOOP_NESTING_LIMIT_EXCEEDED; - if (compiler->loop_for_of_var_index != -1) - result = ERROR_NESTED_FOR_OF_LOOP; + if (compiler->loop_for_of_var_index != -1) + result = ERROR_NESTED_FOR_OF_LOOP; - fail_if_error(result); + fail_if_error(result); - compiler->loop_index++; + compiler->loop_index++; - var_frame = _yr_compiler_get_var_frame(compiler); + var_frame = _yr_compiler_get_var_frame(compiler); - yr_parser_emit_with_arg(yyscanner, OP_CLEAR_M, var_frame + 1, NULL, NULL); + yr_parser_emit_with_arg( + yyscanner, OP_CLEAR_M, var_frame + 1, NULL, NULL); - yr_parser_emit_with_arg(yyscanner, OP_CLEAR_M, var_frame + 2, NULL, NULL); + yr_parser_emit_with_arg( + yyscanner, OP_CLEAR_M, var_frame + 2, NULL, NULL); - // Pop the first string. - yr_parser_emit_with_arg(yyscanner, OP_POP_M, var_frame, &ref, NULL); + // Pop the first string. + yr_parser_emit_with_arg( + yyscanner, OP_POP_M, var_frame, &ref, NULL); - compiler->loop_for_of_var_index = var_frame; - compiler->loop[compiler->loop_index].start_ref = ref; - compiler->loop[compiler->loop_index].vars_count = 0; - compiler->loop[compiler->loop_index].vars_internal_count = - YR_INTERNAL_LOOP_VARS; - } -#line 3369 "grammar.c" /* yacc.c:1663 */ - break; + compiler->loop_for_of_var_index = var_frame; + compiler->loop[compiler->loop_index].start_ref = ref; + compiler->loop[compiler->loop_index].vars_count = 0; + compiler->loop[compiler->loop_index].vars_internal_count = \ + YR_INTERNAL_LOOP_VARS; + } +#line 3366 "grammar.c" /* yacc.c:1663 */ + break; case 92: -#line 1718 "grammar.y" /* yacc.c:1663 */ - { - int var_frame = 0; +#line 1715 "grammar.y" /* yacc.c:1663 */ + { + int var_frame = 0; - compiler->loop_for_of_var_index = -1; + compiler->loop_for_of_var_index = -1; - var_frame = _yr_compiler_get_var_frame(compiler); + var_frame = _yr_compiler_get_var_frame(compiler); - // Increment counter by the value returned by the - // boolean expression (0 or 1). If the boolean expression - // returned YR_UNDEFINED the OP_ADD_M won't do anything. + // Increment counter by the value returned by the + // boolean expression (0 or 1). If the boolean expression + // returned YR_UNDEFINED the OP_ADD_M won't do anything. - yr_parser_emit_with_arg(yyscanner, OP_ADD_M, var_frame + 1, NULL, NULL); + yr_parser_emit_with_arg( + yyscanner, OP_ADD_M, var_frame + 1, NULL, NULL); - // Increment iterations counter. - yr_parser_emit_with_arg(yyscanner, OP_INCR_M, var_frame + 2, NULL, NULL); + // Increment iterations counter. + yr_parser_emit_with_arg( + yyscanner, OP_INCR_M, var_frame + 2, NULL, NULL); - int32_t jmp_offset = compiler->loop[compiler->loop_index].start_ref.offset - - yr_arena_get_current_offset( - compiler->arena, YR_CODE_SECTION); + int32_t jmp_offset = \ + compiler->loop[compiler->loop_index].start_ref.offset - + yr_arena_get_current_offset(compiler->arena, YR_CODE_SECTION); - // If next string is not undefined, go back to the - // beginning of the loop. - yr_parser_emit_with_arg_int32( - yyscanner, OP_JNUNDEF, jmp_offset, NULL, NULL); + // If next string is not undefined, go back to the + // beginning of the loop. + yr_parser_emit_with_arg_int32( + yyscanner, + OP_JNUNDEF, + jmp_offset, + NULL, + NULL); - // Pop end-of-list marker. - yr_parser_emit(yyscanner, OP_POP, NULL); + // Pop end-of-list marker. + yr_parser_emit(yyscanner, OP_POP, NULL); - // At this point the loop quantifier (any, all, 1, 2,..) - // is at top of the stack. Check if the quantifier is - // undefined (meaning "all") and replace it with the - // iterations counter in that case. - yr_parser_emit_with_arg(yyscanner, OP_SWAPUNDEF, var_frame + 2, NULL, NULL); + // At this point the loop quantifier (any, all, 1, 2,..) + // is at top of the stack. Check if the quantifier is + // undefined (meaning "all") and replace it with the + // iterations counter in that case. + yr_parser_emit_with_arg( + yyscanner, OP_SWAPUNDEF, var_frame + 2, NULL, NULL); - // Compare the loop quantifier with the number of - // expressions evaluating to true. - yr_parser_emit_with_arg(yyscanner, OP_PUSH_M, var_frame + 1, NULL, NULL); + // Compare the loop quantifier with the number of + // expressions evaluating to true. + yr_parser_emit_with_arg( + yyscanner, OP_PUSH_M, var_frame + 1, NULL, NULL); - yr_parser_emit(yyscanner, OP_INT_LE, NULL); + yr_parser_emit(yyscanner, OP_INT_LE, NULL); - loop_vars_cleanup(compiler->loop_index); + loop_vars_cleanup(compiler->loop_index); - compiler->loop_index--; + compiler->loop_index--; - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } -#line 3428 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } +#line 3425 "grammar.c" /* yacc.c:1663 */ + break; case 93: -#line 1773 "grammar.y" /* yacc.c:1663 */ - { - yr_parser_emit(yyscanner, OP_OF, NULL); +#line 1770 "grammar.y" /* yacc.c:1663 */ + { + yr_parser_emit(yyscanner, OP_OF, NULL); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } -#line 3438 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } +#line 3435 "grammar.c" /* yacc.c:1663 */ + break; case 94: -#line 1779 "grammar.y" /* yacc.c:1663 */ - { - yr_parser_emit(yyscanner, OP_NOT, NULL); +#line 1776 "grammar.y" /* yacc.c:1663 */ + { + yr_parser_emit(yyscanner, OP_NOT, NULL); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } -#line 3448 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } +#line 3445 "grammar.c" /* yacc.c:1663 */ + break; case 95: -#line 1785 "grammar.y" /* yacc.c:1663 */ - { - YR_FIXUP* fixup; - YR_ARENA_REF jmp_offset_ref; +#line 1782 "grammar.y" /* yacc.c:1663 */ + { + YR_FIXUP* fixup; + YR_ARENA_REF jmp_offset_ref; - fail_if_error(yr_parser_emit_with_arg_int32( - yyscanner, - OP_JFALSE, - 0, // still don't know the jump offset, use 0 for now. - NULL, - &jmp_offset_ref)); + fail_if_error(yr_parser_emit_with_arg_int32( + yyscanner, + OP_JFALSE, + 0, // still don't know the jump offset, use 0 for now. + NULL, + &jmp_offset_ref)); - // Create a fixup entry for the jump and push it in the stack. - fixup = (YR_FIXUP*) yr_malloc(sizeof(YR_FIXUP)); + // Create a fixup entry for the jump and push it in the stack. + fixup = (YR_FIXUP*) yr_malloc(sizeof(YR_FIXUP)); - if (fixup == NULL) - fail_with_error(ERROR_INSUFFICIENT_MEMORY); + if (fixup == NULL) + fail_with_error(ERROR_INSUFFICIENT_MEMORY); - fixup->ref = jmp_offset_ref; - fixup->next = compiler->fixup_stack_head; - compiler->fixup_stack_head = fixup; - } -#line 3474 "grammar.c" /* yacc.c:1663 */ - break; + fixup->ref = jmp_offset_ref; + fixup->next = compiler->fixup_stack_head; + compiler->fixup_stack_head = fixup; + } +#line 3471 "grammar.c" /* yacc.c:1663 */ + break; case 96: -#line 1807 "grammar.y" /* yacc.c:1663 */ - { - YR_FIXUP* fixup; +#line 1804 "grammar.y" /* yacc.c:1663 */ + { + YR_FIXUP* fixup; - fail_if_error(yr_parser_emit(yyscanner, OP_AND, NULL)); + fail_if_error(yr_parser_emit(yyscanner, OP_AND, NULL)); - fixup = compiler->fixup_stack_head; + fixup = compiler->fixup_stack_head; - int32_t* jmp_offset_addr = (int32_t*) yr_arena_ref_to_ptr( - compiler->arena, &fixup->ref); + int32_t* jmp_offset_addr = (int32_t*) yr_arena_ref_to_ptr( + compiler->arena, &fixup->ref); - int32_t jmp_offset = yr_arena_get_current_offset( - compiler->arena, YR_CODE_SECTION) - - fixup->ref.offset + 1; + int32_t jmp_offset = \ + yr_arena_get_current_offset(compiler->arena, YR_CODE_SECTION) - + fixup->ref.offset + 1; - *jmp_offset_addr = jmp_offset; + *jmp_offset_addr = jmp_offset; - // Remove fixup from the stack. - compiler->fixup_stack_head = fixup->next; - yr_free(fixup); + // Remove fixup from the stack. + compiler->fixup_stack_head = fixup->next; + yr_free(fixup); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } -#line 3501 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } +#line 3498 "grammar.c" /* yacc.c:1663 */ + break; case 97: -#line 1830 "grammar.y" /* yacc.c:1663 */ - { - YR_FIXUP* fixup; - YR_ARENA_REF jmp_offset_ref; +#line 1827 "grammar.y" /* yacc.c:1663 */ + { + YR_FIXUP* fixup; + YR_ARENA_REF jmp_offset_ref; - fail_if_error(yr_parser_emit_with_arg_int32( - yyscanner, - OP_JTRUE, - 0, // still don't know the jump destination, use 0 for now. - NULL, - &jmp_offset_ref)); + fail_if_error(yr_parser_emit_with_arg_int32( + yyscanner, + OP_JTRUE, + 0, // still don't know the jump destination, use 0 for now. + NULL, + &jmp_offset_ref)); - fixup = (YR_FIXUP*) yr_malloc(sizeof(YR_FIXUP)); + fixup = (YR_FIXUP*) yr_malloc(sizeof(YR_FIXUP)); - if (fixup == NULL) - fail_with_error(ERROR_INSUFFICIENT_MEMORY); + if (fixup == NULL) + fail_with_error(ERROR_INSUFFICIENT_MEMORY); - fixup->ref = jmp_offset_ref; - fixup->next = compiler->fixup_stack_head; - compiler->fixup_stack_head = fixup; - } -#line 3526 "grammar.c" /* yacc.c:1663 */ - break; + fixup->ref = jmp_offset_ref; + fixup->next = compiler->fixup_stack_head; + compiler->fixup_stack_head = fixup; + } +#line 3523 "grammar.c" /* yacc.c:1663 */ + break; case 98: -#line 1851 "grammar.y" /* yacc.c:1663 */ - { - YR_FIXUP* fixup; +#line 1848 "grammar.y" /* yacc.c:1663 */ + { + YR_FIXUP* fixup; - fail_if_error(yr_parser_emit(yyscanner, OP_OR, NULL)); + fail_if_error(yr_parser_emit(yyscanner, OP_OR, NULL)); - fixup = compiler->fixup_stack_head; + fixup = compiler->fixup_stack_head; - int32_t jmp_offset = yr_arena_get_current_offset( - compiler->arena, YR_CODE_SECTION) - - fixup->ref.offset + 1; + int32_t jmp_offset = \ + yr_arena_get_current_offset(compiler->arena, YR_CODE_SECTION) - + fixup->ref.offset + 1; - int32_t* jmp_offset_addr = (int32_t*) yr_arena_ref_to_ptr( - compiler->arena, &fixup->ref); + int32_t* jmp_offset_addr = (int32_t*) yr_arena_ref_to_ptr( + compiler->arena, &fixup->ref); - *jmp_offset_addr = jmp_offset; + *jmp_offset_addr = jmp_offset; - // Remove fixup from the stack. - compiler->fixup_stack_head = fixup->next; - yr_free(fixup); + // Remove fixup from the stack. + compiler->fixup_stack_head = fixup->next; + yr_free(fixup); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } -#line 3553 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } +#line 3550 "grammar.c" /* yacc.c:1663 */ + break; case 99: -#line 1874 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_reduce_operation( - yyscanner, "<", (yyvsp[-2].expression), (yyvsp[0].expression))); +#line 1871 "grammar.y" /* yacc.c:1663 */ + { + fail_if_error(yr_parser_reduce_operation( + yyscanner, "<", (yyvsp[-2].expression), (yyvsp[0].expression))); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } -#line 3564 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } +#line 3561 "grammar.c" /* yacc.c:1663 */ + break; case 100: -#line 1881 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_reduce_operation( - yyscanner, ">", (yyvsp[-2].expression), (yyvsp[0].expression))); +#line 1878 "grammar.y" /* yacc.c:1663 */ + { + fail_if_error(yr_parser_reduce_operation( + yyscanner, ">", (yyvsp[-2].expression), (yyvsp[0].expression))); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } -#line 3575 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } +#line 3572 "grammar.c" /* yacc.c:1663 */ + break; case 101: -#line 1888 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_reduce_operation( - yyscanner, "<=", (yyvsp[-2].expression), (yyvsp[0].expression))); +#line 1885 "grammar.y" /* yacc.c:1663 */ + { + fail_if_error(yr_parser_reduce_operation( + yyscanner, "<=", (yyvsp[-2].expression), (yyvsp[0].expression))); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } -#line 3586 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } +#line 3583 "grammar.c" /* yacc.c:1663 */ + break; case 102: -#line 1895 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_reduce_operation( - yyscanner, ">=", (yyvsp[-2].expression), (yyvsp[0].expression))); +#line 1892 "grammar.y" /* yacc.c:1663 */ + { + fail_if_error(yr_parser_reduce_operation( + yyscanner, ">=", (yyvsp[-2].expression), (yyvsp[0].expression))); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } -#line 3597 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } +#line 3594 "grammar.c" /* yacc.c:1663 */ + break; case 103: -#line 1902 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_reduce_operation( - yyscanner, "==", (yyvsp[-2].expression), (yyvsp[0].expression))); +#line 1899 "grammar.y" /* yacc.c:1663 */ + { + fail_if_error(yr_parser_reduce_operation( + yyscanner, "==", (yyvsp[-2].expression), (yyvsp[0].expression))); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } -#line 3608 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } +#line 3605 "grammar.c" /* yacc.c:1663 */ + break; case 104: -#line 1909 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_reduce_operation( - yyscanner, "!=", (yyvsp[-2].expression), (yyvsp[0].expression))); +#line 1906 "grammar.y" /* yacc.c:1663 */ + { + fail_if_error(yr_parser_reduce_operation( + yyscanner, "!=", (yyvsp[-2].expression), (yyvsp[0].expression))); - (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; - } -#line 3619 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_BOOLEAN; + } +#line 3616 "grammar.c" /* yacc.c:1663 */ + break; case 105: -#line 1916 "grammar.y" /* yacc.c:1663 */ - { - (yyval.expression) = (yyvsp[0].expression); - } -#line 3627 "grammar.c" /* yacc.c:1663 */ - break; +#line 1913 "grammar.y" /* yacc.c:1663 */ + { + (yyval.expression) = (yyvsp[0].expression); + } +#line 3624 "grammar.c" /* yacc.c:1663 */ + break; case 106: -#line 1920 "grammar.y" /* yacc.c:1663 */ - { - (yyval.expression) = (yyvsp[-1].expression); - } -#line 3635 "grammar.c" /* yacc.c:1663 */ - break; +#line 1917 "grammar.y" /* yacc.c:1663 */ + { + (yyval.expression) = (yyvsp[-1].expression); + } +#line 3632 "grammar.c" /* yacc.c:1663 */ + break; case 107: -#line 1928 "grammar.y" /* yacc.c:1663 */ - { - int result = ERROR_SUCCESS; - - YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; - - if (yr_parser_lookup_loop_variable(yyscanner, (yyvsp[0].c_string), NULL) >= - 0) +#line 1925 "grammar.y" /* yacc.c:1663 */ { - yr_compiler_set_error_extra_info(compiler, (yyvsp[0].c_string)); - yr_free((yyvsp[0].c_string)); + int result = ERROR_SUCCESS; - result = ERROR_DUPLICATED_LOOP_IDENTIFIER; - } + YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; - fail_if_error(result); + if (yr_parser_lookup_loop_variable(yyscanner, (yyvsp[0].c_string), NULL) >= 0) + { + yr_compiler_set_error_extra_info(compiler, (yyvsp[0].c_string)); + yr_free((yyvsp[0].c_string)); - loop_ctx->vars[loop_ctx->vars_count++].identifier.ptr = (yyvsp[0].c_string); + result = ERROR_DUPLICATED_LOOP_IDENTIFIER; + } - assert(loop_ctx->vars_count <= YR_MAX_LOOP_VARS); - } -#line 3659 "grammar.c" /* yacc.c:1663 */ - break; + fail_if_error(result); + + loop_ctx->vars[loop_ctx->vars_count++].identifier.ptr = (yyvsp[0].c_string); + + assert(loop_ctx->vars_count <= YR_MAX_LOOP_VARS); + } +#line 3656 "grammar.c" /* yacc.c:1663 */ + break; case 108: -#line 1948 "grammar.y" /* yacc.c:1663 */ - { - int result = ERROR_SUCCESS; - - YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; - - if (loop_ctx->vars_count == YR_MAX_LOOP_VARS) +#line 1945 "grammar.y" /* yacc.c:1663 */ { - yr_compiler_set_error_extra_info(compiler, "too many loop variables"); - yr_free((yyvsp[0].c_string)); + int result = ERROR_SUCCESS; - result = ERROR_SYNTAX_ERROR; - } - else if ( - yr_parser_lookup_loop_variable(yyscanner, (yyvsp[0].c_string), NULL) >= - 0) - { - yr_compiler_set_error_extra_info(compiler, (yyvsp[0].c_string)); - yr_free((yyvsp[0].c_string)); + YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; - result = ERROR_DUPLICATED_LOOP_IDENTIFIER; - } + if (loop_ctx->vars_count == YR_MAX_LOOP_VARS) + { + yr_compiler_set_error_extra_info(compiler, "too many loop variables"); + yr_free((yyvsp[0].c_string)); - fail_if_error(result); + result = ERROR_SYNTAX_ERROR; + } + else if (yr_parser_lookup_loop_variable(yyscanner, (yyvsp[0].c_string), NULL) >= 0) + { + yr_compiler_set_error_extra_info(compiler, (yyvsp[0].c_string)); + yr_free((yyvsp[0].c_string)); - loop_ctx->vars[loop_ctx->vars_count++].identifier.ptr = (yyvsp[0].c_string); - } -#line 3688 "grammar.c" /* yacc.c:1663 */ - break; + result = ERROR_DUPLICATED_LOOP_IDENTIFIER; + } + + fail_if_error(result); + + loop_ctx->vars[loop_ctx->vars_count++].identifier.ptr = (yyvsp[0].c_string); + } +#line 3685 "grammar.c" /* yacc.c:1663 */ + break; case 109: -#line 1976 "grammar.y" /* yacc.c:1663 */ - { - YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; - - // Initially we assume that the identifier is from a non-iterable type, - // this will change later if it's iterable. - int result = ERROR_WRONG_TYPE; - - if ((yyvsp[0].expression).type == EXPRESSION_TYPE_OBJECT) +#line 1973 "grammar.y" /* yacc.c:1663 */ { - switch ((yyvsp[0].expression).value.object->type) - { - case OBJECT_TYPE_ARRAY: - // If iterating an array the loop must define a single variable - // that will hold the current item. If a different number of - // variables were defined that's an error. + YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; + + // Initially we assume that the identifier is from a non-iterable type, + // this will change later if it's iterable. + int result = ERROR_WRONG_TYPE; + + if ((yyvsp[0].expression).type == EXPRESSION_TYPE_OBJECT) + { + switch((yyvsp[0].expression).value.object->type) + { + case OBJECT_TYPE_ARRAY: + // If iterating an array the loop must define a single variable + // that will hold the current item. If a different number of + // variables were defined that's an error. + if (loop_ctx->vars_count == 1) + { + loop_ctx->vars[0].type = EXPRESSION_TYPE_OBJECT; + loop_ctx->vars[0].value.object = \ + object_as_array((yyvsp[0].expression).value.object)->prototype_item; + + result = yr_parser_emit(yyscanner, OP_ITER_START_ARRAY, NULL); + } + else + { + yr_compiler_set_error_extra_info_fmt( + compiler, + "iterator for \"%s\" yields a single item on each iteration" + ", but the loop expects %d", + expression_identifier((yyvsp[0].expression)), + loop_ctx->vars_count); + + result = ERROR_SYNTAX_ERROR; + } + break; + + case OBJECT_TYPE_DICTIONARY: + // If iterating a dictionary the loop must define exactly two + // variables, one for the key and another for the value . If a + // different number of variables were defined that's an error. + if (loop_ctx->vars_count == 2) + { + loop_ctx->vars[0].type = EXPRESSION_TYPE_STRING; + loop_ctx->vars[0].value.sized_string_ref = YR_ARENA_NULL_REF; + loop_ctx->vars[1].type = EXPRESSION_TYPE_OBJECT; + loop_ctx->vars[1].value.object = \ + object_as_array((yyvsp[0].expression).value.object)->prototype_item; + + result = yr_parser_emit(yyscanner, OP_ITER_START_DICT, NULL); + } + else + { + yr_compiler_set_error_extra_info_fmt( + compiler, + "iterator for \"%s\" yields a key,value pair item on each iteration", + expression_identifier((yyvsp[0].expression))); + + result = ERROR_SYNTAX_ERROR; + } + break; + } + } + + if (result == ERROR_WRONG_TYPE) + { + yr_compiler_set_error_extra_info_fmt( + compiler, + "identifier \"%s\" is not iterable", + expression_identifier((yyvsp[0].expression))); + } + + fail_if_error(result); + } +#line 3763 "grammar.c" /* yacc.c:1663 */ + break; + + case 110: +#line 2047 "grammar.y" /* yacc.c:1663 */ + { + int result = ERROR_SUCCESS; + + YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; + if (loop_ctx->vars_count == 1) { - loop_ctx->vars[0].type = EXPRESSION_TYPE_OBJECT; - loop_ctx->vars[0].value.object = - object_as_array((yyvsp[0].expression).value.object) - ->prototype_item; - - result = yr_parser_emit(yyscanner, OP_ITER_START_ARRAY, NULL); + loop_ctx->vars[0].type = EXPRESSION_TYPE_INTEGER; + loop_ctx->vars[0].value.integer = YR_UNDEFINED; } else { yr_compiler_set_error_extra_info_fmt( compiler, - "iterator for \"%s\" yields a single item on each iteration" + "iterator yields an integer on each iteration " ", but the loop expects %d", - expression_identifier((yyvsp[0].expression)), loop_ctx->vars_count); result = ERROR_SYNTAX_ERROR; } - break; - case OBJECT_TYPE_DICTIONARY: - // If iterating a dictionary the loop must define exactly two - // variables, one for the key and another for the value . If a - // different number of variables were defined that's an error. - if (loop_ctx->vars_count == 2) + fail_if_error(result); + } +#line 3791 "grammar.c" /* yacc.c:1663 */ + break; + + case 111: +#line 2075 "grammar.y" /* yacc.c:1663 */ + { + // $2 contains the number of integers in the enumeration + 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 3803 "grammar.c" /* yacc.c:1663 */ + break; + + case 112: +#line 2083 "grammar.y" /* yacc.c:1663 */ + { + fail_if_error(yr_parser_emit( + yyscanner, OP_ITER_START_INT_RANGE, NULL)); + } +#line 3812 "grammar.c" /* yacc.c:1663 */ + break; + + case 113: +#line 2092 "grammar.y" /* yacc.c:1663 */ + { + int result = ERROR_SUCCESS; + + if ((yyvsp[-3].expression).type != EXPRESSION_TYPE_INTEGER) { - loop_ctx->vars[0].type = EXPRESSION_TYPE_STRING; - loop_ctx->vars[0].value.sized_string_ref = YR_ARENA_NULL_REF; - loop_ctx->vars[1].type = EXPRESSION_TYPE_OBJECT; - loop_ctx->vars[1].value.object = - object_as_array((yyvsp[0].expression).value.object) - ->prototype_item; + yr_compiler_set_error_extra_info( + compiler, "wrong type for range's lower bound"); + result = ERROR_WRONG_TYPE; + } - result = yr_parser_emit(yyscanner, OP_ITER_START_DICT, NULL); + if ((yyvsp[-1].expression).type != EXPRESSION_TYPE_INTEGER) + { + yr_compiler_set_error_extra_info( + compiler, "wrong type for range's upper bound"); + result = ERROR_WRONG_TYPE; + } + + fail_if_error(result); + } +#line 3836 "grammar.c" /* yacc.c:1663 */ + break; + + case 114: +#line 2116 "grammar.y" /* yacc.c:1663 */ + { + int result = ERROR_SUCCESS; + + if ((yyvsp[0].expression).type != EXPRESSION_TYPE_INTEGER) + { + yr_compiler_set_error_extra_info( + compiler, "wrong type for enumeration item"); + result = ERROR_WRONG_TYPE; + } + + fail_if_error(result); + + (yyval.integer) = 1; + } +#line 3855 "grammar.c" /* yacc.c:1663 */ + break; + + case 115: +#line 2131 "grammar.y" /* yacc.c:1663 */ + { + int result = ERROR_SUCCESS; + + if ((yyvsp[0].expression).type != EXPRESSION_TYPE_INTEGER) + { + yr_compiler_set_error_extra_info( + compiler, "wrong type for enumeration item"); + result = ERROR_WRONG_TYPE; + } + + fail_if_error(result); + + (yyval.integer) = (yyvsp[-2].integer) + 1; + } +#line 3874 "grammar.c" /* yacc.c:1663 */ + break; + + case 116: +#line 2150 "grammar.y" /* yacc.c:1663 */ + { + // Push end-of-list marker + yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); + } +#line 3883 "grammar.c" /* yacc.c:1663 */ + break; + + case 118: +#line 2156 "grammar.y" /* yacc.c:1663 */ + { + fail_if_error(yr_parser_emit_push_const(yyscanner, YR_UNDEFINED)); + + fail_if_error(yr_parser_emit_pushes_for_strings( + yyscanner, "$*")); + } +#line 3894 "grammar.c" /* yacc.c:1663 */ + break; + + case 121: +#line 2173 "grammar.y" /* yacc.c:1663 */ + { + int result = yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[0].c_string)); + yr_free((yyvsp[0].c_string)); + + fail_if_error(result); + } +#line 3905 "grammar.c" /* yacc.c:1663 */ + break; + + case 122: +#line 2180 "grammar.y" /* yacc.c:1663 */ + { + int result = yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[0].c_string)); + yr_free((yyvsp[0].c_string)); + + fail_if_error(result); + } +#line 3916 "grammar.c" /* yacc.c:1663 */ + break; + + case 123: +#line 2191 "grammar.y" /* yacc.c:1663 */ + { + (yyval.integer) = FOR_EXPRESSION_ANY; + } +#line 3924 "grammar.c" /* yacc.c:1663 */ + break; + + case 124: +#line 2195 "grammar.y" /* yacc.c:1663 */ + { + yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); + (yyval.integer) = FOR_EXPRESSION_ALL; + } +#line 3933 "grammar.c" /* yacc.c:1663 */ + break; + + case 125: +#line 2200 "grammar.y" /* yacc.c:1663 */ + { + yr_parser_emit_push_const(yyscanner, 1); + (yyval.integer) = FOR_EXPRESSION_ANY; + } +#line 3942 "grammar.c" /* yacc.c:1663 */ + break; + + case 126: +#line 2209 "grammar.y" /* yacc.c:1663 */ + { + (yyval.expression) = (yyvsp[-1].expression); + } +#line 3950 "grammar.c" /* yacc.c:1663 */ + break; + + case 127: +#line 2213 "grammar.y" /* yacc.c:1663 */ + { + fail_if_error(yr_parser_emit( + yyscanner, OP_FILESIZE, NULL)); + + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).value.integer = YR_UNDEFINED; + } +#line 3962 "grammar.c" /* yacc.c:1663 */ + break; + + case 128: +#line 2221 "grammar.y" /* yacc.c:1663 */ + { + yywarning(yyscanner, + "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " + "function from PE module instead."); + + fail_if_error(yr_parser_emit( + yyscanner, OP_ENTRYPOINT, NULL)); + + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).value.integer = YR_UNDEFINED; + } +#line 3978 "grammar.c" /* yacc.c:1663 */ + break; + + case 129: +#line 2233 "grammar.y" /* yacc.c:1663 */ + { + check_type((yyvsp[-1].expression), EXPRESSION_TYPE_INTEGER, "intXXXX or uintXXXX"); + + // _INTEGER_FUNCTION_ could be any of int8, int16, int32, uint8, + // uint32, etc. $1 contains an index that added to OP_READ_INT results + // in the proper OP_INTXX opcode. + + fail_if_error(yr_parser_emit( + yyscanner, (uint8_t) (OP_READ_INT + (yyvsp[-3].integer)), NULL)); + + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).value.integer = YR_UNDEFINED; + } +#line 3996 "grammar.c" /* yacc.c:1663 */ + break; + + case 130: +#line 2247 "grammar.y" /* yacc.c:1663 */ + { + 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 4007 "grammar.c" /* yacc.c:1663 */ + break; + + case 131: +#line 2254 "grammar.y" /* yacc.c:1663 */ + { + fail_if_error(yr_parser_emit_with_arg_double( + yyscanner, OP_PUSH, (yyvsp[0].double_), NULL, NULL)); + + (yyval.expression).type = EXPRESSION_TYPE_FLOAT; + } +#line 4018 "grammar.c" /* yacc.c:1663 */ + break; + + case 132: +#line 2261 "grammar.y" /* yacc.c:1663 */ + { + YR_ARENA_REF ref; + + int result = _yr_compiler_store_data( + compiler, + (yyvsp[0].sized_string), + (yyvsp[0].sized_string)->length + sizeof(SIZED_STRING), + &ref); + + yr_free((yyvsp[0].sized_string)); + + if (result == ERROR_SUCCESS) + result = yr_parser_emit_with_arg_reloc( + yyscanner, + OP_PUSH, + yr_arena_ref_to_ptr(compiler->arena, &ref), + NULL, + NULL); + + fail_if_error(result); + + (yyval.expression).type = EXPRESSION_TYPE_STRING; + (yyval.expression).value.sized_string_ref = ref; + } +#line 4047 "grammar.c" /* yacc.c:1663 */ + break; + + case 133: +#line 2286 "grammar.y" /* yacc.c:1663 */ + { + int result = yr_parser_reduce_string_identifier( + yyscanner, (yyvsp[0].c_string), OP_COUNT, YR_UNDEFINED); + + yr_free((yyvsp[0].c_string)); + + fail_if_error(result); + + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).value.integer = YR_UNDEFINED; + } +#line 4063 "grammar.c" /* yacc.c:1663 */ + break; + + case 134: +#line 2298 "grammar.y" /* yacc.c:1663 */ + { + int result = yr_parser_reduce_string_identifier( + yyscanner, (yyvsp[-3].c_string), OP_OFFSET, YR_UNDEFINED); + + yr_free((yyvsp[-3].c_string)); + + fail_if_error(result); + + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).value.integer = YR_UNDEFINED; + } +#line 4079 "grammar.c" /* yacc.c:1663 */ + break; + + case 135: +#line 2310 "grammar.y" /* yacc.c:1663 */ + { + int result = yr_parser_emit_push_const(yyscanner, 1); + + if (result == ERROR_SUCCESS) + result = yr_parser_reduce_string_identifier( + yyscanner, (yyvsp[0].c_string), OP_OFFSET, YR_UNDEFINED); + + yr_free((yyvsp[0].c_string)); + + fail_if_error(result); + + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).value.integer = YR_UNDEFINED; + } +#line 4098 "grammar.c" /* yacc.c:1663 */ + break; + + case 136: +#line 2325 "grammar.y" /* yacc.c:1663 */ + { + int result = yr_parser_reduce_string_identifier( + yyscanner, (yyvsp[-3].c_string), OP_LENGTH, YR_UNDEFINED); + + yr_free((yyvsp[-3].c_string)); + + fail_if_error(result); + + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).value.integer = YR_UNDEFINED; + } +#line 4114 "grammar.c" /* yacc.c:1663 */ + break; + + case 137: +#line 2337 "grammar.y" /* yacc.c:1663 */ + { + int result = yr_parser_emit_push_const(yyscanner, 1); + + if (result == ERROR_SUCCESS) + result = yr_parser_reduce_string_identifier( + yyscanner, (yyvsp[0].c_string), OP_LENGTH, YR_UNDEFINED); + + yr_free((yyvsp[0].c_string)); + + fail_if_error(result); + + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).value.integer = YR_UNDEFINED; + } +#line 4133 "grammar.c" /* yacc.c:1663 */ + break; + + case 138: +#line 2352 "grammar.y" /* yacc.c:1663 */ + { + 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: + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).value.integer = YR_UNDEFINED; + break; + case OBJECT_TYPE_FLOAT: + (yyval.expression).type = EXPRESSION_TYPE_FLOAT; + break; + case OBJECT_TYPE_STRING: + (yyval.expression).type = EXPRESSION_TYPE_STRING; + (yyval.expression).value.sized_string_ref = YR_ARENA_NULL_REF; + 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 { - yr_compiler_set_error_extra_info_fmt( - compiler, - "iterator for \"%s\" yields a key,value pair item on each " - "iteration", - expression_identifier((yyvsp[0].expression))); - - result = ERROR_SYNTAX_ERROR; + (yyval.expression) = (yyvsp[0].expression); } - break; + + fail_if_error(result); } - } - - if (result == ERROR_WRONG_TYPE) - { - yr_compiler_set_error_extra_info_fmt( - compiler, - "identifier \"%s\" is not iterable", - expression_identifier((yyvsp[0].expression))); - } - - fail_if_error(result); - } -#line 3766 "grammar.c" /* yacc.c:1663 */ - break; - - case 110: -#line 2050 "grammar.y" /* yacc.c:1663 */ - { - int result = ERROR_SUCCESS; - - YR_LOOP_CONTEXT* loop_ctx = &compiler->loop[compiler->loop_index]; - - if (loop_ctx->vars_count == 1) - { - loop_ctx->vars[0].type = EXPRESSION_TYPE_INTEGER; - loop_ctx->vars[0].value.integer = YR_UNDEFINED; - } - else - { - yr_compiler_set_error_extra_info_fmt( - compiler, - "iterator yields an integer on each iteration " - ", but the loop expects %d", - loop_ctx->vars_count); - - result = ERROR_SYNTAX_ERROR; - } - - fail_if_error(result); - } -#line 3794 "grammar.c" /* yacc.c:1663 */ - break; - - case 111: -#line 2078 "grammar.y" /* yacc.c:1663 */ - { - // $2 contains the number of integers in the enumeration - 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 3806 "grammar.c" /* yacc.c:1663 */ - break; - - case 112: -#line 2086 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_emit(yyscanner, OP_ITER_START_INT_RANGE, NULL)); - } -#line 3815 "grammar.c" /* yacc.c:1663 */ - break; - - case 113: -#line 2095 "grammar.y" /* yacc.c:1663 */ - { - int result = ERROR_SUCCESS; - - if ((yyvsp[-3].expression).type != EXPRESSION_TYPE_INTEGER) - { - yr_compiler_set_error_extra_info( - compiler, "wrong type for range's lower bound"); - result = ERROR_WRONG_TYPE; - } - - if ((yyvsp[-1].expression).type != EXPRESSION_TYPE_INTEGER) - { - yr_compiler_set_error_extra_info( - compiler, "wrong type for range's upper bound"); - result = ERROR_WRONG_TYPE; - } - - fail_if_error(result); - } -#line 3839 "grammar.c" /* yacc.c:1663 */ - break; - - case 114: -#line 2119 "grammar.y" /* yacc.c:1663 */ - { - int result = ERROR_SUCCESS; - - if ((yyvsp[0].expression).type != EXPRESSION_TYPE_INTEGER) - { - yr_compiler_set_error_extra_info( - compiler, "wrong type for enumeration item"); - result = ERROR_WRONG_TYPE; - } - - fail_if_error(result); - - (yyval.integer) = 1; - } -#line 3858 "grammar.c" /* yacc.c:1663 */ - break; - - case 115: -#line 2134 "grammar.y" /* yacc.c:1663 */ - { - int result = ERROR_SUCCESS; - - if ((yyvsp[0].expression).type != EXPRESSION_TYPE_INTEGER) - { - yr_compiler_set_error_extra_info( - compiler, "wrong type for enumeration item"); - result = ERROR_WRONG_TYPE; - } - - fail_if_error(result); - - (yyval.integer) = (yyvsp[-2].integer) + 1; - } -#line 3877 "grammar.c" /* yacc.c:1663 */ - break; - - case 116: -#line 2153 "grammar.y" /* yacc.c:1663 */ - { - // Push end-of-list marker - yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); - } -#line 3886 "grammar.c" /* yacc.c:1663 */ - break; - - case 118: -#line 2159 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_emit_push_const(yyscanner, YR_UNDEFINED)); - - fail_if_error(yr_parser_emit_pushes_for_strings(yyscanner, "$*")); - } -#line 3897 "grammar.c" /* yacc.c:1663 */ - break; - - case 121: -#line 2176 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_emit_pushes_for_strings( - yyscanner, (yyvsp[0].c_string)); - yr_free((yyvsp[0].c_string)); - - fail_if_error(result); - } -#line 3908 "grammar.c" /* yacc.c:1663 */ - break; - - case 122: -#line 2183 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_emit_pushes_for_strings( - yyscanner, (yyvsp[0].c_string)); - yr_free((yyvsp[0].c_string)); - - fail_if_error(result); - } -#line 3919 "grammar.c" /* yacc.c:1663 */ - break; - - case 123: -#line 2194 "grammar.y" /* yacc.c:1663 */ - { - (yyval.integer) = FOR_EXPRESSION_ANY; - } -#line 3927 "grammar.c" /* yacc.c:1663 */ - break; - - case 124: -#line 2198 "grammar.y" /* yacc.c:1663 */ - { - yr_parser_emit_push_const(yyscanner, YR_UNDEFINED); - (yyval.integer) = FOR_EXPRESSION_ALL; - } -#line 3936 "grammar.c" /* yacc.c:1663 */ - break; - - case 125: -#line 2203 "grammar.y" /* yacc.c:1663 */ - { - yr_parser_emit_push_const(yyscanner, 1); - (yyval.integer) = FOR_EXPRESSION_ANY; - } -#line 3945 "grammar.c" /* yacc.c:1663 */ - break; - - case 126: -#line 2212 "grammar.y" /* yacc.c:1663 */ - { - (yyval.expression) = (yyvsp[-1].expression); - } -#line 3953 "grammar.c" /* yacc.c:1663 */ - break; - - case 127: -#line 2216 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_emit(yyscanner, OP_FILESIZE, NULL)); - - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - (yyval.expression).value.integer = YR_UNDEFINED; - } -#line 3965 "grammar.c" /* yacc.c:1663 */ - break; - - case 128: -#line 2224 "grammar.y" /* yacc.c:1663 */ - { - yywarning( - yyscanner, - "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " - "function from PE module instead."); - - fail_if_error(yr_parser_emit(yyscanner, OP_ENTRYPOINT, NULL)); - - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - (yyval.expression).value.integer = YR_UNDEFINED; - } -#line 3981 "grammar.c" /* yacc.c:1663 */ - break; - - case 129: -#line 2236 "grammar.y" /* yacc.c:1663 */ - { - check_type( - (yyvsp[-1].expression), EXPRESSION_TYPE_INTEGER, "intXXXX or uintXXXX"); - - // _INTEGER_FUNCTION_ could be any of int8, int16, int32, uint8, - // uint32, etc. $1 contains an index that added to OP_READ_INT results - // in the proper OP_INTXX opcode. - - fail_if_error(yr_parser_emit( - yyscanner, (uint8_t)(OP_READ_INT + (yyvsp[-3].integer)), NULL)); - - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - (yyval.expression).value.integer = YR_UNDEFINED; - } -#line 3999 "grammar.c" /* yacc.c:1663 */ - break; - - case 130: -#line 2250 "grammar.y" /* yacc.c:1663 */ - { - 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 4010 "grammar.c" /* yacc.c:1663 */ - break; - - case 131: -#line 2257 "grammar.y" /* yacc.c:1663 */ - { - fail_if_error(yr_parser_emit_with_arg_double( - yyscanner, OP_PUSH, (yyvsp[0].double_), NULL, NULL)); - - (yyval.expression).type = EXPRESSION_TYPE_FLOAT; - } -#line 4021 "grammar.c" /* yacc.c:1663 */ - break; - - case 132: -#line 2264 "grammar.y" /* yacc.c:1663 */ - { - YR_ARENA_REF ref; - - int result = _yr_compiler_store_data( - compiler, - (yyvsp[0].sized_string), - (yyvsp[0].sized_string)->length + sizeof(SIZED_STRING), - &ref); - - yr_free((yyvsp[0].sized_string)); - - if (result == ERROR_SUCCESS) - result = yr_parser_emit_with_arg_reloc( - yyscanner, - OP_PUSH, - yr_arena_ref_to_ptr(compiler->arena, &ref), - NULL, - NULL); - - fail_if_error(result); - - (yyval.expression).type = EXPRESSION_TYPE_STRING; - (yyval.expression).value.sized_string_ref = ref; - } -#line 4050 "grammar.c" /* yacc.c:1663 */ - break; - - case 133: -#line 2289 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_string_identifier( - yyscanner, (yyvsp[0].c_string), OP_COUNT, YR_UNDEFINED); - - yr_free((yyvsp[0].c_string)); - - fail_if_error(result); - - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - (yyval.expression).value.integer = YR_UNDEFINED; - } -#line 4066 "grammar.c" /* yacc.c:1663 */ - break; - - case 134: -#line 2301 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_string_identifier( - yyscanner, (yyvsp[-3].c_string), OP_OFFSET, YR_UNDEFINED); - - yr_free((yyvsp[-3].c_string)); - - fail_if_error(result); - - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - (yyval.expression).value.integer = YR_UNDEFINED; - } -#line 4082 "grammar.c" /* yacc.c:1663 */ - break; - - case 135: -#line 2313 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_emit_push_const(yyscanner, 1); - - if (result == ERROR_SUCCESS) - result = yr_parser_reduce_string_identifier( - yyscanner, (yyvsp[0].c_string), OP_OFFSET, YR_UNDEFINED); - - yr_free((yyvsp[0].c_string)); - - fail_if_error(result); - - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - (yyval.expression).value.integer = YR_UNDEFINED; - } -#line 4101 "grammar.c" /* yacc.c:1663 */ - break; - - case 136: -#line 2328 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_string_identifier( - yyscanner, (yyvsp[-3].c_string), OP_LENGTH, YR_UNDEFINED); - - yr_free((yyvsp[-3].c_string)); - - fail_if_error(result); - - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - (yyval.expression).value.integer = YR_UNDEFINED; - } -#line 4117 "grammar.c" /* yacc.c:1663 */ - break; - - case 137: -#line 2340 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_emit_push_const(yyscanner, 1); - - if (result == ERROR_SUCCESS) - result = yr_parser_reduce_string_identifier( - yyscanner, (yyvsp[0].c_string), OP_LENGTH, YR_UNDEFINED); - - yr_free((yyvsp[0].c_string)); - - fail_if_error(result); - - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - (yyval.expression).value.integer = YR_UNDEFINED; - } -#line 4136 "grammar.c" /* yacc.c:1663 */ - break; - - case 138: -#line 2355 "grammar.y" /* yacc.c:1663 */ - { - 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: - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - (yyval.expression).value.integer = YR_UNDEFINED; - break; - case OBJECT_TYPE_FLOAT: - (yyval.expression).type = EXPRESSION_TYPE_FLOAT; - break; - case OBJECT_TYPE_STRING: - (yyval.expression).type = EXPRESSION_TYPE_STRING; - (yyval.expression).value.sized_string_ref = YR_ARENA_NULL_REF; - 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 4183 "grammar.c" /* yacc.c:1663 */ - break; +#line 4180 "grammar.c" /* yacc.c:1663 */ + break; case 139: -#line 2398 "grammar.y" /* yacc.c:1663 */ - { - int result = ERROR_SUCCESS; - - check_type( - (yyvsp[0].expression), - EXPRESSION_TYPE_INTEGER | EXPRESSION_TYPE_FLOAT, - "-"); - - if ((yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER) +#line 2395 "grammar.y" /* yacc.c:1663 */ { - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - (yyval.expression).value.integer = - ((yyvsp[0].expression).value.integer == YR_UNDEFINED) - ? YR_UNDEFINED - : -((yyvsp[0].expression).value.integer); - result = yr_parser_emit(yyscanner, OP_INT_MINUS, NULL); - } - else if ((yyvsp[0].expression).type == EXPRESSION_TYPE_FLOAT) - { - (yyval.expression).type = EXPRESSION_TYPE_FLOAT; - result = yr_parser_emit(yyscanner, OP_DBL_MINUS, NULL); - } + int result = ERROR_SUCCESS; - fail_if_error(result); - } -#line 4208 "grammar.c" /* yacc.c:1663 */ - break; + check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER | EXPRESSION_TYPE_FLOAT, "-"); + + if ((yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER) + { + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).value.integer = ((yyvsp[0].expression).value.integer == YR_UNDEFINED) ? + YR_UNDEFINED : -((yyvsp[0].expression).value.integer); + result = yr_parser_emit(yyscanner, OP_INT_MINUS, NULL); + } + else if ((yyvsp[0].expression).type == EXPRESSION_TYPE_FLOAT) + { + (yyval.expression).type = EXPRESSION_TYPE_FLOAT; + result = yr_parser_emit(yyscanner, OP_DBL_MINUS, NULL); + } + + fail_if_error(result); + } +#line 4205 "grammar.c" /* yacc.c:1663 */ + break; case 140: -#line 2419 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_operation( - yyscanner, "+", (yyvsp[-2].expression), (yyvsp[0].expression)); - - if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER && - (yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER) +#line 2416 "grammar.y" /* yacc.c:1663 */ { - int64_t i1 = (yyvsp[-2].expression).value.integer; - int64_t i2 = (yyvsp[0].expression).value.integer; + int result = yr_parser_reduce_operation( + yyscanner, "+", (yyvsp[-2].expression), (yyvsp[0].expression)); - if (!IS_UNDEFINED(i1) && !IS_UNDEFINED(i2) && - ((i2 > 0 && i1 > INT64_MAX - i2) || (i2 < 0 && i1 < INT64_MIN - i2))) - { - yr_compiler_set_error_extra_info_fmt( - compiler, "%" PRId64 " + %" PRId64, i1, i2); + if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER && + (yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER) + { + int64_t i1 = (yyvsp[-2].expression).value.integer; + int64_t i2 = (yyvsp[0].expression).value.integer; - result = ERROR_INTEGER_OVERFLOW; + if (!IS_UNDEFINED(i1) && !IS_UNDEFINED(i2) && + ( + (i2 > 0 && i1 > INT64_MAX - i2) || + (i2 < 0 && i1 < INT64_MIN - i2) + )) + { + yr_compiler_set_error_extra_info_fmt( + compiler, "%" PRId64 " + %" PRId64, i1, i2); + + result = ERROR_INTEGER_OVERFLOW; + } + else + { + (yyval.expression).value.integer = OPERATION(+, i1, i2); + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + } + } + else + { + (yyval.expression).type = EXPRESSION_TYPE_FLOAT; + } + + fail_if_error(result); } - else - { - (yyval.expression).value.integer = OPERATION(+, i1, i2); - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - } - } - else - { - (yyval.expression).type = EXPRESSION_TYPE_FLOAT; - } - - fail_if_error(result); - } -#line 4247 "grammar.c" /* yacc.c:1663 */ - break; +#line 4244 "grammar.c" /* yacc.c:1663 */ + break; case 141: -#line 2454 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_operation( - yyscanner, "-", (yyvsp[-2].expression), (yyvsp[0].expression)); - - if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER && - (yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER) +#line 2451 "grammar.y" /* yacc.c:1663 */ { - int64_t i1 = (yyvsp[-2].expression).value.integer; - int64_t i2 = (yyvsp[0].expression).value.integer; + int result = yr_parser_reduce_operation( + yyscanner, "-", (yyvsp[-2].expression), (yyvsp[0].expression)); - if (!IS_UNDEFINED(i1) && !IS_UNDEFINED(i2) && - ((i2 < 0 && i1 > INT64_MAX + i2) || (i2 > 0 && i1 < INT64_MIN + i2))) - { - yr_compiler_set_error_extra_info_fmt( - compiler, "%" PRId64 " - %" PRId64, i1, i2); + if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER && + (yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER) + { + int64_t i1 = (yyvsp[-2].expression).value.integer; + int64_t i2 = (yyvsp[0].expression).value.integer; - result = ERROR_INTEGER_OVERFLOW; + if (!IS_UNDEFINED(i1) && !IS_UNDEFINED(i2) && + ( + (i2 < 0 && i1 > INT64_MAX + i2) || + (i2 > 0 && i1 < INT64_MIN + i2) + )) + { + yr_compiler_set_error_extra_info_fmt( + compiler, "%" PRId64 " - %" PRId64, i1, i2); + + result = ERROR_INTEGER_OVERFLOW; + } + else + { + (yyval.expression).value.integer = OPERATION(-, i1, i2); + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + } + } + else + { + (yyval.expression).type = EXPRESSION_TYPE_FLOAT; + } + + fail_if_error(result); } - else - { - (yyval.expression).value.integer = OPERATION(-, i1, i2); - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - } - } - else - { - (yyval.expression).type = EXPRESSION_TYPE_FLOAT; - } - - fail_if_error(result); - } -#line 4286 "grammar.c" /* yacc.c:1663 */ - break; +#line 4283 "grammar.c" /* yacc.c:1663 */ + break; case 142: -#line 2489 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_operation( - yyscanner, "*", (yyvsp[-2].expression), (yyvsp[0].expression)); - - if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER && - (yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER) +#line 2486 "grammar.y" /* yacc.c:1663 */ { - int64_t i1 = (yyvsp[-2].expression).value.integer; - int64_t i2 = (yyvsp[0].expression).value.integer; + int result = yr_parser_reduce_operation( + yyscanner, "*", (yyvsp[-2].expression), (yyvsp[0].expression)); - if (!IS_UNDEFINED(i1) && !IS_UNDEFINED(i2) && - (i2 != 0 && llabs(i1) > INT64_MAX / llabs(i2))) - { - yr_compiler_set_error_extra_info_fmt( - compiler, "%" PRId64 " * %" PRId64, i1, i2); + if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER && + (yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER) + { + int64_t i1 = (yyvsp[-2].expression).value.integer; + int64_t i2 = (yyvsp[0].expression).value.integer; - result = ERROR_INTEGER_OVERFLOW; + if (!IS_UNDEFINED(i1) && !IS_UNDEFINED(i2) && + ( + i2 != 0 && llabs(i1) > INT64_MAX / llabs(i2) + )) + { + yr_compiler_set_error_extra_info_fmt( + compiler, "%" PRId64 " * %" PRId64, i1, i2); + + result = ERROR_INTEGER_OVERFLOW; + } + else + { + (yyval.expression).value.integer = OPERATION(*, i1, i2); + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + } + } + else + { + (yyval.expression).type = EXPRESSION_TYPE_FLOAT; + } + + fail_if_error(result); } - else - { - (yyval.expression).value.integer = OPERATION(*, i1, i2); - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - } - } - else - { - (yyval.expression).type = EXPRESSION_TYPE_FLOAT; - } - - fail_if_error(result); - } -#line 4324 "grammar.c" /* yacc.c:1663 */ - break; +#line 4321 "grammar.c" /* yacc.c:1663 */ + break; case 143: -#line 2523 "grammar.y" /* yacc.c:1663 */ - { - int result = yr_parser_reduce_operation( - yyscanner, "\\", (yyvsp[-2].expression), (yyvsp[0].expression)); - - if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER && - (yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER) +#line 2520 "grammar.y" /* yacc.c:1663 */ { - if ((yyvsp[0].expression).value.integer != 0) - { - (yyval.expression).value.integer = OPERATION( - /, - (yyvsp[-2].expression).value.integer, - (yyvsp[0].expression).value.integer); - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - } - else - { - result = ERROR_DIVISION_BY_ZERO; - } - } - else - { - (yyval.expression).type = EXPRESSION_TYPE_FLOAT; - } + int result = yr_parser_reduce_operation( + yyscanner, "\\", (yyvsp[-2].expression), (yyvsp[0].expression)); - fail_if_error(result); - } -#line 4353 "grammar.c" /* yacc.c:1663 */ - break; + if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER && + (yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER) + { + if ((yyvsp[0].expression).value.integer != 0) + { + (yyval.expression).value.integer = OPERATION(/, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer); + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + } + else + { + result = ERROR_DIVISION_BY_ZERO; + } + } + else + { + (yyval.expression).type = EXPRESSION_TYPE_FLOAT; + } + + fail_if_error(result); + } +#line 4350 "grammar.c" /* yacc.c:1663 */ + break; case 144: -#line 2548 "grammar.y" /* yacc.c:1663 */ - { - check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "%"); - check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "%"); - - fail_if_error(yr_parser_emit(yyscanner, OP_MOD, NULL)); - - if ((yyvsp[0].expression).value.integer != 0) +#line 2545 "grammar.y" /* yacc.c:1663 */ { - (yyval.expression).value.integer = OPERATION( - %, - (yyvsp[-2].expression).value.integer, - (yyvsp[0].expression).value.integer); - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - } - else - { - fail_if_error(ERROR_DIVISION_BY_ZERO); - } - } -#line 4374 "grammar.c" /* yacc.c:1663 */ - break; + check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "%"); + check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "%"); + + fail_if_error(yr_parser_emit(yyscanner, OP_MOD, NULL)); + + if ((yyvsp[0].expression).value.integer != 0) + { + (yyval.expression).value.integer = OPERATION(%, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer); + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + } + else + { + fail_if_error(ERROR_DIVISION_BY_ZERO); + } + } +#line 4371 "grammar.c" /* yacc.c:1663 */ + break; case 145: -#line 2565 "grammar.y" /* yacc.c:1663 */ - { - check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); - check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); +#line 2562 "grammar.y" /* yacc.c:1663 */ + { + check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); + check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); - fail_if_error(yr_parser_emit(yyscanner, OP_BITWISE_XOR, NULL)); + fail_if_error(yr_parser_emit(yyscanner, OP_BITWISE_XOR, NULL)); - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - (yyval.expression).value.integer = OPERATION( - ^, - (yyvsp[-2].expression).value.integer, - (yyvsp[0].expression).value.integer); - } -#line 4388 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).value.integer = OPERATION(^, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer); + } +#line 4385 "grammar.c" /* yacc.c:1663 */ + break; case 146: -#line 2575 "grammar.y" /* yacc.c:1663 */ - { - check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); - check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); +#line 2572 "grammar.y" /* yacc.c:1663 */ + { + check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^"); + check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^"); - fail_if_error(yr_parser_emit(yyscanner, OP_BITWISE_AND, NULL)); + fail_if_error(yr_parser_emit(yyscanner, OP_BITWISE_AND, NULL)); - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - (yyval.expression).value.integer = OPERATION(&, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer); - } -#line 4402 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).value.integer = OPERATION(&, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer); + } +#line 4399 "grammar.c" /* yacc.c:1663 */ + break; case 147: -#line 2585 "grammar.y" /* yacc.c:1663 */ - { - check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "|"); - check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "|"); +#line 2582 "grammar.y" /* yacc.c:1663 */ + { + check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "|"); + check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "|"); - fail_if_error(yr_parser_emit(yyscanner, OP_BITWISE_OR, NULL)); + fail_if_error(yr_parser_emit(yyscanner, OP_BITWISE_OR, NULL)); - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - (yyval.expression).value.integer = OPERATION( - |, - (yyvsp[-2].expression).value.integer, - (yyvsp[0].expression).value.integer); - } -#line 4416 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).value.integer = OPERATION(|, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer); + } +#line 4413 "grammar.c" /* yacc.c:1663 */ + break; case 148: -#line 2595 "grammar.y" /* yacc.c:1663 */ - { - check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "~"); +#line 2592 "grammar.y" /* yacc.c:1663 */ + { + check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "~"); - fail_if_error(yr_parser_emit(yyscanner, OP_BITWISE_NOT, NULL)); + fail_if_error(yr_parser_emit(yyscanner, OP_BITWISE_NOT, NULL)); - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - (yyval.expression).value.integer = - ((yyvsp[0].expression).value.integer == YR_UNDEFINED) - ? YR_UNDEFINED - : ~((yyvsp[0].expression).value.integer); - } -#line 4430 "grammar.c" /* yacc.c:1663 */ - break; + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).value.integer = ((yyvsp[0].expression).value.integer == YR_UNDEFINED) ? + YR_UNDEFINED : ~((yyvsp[0].expression).value.integer); + } +#line 4427 "grammar.c" /* yacc.c:1663 */ + break; case 149: -#line 2605 "grammar.y" /* yacc.c:1663 */ - { - int result; +#line 2602 "grammar.y" /* yacc.c:1663 */ + { + int result; - check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "<<"); - check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "<<"); + check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "<<"); + check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "<<"); - result = yr_parser_emit(yyscanner, OP_SHL, NULL); + result = yr_parser_emit(yyscanner, OP_SHL, NULL); - if (!IS_UNDEFINED((yyvsp[0].expression).value.integer) && - (yyvsp[0].expression).value.integer < 0) - result = ERROR_INVALID_OPERAND; - else if ( - !IS_UNDEFINED((yyvsp[0].expression).value.integer) && - (yyvsp[0].expression).value.integer >= 64) - (yyval.expression).value.integer = 0; - else - (yyval.expression).value.integer = OPERATION( - <<, - (yyvsp[-2].expression).value.integer, - (yyvsp[0].expression).value.integer); + if (!IS_UNDEFINED((yyvsp[0].expression).value.integer) && (yyvsp[0].expression).value.integer < 0) + result = ERROR_INVALID_OPERAND; + else if (!IS_UNDEFINED((yyvsp[0].expression).value.integer) && (yyvsp[0].expression).value.integer >= 64) + (yyval.expression).value.integer = 0; + else + (yyval.expression).value.integer = OPERATION(<<, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer); - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - fail_if_error(result); - } -#line 4454 "grammar.c" /* yacc.c:1663 */ - break; + fail_if_error(result); + } +#line 4451 "grammar.c" /* yacc.c:1663 */ + break; case 150: -#line 2625 "grammar.y" /* yacc.c:1663 */ - { - int result; +#line 2622 "grammar.y" /* yacc.c:1663 */ + { + int result; - check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, ">>"); - check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, ">>"); + check_type((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, ">>"); + check_type((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, ">>"); - result = yr_parser_emit(yyscanner, OP_SHR, NULL); + result = yr_parser_emit(yyscanner, OP_SHR, NULL); - if (!IS_UNDEFINED((yyvsp[0].expression).value.integer) && - (yyvsp[0].expression).value.integer < 0) - result = ERROR_INVALID_OPERAND; - else if ( - !IS_UNDEFINED((yyvsp[0].expression).value.integer) && - (yyvsp[0].expression).value.integer >= 64) - (yyval.expression).value.integer = 0; - else - (yyval.expression).value.integer = OPERATION( - <<, - (yyvsp[-2].expression).value.integer, - (yyvsp[0].expression).value.integer); + if (!IS_UNDEFINED((yyvsp[0].expression).value.integer) && (yyvsp[0].expression).value.integer < 0) + result = ERROR_INVALID_OPERAND; + else if (!IS_UNDEFINED((yyvsp[0].expression).value.integer) && (yyvsp[0].expression).value.integer >= 64) + (yyval.expression).value.integer = 0; + else + (yyval.expression).value.integer = OPERATION(<<, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer); - (yyval.expression).type = EXPRESSION_TYPE_INTEGER; + (yyval.expression).type = EXPRESSION_TYPE_INTEGER; - fail_if_error(result); - } -#line 4478 "grammar.c" /* yacc.c:1663 */ - break; + fail_if_error(result); + } +#line 4475 "grammar.c" /* yacc.c:1663 */ + break; case 151: -#line 2645 "grammar.y" /* yacc.c:1663 */ - { - (yyval.expression) = (yyvsp[0].expression); - } -#line 4486 "grammar.c" /* yacc.c:1663 */ - break; - - -#line 4490 "grammar.c" /* yacc.c:1663 */ - default: +#line 2642 "grammar.y" /* yacc.c:1663 */ + { + (yyval.expression) = (yyvsp[0].expression); + } +#line 4483 "grammar.c" /* yacc.c:1663 */ break; - } + + +#line 4487 "grammar.c" /* yacc.c:1663 */ + default: break; + } /* User semantic actions sometimes alter yychar, and that requires that yytoken be updated with the new translation. We take the approach of translating immediately before every use of yytoken. @@ -4594,11 +4497,11 @@ yyreduce: 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 ("-> $$ =", yyr1[yyn], &yyval, &yyloc); - YYPOPSTACK(yylen); + YYPOPSTACK (yylen); yylen = 0; - YY_STACK_PRINT(yyss, yyssp); + YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; @@ -4623,65 +4526,68 @@ yyreduce: 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 ? 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) + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (yyscanner, compiler, YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) { - 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; + 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; } - yyerror(yyscanner, compiler, yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; - } -#undef YYSYNTAX_ERROR +# undef YYSYNTAX_ERROR #endif - } + } + if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, yyscanner, compiler); + yychar = YYEMPTY; + } } - else - { - yydestruct("Error: discarding", yytoken, &yylval, yyscanner, compiler); - yychar = YYEMPTY; - } - } /* Else will try to reuse lookahead token after shifting the error token. */ @@ -4697,13 +4603,13 @@ yyerrorlab: YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) - goto yyerrorlab; + goto yyerrorlab; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ - YYPOPSTACK(yylen); + YYPOPSTACK (yylen); yylen = 0; - YY_STACK_PRINT(yyss, yyssp); + YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; @@ -4712,40 +4618,41 @@ yyerrorlab: | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) - { - yyn = yypact[yystate]; - if (!yypact_value_is_default(yyn)) { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yyscanner, compiler); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); } - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - - yydestruct("Error: popping", yystos[yystate], yyvsp, yyscanner, compiler); - YYPOPSTACK(1); - yystate = *yyssp; - YY_STACK_PRINT(yyss, yyssp); - } - YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ - YY_SYMBOL_PRINT("Shifting", yystos[yyn], yyvsp, yylsp); + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -4770,37 +4677,39 @@ yyabortlab: | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: - yyerror(yyscanner, compiler, YY_("memory exhausted")); + yyerror (yyscanner, compiler, YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEMPTY) - { - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = YYTRANSLATE(yychar); - yydestruct( - "Cleanup: discarding lookahead", yytoken, &yylval, yyscanner, compiler); - } + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, yyscanner, compiler); + } /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ - YYPOPSTACK(yylen); - YY_STACK_PRINT(yyss, yyssp); + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) - { - yydestruct("Cleanup: popping", yystos[*yyssp], yyvsp, yyscanner, compiler); - YYPOPSTACK(1); - } + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yyscanner, compiler); + YYPOPSTACK (1); + } #ifndef yyoverflow if (yyss != yyssa) - YYSTACK_FREE(yyss); + YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) - YYSTACK_FREE(yymsg); + YYSTACK_FREE (yymsg); #endif return yyresult; } -#line 2650 "grammar.y" /* yacc.c:1907 */ +#line 2647 "grammar.y" /* yacc.c:1907 */ + diff --git a/libyara/grammar.h b/libyara/grammar.h index b7a45faf..c9f9a3d9 100644 --- a/libyara/grammar.h +++ b/libyara/grammar.h @@ -31,10 +31,10 @@ version 2.2 of Bison. */ #ifndef YY_YARA_YY_GRAMMAR_H_INCLUDED -#define YY_YARA_YY_GRAMMAR_H_INCLUDED +# define YY_YARA_YY_GRAMMAR_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG -#define YYDEBUG 0 +# define YYDEBUG 0 #endif #if YYDEBUG extern int yara_yydebug; @@ -42,144 +42,144 @@ extern int yara_yydebug; /* Token type. */ #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, - _STARTSWITH_ = 296, - _ENDSWITH_ = 297, - _ICONTAINS_ = 298, - _ISTARTSWITH_ = 299, - _IENDSWITH_ = 300, - _IMPORT_ = 301, - _TRUE_ = 302, - _FALSE_ = 303, - _OR_ = 304, - _AND_ = 305, - _NOT_ = 306, - _EQ_ = 307, - _NEQ_ = 308, - _LT_ = 309, - _LE_ = 310, - _GT_ = 311, - _GE_ = 312, - _SHIFT_LEFT_ = 313, - _SHIFT_RIGHT_ = 314, - UNARY_MINUS = 315 -}; +# 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, + _STARTSWITH_ = 296, + _ENDSWITH_ = 297, + _ICONTAINS_ = 298, + _ISTARTSWITH_ = 299, + _IENDSWITH_ = 300, + _IMPORT_ = 301, + _TRUE_ = 302, + _FALSE_ = 303, + _OR_ = 304, + _AND_ = 305, + _NOT_ = 306, + _EQ_ = 307, + _NEQ_ = 308, + _LT_ = 309, + _LE_ = 310, + _GT_ = 311, + _GE_ = 312, + _SHIFT_LEFT_ = 313, + _SHIFT_RIGHT_ = 314, + UNARY_MINUS = 315 + }; #endif /* Tokens. */ -#define _END_OF_FILE_ 0 -#define _END_OF_INCLUDED_FILE_ 258 -#define _DOT_DOT_ 259 -#define _RULE_ 260 -#define _PRIVATE_ 261 -#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 _END_OF_FILE_ 0 +#define _END_OF_INCLUDED_FILE_ 258 +#define _DOT_DOT_ 259 +#define _RULE_ 260 +#define _PRIVATE_ 261 +#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 _STARTSWITH_ 296 -#define _ENDSWITH_ 297 -#define _ICONTAINS_ 298 -#define _ISTARTSWITH_ 299 -#define _IENDSWITH_ 300 -#define _IMPORT_ 301 -#define _TRUE_ 302 -#define _FALSE_ 303 -#define _OR_ 304 -#define _AND_ 305 -#define _NOT_ 306 -#define _EQ_ 307 -#define _NEQ_ 308 -#define _LT_ 309 -#define _LE_ 310 -#define _GT_ 311 -#define _GE_ 312 -#define _SHIFT_LEFT_ 313 -#define _SHIFT_RIGHT_ 314 -#define UNARY_MINUS 315 +#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 _STARTSWITH_ 296 +#define _ENDSWITH_ 297 +#define _ICONTAINS_ 298 +#define _ISTARTSWITH_ 299 +#define _IENDSWITH_ 300 +#define _IMPORT_ 301 +#define _TRUE_ 302 +#define _FALSE_ 303 +#define _OR_ 304 +#define _AND_ 305 +#define _NOT_ 306 +#define _EQ_ 307 +#define _NEQ_ 308 +#define _LT_ 309 +#define _LE_ 310 +#define _GT_ 311 +#define _GE_ 312 +#define _SHIFT_LEFT_ 313 +#define _SHIFT_RIGHT_ 314 +#define UNARY_MINUS 315 /* Value type. */ -#if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { #line 302 "grammar.y" /* yacc.c:1916 */ - YR_EXPRESSION expression; - SIZED_STRING* sized_string; - char* c_string; - int64_t integer; - double double_; - YR_MODIFIER modifier; + YR_EXPRESSION expression; + SIZED_STRING* sized_string; + char* c_string; + int64_t integer; + double double_; + YR_MODIFIER modifier; YR_ARENA_REF tag; YR_ARENA_REF rule; @@ -190,11 +190,12 @@ union YYSTYPE }; typedef union YYSTYPE YYSTYPE; -#define YYSTYPE_IS_TRIVIAL 1 -#define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 #endif -int yara_yyparse(void* yyscanner, YR_COMPILER* compiler); + +int yara_yyparse (void *yyscanner, YR_COMPILER* compiler); #endif /* !YY_YARA_YY_GRAMMAR_H_INCLUDED */ diff --git a/libyara/grammar.y b/libyara/grammar.y index 201888f5..4b6d175a 100644 --- a/libyara/grammar.y +++ b/libyara/grammar.y @@ -1405,8 +1405,6 @@ expression } | _FOR_ for_expression error { - int i; - // Free all the loop variable identifiers, including the variables for // the current loop (represented by loop_index), and set loop_index to // -1. This is OK even if we have nested loops. If an error occurs while @@ -1414,7 +1412,7 @@ expression // anyways, so it's safe to do this cleanup while processing the error // for the inner loop. - for (i = 0; i <= compiler->loop_index; i++) + for (int i = 0; i <= compiler->loop_index; i++) { loop_vars_cleanup(i); } @@ -1528,7 +1526,6 @@ expression YR_ARENA_REF jmp_offset_ref; int var_frame = _yr_compiler_get_var_frame(compiler); - int i; fail_if_error(yr_parser_emit( yyscanner, OP_ITER_NEXT, &loop_start_ref)); @@ -1538,7 +1535,7 @@ expression // YR_INTERNAL_LOOP_VARS because the first YR_INTERNAL_LOOP_VARS slots // in the frame are for the internal variables. - for (i = 0; i < loop_ctx->vars_count; i++) + for (int i = 0; i < loop_ctx->vars_count; i++) { fail_if_error(yr_parser_emit_with_arg( yyscanner, diff --git a/libyara/hex_lexer.c b/libyara/hex_lexer.c index 9479bb3a..dfe5a921 100644 --- a/libyara/hex_lexer.c +++ b/libyara/hex_lexer.c @@ -1,26 +1,248 @@ -#line 2 "hex_lexer.c" +#line 1 "hex_lexer.c" -#line 4 "hex_lexer.c" +#line 3 "hex_lexer.c" -#define YY_INT_ALIGNED short int +#define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ #define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 6 -#define YY_FLEX_SUBMINOR_VERSION 0 +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif +#ifdef yy_create_buffer +#define hex_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer hex_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define hex_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer hex_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define hex_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer hex_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define hex_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string hex_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define hex_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes hex_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define hex_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer hex_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define hex_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer hex_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define hex_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state hex_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define hex_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer hex_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define hex_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state hex_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define hex_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state hex_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define hex_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack hex_yyensure_buffer_stack +#endif + +#ifdef yylex +#define hex_yylex_ALREADY_DEFINED +#else +#define yylex hex_yylex +#endif + +#ifdef yyrestart +#define hex_yyrestart_ALREADY_DEFINED +#else +#define yyrestart hex_yyrestart +#endif + +#ifdef yylex_init +#define hex_yylex_init_ALREADY_DEFINED +#else +#define yylex_init hex_yylex_init +#endif + +#ifdef yylex_init_extra +#define hex_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra hex_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define hex_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy hex_yylex_destroy +#endif + +#ifdef yyget_debug +#define hex_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug hex_yyget_debug +#endif + +#ifdef yyset_debug +#define hex_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug hex_yyset_debug +#endif + +#ifdef yyget_extra +#define hex_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra hex_yyget_extra +#endif + +#ifdef yyset_extra +#define hex_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra hex_yyset_extra +#endif + +#ifdef yyget_in +#define hex_yyget_in_ALREADY_DEFINED +#else +#define yyget_in hex_yyget_in +#endif + +#ifdef yyset_in +#define hex_yyset_in_ALREADY_DEFINED +#else +#define yyset_in hex_yyset_in +#endif + +#ifdef yyget_out +#define hex_yyget_out_ALREADY_DEFINED +#else +#define yyget_out hex_yyget_out +#endif + +#ifdef yyset_out +#define hex_yyset_out_ALREADY_DEFINED +#else +#define yyset_out hex_yyset_out +#endif + +#ifdef yyget_leng +#define hex_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng hex_yyget_leng +#endif + +#ifdef yyget_text +#define hex_yyget_text_ALREADY_DEFINED +#else +#define yyget_text hex_yyget_text +#endif + +#ifdef yyget_lineno +#define hex_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno hex_yyget_lineno +#endif + +#ifdef yyset_lineno +#define hex_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno hex_yyset_lineno +#endif + +#ifdef yyget_column +#define hex_yyget_column_ALREADY_DEFINED +#else +#define yyget_column hex_yyget_column +#endif + +#ifdef yyset_column +#define hex_yyset_column_ALREADY_DEFINED +#else +#define yyset_column hex_yyset_column +#endif + +#ifdef yywrap +#define hex_yywrap_ALREADY_DEFINED +#else +#define yywrap hex_yywrap +#endif + +#ifdef yyget_lval +#define hex_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval hex_yyget_lval +#endif + +#ifdef yyset_lval +#define hex_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval hex_yyset_lval +#endif + +#ifdef yyalloc +#define hex_yyalloc_ALREADY_DEFINED +#else +#define yyalloc hex_yyalloc +#endif + +#ifdef yyrealloc +#define hex_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc hex_yyrealloc +#endif + +#ifdef yyfree +#define hex_yyfree_ALREADY_DEFINED +#else +#define yyfree hex_yyfree +#endif + /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ -#include #include -#include #include +#include +#include /* end standard C headers. */ @@ -31,10 +253,10 @@ /* C99 systems have . Non-C99 systems may or may not. */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -51,89 +273,81 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; /* Limits of integral types. */ #ifndef INT8_MIN -#define INT8_MIN (-128) +#define INT8_MIN (-128) #endif #ifndef INT16_MIN -#define INT16_MIN (-32767 - 1) +#define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN -#define INT32_MIN (-2147483647 - 1) +#define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX -#define INT8_MAX (127) +#define INT8_MAX (127) #endif #ifndef INT16_MAX -#define INT16_MAX (32767) +#define INT16_MAX (32767) #endif #ifndef INT32_MAX -#define INT32_MAX (2147483647) +#define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX -#define UINT8_MAX (255U) +#define UINT8_MAX (255U) #endif #ifndef UINT16_MAX -#define UINT16_MAX (65535U) +#define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) #endif #endif /* ! C99 */ #endif /* ! FLEXINT_H */ -#ifdef __cplusplus +/* begin standard C++ headers. */ -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined(__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST +/* TODO: this is always defined, so inline it */ #define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) #else -#define yyconst +#define yynoreturn #endif /* Returned upon end-of-file. */ #define YY_NULL 0 -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T #define YY_TYPEDEF_YY_SCANNER_T -typedef void *yyscan_t; +typedef void* yyscan_t; #endif /* For convenience, these vars (plus the bison vars far below) are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) #define yy_flex_debug yyg->yy_flex_debug_r /* Enter a start condition. This macro really ought to take a parameter, @@ -141,20 +355,16 @@ typedef void *yyscan_t; * definition of BEGIN. */ #define BEGIN yyg->yy_start = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START - +#define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE hex_yyrestart(yyin, yyscanner) - +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ @@ -170,10 +380,9 @@ typedef void *yyscan_t; #endif /* __ia64__ */ #endif -/* The state buf must be large enough to hold one state per character in the - * main buffer. +/* The state buf must be large enough to hold one state per character in the main buffer. */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE @@ -186,110 +395,109 @@ typedef size_t yy_size_t; #endif #define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* Note: We specifically omit the test for yy_rule_can_match_eol because it - * requires access to the local variable yy_act. Since yyless() is a macro, it - * would break existing scanners that call yyless() from OUTSIDE hex_yylex. One - * obvious solution it to make yy_act a global. I tried that, and saw a 5% - * performance hit in a non-yylineno scanner, because yy_act is normally - * declared as a register variable-- so it is not worth it. - */ -#define YY_LESS_LINENO(n) \ - do \ - { \ - int yyl; \ - for (yyl = n; yyl < yyleng; ++yyl) \ - if (yytext[yyl] == '\n') \ - --yylineno; \ - } while (0) -#define YY_LINENO_REWIND_TO(dst) \ - do \ - { \ - const char *p; \ - for (p = yy_cp - 1; p >= (dst); --p) \ - if (*p == '\n') \ - --yylineno; \ - } while (0) - +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires + * access to the local variable yy_act. Since yyless() is a macro, it would break + * existing scanners that call yyless() from OUTSIDE yylex. + * One obvious solution it to make yy_act a global. I tried that, and saw + * a 5% performance hit in a non-yylineno scanner, because yy_act is + * normally declared as a register variable-- so it is not worth it. + */ + #define YY_LESS_LINENO(n) \ + do { \ + int yyl;\ + for ( yyl = n; yyl < yyleng; ++yyl )\ + if ( yytext[yyl] == '\n' )\ + --yylineno;\ + }while(0) + #define YY_LINENO_REWIND_TO(dst) \ + do {\ + const char *p;\ + for ( p = yy_cp-1; p >= (dst); --p)\ + if ( *p == '\n' )\ + --yylineno;\ + }while(0) + /* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg); \ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } while (0) - -#define unput(c) yyunput(c, yyg->yytext_ptr, yyscanner) +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state -{ - FILE *yy_input_file; + { + FILE *yy_input_file; - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; - int yy_buffer_status; + int yy_buffer_status; -#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via hex_yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ #define YY_BUFFER_EOF_PENDING 2 -}; + + }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* We provide macros for accessing buffer states in case in the @@ -298,163 +506,182 @@ struct yy_buffer_state * * Returns the top of the stack, or NULL. */ -#define YY_CURRENT_BUFFER \ - (yyg->yy_buffer_stack ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] : NULL) - +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] -void hex_yyrestart(FILE *input_file, yyscan_t yyscanner); -void hex_yy_switch_to_buffer(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner); -YY_BUFFER_STATE hex_yy_create_buffer(FILE *file, int size, yyscan_t yyscanner); -void hex_yy_delete_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner); -void hex_yy_flush_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner); -void hex_yypush_buffer_state(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner); -void hex_yypop_buffer_state(yyscan_t yyscanner); +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); -static void hex_yyensure_buffer_stack(yyscan_t yyscanner); -static void hex_yy_load_buffer_state(yyscan_t yyscanner); -static void hex_yy_init_buffer( - YY_BUFFER_STATE b, - FILE *file, - yyscan_t yyscanner); +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) -#define YY_FLUSH_BUFFER hex_yy_flush_buffer(YY_CURRENT_BUFFER, yyscanner) +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner ); -YY_BUFFER_STATE hex_yy_scan_buffer( - char *base, - yy_size_t size, - yyscan_t yyscanner); -YY_BUFFER_STATE hex_yy_scan_string(yyconst char *yy_str, yyscan_t yyscanner); -YY_BUFFER_STATE hex_yy_scan_bytes( - yyconst char *bytes, - yy_size_t len, - yyscan_t yyscanner); - -void *hex_yyalloc(yy_size_t, yyscan_t yyscanner); -void *hex_yyrealloc(void *, yy_size_t, yyscan_t yyscanner); -void hex_yyfree(void *, yyscan_t yyscanner); - -#define yy_new_buffer hex_yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if (!YY_CURRENT_BUFFER) \ - { \ - hex_yyensure_buffer_stack(yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = hex_yy_create_buffer( \ - yyin, YY_BUF_SIZE, yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if (!YY_CURRENT_BUFFER) \ - { \ - hex_yyensure_buffer_stack(yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = hex_yy_create_buffer( \ - yyin, YY_BUF_SIZE, yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ -#define hex_yywrap(yyscanner) (/*CONSTCOND*/ 1) +#define hex_yywrap(yyscanner) (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; +typedef flex_uint8_t YY_CHAR; typedef int yy_state_type; #define yytext_ptr yytext_r -static yy_state_type yy_get_previous_state(yyscan_t yyscanner); -static yy_state_type yy_try_NUL_trans( - yy_state_type current_state, - yyscan_t yyscanner); -static int yy_get_next_buffer(yyscan_t yyscanner); -#if defined(__GNUC__) && __GNUC__ >= 3 -__attribute__((__noreturn__)) -#endif -static void -yy_fatal_error(yyconst char msg[], yyscan_t yyscanner); +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ - yyleng = (size_t)(yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yyg->yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 18 -#define YY_END_OF_BUFFER 19 +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 19 +#define YY_END_OF_BUFFER 20 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info -{ - flex_int32_t yy_verify; - flex_int32_t yy_nxt; -}; -static yyconst flex_int16_t yy_accept[34] = { - 0, 0, 0, 0, 0, 0, 0, 19, 17, 15, 15, 16, 17, 17, 17, 5, 8, - 8, 14, 13, 13, 10, 11, 12, 6, 9, 1, 2, 3, 4, 7, 11, 9, 0}; + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[34] = + { 0, + 0, 0, 0, 0, 0, 0, 20, 18, 16, 16, + 17, 18, 5, 18, 6, 9, 9, 15, 14, 14, + 11, 12, 13, 7, 10, 1, 2, 3, 4, 8, + 12, 10, 0 + } ; -static yyconst YY_CHAR yy_ec[256] = { - 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 4, 4, - 5, 1, 1, 6, 1, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, 1, 1, - 9, 1, 10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 11, 1, 12, 1, 1, 1, 10, 10, 10, 10, +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 4, + 4, 5, 1, 1, 6, 1, 7, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, + 1, 1, 9, 1, 10, 10, 10, 10, 10, 10, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 11, 1, 12, 1, 1, 1, 10, 10, 10, 10, - 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 4, 4, 4, 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, 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, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 4, 4, 4, 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, 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, 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, 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, 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, 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, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; -static yyconst YY_CHAR yy_meta[13] = {0, 1, 1, 2, 1, 1, 1, 1, 3, 3, 3, 1, 1}; +static const YY_CHAR yy_meta[13] = + { 0, + 1, 1, 2, 1, 1, 1, 1, 3, 3, 3, + 1, 1 + } ; -static yyconst flex_uint16_t yy_base[38] = { - 0, 0, 0, 36, 35, 12, 0, 39, 42, 42, 42, 42, 20, 29, 28, 42, 42, 29, 42, - 42, 42, 42, 27, 42, 42, 0, 42, 42, 42, 42, 42, 26, 0, 42, 27, 29, 23, 30}; +static const flex_int16_t yy_base[38] = + { 0, + 0, 0, 36, 35, 12, 0, 39, 42, 42, 42, + 42, 20, 29, 28, 42, 42, 29, 42, 42, 42, + 42, 27, 42, 42, 0, 42, 42, 42, 42, 42, + 26, 0, 42, 27, 29, 23, 30 + } ; -static yyconst flex_int16_t yy_def[38] = { - 0, 33, 1, 34, 34, 33, 5, 33, 33, 33, 33, 33, 33, 35, 36, 33, 33, 33, 33, - 33, 33, 33, 33, 33, 33, 37, 33, 33, 33, 33, 33, 33, 37, 0, 33, 33, 33, 33}; +static const flex_int16_t yy_def[38] = + { 0, + 33, 1, 34, 34, 33, 5, 33, 33, 33, 33, + 33, 33, 35, 36, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 37, 33, 33, 33, 33, 33, + 33, 37, 0, 33, 33, 33, 33 + } ; -static yyconst flex_uint16_t yy_nxt[55] = { - 0, 8, 9, 10, 11, 8, 8, 12, 13, 14, 13, 15, 8, 18, 19, 20, 18, 18, 21, - 18, 22, 18, 18, 18, 23, 24, 28, 25, 16, 16, 16, 32, 26, 32, 31, 31, 30, 29, - 27, 33, 17, 17, 7, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33}; +static const flex_int16_t yy_nxt[55] = + { 0, + 8, 9, 10, 11, 8, 8, 12, 13, 14, 13, + 15, 8, 18, 19, 20, 18, 18, 21, 18, 22, + 18, 18, 18, 23, 24, 28, 25, 16, 16, 16, + 32, 26, 32, 31, 31, 30, 29, 27, 33, 17, + 17, 7, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33 + } ; -static yyconst flex_int16_t yy_chk[55] = { - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 12, 36, 12, 34, 34, 34, 37, 35, 37, 31, 22, 17, 14, - 13, 7, 4, 3, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33}; +static const flex_int16_t yy_chk[55] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 12, 36, 12, 34, 34, 34, + 37, 35, 37, 31, 22, 17, 14, 13, 7, 4, + 3, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33 + } ; /* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[19] = { - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, -}; +static const flex_int32_t yy_rule_can_match_eol[20] = + { 0, +0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, + }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET #line 1 "hex_lexer.l" @@ -503,14 +730,15 @@ with noyywrap then we can remove this pragma. #endif #include -#include + #include -#include #include +#include #include #include -#include #include +#include +#include #include "hex_grammar.h" @@ -518,23 +746,23 @@ with noyywrap then we can remove this pragma. #define snprintf _snprintf #endif -#define ERROR_IF(x, error) \ - if (x) \ - { \ - RE_AST *re_ast = hex_yyget_extra(yyscanner); \ - re_ast->error_code = error; \ - YYABORT; \ - } +#define ERROR_IF(x, error) \ + if (x) \ + { \ + RE_AST* re_ast = yyget_extra(yyscanner); \ + re_ast->error_code = error; \ + YYABORT; \ + } \ +#line 757 "hex_lexer.c" #define YY_NO_UNISTD_H 1 -#define YY_NO_INPUT 1 +#define YY_NO_INPUT 1 - -#line 562 "hex_lexer.c" +#line 761 "hex_lexer.c" #define INITIAL 0 #define comment 1 -#define range 2 +#define range 2 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way @@ -550,86 +778,86 @@ with noyywrap then we can remove this pragma. /* Holds the entire state of the reentrant scanner. */ struct yyguts_t -{ - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; + { - /* The rest are the same as the globals declared in the non-reentrant scanner. - */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE *yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - yy_size_t yy_n_chars; - yy_size_t yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char *yy_last_accepting_cpos; + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; - int yylineno_r; - int yy_flex_debug_r; + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; - char *yytext_r; - int yy_more_flag; - int yy_more_len; + int yylineno_r; + int yy_flex_debug_r; - YYSTYPE *yylval_r; + char *yytext_r; + int yy_more_flag; + int yy_more_len; -}; /* end struct yyguts_t */ + YYSTYPE * yylval_r; -static int yy_init_globals(yyscan_t yyscanner); + }; /* end struct yyguts_t */ -/* This must go here because YYSTYPE and YYLTYPE are included - * from bison output in section 1.*/ -#define yylval yyg->yylval_r +static int yy_init_globals ( yyscan_t yyscanner ); -int hex_yylex_init(yyscan_t *scanner); + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); -int hex_yylex_init_extra(YY_EXTRA_TYPE user_defined, yyscan_t *scanner); +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int hex_yylex_destroy(yyscan_t yyscanner); +int yylex_destroy ( yyscan_t yyscanner ); -int hex_yyget_debug(yyscan_t yyscanner); +int yyget_debug ( yyscan_t yyscanner ); -void hex_yyset_debug(int debug_flag, yyscan_t yyscanner); +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); -YY_EXTRA_TYPE hex_yyget_extra(yyscan_t yyscanner); +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); -void hex_yyset_extra(YY_EXTRA_TYPE user_defined, yyscan_t yyscanner); +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); -FILE *hex_yyget_in(yyscan_t yyscanner); +FILE *yyget_in ( yyscan_t yyscanner ); -void hex_yyset_in(FILE *_in_str, yyscan_t yyscanner); +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); -FILE *hex_yyget_out(yyscan_t yyscanner); +FILE *yyget_out ( yyscan_t yyscanner ); -void hex_yyset_out(FILE *_out_str, yyscan_t yyscanner); +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); -yy_size_t hex_yyget_leng(yyscan_t yyscanner); + int yyget_leng ( yyscan_t yyscanner ); -char *hex_yyget_text(yyscan_t yyscanner); +char *yyget_text ( yyscan_t yyscanner ); -int hex_yyget_lineno(yyscan_t yyscanner); +int yyget_lineno ( yyscan_t yyscanner ); -void hex_yyset_lineno(int _line_number, yyscan_t yyscanner); +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); -int hex_yyget_column(yyscan_t yyscanner); +int yyget_column ( yyscan_t yyscanner ); -void hex_yyset_column(int _column_no, yyscan_t yyscanner); +void yyset_column ( int _column_no , yyscan_t yyscanner ); -YYSTYPE *hex_yyget_lval(yyscan_t yyscanner); +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); -void hex_yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner); +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -637,30 +865,29 @@ void hex_yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int hex_yywrap(yyscan_t yyscanner); +extern "C" int yywrap ( yyscan_t yyscanner ); #else -extern int hex_yywrap(yyscan_t yyscanner); +extern int yywrap ( yyscan_t yyscanner ); #endif #endif #ifndef YY_NO_UNPUT - + #endif #ifndef yytext_ptr -static void yy_flex_strncpy(char *, yyconst char *, int, yyscan_t yyscanner); +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen(yyconst char *, yyscan_t yyscanner); +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); #endif #ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput(yyscan_t yyscanner); +static int yyinput ( yyscan_t yyscanner ); #else -static int input(yyscan_t yyscanner); +static int input ( yyscan_t yyscanner ); #endif #endif @@ -680,47 +907,42 @@ static int input(yyscan_t yyscanner); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO \ - do \ - { \ - if (fwrite(yytext, yyleng, 1, yyout)) \ - { \ - } \ - } while (0) +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT -#define YY_INPUT(buf, result, max_size) \ - if (YY_CURRENT_BUFFER_LVALUE->yy_is_interactive) \ - { \ - int c = '*'; \ - size_t n; \ - for (n = 0; n < max_size && (c = getc(yyin)) != EOF && c != '\n'; ++n) \ - buf[n] = (char) c; \ - if (c == '\n') \ - buf[n++] = (char) c; \ - if (c == EOF && ferror(yyin)) \ - YY_FATAL_ERROR("input in flex scanner failed"); \ - result = n; \ - } \ - else \ - { \ - errno = 0; \ - while ((result = fread(buf, 1, max_size, yyin)) == 0 && ferror(yyin)) \ - { \ - if (errno != EINTR) \ - { \ - YY_FATAL_ERROR("input in flex scanner failed"); \ - break; \ - } \ - errno = 0; \ - clearerr(yyin); \ - } \ - } - +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + int n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ #endif @@ -739,7 +961,7 @@ static int input(yyscan_t yyscanner); /* Report a fatal error. */ #ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error(msg, yyscanner) +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) #endif /* end tables serialization structures and prototypes */ @@ -750,9 +972,11 @@ static int input(yyscan_t yyscanner); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int hex_yylex(YYSTYPE *yylval_param, yyscan_t yyscanner); +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); -#define YY_DECL int hex_yylex(YYSTYPE *yylval_param, yyscan_t yyscanner) +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng @@ -764,387 +988,407 @@ extern int hex_yylex(YYSTYPE *yylval_param, yyscan_t yyscanner); /* Code executed at the end of each rule. */ #ifndef YY_BREAK -#define YY_BREAK /*LINTED*/ break; +#define YY_BREAK /*LINTED*/break; #endif -#define YY_RULE_SETUP YY_USER_ACTION +#define YY_RULE_SETUP \ + YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { - yy_state_type yy_current_state; - char *yy_cp, *yy_bp; - int yy_act; - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yylval = yylval_param; + yylval = yylval_param; - if (!yyg->yy_init) - { - yyg->yy_init = 1; + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; #ifdef YY_USER_INIT - YY_USER_INIT; + YY_USER_INIT; #endif - if (!yyg->yy_start) - yyg->yy_start = 1; /* first start state */ + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ - if (!yyin) - yyin = stdin; + if ( ! yyin ) + yyin = stdin; - if (!yyout) - yyout = stdout; + if ( ! yyout ) + yyout = stdout; - if (!YY_CURRENT_BUFFER) - { - hex_yyensure_buffer_stack(yyscanner); - YY_CURRENT_BUFFER_LVALUE = hex_yy_create_buffer( - yyin, YY_BUF_SIZE, yyscanner); - } + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } - hex_yy_load_buffer_state(yyscanner); - } + yy_load_buffer_state( yyscanner ); + } - { + { #line 95 "hex_lexer.l" -#line 841 "hex_lexer.c" - while (/*CONSTCOND*/ 1) /* loops until end-of-file is reached */ - { - yy_cp = yyg->yy_c_buf_p; +#line 1039 "hex_lexer.c" - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; - yy_current_state = yyg->yy_start; - yy_match: - do - { - YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if (yy_accept[yy_current_state]) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - 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 >= 34) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = - yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } while (yy_current_state != 33); - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; - yy_find_action: - yy_act = yy_accept[yy_current_state]; + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + 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 >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 33 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; - YY_DO_BEFORE_ACTION; +yy_find_action: + yy_act = yy_accept[yy_current_state]; - if (yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act]) - { - yy_size_t yyl; - for (yyl = 0; yyl < yyleng; ++yyl) - if (yytext[yyl] == '\n') + YY_DO_BEFORE_ACTION; - do - { - yylineno++; - yycolumn = 0; - } while (0); - } + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) + { + int yyl; + for ( yyl = 0; yyl < yyleng; ++yyl ) + if ( yytext[yyl] == '\n' ) + + do{ yylineno++; + yycolumn=0; + }while(0) +; + } - do_action: /* This label is used only to access EOF actions. */ +do_action: /* This label is used only to access EOF actions. */ - switch (yy_act) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; - case 1: - YY_RULE_SETUP +case 1: +YY_RULE_SETUP #line 98 "hex_lexer.l" - { - yylval->integer = xtoi(yytext); - return _BYTE_; - } - YY_BREAK - case 2: - YY_RULE_SETUP +{ + + yylval->integer = xtoi(yytext); + return _BYTE_; +} + YY_BREAK +case 2: +YY_RULE_SETUP #line 104 "hex_lexer.l" - { - yytext[1] = '0'; // replace ? by 0 - yylval->integer = xtoi(yytext) | 0xF000; - return _MASKED_BYTE_; - } - YY_BREAK - case 3: - YY_RULE_SETUP +{ + + yytext[1] = '0'; // replace ? by 0 + yylval->integer = xtoi(yytext) | 0xF000 ; + return _MASKED_BYTE_; +} + YY_BREAK +case 3: +YY_RULE_SETUP #line 111 "hex_lexer.l" - { - yytext[0] = '0'; // replace ? by 0 - yylval->integer = xtoi(yytext) | 0x0F00; - return _MASKED_BYTE_; - } - YY_BREAK - case 4: - YY_RULE_SETUP +{ + + yytext[0] = '0'; // replace ? by 0 + yylval->integer = xtoi(yytext) | 0x0F00 ; + return _MASKED_BYTE_; +} + YY_BREAK +case 4: +YY_RULE_SETUP #line 118 "hex_lexer.l" - { - yylval->integer = 0x0000; - return _MASKED_BYTE_; - } - YY_BREAK - case 5: - YY_RULE_SETUP +{ + + yylval->integer = 0x0000; + return _MASKED_BYTE_; +} + YY_BREAK +case 5: +YY_RULE_SETUP #line 124 "hex_lexer.l" - { - BEGIN(range); - return yytext[0]; - } - YY_BREAK - case 6: - YY_RULE_SETUP +{ + + yyerror(yyscanner, lex_env, "uneven number of digits in hex string"); + yyterminate(); +} + YY_BREAK +case 6: +YY_RULE_SETUP #line 130 "hex_lexer.l" - { - BEGIN(comment); - } - YY_BREAK - case 7: - YY_RULE_SETUP -#line 135 "hex_lexer.l" - { - BEGIN(INITIAL); - } - YY_BREAK - case 8: - /* rule 8 can match eol */ - YY_RULE_SETUP -#line 140 "hex_lexer.l" - // skip comments - YY_BREAK - case 9: - YY_RULE_SETUP -#line 142 "hex_lexer.l" - // skip single-line comments - YY_BREAK - case 10: - YY_RULE_SETUP -#line 144 "hex_lexer.l" - { - return yytext[0]; - } - YY_BREAK - case 11: - YY_RULE_SETUP -#line 149 "hex_lexer.l" - { - yylval->integer = atoi(yytext); - return _NUMBER_; - } - YY_BREAK - case 12: - YY_RULE_SETUP +{ + + BEGIN(range); + return yytext[0]; +} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 136 "hex_lexer.l" +{ + + BEGIN(comment); +} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 141 "hex_lexer.l" +{ + + BEGIN(INITIAL); +} + YY_BREAK +case 9: +/* rule 9 can match eol */ +YY_RULE_SETUP +#line 146 "hex_lexer.l" +// skip comments + YY_BREAK +case 10: +YY_RULE_SETUP +#line 148 "hex_lexer.l" +// skip single-line comments + YY_BREAK +case 11: +YY_RULE_SETUP +#line 150 "hex_lexer.l" +{ + + return yytext[0]; +} + YY_BREAK +case 12: +YY_RULE_SETUP #line 155 "hex_lexer.l" - { - BEGIN(INITIAL); - return yytext[0]; - } - YY_BREAK - case 13: - /* rule 13 can match eol */ - YY_RULE_SETUP +{ + + yylval->integer = atoi(yytext); + return _NUMBER_; +} + YY_BREAK +case 13: +YY_RULE_SETUP #line 161 "hex_lexer.l" - // skip whitespaces - YY_BREAK - case 14: - YY_RULE_SETUP -#line 163 "hex_lexer.l" - { - yyerror(yyscanner, lex_env, "invalid character in hex string jump"); - yyterminate(); - } - YY_BREAK - case 15: - /* rule 15 can match eol */ - YY_RULE_SETUP +{ + + BEGIN(INITIAL); + return yytext[0]; +} + YY_BREAK +case 14: +/* rule 14 can match eol */ +YY_RULE_SETUP +#line 167 "hex_lexer.l" +// skip whitespaces + YY_BREAK +case 15: +YY_RULE_SETUP #line 169 "hex_lexer.l" - // skip whitespaces - YY_BREAK - case 16: - YY_RULE_SETUP -#line 171 "hex_lexer.l" - { // pass valid characters to the parser +{ - return yytext[0]; - } - YY_BREAK - case 17: - YY_RULE_SETUP -#line 176 "hex_lexer.l" - { // reject all other characters + yyerror(yyscanner, lex_env, "invalid character in hex string jump"); + yyterminate(); +} + YY_BREAK +case 16: +/* rule 16 can match eol */ +YY_RULE_SETUP +#line 175 "hex_lexer.l" +// skip whitespaces + YY_BREAK +case 17: +YY_RULE_SETUP +#line 177 "hex_lexer.l" +{ // pass valid characters to the parser - yyerror(yyscanner, lex_env, "invalid character in hex string"); - yyterminate(); - } - YY_BREAK - case 18: - YY_RULE_SETUP + return yytext[0]; +} + YY_BREAK +case 18: +YY_RULE_SETUP #line 182 "hex_lexer.l" - ECHO; - YY_BREAK -#line 1049 "hex_lexer.c" - case YY_STATE_EOF(INITIAL): - case YY_STATE_EOF(comment): - case YY_STATE_EOF(range): - yyterminate(); +{ // reject all other characters - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + yyerror(yyscanner, lex_env, "invalid character in hex string"); + yyterminate(); +} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 188 "hex_lexer.l" +ECHO; + YY_BREAK +#line 1256 "hex_lexer.c" +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(comment): +case YY_STATE_EOF(range): + yyterminate(); - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * hex_yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if (yyg->yy_c_buf_p <= - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]) - { /* This was really a NUL. */ - yy_state_type yy_next_state; + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; - yy_current_state = yy_get_previous_state(yyscanner); + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ + yy_current_state = yy_get_previous_state( yyscanner ); - yy_next_state = yy_try_NUL_trans(yy_current_state, yyscanner); + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - if (yy_next_state) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - else - { - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - } - } + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } - else - switch (yy_get_next_buffer(yyscanner)) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } - if (hex_yywrap(yyscanner)) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - else - { - if (!yyg->yy_did_buffer_switch_on_eof) - YY_NEW_FILE; - } - break; - } + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } - yy_current_state = yy_get_previous_state(yyscanner); + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; + yy_current_state = yy_get_previous_state( yyscanner ); - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; - yy_current_state = yy_get_previous_state(yyscanner); + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } + yy_current_state = yy_get_previous_state( yyscanner ); - default: - YY_FATAL_ERROR("fatal flex scanner internal error--no action found"); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of user's declarations */ -} /* end of hex_yylex */ + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * @@ -1153,168 +1397,171 @@ YY_DECL * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ -static int yy_get_next_buffer(yyscan_t yyscanner) +static int yy_get_next_buffer (yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - char *source = yyg->yytext_ptr; - yy_size_t number_to_move, i; - int ret_val; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; - if (yyg->yy_c_buf_p > - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1]) - YY_FATAL_ERROR("fatal flex scanner internal error--end of buffer missed"); + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); - if (YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0) - { /* Don't try to fill the buffer, so this is an EOF. */ - if (yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } - /* Try to read more data. */ + /* Try to read more data. */ - /* First move last chars to start of buffer. */ - number_to_move = (yy_size_t)(yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); - for (i = 0; i < number_to_move; ++i) *(dest++) = *(source++); + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); - if (YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - else - { - yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - while (num_to_read <= 0) - { /* Not enough room in the buffer - grow it. */ + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; - int yy_c_buf_p_offset = (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - if (b->yy_is_our_buffer) - { - yy_size_t new_size = b->yy_buf_size * 2; + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; - if (new_size <= 0) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - hex_yyrealloc((void *) b->yy_ch_buf, b->yy_buf_size + 2, yyscanner); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; - if (!b->yy_ch_buf) - YY_FATAL_ERROR("fatal error - scanner input buffer overflow"); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - } + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; - if (num_to_read > YY_READ_BUF_SIZE) - num_to_read = YY_READ_BUF_SIZE; + } - /* Read in more data. */ - YY_INPUT( - (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, - num_to_read); + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); - if (yyg->yy_n_chars == 0) - { - if (number_to_move == YY_MORE_ADJ) - { - ret_val = EOB_ACT_END_OF_FILE; - hex_yyrestart(yyin, yyscanner); - } + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; - } - } + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } - else - ret_val = EOB_ACT_CONTINUE_SCAN; + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } - if ((yy_size_t)(yyg->yy_n_chars + number_to_move) > - YY_CURRENT_BUFFER_LVALUE->yy_buf_size) - { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = yyg->yy_n_chars + number_to_move + - (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) hex_yyrealloc( - (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, new_size, yyscanner); - if (!YY_CURRENT_BUFFER_LVALUE->yy_ch_buf) - YY_FATAL_ERROR("out of dynamic memory in yy_get_next_buffer()"); - } + else + ret_val = EOB_ACT_CONTINUE_SCAN; - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = - YY_END_OF_BUFFER_CHAR; + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - return ret_val; + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ -static yy_state_type yy_get_previous_state(yyscan_t yyscanner) + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { - yy_state_type yy_current_state; - char *yy_cp; - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_current_state = yyg->yy_start; + yy_current_state = yyg->yy_start; - for (yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp) - { - YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if (yy_accept[yy_current_state]) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - 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 >= 34) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + 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 >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } - return yy_current_state; + return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character @@ -1322,32 +1569,29 @@ static yy_state_type yy_get_previous_state(yyscan_t yyscanner) * synopsis * next_state = yy_try_NUL_trans( current_state ); */ -static yy_state_type yy_try_NUL_trans( - yy_state_type yy_current_state, - yyscan_t yyscanner) + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) { - int yy_is_jam; - struct yyguts_t *yyg = (struct yyguts_t *) - yyscanner; /* This var may be unused depending upon options. */ - char *yy_cp = yyg->yy_c_buf_p; + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; - YY_CHAR yy_c = 1; - if (yy_accept[yy_current_state]) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - 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 >= 34) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 33); + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + 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 >= 34 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 33); - (void) yyg; - return yy_is_jam ? 0 : yy_current_state; + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; } #ifndef YY_NO_UNPUT @@ -1356,262 +1600,255 @@ static yy_state_type yy_try_NUL_trans( #ifndef YY_NO_INPUT #ifdef __cplusplus -static int yyinput(yyscan_t yyscanner) + static int yyinput (yyscan_t yyscanner) #else -static int input(yyscan_t yyscanner) + static int input (yyscan_t yyscanner) #endif { - int c; - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - *yyg->yy_c_buf_p = yyg->yy_hold_char; + *yyg->yy_c_buf_p = yyg->yy_hold_char; - if (*yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if (yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; - else - { /* need more input */ - yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; - ++yyg->yy_c_buf_p; + else + { /* need more input */ + int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr); + ++yyg->yy_c_buf_p; - switch (yy_get_next_buffer(yyscanner)) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ - /* Reset buffer status. */ - hex_yyrestart(yyin, yyscanner); + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); - /*FALLTHROUGH*/ + /*FALLTHROUGH*/ - case EOB_ACT_END_OF_FILE: - { - if (hex_yywrap(yyscanner)) - return EOF; + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; - if (!yyg->yy_did_buffer_switch_on_eof) - YY_NEW_FILE; + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; #ifdef __cplusplus - return yyinput(yyscanner); + return yyinput(yyscanner); #else - return input(yyscanner); + return input(yyscanner); #endif - } + } - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; - if (c == '\n') + if ( c == '\n' ) + + do{ yylineno++; + yycolumn=0; + }while(0) +; - do - { - yylineno++; - yycolumn = 0; - } while (0); - - return c; + return c; } -#endif /* ifndef YY_NO_INPUT */ +#endif /* ifndef YY_NO_INPUT */ /** Immediately switch to a different input stream. * @param input_file A readable stream. * @param yyscanner The scanner object. * @note This function does not reset the start condition to @c INITIAL . */ -void hex_yyrestart(FILE *input_file, yyscan_t yyscanner) + void yyrestart (FILE * input_file , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - { - hex_yyensure_buffer_stack(yyscanner); - YY_CURRENT_BUFFER_LVALUE = hex_yy_create_buffer( - yyin, YY_BUF_SIZE, yyscanner); - } + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } - hex_yy_init_buffer(YY_CURRENT_BUFFER, input_file, yyscanner); - hex_yy_load_buffer_state(yyscanner); + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * @param yyscanner The scanner object. */ -void hex_yy_switch_to_buffer(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner) + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* TODO. We should be able to replace this entire function body - * with - * hex_yypop_buffer_state(); - * hex_yypush_buffer_state(new_buffer); - */ - hex_yyensure_buffer_stack(yyscanner); - if (YY_CURRENT_BUFFER == new_buffer) - return; + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; - if (YY_CURRENT_BUFFER) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } - YY_CURRENT_BUFFER_LVALUE = new_buffer; - hex_yy_load_buffer_state(yyscanner); + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); - /* We don't actually know whether we did this switch during - * EOF (hex_yywrap()) processing, but the only time this flag - * is looked at is after hex_yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; } -static void hex_yy_load_buffer_state(yyscan_t yyscanner) +static void yy_load_buffer_state (yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; } /** Allocate and initialize an input buffer state. * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c - * YY_BUF_SIZE. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. * @param yyscanner The scanner object. * @return the allocated buffer state. */ -YY_BUFFER_STATE hex_yy_create_buffer(FILE *file, int size, yyscan_t yyscanner) + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { - YY_BUFFER_STATE b; + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - b = (YY_BUFFER_STATE) hex_yyalloc(sizeof(struct yy_buffer_state), yyscanner); - if (!b) - YY_FATAL_ERROR("out of dynamic memory in hex_yy_create_buffer()"); + b->yy_buf_size = size; - b->yy_buf_size = (yy_size_t) size; + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) hex_yyalloc(b->yy_buf_size + 2, yyscanner); - if (!b->yy_ch_buf) - YY_FATAL_ERROR("out of dynamic memory in hex_yy_create_buffer()"); + b->yy_is_our_buffer = 1; - b->yy_is_our_buffer = 1; + yy_init_buffer( b, file , yyscanner); - hex_yy_init_buffer(b, file, yyscanner); - - return b; + return b; } /** Destroy the buffer. - * @param b a buffer created with hex_yy_create_buffer() + * @param b a buffer created with yy_create_buffer() * @param yyscanner The scanner object. */ -void hex_yy_delete_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner) + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!b) - return; + if ( ! b ) + return; - if (b == YY_CURRENT_BUFFER) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - if (b->yy_is_our_buffer) - hex_yyfree((void *) b->yy_ch_buf, yyscanner); + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); - hex_yyfree((void *) b, yyscanner); + yyfree( (void *) b , yyscanner ); } /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, - * such as during a hex_yyrestart() or at EOF. + * such as during a yyrestart() or at EOF. */ -static void hex_yy_init_buffer( - YY_BUFFER_STATE b, - FILE *file, - yyscan_t yyscanner) + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) { - int oerrno = errno; - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - hex_yy_flush_buffer(b, yyscanner); + yy_flush_buffer( b , yyscanner); - b->yy_input_file = file; - b->yy_fill_buffer = 1; + b->yy_input_file = file; + b->yy_fill_buffer = 1; - /* If b is the current buffer, then hex_yy_init_buffer was _probably_ - * called from hex_yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER) - { - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } - b->yy_is_interactive = 0; - - errno = oerrno; + b->yy_is_interactive = 0; + + errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * @param yyscanner The scanner object. */ -void hex_yy_flush_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner) + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - if (!b) - return; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; - b->yy_n_chars = 0; + b->yy_n_chars = 0; - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - b->yy_buf_pos = &b->yy_ch_buf[0]; + b->yy_buf_pos = &b->yy_ch_buf[0]; - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; - if (b == YY_CURRENT_BUFFER) - hex_yy_load_buffer_state(yyscanner); + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); } /** Pushes the new state onto the stack. The new state becomes @@ -1620,518 +1857,495 @@ void hex_yy_flush_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner) * @param new_buffer The new state. * @param yyscanner The scanner object. */ -void hex_yypush_buffer_state(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner) +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - if (new_buffer == NULL) - return; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; - hex_yyensure_buffer_stack(yyscanner); + yyensure_buffer_stack(yyscanner); - /* This block is copied from hex_yy_switch_to_buffer. */ - if (YY_CURRENT_BUFFER) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; - /* copied from hex_yy_switch_to_buffer. */ - hex_yy_load_buffer_state(yyscanner); - yyg->yy_did_buffer_switch_on_eof = 1; + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * @param yyscanner The scanner object. */ -void hex_yypop_buffer_state(yyscan_t yyscanner) +void yypop_buffer_state (yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - if (!YY_CURRENT_BUFFER) - return; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; - hex_yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; - if (YY_CURRENT_BUFFER) - { - hex_yy_load_buffer_state(yyscanner); - yyg->yy_did_buffer_switch_on_eof = 1; - } + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } } /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -static void hex_yyensure_buffer_stack(yyscan_t yyscanner) +static void yyensure_buffer_stack (yyscan_t yyscanner) { - yy_size_t num_to_alloc; - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!yyg->yy_buffer_stack) - { - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; // After all that talk, this was set to 1 anyways... - yyg->yy_buffer_stack = (struct yy_buffer_state **) hex_yyalloc( - num_to_alloc * sizeof(struct yy_buffer_state *), yyscanner); - if (!yyg->yy_buffer_stack) - YY_FATAL_ERROR("out of dynamic memory in hex_yyensure_buffer_stack()"); + if (!yyg->yy_buffer_stack) { - memset( - yyg->yy_buffer_stack, - 0, - num_to_alloc * sizeof(struct yy_buffer_state *)); + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1) - { - /* Increase the buffer to prepare for a possible push. */ - yy_size_t grow_size = 8 /* arbitrary grow size */; + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state **) hex_yyrealloc( - yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state *), - yyscanner); - if (!yyg->yy_buffer_stack) - YY_FATAL_ERROR("out of dynamic memory in hex_yyensure_buffer_stack()"); + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - /* zero only the new slots.*/ - memset( - yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, - 0, - grow_size * sizeof(struct yy_buffer_state *)); - yyg->yy_buffer_stack_max = num_to_alloc; - } + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } } -/** Setup the input buffer state to scan directly from a user-specified - * character buffer. +/** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE hex_yy_scan_buffer( - char *base, - yy_size_t size, - yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { - YY_BUFFER_STATE b; + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; - if (size < 2 || base[size - 2] != YY_END_OF_BUFFER_CHAR || - base[size - 1] != YY_END_OF_BUFFER_CHAR) - /* They forgot to leave room for the EOB's. */ - return 0; + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b = (YY_BUFFER_STATE) hex_yyalloc(sizeof(struct yy_buffer_state), yyscanner); - if (!b) - YY_FATAL_ERROR("out of dynamic memory in hex_yy_scan_buffer()"); + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; + yy_switch_to_buffer( b , yyscanner ); - hex_yy_switch_to_buffer(b, yyscanner); - - return b; + return b; } -/** Setup the input buffer state to scan a string. The next call to hex_yylex() - * will scan from a @e copy of @a str. +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * @param yyscanner The scanner object. * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use - * hex_yy_scan_bytes() instead. + * yy_scan_bytes() instead. */ -YY_BUFFER_STATE hex_yy_scan_string(yyconst char *yystr, yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) { - return hex_yy_scan_bytes(yystr, strlen(yystr), yyscanner); + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); } -/** Setup the input buffer state to scan the given bytes. The next call to - * hex_yylex() will scan from a @e copy of @a bytes. +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE hex_yy_scan_bytes( - yyconst char *yybytes, - yy_size_t _yybytes_len, - yyscan_t yyscanner) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner) { - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - yy_size_t i; + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) hex_yyalloc(n, yyscanner); - if (!buf) - YY_FATAL_ERROR("out of dynamic memory in hex_yy_scan_bytes()"); + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; - for (i = 0; i < _yybytes_len; ++i) buf[i] = yybytes[i]; + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - buf[_yybytes_len] = buf[_yybytes_len + 1] = YY_END_OF_BUFFER_CHAR; + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - b = hex_yy_scan_buffer(buf, n, yyscanner); - if (!b) - YY_FATAL_ERROR("bad buffer in hex_yy_scan_bytes()"); + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; + return b; } #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error(yyconst char *msg, yyscan_t yyscanner) +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - (void) yyg; - (void) fprintf(stderr, "%s\n", msg); - exit(YY_EXIT_FAILURE); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg); \ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } while (0) +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /** Get the user-defined data for this scanner. * @param yyscanner The scanner object. */ -YY_EXTRA_TYPE hex_yyget_extra(yyscan_t yyscanner) +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - return yyextra; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; } /** Get the current line number. * @param yyscanner The scanner object. */ -int hex_yyget_lineno(yyscan_t yyscanner) +int yyget_lineno (yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return 0; - - return yylineno; + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; } /** Get the current column number. * @param yyscanner The scanner object. */ -int hex_yyget_column(yyscan_t yyscanner) +int yyget_column (yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return 0; - - return yycolumn; + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; } /** Get the input stream. * @param yyscanner The scanner object. */ -FILE *hex_yyget_in(yyscan_t yyscanner) +FILE *yyget_in (yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - return yyin; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; } /** Get the output stream. * @param yyscanner The scanner object. */ -FILE *hex_yyget_out(yyscan_t yyscanner) +FILE *yyget_out (yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - return yyout; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; } /** Get the length of the current token. * @param yyscanner The scanner object. */ -yy_size_t hex_yyget_leng(yyscan_t yyscanner) +int yyget_leng (yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - return yyleng; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; } /** Get the current token. * @param yyscanner The scanner object. */ -char *hex_yyget_text(yyscan_t yyscanner) +char *yyget_text (yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - return yytext; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; } /** Set the user-defined data. This data is never touched by the scanner. * @param user_defined The data to be associated with this scanner. * @param yyscanner The scanner object. */ -void hex_yyset_extra(YY_EXTRA_TYPE user_defined, yyscan_t yyscanner) +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - yyextra = user_defined; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; } /** Set the current line number. * @param _line_number line number * @param yyscanner The scanner object. */ -void hex_yyset_lineno(int _line_number, yyscan_t yyscanner) +void yyset_lineno (int _line_number , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* lineno is only valid if an input buffer exists. */ - if (!YY_CURRENT_BUFFER) - YY_FATAL_ERROR("hex_yyset_lineno called with no buffer"); - - yylineno = _line_number; + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; } /** Set the current column. * @param _column_no column number * @param yyscanner The scanner object. */ -void hex_yyset_column(int _column_no, yyscan_t yyscanner) +void yyset_column (int _column_no , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* column is only valid if an input buffer exists. */ - if (!YY_CURRENT_BUFFER) - YY_FATAL_ERROR("hex_yyset_column called with no buffer"); - - yycolumn = _column_no; + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; } /** Set the input stream. This does not discard the current * input buffer. * @param _in_str A readable stream. * @param yyscanner The scanner object. - * @see hex_yy_switch_to_buffer + * @see yy_switch_to_buffer */ -void hex_yyset_in(FILE *_in_str, yyscan_t yyscanner) +void yyset_in (FILE * _in_str , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - yyin = _in_str; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; } -void hex_yyset_out(FILE *_out_str, yyscan_t yyscanner) +void yyset_out (FILE * _out_str , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - yyout = _out_str; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; } -int hex_yyget_debug(yyscan_t yyscanner) +int yyget_debug (yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - return yy_flex_debug; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; } -void hex_yyset_debug(int _bdebug, yyscan_t yyscanner) +void yyset_debug (int _bdebug , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - yy_flex_debug = _bdebug; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; } /* Accessor methods for yylval and yylloc */ -YYSTYPE *hex_yyget_lval(yyscan_t yyscanner) +YYSTYPE * yyget_lval (yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - return yylval; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; } -void hex_yyset_lval(YYSTYPE *yylval_param, yyscan_t yyscanner) +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - yylval = yylval_param; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; } /* User-visible API */ -/* hex_yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last - * argument. That's why we explicitly handle the declaration, instead of using - * our macros. +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. */ - -int hex_yylex_init(yyscan_t *ptr_yy_globals) - +int yylex_init(yyscan_t* ptr_yy_globals) { - if (ptr_yy_globals == NULL) - { - errno = EINVAL; - return 1; - } + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } - *ptr_yy_globals = (yyscan_t) hex_yyalloc(sizeof(struct yyguts_t), NULL); + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); - if (*ptr_yy_globals == NULL) - { - errno = ENOMEM; - return 1; - } + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for - * releases. */ - memset(*ptr_yy_globals, 0x00, sizeof(struct yyguts_t)); + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - return yy_init_globals(*ptr_yy_globals); + return yy_init_globals ( *ptr_yy_globals ); } -/* hex_yylex_init_extra has the same functionality as hex_yylex_init, but - * follows the convention of taking the scanner as the last argument. Note - * however, that this is a *pointer* to a scanner, as it will be allocated by - * this call (and is the reason, too, why this function also must handle its own - * declaration). The user defined value in the first argument will be available - * to hex_yyalloc in the yyextra field. +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. */ - -int hex_yylex_init_extra( - YY_EXTRA_TYPE yy_user_defined, - yyscan_t *ptr_yy_globals) - +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) { - struct yyguts_t dummy_yyguts; + struct yyguts_t dummy_yyguts; - hex_yyset_extra(yy_user_defined, &dummy_yyguts); + yyset_extra (yy_user_defined, &dummy_yyguts); - if (ptr_yy_globals == NULL) - { - errno = EINVAL; - return 1; - } + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } - *ptr_yy_globals = (yyscan_t) hex_yyalloc( - sizeof(struct yyguts_t), &dummy_yyguts); + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - if (*ptr_yy_globals == NULL) - { - errno = ENOMEM; - return 1; - } + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals, 0x00, sizeof(struct yyguts_t)); + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - hex_yyset_extra(yy_user_defined, *ptr_yy_globals); + yyset_extra (yy_user_defined, *ptr_yy_globals); - return yy_init_globals(*ptr_yy_globals); + return yy_init_globals ( *ptr_yy_globals ); } -static int yy_init_globals(yyscan_t yyscanner) +static int yy_init_globals (yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from hex_yylex_destroy(), so don't allocate here. - */ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ - yyg->yy_buffer_stack = 0; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = (char *) 0; - yyg->yy_init = 0; - yyg->yy_start = 0; + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; /* Defined in main.c */ #ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; + yyin = stdin; + yyout = stdout; #else - yyin = (FILE *) 0; - yyout = (FILE *) 0; + yyin = NULL; + yyout = NULL; #endif - /* For future reference: Set errno on error, since we are called by - * hex_yylex_init() - */ - return 0; + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; } -/* hex_yylex_destroy is for both reentrant and non-reentrant scanners. */ -int hex_yylex_destroy(yyscan_t yyscanner) +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Pop the buffer stack, destroying each element. */ - while (YY_CURRENT_BUFFER) - { - hex_yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - hex_yypop_buffer_state(yyscanner); - } + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } - /* Destroy the stack itself. */ - hex_yyfree(yyg->yy_buffer_stack, yyscanner); - yyg->yy_buffer_stack = NULL; + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; - /* Destroy the start condition stack. */ - hex_yyfree(yyg->yy_start_stack, yyscanner); - yyg->yy_start_stack = NULL; + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; - /* Reset the globals. This is important in a non-reentrant scanner so the next - * time hex_yylex() is called, initialization will occur. */ - yy_init_globals(yyscanner); + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); - /* Destroy the main struct (reentrant only). */ - hex_yyfree(yyscanner, yyscanner); - yyscanner = NULL; - return 0; + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; } /* @@ -2139,63 +2353,60 @@ int hex_yylex_destroy(yyscan_t yyscanner) */ #ifndef yytext_ptr -static void yy_flex_strncpy( - char *s1, - yyconst char *s2, - int n, - yyscan_t yyscanner) +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - (void) yyg; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; - int i; - for (i = 0; i < n; ++i) s1[i] = s2[i]; + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen(yyconst char *s, yyscan_t yyscanner) +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) { - int n; - for (n = 0; s[n]; ++n) - ; + int n; + for ( n = 0; s[n]; ++n ) + ; - return n; + return n; } #endif -void *hex_yyalloc(yy_size_t size, yyscan_t yyscanner) +void *yyalloc (yy_size_t size , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - (void) yyg; - return (void *) malloc(size); + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); } -void *hex_yyrealloc(void *ptr, yy_size_t size, yyscan_t yyscanner) +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - (void) yyg; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc((char *) ptr, size); + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); } -void hex_yyfree(void *ptr, yyscan_t yyscanner) +void yyfree (void * ptr , yyscan_t yyscanner) { - struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; - (void) yyg; - free((char *) ptr); /* see hex_yyrealloc() for (char *) cast */ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" -#line 182 "hex_lexer.l" +#line 188 "hex_lexer.l" // @@ -2204,9 +2415,11 @@ void hex_yyfree(void *ptr, yyscan_t yyscanner) // happens we are deep inside the parsing logic generated by flex/bison and // the only way to exit gracefully from there is using setjmp/longjmp. // -void yyfatal(yyscan_t yyscanner, const char *error_message) +void yyfatal( + yyscan_t yyscanner, + const char *error_message) { - jmp_buf *recovery_trampoline = (jmp_buf *) yr_thread_storage_get_value( + jmp_buf* recovery_trampoline = (jmp_buf*) yr_thread_storage_get_value( &yr_yyfatal_trampoline_tls); // Never returns. @@ -2215,7 +2428,7 @@ void yyfatal(yyscan_t yyscanner, const char *error_message) void yyerror( yyscan_t yyscanner, - HEX_LEX_ENVIRONMENT *lex_env, + HEX_LEX_ENVIRONMENT* lex_env, const char *error_message) { // if lex_env->last_error was set to some error code before @@ -2236,9 +2449,9 @@ void yyerror( int yr_parse_hex_string( - const char *hex_string, - RE_AST **re_ast, - RE_ERROR *error) + const char* hex_string, + RE_AST** re_ast, + RE_ERROR* error) { yyscan_t yyscanner; jmp_buf recovery_trampoline; @@ -2247,7 +2460,9 @@ int yr_parse_hex_string( lex_env.last_error = ERROR_SUCCESS; lex_env.inside_or = 0; - yr_thread_storage_set_value(&yr_yyfatal_trampoline_tls, &recovery_trampoline); + yr_thread_storage_set_value( + &yr_yyfatal_trampoline_tls, + &recovery_trampoline); if (setjmp(recovery_trampoline) != 0) return ERROR_INTERNAL_FATAL_ERROR; @@ -2269,11 +2484,11 @@ int yr_parse_hex_string( (*re_ast)->flags |= RE_FLAGS_DOT_ALL; - hex_yylex_init(&yyscanner); - hex_yyset_extra(*re_ast, yyscanner); - hex_yy_scan_string(hex_string, yyscanner); + yylex_init(&yyscanner); + yyset_extra(*re_ast, yyscanner); + yy_scan_string(hex_string, yyscanner); yyparse(yyscanner, &lex_env); - hex_yylex_destroy(yyscanner); + yylex_destroy(yyscanner); if (lex_env.last_error != ERROR_SUCCESS) { @@ -2283,3 +2498,4 @@ int yr_parse_hex_string( return ERROR_SUCCESS; } + diff --git a/libyara/hex_lexer.l b/libyara/hex_lexer.l index ce2b805f..b913a9f9 100644 --- a/libyara/hex_lexer.l +++ b/libyara/hex_lexer.l @@ -121,6 +121,12 @@ hexdigit [a-fA-F0-9] return _MASKED_BYTE_; } +{hexdigit} { + + yyerror(yyscanner, lex_env, "uneven number of digits in hex string"); + yyterminate(); +} + \[ { BEGIN(range);