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