/src/yara/libyara/hex_grammar.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* A Bison parser, made by GNU Bison 3.8.2. */ |
2 | | |
3 | | /* Bison implementation for Yacc-like parsers in C |
4 | | |
5 | | Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, |
6 | | Inc. |
7 | | |
8 | | This program is free software: you can redistribute it and/or modify |
9 | | it under the terms of the GNU General Public License as published by |
10 | | the Free Software Foundation, either version 3 of the License, or |
11 | | (at your option) any later version. |
12 | | |
13 | | This program is distributed in the hope that it will be useful, |
14 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | | GNU General Public License for more details. |
17 | | |
18 | | You should have received a copy of the GNU General Public License |
19 | | along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
20 | | |
21 | | /* As a special exception, you may create a larger work that contains |
22 | | part or all of the Bison parser skeleton and distribute that work |
23 | | under terms of your choice, so long as that work isn't itself a |
24 | | parser generator using the skeleton or a modified version thereof |
25 | | as a parser skeleton. Alternatively, if you modify or redistribute |
26 | | the parser skeleton itself, you may (at your option) remove this |
27 | | special exception, which will cause the skeleton and the resulting |
28 | | Bison output files to be licensed under the GNU General Public |
29 | | License without this special exception. |
30 | | |
31 | | This special exception was added by the Free Software Foundation in |
32 | | version 2.2 of Bison. */ |
33 | | |
34 | | /* C LALR(1) parser skeleton written by Richard Stallman, by |
35 | | simplifying the original so-called "semantic" parser. */ |
36 | | |
37 | | /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, |
38 | | especially those whose name start with YY_ or yy_. They are |
39 | | private implementation details that can be changed or removed. */ |
40 | | |
41 | | /* All symbols defined below should begin with yy or YY, to avoid |
42 | | infringing on user name space. This should be done even for local |
43 | | variables, as they might otherwise be expanded by user macros. |
44 | | There are some unavoidable exceptions within include files to |
45 | | define necessary library symbols; they are noted "INFRINGES ON |
46 | | USER NAME SPACE" below. */ |
47 | | |
48 | | /* Identify Bison output, and Bison version. */ |
49 | | #define YYBISON 30802 |
50 | | |
51 | | /* Bison version string. */ |
52 | | #define YYBISON_VERSION "3.8.2" |
53 | | |
54 | | /* Skeleton name. */ |
55 | | #define YYSKELETON_NAME "yacc.c" |
56 | | |
57 | | /* Pure parsers. */ |
58 | | #define YYPURE 1 |
59 | | |
60 | | /* Push parsers. */ |
61 | | #define YYPUSH 0 |
62 | | |
63 | | /* Pull parsers. */ |
64 | | #define YYPULL 1 |
65 | | |
66 | | |
67 | | /* Substitute the variable and function names. */ |
68 | | #define yyparse hex_yyparse |
69 | | #define yylex hex_yylex |
70 | | #define yyerror hex_yyerror |
71 | | #define yydebug hex_yydebug |
72 | | #define yynerrs hex_yynerrs |
73 | | |
74 | | /* First part of user prologue. */ |
75 | | #line 30 "hex_grammar.y" |
76 | | |
77 | | |
78 | | #include <string.h> |
79 | | #include <limits.h> |
80 | | |
81 | | #include <yara/integers.h> |
82 | | #include <yara/utils.h> |
83 | | #include <yara/hex_lexer.h> |
84 | | #include <yara/limits.h> |
85 | | #include <yara/mem.h> |
86 | | #include <yara/error.h> |
87 | | |
88 | | |
89 | | #define STR_EXPAND(tok) #tok |
90 | | #define STR(tok) STR_EXPAND(tok) |
91 | | |
92 | | #define YYERROR_VERBOSE |
93 | | |
94 | | #define YYMALLOC yr_malloc |
95 | 0 | #define YYFREE yr_free |
96 | | |
97 | | #define mark_as_not_fast_regexp() \ |
98 | 0 | ((RE_AST*) yyget_extra(yyscanner))->flags &= ~RE_FLAGS_FAST_REGEXP |
99 | | |
100 | | #define fail_if(x, error) \ |
101 | 0 | if (x) \ |
102 | 0 | { \ |
103 | 0 | lex_env->last_error = error; \ |
104 | 0 | YYABORT; \ |
105 | 0 | } \ |
106 | | |
107 | | #define destroy_node_if(x, node) \ |
108 | 0 | if (x) \ |
109 | 0 | { \ |
110 | 0 | yr_re_node_destroy(node); \ |
111 | 0 | } \ |
112 | | |
113 | | |
114 | | #line 115 "hex_grammar.c" |
115 | | |
116 | | # ifndef YY_CAST |
117 | | # ifdef __cplusplus |
118 | | # define YY_CAST(Type, Val) static_cast<Type> (Val) |
119 | | # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val) |
120 | | # else |
121 | 0 | # define YY_CAST(Type, Val) ((Type) (Val)) |
122 | | # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) |
123 | | # endif |
124 | | # endif |
125 | | # ifndef YY_NULLPTR |
126 | | # if defined __cplusplus |
127 | | # if 201103L <= __cplusplus |
128 | | # define YY_NULLPTR nullptr |
129 | | # else |
130 | | # define YY_NULLPTR 0 |
131 | | # endif |
132 | | # else |
133 | | # define YY_NULLPTR ((void*)0) |
134 | | # endif |
135 | | # endif |
136 | | |
137 | | /* Use api.header.include to #include this header |
138 | | instead of duplicating it here. */ |
139 | | #ifndef YY_HEX_YY_HEX_GRAMMAR_H_INCLUDED |
140 | | # define YY_HEX_YY_HEX_GRAMMAR_H_INCLUDED |
141 | | /* Debug traces. */ |
142 | | #ifndef YYDEBUG |
143 | | # define YYDEBUG 0 |
144 | | #endif |
145 | | #if YYDEBUG |
146 | | extern int hex_yydebug; |
147 | | #endif |
148 | | |
149 | | /* Token kinds. */ |
150 | | #ifndef YYTOKENTYPE |
151 | | # define YYTOKENTYPE |
152 | | enum yytokentype |
153 | | { |
154 | | YYEMPTY = -2, |
155 | | YYEOF = 0, /* "end of file" */ |
156 | | YYerror = 256, /* error */ |
157 | | YYUNDEF = 257, /* "invalid token" */ |
158 | | _BYTE_ = 258, /* _BYTE_ */ |
159 | | _MASKED_BYTE_ = 259, /* _MASKED_BYTE_ */ |
160 | | _NOT_BYTE_ = 260, /* _NOT_BYTE_ */ |
161 | | _MASKED_NOT_BYTE_ = 261, /* _MASKED_NOT_BYTE_ */ |
162 | | _NUMBER_ = 262 /* _NUMBER_ */ |
163 | | }; |
164 | | typedef enum yytokentype yytoken_kind_t; |
165 | | #endif |
166 | | /* Token kinds. */ |
167 | | #define YYEMPTY -2 |
168 | | #define YYEOF 0 |
169 | | #define YYerror 256 |
170 | | #define YYUNDEF 257 |
171 | | #define _BYTE_ 258 |
172 | | #define _MASKED_BYTE_ 259 |
173 | | #define _NOT_BYTE_ 260 |
174 | | #define _MASKED_NOT_BYTE_ 261 |
175 | | #define _NUMBER_ 262 |
176 | | |
177 | | /* Value type. */ |
178 | | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
179 | | union YYSTYPE |
180 | | { |
181 | | #line 78 "hex_grammar.y" |
182 | | |
183 | | int64_t integer; |
184 | | RE_NODE *re_node; |
185 | | |
186 | | #line 187 "hex_grammar.c" |
187 | | |
188 | | }; |
189 | | typedef union YYSTYPE YYSTYPE; |
190 | | # define YYSTYPE_IS_TRIVIAL 1 |
191 | | # define YYSTYPE_IS_DECLARED 1 |
192 | | #endif |
193 | | |
194 | | |
195 | | |
196 | | |
197 | | int hex_yyparse (void *yyscanner, HEX_LEX_ENVIRONMENT *lex_env); |
198 | | |
199 | | |
200 | | #endif /* !YY_HEX_YY_HEX_GRAMMAR_H_INCLUDED */ |
201 | | /* Symbol kind. */ |
202 | | enum yysymbol_kind_t |
203 | | { |
204 | | YYSYMBOL_YYEMPTY = -2, |
205 | | YYSYMBOL_YYEOF = 0, /* "end of file" */ |
206 | | YYSYMBOL_YYerror = 1, /* error */ |
207 | | YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ |
208 | | YYSYMBOL__BYTE_ = 3, /* _BYTE_ */ |
209 | | YYSYMBOL__MASKED_BYTE_ = 4, /* _MASKED_BYTE_ */ |
210 | | YYSYMBOL__NOT_BYTE_ = 5, /* _NOT_BYTE_ */ |
211 | | YYSYMBOL__MASKED_NOT_BYTE_ = 6, /* _MASKED_NOT_BYTE_ */ |
212 | | YYSYMBOL__NUMBER_ = 7, /* _NUMBER_ */ |
213 | | YYSYMBOL_8_ = 8, /* '{' */ |
214 | | YYSYMBOL_9_ = 9, /* '}' */ |
215 | | YYSYMBOL_10_ = 10, /* '(' */ |
216 | | YYSYMBOL_11_ = 11, /* ')' */ |
217 | | YYSYMBOL_12_ = 12, /* '[' */ |
218 | | YYSYMBOL_13_ = 13, /* ']' */ |
219 | | YYSYMBOL_14_ = 14, /* '-' */ |
220 | | YYSYMBOL_15_ = 15, /* '|' */ |
221 | | YYSYMBOL_YYACCEPT = 16, /* $accept */ |
222 | | YYSYMBOL_hex_string = 17, /* hex_string */ |
223 | | YYSYMBOL_tokens = 18, /* tokens */ |
224 | | YYSYMBOL_token_sequence = 19, /* token_sequence */ |
225 | | YYSYMBOL_token_or_range = 20, /* token_or_range */ |
226 | | YYSYMBOL_token = 21, /* token */ |
227 | | YYSYMBOL_22_1 = 22, /* $@1 */ |
228 | | YYSYMBOL_range = 23, /* range */ |
229 | | YYSYMBOL_alternatives = 24, /* alternatives */ |
230 | | YYSYMBOL_byte = 25 /* byte */ |
231 | | }; |
232 | | typedef enum yysymbol_kind_t yysymbol_kind_t; |
233 | | |
234 | | |
235 | | |
236 | | |
237 | | #ifdef short |
238 | | # undef short |
239 | | #endif |
240 | | |
241 | | /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure |
242 | | <limits.h> and (if available) <stdint.h> are included |
243 | | so that the code can choose integer types of a good width. */ |
244 | | |
245 | | #ifndef __PTRDIFF_MAX__ |
246 | | # include <limits.h> /* INFRINGES ON USER NAME SPACE */ |
247 | | # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ |
248 | | # include <stdint.h> /* INFRINGES ON USER NAME SPACE */ |
249 | | # define YY_STDINT_H |
250 | | # endif |
251 | | #endif |
252 | | |
253 | | /* Narrow types that promote to a signed type and that can represent a |
254 | | signed or unsigned integer of at least N bits. In tables they can |
255 | | save space and decrease cache pressure. Promoting to a signed type |
256 | | helps avoid bugs in integer arithmetic. */ |
257 | | |
258 | | #ifdef __INT_LEAST8_MAX__ |
259 | | typedef __INT_LEAST8_TYPE__ yytype_int8; |
260 | | #elif defined YY_STDINT_H |
261 | | typedef int_least8_t yytype_int8; |
262 | | #else |
263 | | typedef signed char yytype_int8; |
264 | | #endif |
265 | | |
266 | | #ifdef __INT_LEAST16_MAX__ |
267 | | typedef __INT_LEAST16_TYPE__ yytype_int16; |
268 | | #elif defined YY_STDINT_H |
269 | | typedef int_least16_t yytype_int16; |
270 | | #else |
271 | | typedef short yytype_int16; |
272 | | #endif |
273 | | |
274 | | /* Work around bug in HP-UX 11.23, which defines these macros |
275 | | incorrectly for preprocessor constants. This workaround can likely |
276 | | be removed in 2023, as HPE has promised support for HP-UX 11.23 |
277 | | (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of |
278 | | <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */ |
279 | | #ifdef __hpux |
280 | | # undef UINT_LEAST8_MAX |
281 | | # undef UINT_LEAST16_MAX |
282 | | # define UINT_LEAST8_MAX 255 |
283 | | # define UINT_LEAST16_MAX 65535 |
284 | | #endif |
285 | | |
286 | | #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ |
287 | | typedef __UINT_LEAST8_TYPE__ yytype_uint8; |
288 | | #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ |
289 | | && UINT_LEAST8_MAX <= INT_MAX) |
290 | | typedef uint_least8_t yytype_uint8; |
291 | | #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX |
292 | | typedef unsigned char yytype_uint8; |
293 | | #else |
294 | | typedef short yytype_uint8; |
295 | | #endif |
296 | | |
297 | | #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ |
298 | | typedef __UINT_LEAST16_TYPE__ yytype_uint16; |
299 | | #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ |
300 | | && UINT_LEAST16_MAX <= INT_MAX) |
301 | | typedef uint_least16_t yytype_uint16; |
302 | | #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX |
303 | | typedef unsigned short yytype_uint16; |
304 | | #else |
305 | | typedef int yytype_uint16; |
306 | | #endif |
307 | | |
308 | | #ifndef YYPTRDIFF_T |
309 | | # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ |
310 | 0 | # define YYPTRDIFF_T __PTRDIFF_TYPE__ |
311 | | # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ |
312 | | # elif defined PTRDIFF_MAX |
313 | | # ifndef ptrdiff_t |
314 | | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
315 | | # endif |
316 | | # define YYPTRDIFF_T ptrdiff_t |
317 | | # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX |
318 | | # else |
319 | | # define YYPTRDIFF_T long |
320 | | # define YYPTRDIFF_MAXIMUM LONG_MAX |
321 | | # endif |
322 | | #endif |
323 | | |
324 | | #ifndef YYSIZE_T |
325 | | # ifdef __SIZE_TYPE__ |
326 | | # define YYSIZE_T __SIZE_TYPE__ |
327 | | # elif defined size_t |
328 | | # define YYSIZE_T size_t |
329 | | # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ |
330 | | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
331 | | # define YYSIZE_T size_t |
332 | | # else |
333 | | # define YYSIZE_T unsigned |
334 | | # endif |
335 | | #endif |
336 | | |
337 | | #define YYSIZE_MAXIMUM \ |
338 | | YY_CAST (YYPTRDIFF_T, \ |
339 | | (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ |
340 | | ? YYPTRDIFF_MAXIMUM \ |
341 | | : YY_CAST (YYSIZE_T, -1))) |
342 | | |
343 | 0 | #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) |
344 | | |
345 | | |
346 | | /* Stored state numbers (used for stacks). */ |
347 | | typedef yytype_int8 yy_state_t; |
348 | | |
349 | | /* State numbers in computations. */ |
350 | | typedef int yy_state_fast_t; |
351 | | |
352 | | #ifndef YY_ |
353 | | # if defined YYENABLE_NLS && YYENABLE_NLS |
354 | | # if ENABLE_NLS |
355 | | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
356 | | # define YY_(Msgid) dgettext ("bison-runtime", Msgid) |
357 | | # endif |
358 | | # endif |
359 | | # ifndef YY_ |
360 | 0 | # define YY_(Msgid) Msgid |
361 | | # endif |
362 | | #endif |
363 | | |
364 | | |
365 | | #ifndef YY_ATTRIBUTE_PURE |
366 | | # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) |
367 | | # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) |
368 | | # else |
369 | | # define YY_ATTRIBUTE_PURE |
370 | | # endif |
371 | | #endif |
372 | | |
373 | | #ifndef YY_ATTRIBUTE_UNUSED |
374 | | # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) |
375 | | # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) |
376 | | # else |
377 | | # define YY_ATTRIBUTE_UNUSED |
378 | | # endif |
379 | | #endif |
380 | | |
381 | | /* Suppress unused-variable warnings by "using" E. */ |
382 | | #if ! defined lint || defined __GNUC__ |
383 | 0 | # define YY_USE(E) ((void) (E)) |
384 | | #else |
385 | | # define YY_USE(E) /* empty */ |
386 | | #endif |
387 | | |
388 | | /* Suppress an incorrect diagnostic about yylval being uninitialized. */ |
389 | | #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ |
390 | | # if __GNUC__ * 100 + __GNUC_MINOR__ < 407 |
391 | | # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ |
392 | | _Pragma ("GCC diagnostic push") \ |
393 | | _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") |
394 | | # else |
395 | | # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ |
396 | | _Pragma ("GCC diagnostic push") \ |
397 | | _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ |
398 | | _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") |
399 | | # endif |
400 | | # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ |
401 | | _Pragma ("GCC diagnostic pop") |
402 | | #else |
403 | 0 | # define YY_INITIAL_VALUE(Value) Value |
404 | | #endif |
405 | | #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
406 | | # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
407 | | # define YY_IGNORE_MAYBE_UNINITIALIZED_END |
408 | | #endif |
409 | | #ifndef YY_INITIAL_VALUE |
410 | | # define YY_INITIAL_VALUE(Value) /* Nothing. */ |
411 | | #endif |
412 | | |
413 | | #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ |
414 | | # define YY_IGNORE_USELESS_CAST_BEGIN \ |
415 | | _Pragma ("GCC diagnostic push") \ |
416 | | _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") |
417 | | # define YY_IGNORE_USELESS_CAST_END \ |
418 | | _Pragma ("GCC diagnostic pop") |
419 | | #endif |
420 | | #ifndef YY_IGNORE_USELESS_CAST_BEGIN |
421 | | # define YY_IGNORE_USELESS_CAST_BEGIN |
422 | | # define YY_IGNORE_USELESS_CAST_END |
423 | | #endif |
424 | | |
425 | | |
426 | 0 | #define YY_ASSERT(E) ((void) (0 && (E))) |
427 | | |
428 | | #if !defined yyoverflow |
429 | | |
430 | | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
431 | | |
432 | | # ifdef YYSTACK_USE_ALLOCA |
433 | | # if YYSTACK_USE_ALLOCA |
434 | | # ifdef __GNUC__ |
435 | | # define YYSTACK_ALLOC __builtin_alloca |
436 | | # elif defined __BUILTIN_VA_ARG_INCR |
437 | | # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ |
438 | | # elif defined _AIX |
439 | | # define YYSTACK_ALLOC __alloca |
440 | | # elif defined _MSC_VER |
441 | | # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ |
442 | | # define alloca _alloca |
443 | | # else |
444 | | # define YYSTACK_ALLOC alloca |
445 | | # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS |
446 | | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
447 | | /* Use EXIT_SUCCESS as a witness for stdlib.h. */ |
448 | | # ifndef EXIT_SUCCESS |
449 | | # define EXIT_SUCCESS 0 |
450 | | # endif |
451 | | # endif |
452 | | # endif |
453 | | # endif |
454 | | # endif |
455 | | |
456 | | # ifdef YYSTACK_ALLOC |
457 | | /* Pacify GCC's 'empty if-body' warning. */ |
458 | | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
459 | | # ifndef YYSTACK_ALLOC_MAXIMUM |
460 | | /* The OS might guarantee only one guard page at the bottom of the stack, |
461 | | and a page size can be as small as 4096 bytes. So we cannot safely |
462 | | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
463 | | to allow for a few compiler-allocated temporary stack slots. */ |
464 | | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ |
465 | | # endif |
466 | | # else |
467 | | # define YYSTACK_ALLOC YYMALLOC |
468 | 0 | # define YYSTACK_FREE YYFREE |
469 | | # ifndef YYSTACK_ALLOC_MAXIMUM |
470 | | # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
471 | | # endif |
472 | | # if (defined __cplusplus && ! defined EXIT_SUCCESS \ |
473 | | && ! ((defined YYMALLOC || defined malloc) \ |
474 | | && (defined YYFREE || defined free))) |
475 | | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
476 | | # ifndef EXIT_SUCCESS |
477 | | # define EXIT_SUCCESS 0 |
478 | | # endif |
479 | | # endif |
480 | | # ifndef YYMALLOC |
481 | | # define YYMALLOC malloc |
482 | | # if ! defined malloc && ! defined EXIT_SUCCESS |
483 | | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
484 | | # endif |
485 | | # endif |
486 | | # ifndef YYFREE |
487 | | # define YYFREE free |
488 | | # if ! defined free && ! defined EXIT_SUCCESS |
489 | | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
490 | | # endif |
491 | | # endif |
492 | | # endif |
493 | | #endif /* !defined yyoverflow */ |
494 | | |
495 | | #if (! defined yyoverflow \ |
496 | | && (! defined __cplusplus \ |
497 | | || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) |
498 | | |
499 | | /* A type that is properly aligned for any stack member. */ |
500 | | union yyalloc |
501 | | { |
502 | | yy_state_t yyss_alloc; |
503 | | YYSTYPE yyvs_alloc; |
504 | | }; |
505 | | |
506 | | /* The size of the maximum gap between one aligned stack and the next. */ |
507 | 0 | # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) |
508 | | |
509 | | /* The size of an array large to enough to hold all stacks, each with |
510 | | N elements. */ |
511 | | # define YYSTACK_BYTES(N) \ |
512 | | ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ |
513 | | + YYSTACK_GAP_MAXIMUM) |
514 | | |
515 | | # define YYCOPY_NEEDED 1 |
516 | | |
517 | | /* Relocate STACK from its old location to the new one. The |
518 | | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
519 | | elements in the stack, and YYPTR gives the new location of the |
520 | | stack. Advance YYPTR to a properly aligned location for the next |
521 | | stack. */ |
522 | | # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ |
523 | 0 | do \ |
524 | 0 | { \ |
525 | 0 | YYPTRDIFF_T yynewbytes; \ |
526 | 0 | YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ |
527 | 0 | Stack = &yyptr->Stack_alloc; \ |
528 | 0 | yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
529 | 0 | yyptr += yynewbytes / YYSIZEOF (*yyptr); \ |
530 | 0 | } \ |
531 | 0 | while (0) |
532 | | |
533 | | #endif |
534 | | |
535 | | #if defined YYCOPY_NEEDED && YYCOPY_NEEDED |
536 | | /* Copy COUNT objects from SRC to DST. The source and destination do |
537 | | not overlap. */ |
538 | | # ifndef YYCOPY |
539 | | # if defined __GNUC__ && 1 < __GNUC__ |
540 | | # define YYCOPY(Dst, Src, Count) \ |
541 | 0 | __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) |
542 | | # else |
543 | | # define YYCOPY(Dst, Src, Count) \ |
544 | | do \ |
545 | | { \ |
546 | | YYPTRDIFF_T yyi; \ |
547 | | for (yyi = 0; yyi < (Count); yyi++) \ |
548 | | (Dst)[yyi] = (Src)[yyi]; \ |
549 | | } \ |
550 | | while (0) |
551 | | # endif |
552 | | # endif |
553 | | #endif /* !YYCOPY_NEEDED */ |
554 | | |
555 | | /* YYFINAL -- State number of the termination state. */ |
556 | 0 | #define YYFINAL 11 |
557 | | /* YYLAST -- Last index in YYTABLE. */ |
558 | 0 | #define YYLAST 35 |
559 | | |
560 | | /* YYNTOKENS -- Number of terminals. */ |
561 | 0 | #define YYNTOKENS 16 |
562 | | /* YYNNTS -- Number of nonterminals. */ |
563 | | #define YYNNTS 10 |
564 | | /* YYNRULES -- Number of rules. */ |
565 | | #define YYNRULES 22 |
566 | | /* YYNSTATES -- Number of states. */ |
567 | | #define YYNSTATES 34 |
568 | | |
569 | | /* YYMAXUTOK -- Last valid token kind. */ |
570 | 0 | #define YYMAXUTOK 262 |
571 | | |
572 | | |
573 | | /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM |
574 | | as returned by yylex, with out-of-bounds checking. */ |
575 | | #define YYTRANSLATE(YYX) \ |
576 | 0 | (0 <= (YYX) && (YYX) <= YYMAXUTOK \ |
577 | 0 | ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ |
578 | 0 | : YYSYMBOL_YYUNDEF) |
579 | | |
580 | | /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM |
581 | | as returned by yylex. */ |
582 | | static const yytype_int8 yytranslate[] = |
583 | | { |
584 | | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
585 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
586 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
587 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
588 | | 10, 11, 2, 2, 2, 14, 2, 2, 2, 2, |
589 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
590 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
591 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
592 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
593 | | 2, 12, 2, 13, 2, 2, 2, 2, 2, 2, |
594 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
595 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
596 | | 2, 2, 2, 8, 15, 9, 2, 2, 2, 2, |
597 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
598 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
599 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
600 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
601 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
602 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
603 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
604 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
605 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
606 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
607 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
608 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
609 | | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
610 | | 5, 6, 7 |
611 | | }; |
612 | | |
613 | | #if YYDEBUG |
614 | | /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ |
615 | | static const yytype_int16 yyrline[] = |
616 | | { |
617 | | 0, 107, 107, 116, 120, 132, 143, 152, 161, 165, |
618 | | 174, 179, 178, 191, 227, 259, 281, 301, 305, 322, |
619 | | 331, 340, 363 |
620 | | }; |
621 | | #endif |
622 | | |
623 | | /** Accessing symbol of state STATE. */ |
624 | 0 | #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) |
625 | | |
626 | | #if YYDEBUG || 0 |
627 | | /* The user-facing name of the symbol whose (internal) number is |
628 | | YYSYMBOL. No bounds checking. */ |
629 | | static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; |
630 | | |
631 | | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
632 | | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
633 | | static const char *const yytname[] = |
634 | | { |
635 | | "\"end of file\"", "error", "\"invalid token\"", "_BYTE_", |
636 | | "_MASKED_BYTE_", "_NOT_BYTE_", "_MASKED_NOT_BYTE_", "_NUMBER_", "'{'", |
637 | | "'}'", "'('", "')'", "'['", "']'", "'-'", "'|'", "$accept", "hex_string", |
638 | | "tokens", "token_sequence", "token_or_range", "token", "$@1", "range", |
639 | | "alternatives", "byte", YY_NULLPTR |
640 | | }; |
641 | | |
642 | | static const char * |
643 | | yysymbol_name (yysymbol_kind_t yysymbol) |
644 | | { |
645 | | return yytname[yysymbol]; |
646 | | } |
647 | | #endif |
648 | | |
649 | 0 | #define YYPACT_NINF (-13) |
650 | | |
651 | | #define yypact_value_is_default(Yyn) \ |
652 | 0 | ((Yyn) == YYPACT_NINF) |
653 | | |
654 | | #define YYTABLE_NINF (-6) |
655 | | |
656 | | #define yytable_value_is_error(Yyn) \ |
657 | 0 | 0 |
658 | | |
659 | | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
660 | | STATE-NUM. */ |
661 | | static const yytype_int8 yypact[] = |
662 | | { |
663 | | 1, 12, 24, -13, -13, -13, -13, -13, 3, -2, |
664 | | -13, -13, 12, -13, -1, -2, -13, -4, -13, -13, |
665 | | 16, 19, 15, -13, 10, -13, 12, -13, 13, -13, |
666 | | -13, 17, -13, -13 |
667 | | }; |
668 | | |
669 | | /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. |
670 | | Performed when YYTABLE does not specify something else to do. Zero |
671 | | means the default is an error. */ |
672 | | static const yytype_int8 yydefact[] = |
673 | | { |
674 | | 0, 0, 0, 19, 21, 20, 22, 11, 0, 3, |
675 | | 10, 1, 0, 2, 0, 0, 6, 8, 9, 17, |
676 | | 0, 0, 0, 7, 8, 12, 0, 13, 0, 16, |
677 | | 18, 0, 15, 14 |
678 | | }; |
679 | | |
680 | | /* YYPGOTO[NTERM-NUM]. */ |
681 | | static const yytype_int8 yypgoto[] = |
682 | | { |
683 | | -13, -13, -12, -13, 20, 14, -13, -13, -13, -13 |
684 | | }; |
685 | | |
686 | | /* YYDEFGOTO[NTERM-NUM]. */ |
687 | | static const yytype_int8 yydefgoto[] = |
688 | | { |
689 | | 0, 2, 8, 15, 16, 9, 12, 18, 20, 10 |
690 | | }; |
691 | | |
692 | | /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If |
693 | | positive, shift that token. If negative, reduce the rule whose |
694 | | number is the opposite. If YYTABLE_NINF, syntax error. */ |
695 | | static const yytype_int8 yytable[] = |
696 | | { |
697 | | 19, 3, 4, 5, 6, -4, 21, -4, 7, 1, |
698 | | 14, -4, 13, 22, 30, 3, 4, 5, 6, -5, |
699 | | 31, -5, 7, 17, 11, -5, 32, 25, 29, 24, |
700 | | 33, 26, 27, 28, 0, 23 |
701 | | }; |
702 | | |
703 | | static const yytype_int8 yycheck[] = |
704 | | { |
705 | | 12, 3, 4, 5, 6, 9, 7, 11, 10, 8, |
706 | | 12, 15, 9, 14, 26, 3, 4, 5, 6, 9, |
707 | | 7, 11, 10, 9, 0, 15, 13, 11, 13, 15, |
708 | | 13, 15, 13, 14, -1, 15 |
709 | | }; |
710 | | |
711 | | /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of |
712 | | state STATE-NUM. */ |
713 | | static const yytype_int8 yystos[] = |
714 | | { |
715 | | 0, 8, 17, 3, 4, 5, 6, 10, 18, 21, |
716 | | 25, 0, 22, 9, 12, 19, 20, 21, 23, 18, |
717 | | 24, 7, 14, 20, 21, 11, 15, 13, 14, 13, |
718 | | 18, 7, 13, 13 |
719 | | }; |
720 | | |
721 | | /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ |
722 | | static const yytype_int8 yyr1[] = |
723 | | { |
724 | | 0, 16, 17, 18, 18, 18, 19, 19, 20, 20, |
725 | | 21, 22, 21, 23, 23, 23, 23, 24, 24, 25, |
726 | | 25, 25, 25 |
727 | | }; |
728 | | |
729 | | /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ |
730 | | static const yytype_int8 yyr2[] = |
731 | | { |
732 | | 0, 2, 3, 1, 2, 3, 1, 2, 1, 1, |
733 | | 1, 0, 4, 3, 5, 4, 3, 1, 3, 1, |
734 | | 1, 1, 1 |
735 | | }; |
736 | | |
737 | | |
738 | | enum { YYENOMEM = -2 }; |
739 | | |
740 | | #define yyerrok (yyerrstatus = 0) |
741 | | #define yyclearin (yychar = YYEMPTY) |
742 | | |
743 | 0 | #define YYACCEPT goto yyacceptlab |
744 | 0 | #define YYABORT goto yyabortlab |
745 | 0 | #define YYERROR goto yyerrorlab |
746 | 0 | #define YYNOMEM goto yyexhaustedlab |
747 | | |
748 | | |
749 | | #define YYRECOVERING() (!!yyerrstatus) |
750 | | |
751 | | #define YYBACKUP(Token, Value) \ |
752 | | do \ |
753 | | if (yychar == YYEMPTY) \ |
754 | | { \ |
755 | | yychar = (Token); \ |
756 | | yylval = (Value); \ |
757 | | YYPOPSTACK (yylen); \ |
758 | | yystate = *yyssp; \ |
759 | | goto yybackup; \ |
760 | | } \ |
761 | | else \ |
762 | | { \ |
763 | | yyerror (yyscanner, lex_env, YY_("syntax error: cannot back up")); \ |
764 | | YYERROR; \ |
765 | | } \ |
766 | | while (0) |
767 | | |
768 | | /* Backward compatibility with an undocumented macro. |
769 | | Use YYerror or YYUNDEF. */ |
770 | | #define YYERRCODE YYUNDEF |
771 | | |
772 | | |
773 | | /* Enable debugging if requested. */ |
774 | | #if YYDEBUG |
775 | | |
776 | | # ifndef YYFPRINTF |
777 | | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
778 | | # define YYFPRINTF fprintf |
779 | | # endif |
780 | | |
781 | | # define YYDPRINTF(Args) \ |
782 | | do { \ |
783 | | if (yydebug) \ |
784 | | YYFPRINTF Args; \ |
785 | | } while (0) |
786 | | |
787 | | |
788 | | |
789 | | |
790 | | # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ |
791 | | do { \ |
792 | | if (yydebug) \ |
793 | | { \ |
794 | | YYFPRINTF (stderr, "%s ", Title); \ |
795 | | yy_symbol_print (stderr, \ |
796 | | Kind, Value, yyscanner, lex_env); \ |
797 | | YYFPRINTF (stderr, "\n"); \ |
798 | | } \ |
799 | | } while (0) |
800 | | |
801 | | |
802 | | /*-----------------------------------. |
803 | | | Print this symbol's value on YYO. | |
804 | | `-----------------------------------*/ |
805 | | |
806 | | static void |
807 | | yy_symbol_value_print (FILE *yyo, |
808 | | yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, void *yyscanner, HEX_LEX_ENVIRONMENT *lex_env) |
809 | | { |
810 | | FILE *yyoutput = yyo; |
811 | | YY_USE (yyoutput); |
812 | | YY_USE (yyscanner); |
813 | | YY_USE (lex_env); |
814 | | if (!yyvaluep) |
815 | | return; |
816 | | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
817 | | YY_USE (yykind); |
818 | | YY_IGNORE_MAYBE_UNINITIALIZED_END |
819 | | } |
820 | | |
821 | | |
822 | | /*---------------------------. |
823 | | | Print this symbol on YYO. | |
824 | | `---------------------------*/ |
825 | | |
826 | | static void |
827 | | yy_symbol_print (FILE *yyo, |
828 | | yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, void *yyscanner, HEX_LEX_ENVIRONMENT *lex_env) |
829 | | { |
830 | | YYFPRINTF (yyo, "%s %s (", |
831 | | yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); |
832 | | |
833 | | yy_symbol_value_print (yyo, yykind, yyvaluep, yyscanner, lex_env); |
834 | | YYFPRINTF (yyo, ")"); |
835 | | } |
836 | | |
837 | | /*------------------------------------------------------------------. |
838 | | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
839 | | | TOP (included). | |
840 | | `------------------------------------------------------------------*/ |
841 | | |
842 | | static void |
843 | | yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) |
844 | | { |
845 | | YYFPRINTF (stderr, "Stack now"); |
846 | | for (; yybottom <= yytop; yybottom++) |
847 | | { |
848 | | int yybot = *yybottom; |
849 | | YYFPRINTF (stderr, " %d", yybot); |
850 | | } |
851 | | YYFPRINTF (stderr, "\n"); |
852 | | } |
853 | | |
854 | | # define YY_STACK_PRINT(Bottom, Top) \ |
855 | | do { \ |
856 | | if (yydebug) \ |
857 | | yy_stack_print ((Bottom), (Top)); \ |
858 | | } while (0) |
859 | | |
860 | | |
861 | | /*------------------------------------------------. |
862 | | | Report that the YYRULE is going to be reduced. | |
863 | | `------------------------------------------------*/ |
864 | | |
865 | | static void |
866 | | yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, |
867 | | int yyrule, void *yyscanner, HEX_LEX_ENVIRONMENT *lex_env) |
868 | | { |
869 | | int yylno = yyrline[yyrule]; |
870 | | int yynrhs = yyr2[yyrule]; |
871 | | int yyi; |
872 | | YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", |
873 | | yyrule - 1, yylno); |
874 | | /* The symbols being reduced. */ |
875 | | for (yyi = 0; yyi < yynrhs; yyi++) |
876 | | { |
877 | | YYFPRINTF (stderr, " $%d = ", yyi + 1); |
878 | | yy_symbol_print (stderr, |
879 | | YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), |
880 | | &yyvsp[(yyi + 1) - (yynrhs)], yyscanner, lex_env); |
881 | | YYFPRINTF (stderr, "\n"); |
882 | | } |
883 | | } |
884 | | |
885 | | # define YY_REDUCE_PRINT(Rule) \ |
886 | | do { \ |
887 | | if (yydebug) \ |
888 | | yy_reduce_print (yyssp, yyvsp, Rule, yyscanner, lex_env); \ |
889 | | } while (0) |
890 | | |
891 | | /* Nonzero means print parse trace. It is left uninitialized so that |
892 | | multiple parsers can coexist. */ |
893 | | int yydebug; |
894 | | #else /* !YYDEBUG */ |
895 | 0 | # define YYDPRINTF(Args) ((void) 0) |
896 | | # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) |
897 | | # define YY_STACK_PRINT(Bottom, Top) |
898 | | # define YY_REDUCE_PRINT(Rule) |
899 | | #endif /* !YYDEBUG */ |
900 | | |
901 | | |
902 | | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
903 | | #ifndef YYINITDEPTH |
904 | 0 | # define YYINITDEPTH 200 |
905 | | #endif |
906 | | |
907 | | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
908 | | if the built-in stack extension method is used). |
909 | | |
910 | | Do not make this value too large; the results are undefined if |
911 | | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
912 | | evaluated with infinite-precision integer arithmetic. */ |
913 | | |
914 | | #ifndef YYMAXDEPTH |
915 | 0 | # define YYMAXDEPTH 10000 |
916 | | #endif |
917 | | |
918 | | |
919 | | |
920 | | |
921 | | |
922 | | |
923 | | /*-----------------------------------------------. |
924 | | | Release the memory associated to this symbol. | |
925 | | `-----------------------------------------------*/ |
926 | | |
927 | | static void |
928 | | yydestruct (const char *yymsg, |
929 | | yysymbol_kind_t yykind, YYSTYPE *yyvaluep, void *yyscanner, HEX_LEX_ENVIRONMENT *lex_env) |
930 | 0 | { |
931 | 0 | YY_USE (yyvaluep); |
932 | 0 | YY_USE (yyscanner); |
933 | 0 | YY_USE (lex_env); |
934 | 0 | if (!yymsg) |
935 | 0 | yymsg = "Deleting"; |
936 | 0 | YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); |
937 | |
|
938 | 0 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
939 | 0 | switch (yykind) |
940 | 0 | { |
941 | 0 | case YYSYMBOL_tokens: /* tokens */ |
942 | 0 | #line 96 "hex_grammar.y" |
943 | 0 | { yr_re_node_destroy(((*yyvaluep).re_node)); ((*yyvaluep).re_node) = NULL; } |
944 | 0 | #line 945 "hex_grammar.c" |
945 | 0 | break; |
946 | | |
947 | 0 | case YYSYMBOL_token_sequence: /* token_sequence */ |
948 | 0 | #line 97 "hex_grammar.y" |
949 | 0 | { yr_re_node_destroy(((*yyvaluep).re_node)); ((*yyvaluep).re_node) = NULL; } |
950 | 0 | #line 951 "hex_grammar.c" |
951 | 0 | break; |
952 | | |
953 | 0 | case YYSYMBOL_token_or_range: /* token_or_range */ |
954 | 0 | #line 98 "hex_grammar.y" |
955 | 0 | { yr_re_node_destroy(((*yyvaluep).re_node)); ((*yyvaluep).re_node) = NULL; } |
956 | 0 | #line 957 "hex_grammar.c" |
957 | 0 | break; |
958 | | |
959 | 0 | case YYSYMBOL_token: /* token */ |
960 | 0 | #line 99 "hex_grammar.y" |
961 | 0 | { yr_re_node_destroy(((*yyvaluep).re_node)); ((*yyvaluep).re_node) = NULL; } |
962 | 0 | #line 963 "hex_grammar.c" |
963 | 0 | break; |
964 | | |
965 | 0 | case YYSYMBOL_range: /* range */ |
966 | 0 | #line 102 "hex_grammar.y" |
967 | 0 | { yr_re_node_destroy(((*yyvaluep).re_node)); ((*yyvaluep).re_node) = NULL; } |
968 | 0 | #line 969 "hex_grammar.c" |
969 | 0 | break; |
970 | | |
971 | 0 | case YYSYMBOL_alternatives: /* alternatives */ |
972 | 0 | #line 101 "hex_grammar.y" |
973 | 0 | { yr_re_node_destroy(((*yyvaluep).re_node)); ((*yyvaluep).re_node) = NULL; } |
974 | 0 | #line 975 "hex_grammar.c" |
975 | 0 | break; |
976 | | |
977 | 0 | case YYSYMBOL_byte: /* byte */ |
978 | 0 | #line 100 "hex_grammar.y" |
979 | 0 | { yr_re_node_destroy(((*yyvaluep).re_node)); ((*yyvaluep).re_node) = NULL; } |
980 | 0 | #line 981 "hex_grammar.c" |
981 | 0 | break; |
982 | | |
983 | 0 | default: |
984 | 0 | break; |
985 | 0 | } |
986 | 0 | YY_IGNORE_MAYBE_UNINITIALIZED_END |
987 | 0 | } |
988 | | |
989 | | |
990 | | |
991 | | |
992 | | |
993 | | |
994 | | /*----------. |
995 | | | yyparse. | |
996 | | `----------*/ |
997 | | |
998 | | int |
999 | | yyparse (void *yyscanner, HEX_LEX_ENVIRONMENT *lex_env) |
1000 | 0 | { |
1001 | | /* Lookahead token kind. */ |
1002 | 0 | int yychar; |
1003 | | |
1004 | | |
1005 | | /* The semantic value of the lookahead symbol. */ |
1006 | | /* Default value used for initialization, for pacifying older GCCs |
1007 | | or non-GCC compilers. */ |
1008 | 0 | YY_INITIAL_VALUE (static YYSTYPE yyval_default;) |
1009 | 0 | YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); |
1010 | | |
1011 | | /* Number of syntax errors so far. */ |
1012 | 0 | int yynerrs = 0; |
1013 | |
|
1014 | 0 | yy_state_fast_t yystate = 0; |
1015 | | /* Number of tokens to shift before error messages enabled. */ |
1016 | 0 | int yyerrstatus = 0; |
1017 | | |
1018 | | /* Refer to the stacks through separate pointers, to allow yyoverflow |
1019 | | to reallocate them elsewhere. */ |
1020 | | |
1021 | | /* Their size. */ |
1022 | 0 | YYPTRDIFF_T yystacksize = YYINITDEPTH; |
1023 | | |
1024 | | /* The state stack: array, bottom, top. */ |
1025 | 0 | yy_state_t yyssa[YYINITDEPTH]; |
1026 | 0 | yy_state_t *yyss = yyssa; |
1027 | 0 | yy_state_t *yyssp = yyss; |
1028 | | |
1029 | | /* The semantic value stack: array, bottom, top. */ |
1030 | 0 | YYSTYPE yyvsa[YYINITDEPTH]; |
1031 | 0 | YYSTYPE *yyvs = yyvsa; |
1032 | 0 | YYSTYPE *yyvsp = yyvs; |
1033 | |
|
1034 | 0 | int yyn; |
1035 | | /* The return value of yyparse. */ |
1036 | 0 | int yyresult; |
1037 | | /* Lookahead symbol kind. */ |
1038 | 0 | yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; |
1039 | | /* The variables used to return semantic value and location from the |
1040 | | action routines. */ |
1041 | 0 | YYSTYPE yyval; |
1042 | | |
1043 | | |
1044 | |
|
1045 | 0 | #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) |
1046 | | |
1047 | | /* The number of symbols on the RHS of the reduced rule. |
1048 | | Keep to zero when no symbol should be popped. */ |
1049 | 0 | int yylen = 0; |
1050 | |
|
1051 | 0 | YYDPRINTF ((stderr, "Starting parse\n")); |
1052 | |
|
1053 | 0 | yychar = YYEMPTY; /* Cause a token to be read. */ |
1054 | |
|
1055 | 0 | goto yysetstate; |
1056 | | |
1057 | | |
1058 | | /*------------------------------------------------------------. |
1059 | | | yynewstate -- push a new state, which is found in yystate. | |
1060 | | `------------------------------------------------------------*/ |
1061 | 0 | yynewstate: |
1062 | | /* In all cases, when you get here, the value and location stacks |
1063 | | have just been pushed. So pushing a state here evens the stacks. */ |
1064 | 0 | yyssp++; |
1065 | | |
1066 | | |
1067 | | /*--------------------------------------------------------------------. |
1068 | | | yysetstate -- set current state (the top of the stack) to yystate. | |
1069 | | `--------------------------------------------------------------------*/ |
1070 | 0 | yysetstate: |
1071 | 0 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
1072 | 0 | YY_ASSERT (0 <= yystate && yystate < YYNSTATES); |
1073 | 0 | YY_IGNORE_USELESS_CAST_BEGIN |
1074 | 0 | *yyssp = YY_CAST (yy_state_t, yystate); |
1075 | 0 | YY_IGNORE_USELESS_CAST_END |
1076 | 0 | YY_STACK_PRINT (yyss, yyssp); |
1077 | |
|
1078 | 0 | if (yyss + yystacksize - 1 <= yyssp) |
1079 | | #if !defined yyoverflow && !defined YYSTACK_RELOCATE |
1080 | | YYNOMEM; |
1081 | | #else |
1082 | 0 | { |
1083 | | /* Get the current used size of the three stacks, in elements. */ |
1084 | 0 | YYPTRDIFF_T yysize = yyssp - yyss + 1; |
1085 | |
|
1086 | | # if defined yyoverflow |
1087 | | { |
1088 | | /* Give user a chance to reallocate the stack. Use copies of |
1089 | | these so that the &'s don't force the real ones into |
1090 | | memory. */ |
1091 | | yy_state_t *yyss1 = yyss; |
1092 | | YYSTYPE *yyvs1 = yyvs; |
1093 | | |
1094 | | /* Each stack pointer address is followed by the size of the |
1095 | | data in use in that stack, in bytes. This used to be a |
1096 | | conditional around just the two extra args, but that might |
1097 | | be undefined if yyoverflow is a macro. */ |
1098 | | yyoverflow (YY_("memory exhausted"), |
1099 | | &yyss1, yysize * YYSIZEOF (*yyssp), |
1100 | | &yyvs1, yysize * YYSIZEOF (*yyvsp), |
1101 | | &yystacksize); |
1102 | | yyss = yyss1; |
1103 | | yyvs = yyvs1; |
1104 | | } |
1105 | | # else /* defined YYSTACK_RELOCATE */ |
1106 | | /* Extend the stack our own way. */ |
1107 | 0 | if (YYMAXDEPTH <= yystacksize) |
1108 | 0 | YYNOMEM; |
1109 | 0 | yystacksize *= 2; |
1110 | 0 | if (YYMAXDEPTH < yystacksize) |
1111 | 0 | yystacksize = YYMAXDEPTH; |
1112 | |
|
1113 | 0 | { |
1114 | 0 | yy_state_t *yyss1 = yyss; |
1115 | 0 | union yyalloc *yyptr = |
1116 | 0 | YY_CAST (union yyalloc *, |
1117 | 0 | YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); |
1118 | 0 | if (! yyptr) |
1119 | 0 | YYNOMEM; |
1120 | 0 | YYSTACK_RELOCATE (yyss_alloc, yyss); |
1121 | 0 | YYSTACK_RELOCATE (yyvs_alloc, yyvs); |
1122 | 0 | # undef YYSTACK_RELOCATE |
1123 | 0 | if (yyss1 != yyssa) |
1124 | 0 | YYSTACK_FREE (yyss1); |
1125 | 0 | } |
1126 | 0 | # endif |
1127 | | |
1128 | 0 | yyssp = yyss + yysize - 1; |
1129 | 0 | yyvsp = yyvs + yysize - 1; |
1130 | |
|
1131 | 0 | YY_IGNORE_USELESS_CAST_BEGIN |
1132 | 0 | YYDPRINTF ((stderr, "Stack size increased to %ld\n", |
1133 | 0 | YY_CAST (long, yystacksize))); |
1134 | 0 | YY_IGNORE_USELESS_CAST_END |
1135 | |
|
1136 | 0 | if (yyss + yystacksize - 1 <= yyssp) |
1137 | 0 | YYABORT; |
1138 | 0 | } |
1139 | 0 | #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ |
1140 | | |
1141 | | |
1142 | 0 | if (yystate == YYFINAL) |
1143 | 0 | YYACCEPT; |
1144 | | |
1145 | 0 | goto yybackup; |
1146 | | |
1147 | | |
1148 | | /*-----------. |
1149 | | | yybackup. | |
1150 | | `-----------*/ |
1151 | 0 | yybackup: |
1152 | | /* Do appropriate processing given the current state. Read a |
1153 | | lookahead token if we need one and don't already have one. */ |
1154 | | |
1155 | | /* First try to decide what to do without reference to lookahead token. */ |
1156 | 0 | yyn = yypact[yystate]; |
1157 | 0 | if (yypact_value_is_default (yyn)) |
1158 | 0 | goto yydefault; |
1159 | | |
1160 | | /* Not known => get a lookahead token if don't already have one. */ |
1161 | | |
1162 | | /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ |
1163 | 0 | if (yychar == YYEMPTY) |
1164 | 0 | { |
1165 | 0 | YYDPRINTF ((stderr, "Reading a token\n")); |
1166 | 0 | yychar = yylex (&yylval, yyscanner, lex_env); |
1167 | 0 | } |
1168 | |
|
1169 | 0 | if (yychar <= YYEOF) |
1170 | 0 | { |
1171 | 0 | yychar = YYEOF; |
1172 | 0 | yytoken = YYSYMBOL_YYEOF; |
1173 | 0 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
1174 | 0 | } |
1175 | 0 | else if (yychar == YYerror) |
1176 | 0 | { |
1177 | | /* The scanner already issued an error message, process directly |
1178 | | to error recovery. But do not keep the error token as |
1179 | | lookahead, it is too special and may lead us to an endless |
1180 | | loop in error recovery. */ |
1181 | 0 | yychar = YYUNDEF; |
1182 | 0 | yytoken = YYSYMBOL_YYerror; |
1183 | 0 | goto yyerrlab1; |
1184 | 0 | } |
1185 | 0 | else |
1186 | 0 | { |
1187 | 0 | yytoken = YYTRANSLATE (yychar); |
1188 | 0 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
1189 | 0 | } |
1190 | | |
1191 | | /* If the proper action on seeing token YYTOKEN is to reduce or to |
1192 | | detect an error, take that action. */ |
1193 | 0 | yyn += yytoken; |
1194 | 0 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
1195 | 0 | goto yydefault; |
1196 | 0 | yyn = yytable[yyn]; |
1197 | 0 | if (yyn <= 0) |
1198 | 0 | { |
1199 | 0 | if (yytable_value_is_error (yyn)) |
1200 | 0 | goto yyerrlab; |
1201 | 0 | yyn = -yyn; |
1202 | 0 | goto yyreduce; |
1203 | 0 | } |
1204 | | |
1205 | | /* Count tokens shifted since error; after three, turn off error |
1206 | | status. */ |
1207 | 0 | if (yyerrstatus) |
1208 | 0 | yyerrstatus--; |
1209 | | |
1210 | | /* Shift the lookahead token. */ |
1211 | 0 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
1212 | 0 | yystate = yyn; |
1213 | 0 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
1214 | 0 | *++yyvsp = yylval; |
1215 | 0 | YY_IGNORE_MAYBE_UNINITIALIZED_END |
1216 | | |
1217 | | /* Discard the shifted token. */ |
1218 | 0 | yychar = YYEMPTY; |
1219 | 0 | goto yynewstate; |
1220 | | |
1221 | | |
1222 | | /*-----------------------------------------------------------. |
1223 | | | yydefault -- do the default action for the current state. | |
1224 | | `-----------------------------------------------------------*/ |
1225 | 0 | yydefault: |
1226 | 0 | yyn = yydefact[yystate]; |
1227 | 0 | if (yyn == 0) |
1228 | 0 | goto yyerrlab; |
1229 | 0 | goto yyreduce; |
1230 | | |
1231 | | |
1232 | | /*-----------------------------. |
1233 | | | yyreduce -- do a reduction. | |
1234 | | `-----------------------------*/ |
1235 | 0 | yyreduce: |
1236 | | /* yyn is the number of a rule to reduce with. */ |
1237 | 0 | yylen = yyr2[yyn]; |
1238 | | |
1239 | | /* If YYLEN is nonzero, implement the default value of the action: |
1240 | | '$$ = $1'. |
1241 | | |
1242 | | Otherwise, the following line sets YYVAL to garbage. |
1243 | | This behavior is undocumented and Bison |
1244 | | users should not rely upon it. Assigning to YYVAL |
1245 | | unconditionally makes the parser a bit smaller, and it avoids a |
1246 | | GCC warning that YYVAL may be used uninitialized. */ |
1247 | 0 | yyval = yyvsp[1-yylen]; |
1248 | | |
1249 | |
|
1250 | 0 | YY_REDUCE_PRINT (yyn); |
1251 | 0 | switch (yyn) |
1252 | 0 | { |
1253 | 0 | case 2: /* hex_string: '{' tokens '}' */ |
1254 | 0 | #line 108 "hex_grammar.y" |
1255 | 0 | { |
1256 | 0 | RE_AST* re_ast = yyget_extra(yyscanner); |
1257 | 0 | re_ast->root_node = (yyvsp[-1].re_node); |
1258 | 0 | } |
1259 | 0 | #line 1260 "hex_grammar.c" |
1260 | 0 | break; |
1261 | | |
1262 | 0 | case 3: /* tokens: token */ |
1263 | 0 | #line 117 "hex_grammar.y" |
1264 | 0 | { |
1265 | 0 | (yyval.re_node) = (yyvsp[0].re_node); |
1266 | 0 | } |
1267 | 0 | #line 1268 "hex_grammar.c" |
1268 | 0 | break; |
1269 | | |
1270 | 0 | case 4: /* tokens: token token */ |
1271 | 0 | #line 121 "hex_grammar.y" |
1272 | 0 | { |
1273 | 0 | (yyval.re_node) = yr_re_node_create(RE_NODE_CONCAT); |
1274 | |
|
1275 | 0 | destroy_node_if((yyval.re_node) == NULL, (yyvsp[-1].re_node)); |
1276 | 0 | destroy_node_if((yyval.re_node) == NULL, (yyvsp[0].re_node)); |
1277 | |
|
1278 | 0 | fail_if((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY); |
1279 | |
|
1280 | 0 | yr_re_node_append_child((yyval.re_node), (yyvsp[-1].re_node)); |
1281 | 0 | yr_re_node_append_child((yyval.re_node), (yyvsp[0].re_node)); |
1282 | 0 | } |
1283 | 0 | #line 1284 "hex_grammar.c" |
1284 | 0 | break; |
1285 | | |
1286 | 0 | case 5: /* tokens: token token_sequence token */ |
1287 | 0 | #line 133 "hex_grammar.y" |
1288 | 0 | { |
1289 | 0 | yr_re_node_append_child((yyvsp[-1].re_node), (yyvsp[0].re_node)); |
1290 | 0 | yr_re_node_prepend_child((yyvsp[-1].re_node), (yyvsp[-2].re_node)); |
1291 | |
|
1292 | 0 | (yyval.re_node) = (yyvsp[-1].re_node); |
1293 | 0 | } |
1294 | 0 | #line 1295 "hex_grammar.c" |
1295 | 0 | break; |
1296 | | |
1297 | 0 | case 6: /* token_sequence: token_or_range */ |
1298 | 0 | #line 144 "hex_grammar.y" |
1299 | 0 | { |
1300 | 0 | (yyval.re_node) = yr_re_node_create(RE_NODE_CONCAT); |
1301 | |
|
1302 | 0 | destroy_node_if((yyval.re_node) == NULL, (yyvsp[0].re_node)); |
1303 | 0 | fail_if((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY); |
1304 | |
|
1305 | 0 | yr_re_node_append_child((yyval.re_node), (yyvsp[0].re_node)); |
1306 | 0 | } |
1307 | 0 | #line 1308 "hex_grammar.c" |
1308 | 0 | break; |
1309 | | |
1310 | 0 | case 7: /* token_sequence: token_sequence token_or_range */ |
1311 | 0 | #line 153 "hex_grammar.y" |
1312 | 0 | { |
1313 | 0 | yr_re_node_append_child((yyvsp[-1].re_node), (yyvsp[0].re_node)); |
1314 | 0 | (yyval.re_node) = (yyvsp[-1].re_node); |
1315 | 0 | } |
1316 | 0 | #line 1317 "hex_grammar.c" |
1317 | 0 | break; |
1318 | | |
1319 | 0 | case 8: /* token_or_range: token */ |
1320 | 0 | #line 162 "hex_grammar.y" |
1321 | 0 | { |
1322 | 0 | (yyval.re_node) = (yyvsp[0].re_node); |
1323 | 0 | } |
1324 | 0 | #line 1325 "hex_grammar.c" |
1325 | 0 | break; |
1326 | | |
1327 | 0 | case 9: /* token_or_range: range */ |
1328 | 0 | #line 166 "hex_grammar.y" |
1329 | 0 | { |
1330 | 0 | (yyval.re_node) = (yyvsp[0].re_node); |
1331 | 0 | (yyval.re_node)->greedy = false; |
1332 | 0 | } |
1333 | 0 | #line 1334 "hex_grammar.c" |
1334 | 0 | break; |
1335 | | |
1336 | 0 | case 10: /* token: byte */ |
1337 | 0 | #line 175 "hex_grammar.y" |
1338 | 0 | { |
1339 | 0 | (yyval.re_node) = (yyvsp[0].re_node); |
1340 | 0 | } |
1341 | 0 | #line 1342 "hex_grammar.c" |
1342 | 0 | break; |
1343 | | |
1344 | 0 | case 11: /* $@1: %empty */ |
1345 | 0 | #line 179 "hex_grammar.y" |
1346 | 0 | { |
1347 | 0 | lex_env->inside_or++; |
1348 | 0 | } |
1349 | 0 | #line 1350 "hex_grammar.c" |
1350 | 0 | break; |
1351 | | |
1352 | 0 | case 12: /* token: '(' $@1 alternatives ')' */ |
1353 | 0 | #line 183 "hex_grammar.y" |
1354 | 0 | { |
1355 | 0 | (yyval.re_node) = (yyvsp[-1].re_node); |
1356 | 0 | lex_env->inside_or--; |
1357 | 0 | } |
1358 | 0 | #line 1359 "hex_grammar.c" |
1359 | 0 | break; |
1360 | | |
1361 | 0 | case 13: /* range: '[' _NUMBER_ ']' */ |
1362 | 0 | #line 192 "hex_grammar.y" |
1363 | 0 | { |
1364 | 0 | if ((yyvsp[-1].integer) <= 0) |
1365 | 0 | { |
1366 | 0 | yyerror(yyscanner, lex_env, "invalid jump length"); |
1367 | 0 | YYABORT; |
1368 | 0 | } |
1369 | | |
1370 | 0 | if (lex_env->inside_or && (yyvsp[-1].integer) > YR_STRING_CHAINING_THRESHOLD) |
1371 | 0 | { |
1372 | 0 | yyerror(yyscanner, lex_env, "jumps over " |
1373 | 0 | STR(YR_STRING_CHAINING_THRESHOLD) |
1374 | 0 | " not allowed inside alternation (|)"); |
1375 | 0 | YYABORT; |
1376 | 0 | } |
1377 | | |
1378 | | // A jump of one is equivalent to ?? |
1379 | 0 | if ((yyvsp[-1].integer) == 1) |
1380 | 0 | { |
1381 | 0 | (yyval.re_node) = yr_re_node_create(RE_NODE_MASKED_LITERAL); |
1382 | |
|
1383 | 0 | fail_if((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY); |
1384 | |
|
1385 | 0 | (yyval.re_node)->value = 0x00; |
1386 | 0 | (yyval.re_node)->mask = 0x00; |
1387 | 0 | } |
1388 | 0 | else |
1389 | 0 | { |
1390 | 0 | (yyval.re_node) = yr_re_node_create(RE_NODE_RANGE_ANY); |
1391 | |
|
1392 | 0 | fail_if((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY); |
1393 | |
|
1394 | 0 | (yyval.re_node)->start = (int) (yyvsp[-1].integer); |
1395 | 0 | (yyval.re_node)->end = (int) (yyvsp[-1].integer); |
1396 | 0 | } |
1397 | 0 | } |
1398 | 0 | #line 1399 "hex_grammar.c" |
1399 | 0 | break; |
1400 | | |
1401 | 0 | case 14: /* range: '[' _NUMBER_ '-' _NUMBER_ ']' */ |
1402 | 0 | #line 228 "hex_grammar.y" |
1403 | 0 | { |
1404 | 0 | if (lex_env->inside_or && |
1405 | 0 | ((yyvsp[-3].integer) > YR_STRING_CHAINING_THRESHOLD || |
1406 | 0 | (yyvsp[-1].integer) > YR_STRING_CHAINING_THRESHOLD) ) |
1407 | 0 | { |
1408 | 0 | yyerror(yyscanner, lex_env, "jumps over " |
1409 | 0 | STR(YR_STRING_CHAINING_THRESHOLD) |
1410 | 0 | " not allowed inside alternation (|)"); |
1411 | |
|
1412 | 0 | YYABORT; |
1413 | 0 | } |
1414 | | |
1415 | 0 | if ((yyvsp[-3].integer) < 0 || (yyvsp[-1].integer) < 0) |
1416 | 0 | { |
1417 | 0 | yyerror(yyscanner, lex_env, "invalid negative jump length"); |
1418 | 0 | YYABORT; |
1419 | 0 | } |
1420 | | |
1421 | 0 | if ((yyvsp[-3].integer) > (yyvsp[-1].integer)) |
1422 | 0 | { |
1423 | 0 | yyerror(yyscanner, lex_env, "invalid jump range"); |
1424 | 0 | YYABORT; |
1425 | 0 | } |
1426 | | |
1427 | 0 | (yyval.re_node) = yr_re_node_create(RE_NODE_RANGE_ANY); |
1428 | |
|
1429 | 0 | fail_if((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY); |
1430 | |
|
1431 | 0 | (yyval.re_node)->start = (int) (yyvsp[-3].integer); |
1432 | 0 | (yyval.re_node)->end = (int) (yyvsp[-1].integer); |
1433 | 0 | } |
1434 | 0 | #line 1435 "hex_grammar.c" |
1435 | 0 | break; |
1436 | | |
1437 | 0 | case 15: /* range: '[' _NUMBER_ '-' ']' */ |
1438 | 0 | #line 260 "hex_grammar.y" |
1439 | 0 | { |
1440 | 0 | if (lex_env->inside_or) |
1441 | 0 | { |
1442 | 0 | yyerror(yyscanner, lex_env, |
1443 | 0 | "unbounded jumps not allowed inside alternation (|)"); |
1444 | 0 | YYABORT; |
1445 | 0 | } |
1446 | | |
1447 | 0 | if ((yyvsp[-2].integer) < 0) |
1448 | 0 | { |
1449 | 0 | yyerror(yyscanner, lex_env, "invalid negative jump length"); |
1450 | 0 | YYABORT; |
1451 | 0 | } |
1452 | | |
1453 | 0 | (yyval.re_node) = yr_re_node_create(RE_NODE_RANGE_ANY); |
1454 | |
|
1455 | 0 | fail_if((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY); |
1456 | |
|
1457 | 0 | (yyval.re_node)->start = (int) (yyvsp[-2].integer); |
1458 | 0 | (yyval.re_node)->end = INT_MAX; |
1459 | 0 | } |
1460 | 0 | #line 1461 "hex_grammar.c" |
1461 | 0 | break; |
1462 | | |
1463 | 0 | case 16: /* range: '[' '-' ']' */ |
1464 | 0 | #line 282 "hex_grammar.y" |
1465 | 0 | { |
1466 | 0 | if (lex_env->inside_or) |
1467 | 0 | { |
1468 | 0 | yyerror(yyscanner, lex_env, |
1469 | 0 | "unbounded jumps not allowed inside alternation (|)"); |
1470 | 0 | YYABORT; |
1471 | 0 | } |
1472 | | |
1473 | 0 | (yyval.re_node) = yr_re_node_create(RE_NODE_RANGE_ANY); |
1474 | |
|
1475 | 0 | fail_if((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY); |
1476 | |
|
1477 | 0 | (yyval.re_node)->start = 0; |
1478 | 0 | (yyval.re_node)->end = INT_MAX; |
1479 | 0 | } |
1480 | 0 | #line 1481 "hex_grammar.c" |
1481 | 0 | break; |
1482 | | |
1483 | 0 | case 17: /* alternatives: tokens */ |
1484 | 0 | #line 302 "hex_grammar.y" |
1485 | 0 | { |
1486 | 0 | (yyval.re_node) = (yyvsp[0].re_node); |
1487 | 0 | } |
1488 | 0 | #line 1489 "hex_grammar.c" |
1489 | 0 | break; |
1490 | | |
1491 | 0 | case 18: /* alternatives: alternatives '|' tokens */ |
1492 | 0 | #line 306 "hex_grammar.y" |
1493 | 0 | { |
1494 | 0 | mark_as_not_fast_regexp(); |
1495 | |
|
1496 | 0 | (yyval.re_node) = yr_re_node_create(RE_NODE_ALT); |
1497 | |
|
1498 | 0 | destroy_node_if((yyval.re_node) == NULL, (yyvsp[-2].re_node)); |
1499 | 0 | destroy_node_if((yyval.re_node) == NULL, (yyvsp[0].re_node)); |
1500 | |
|
1501 | 0 | fail_if((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY); |
1502 | |
|
1503 | 0 | yr_re_node_append_child((yyval.re_node), (yyvsp[-2].re_node)); |
1504 | 0 | yr_re_node_append_child((yyval.re_node), (yyvsp[0].re_node)); |
1505 | 0 | } |
1506 | 0 | #line 1507 "hex_grammar.c" |
1507 | 0 | break; |
1508 | | |
1509 | 0 | case 19: /* byte: _BYTE_ */ |
1510 | 0 | #line 323 "hex_grammar.y" |
1511 | 0 | { |
1512 | 0 | (yyval.re_node) = yr_re_node_create(RE_NODE_LITERAL); |
1513 | |
|
1514 | 0 | fail_if((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY); |
1515 | |
|
1516 | 0 | (yyval.re_node)->value = (int) (yyvsp[0].integer); |
1517 | 0 | (yyval.re_node)->mask = 0xFF; |
1518 | 0 | } |
1519 | 0 | #line 1520 "hex_grammar.c" |
1520 | 0 | break; |
1521 | | |
1522 | 0 | case 20: /* byte: _NOT_BYTE_ */ |
1523 | 0 | #line 332 "hex_grammar.y" |
1524 | 0 | { |
1525 | 0 | (yyval.re_node) = yr_re_node_create(RE_NODE_NOT_LITERAL); |
1526 | |
|
1527 | 0 | fail_if((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY); |
1528 | |
|
1529 | 0 | (yyval.re_node)->value = (int) (yyvsp[0].integer); |
1530 | 0 | (yyval.re_node)->mask = 0xFF; |
1531 | 0 | } |
1532 | 0 | #line 1533 "hex_grammar.c" |
1533 | 0 | break; |
1534 | | |
1535 | 0 | case 21: /* byte: _MASKED_BYTE_ */ |
1536 | 0 | #line 341 "hex_grammar.y" |
1537 | 0 | { |
1538 | 0 | uint8_t mask = (uint8_t) ((yyvsp[0].integer) >> 8); |
1539 | |
|
1540 | 0 | if (mask == 0x00) |
1541 | 0 | { |
1542 | 0 | (yyval.re_node) = yr_re_node_create(RE_NODE_ANY); |
1543 | |
|
1544 | 0 | fail_if((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY); |
1545 | |
|
1546 | 0 | (yyval.re_node)->value = 0x00; |
1547 | 0 | (yyval.re_node)->mask = 0x00; |
1548 | 0 | } |
1549 | 0 | else |
1550 | 0 | { |
1551 | 0 | (yyval.re_node) = yr_re_node_create(RE_NODE_MASKED_LITERAL); |
1552 | |
|
1553 | 0 | fail_if((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY); |
1554 | |
|
1555 | 0 | (yyval.re_node)->value = (yyvsp[0].integer) & 0xFF; |
1556 | 0 | (yyval.re_node)->mask = mask; |
1557 | 0 | } |
1558 | 0 | } |
1559 | 0 | #line 1560 "hex_grammar.c" |
1560 | 0 | break; |
1561 | | |
1562 | 0 | case 22: /* byte: _MASKED_NOT_BYTE_ */ |
1563 | 0 | #line 364 "hex_grammar.y" |
1564 | 0 | { |
1565 | 0 | uint8_t mask = (uint8_t) ((yyvsp[0].integer) >> 8); |
1566 | |
|
1567 | 0 | (yyval.re_node) = yr_re_node_create(RE_NODE_MASKED_NOT_LITERAL); |
1568 | |
|
1569 | 0 | fail_if((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY); |
1570 | |
|
1571 | 0 | (yyval.re_node)->value = (yyvsp[0].integer) & 0xFF; |
1572 | 0 | (yyval.re_node)->mask = mask; |
1573 | 0 | } |
1574 | 0 | #line 1575 "hex_grammar.c" |
1575 | 0 | break; |
1576 | | |
1577 | | |
1578 | 0 | #line 1579 "hex_grammar.c" |
1579 | | |
1580 | 0 | default: break; |
1581 | 0 | } |
1582 | | /* User semantic actions sometimes alter yychar, and that requires |
1583 | | that yytoken be updated with the new translation. We take the |
1584 | | approach of translating immediately before every use of yytoken. |
1585 | | One alternative is translating here after every semantic action, |
1586 | | but that translation would be missed if the semantic action invokes |
1587 | | YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or |
1588 | | if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an |
1589 | | incorrect destructor might then be invoked immediately. In the |
1590 | | case of YYERROR or YYBACKUP, subsequent parser actions might lead |
1591 | | to an incorrect destructor call or verbose syntax error message |
1592 | | before the lookahead is translated. */ |
1593 | 0 | YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); |
1594 | |
|
1595 | 0 | YYPOPSTACK (yylen); |
1596 | 0 | yylen = 0; |
1597 | |
|
1598 | 0 | *++yyvsp = yyval; |
1599 | | |
1600 | | /* Now 'shift' the result of the reduction. Determine what state |
1601 | | that goes to, based on the state we popped back to and the rule |
1602 | | number reduced by. */ |
1603 | 0 | { |
1604 | 0 | const int yylhs = yyr1[yyn] - YYNTOKENS; |
1605 | 0 | const int yyi = yypgoto[yylhs] + *yyssp; |
1606 | 0 | yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp |
1607 | 0 | ? yytable[yyi] |
1608 | 0 | : yydefgoto[yylhs]); |
1609 | 0 | } |
1610 | |
|
1611 | 0 | goto yynewstate; |
1612 | | |
1613 | | |
1614 | | /*--------------------------------------. |
1615 | | | yyerrlab -- here on detecting error. | |
1616 | | `--------------------------------------*/ |
1617 | 0 | yyerrlab: |
1618 | | /* Make sure we have latest lookahead translation. See comments at |
1619 | | user semantic actions for why this is necessary. */ |
1620 | 0 | yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); |
1621 | | /* If not already recovering from an error, report this error. */ |
1622 | 0 | if (!yyerrstatus) |
1623 | 0 | { |
1624 | 0 | ++yynerrs; |
1625 | 0 | yyerror (yyscanner, lex_env, YY_("syntax error")); |
1626 | 0 | } |
1627 | |
|
1628 | 0 | if (yyerrstatus == 3) |
1629 | 0 | { |
1630 | | /* If just tried and failed to reuse lookahead token after an |
1631 | | error, discard it. */ |
1632 | |
|
1633 | 0 | if (yychar <= YYEOF) |
1634 | 0 | { |
1635 | | /* Return failure if at end of input. */ |
1636 | 0 | if (yychar == YYEOF) |
1637 | 0 | YYABORT; |
1638 | 0 | } |
1639 | 0 | else |
1640 | 0 | { |
1641 | 0 | yydestruct ("Error: discarding", |
1642 | 0 | yytoken, &yylval, yyscanner, lex_env); |
1643 | 0 | yychar = YYEMPTY; |
1644 | 0 | } |
1645 | 0 | } |
1646 | | |
1647 | | /* Else will try to reuse lookahead token after shifting the error |
1648 | | token. */ |
1649 | 0 | goto yyerrlab1; |
1650 | | |
1651 | | |
1652 | | /*---------------------------------------------------. |
1653 | | | yyerrorlab -- error raised explicitly by YYERROR. | |
1654 | | `---------------------------------------------------*/ |
1655 | 0 | yyerrorlab: |
1656 | | /* Pacify compilers when the user code never invokes YYERROR and the |
1657 | | label yyerrorlab therefore never appears in user code. */ |
1658 | 0 | if (0) |
1659 | 0 | YYERROR; |
1660 | 0 | ++yynerrs; |
1661 | | |
1662 | | /* Do not reclaim the symbols of the rule whose action triggered |
1663 | | this YYERROR. */ |
1664 | 0 | YYPOPSTACK (yylen); |
1665 | 0 | yylen = 0; |
1666 | 0 | YY_STACK_PRINT (yyss, yyssp); |
1667 | 0 | yystate = *yyssp; |
1668 | 0 | goto yyerrlab1; |
1669 | | |
1670 | | |
1671 | | /*-------------------------------------------------------------. |
1672 | | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
1673 | | `-------------------------------------------------------------*/ |
1674 | 0 | yyerrlab1: |
1675 | 0 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
1676 | | |
1677 | | /* Pop stack until we find a state that shifts the error token. */ |
1678 | 0 | for (;;) |
1679 | 0 | { |
1680 | 0 | yyn = yypact[yystate]; |
1681 | 0 | if (!yypact_value_is_default (yyn)) |
1682 | 0 | { |
1683 | 0 | yyn += YYSYMBOL_YYerror; |
1684 | 0 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) |
1685 | 0 | { |
1686 | 0 | yyn = yytable[yyn]; |
1687 | 0 | if (0 < yyn) |
1688 | 0 | break; |
1689 | 0 | } |
1690 | 0 | } |
1691 | | |
1692 | | /* Pop the current state because it cannot handle the error token. */ |
1693 | 0 | if (yyssp == yyss) |
1694 | 0 | YYABORT; |
1695 | | |
1696 | | |
1697 | 0 | yydestruct ("Error: popping", |
1698 | 0 | YY_ACCESSING_SYMBOL (yystate), yyvsp, yyscanner, lex_env); |
1699 | 0 | YYPOPSTACK (1); |
1700 | 0 | yystate = *yyssp; |
1701 | 0 | YY_STACK_PRINT (yyss, yyssp); |
1702 | 0 | } |
1703 | | |
1704 | 0 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
1705 | 0 | *++yyvsp = yylval; |
1706 | 0 | YY_IGNORE_MAYBE_UNINITIALIZED_END |
1707 | | |
1708 | | |
1709 | | /* Shift the error token. */ |
1710 | 0 | YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); |
1711 | |
|
1712 | 0 | yystate = yyn; |
1713 | 0 | goto yynewstate; |
1714 | | |
1715 | | |
1716 | | /*-------------------------------------. |
1717 | | | yyacceptlab -- YYACCEPT comes here. | |
1718 | | `-------------------------------------*/ |
1719 | 0 | yyacceptlab: |
1720 | 0 | yyresult = 0; |
1721 | 0 | goto yyreturnlab; |
1722 | | |
1723 | | |
1724 | | /*-----------------------------------. |
1725 | | | yyabortlab -- YYABORT comes here. | |
1726 | | `-----------------------------------*/ |
1727 | 0 | yyabortlab: |
1728 | 0 | yyresult = 1; |
1729 | 0 | goto yyreturnlab; |
1730 | | |
1731 | | |
1732 | | /*-----------------------------------------------------------. |
1733 | | | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. | |
1734 | | `-----------------------------------------------------------*/ |
1735 | 0 | yyexhaustedlab: |
1736 | 0 | yyerror (yyscanner, lex_env, YY_("memory exhausted")); |
1737 | 0 | yyresult = 2; |
1738 | 0 | goto yyreturnlab; |
1739 | | |
1740 | | |
1741 | | /*----------------------------------------------------------. |
1742 | | | yyreturnlab -- parsing is finished, clean up and return. | |
1743 | | `----------------------------------------------------------*/ |
1744 | 0 | yyreturnlab: |
1745 | 0 | if (yychar != YYEMPTY) |
1746 | 0 | { |
1747 | | /* Make sure we have latest lookahead translation. See comments at |
1748 | | user semantic actions for why this is necessary. */ |
1749 | 0 | yytoken = YYTRANSLATE (yychar); |
1750 | 0 | yydestruct ("Cleanup: discarding lookahead", |
1751 | 0 | yytoken, &yylval, yyscanner, lex_env); |
1752 | 0 | } |
1753 | | /* Do not reclaim the symbols of the rule whose action triggered |
1754 | | this YYABORT or YYACCEPT. */ |
1755 | 0 | YYPOPSTACK (yylen); |
1756 | 0 | YY_STACK_PRINT (yyss, yyssp); |
1757 | 0 | while (yyssp != yyss) |
1758 | 0 | { |
1759 | 0 | yydestruct ("Cleanup: popping", |
1760 | 0 | YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, yyscanner, lex_env); |
1761 | 0 | YYPOPSTACK (1); |
1762 | 0 | } |
1763 | 0 | #ifndef yyoverflow |
1764 | 0 | if (yyss != yyssa) |
1765 | 0 | YYSTACK_FREE (yyss); |
1766 | 0 | #endif |
1767 | |
|
1768 | 0 | return yyresult; |
1769 | 0 | } |
1770 | | |
1771 | | #line 376 "hex_grammar.y" |
1772 | | |