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