/src/frr/lib/command_parse.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* A Bison parser, made by GNU Bison 3.5.1. */ |
2 | | |
3 | | /* Bison implementation for Yacc-like parsers in C |
4 | | |
5 | | Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 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 <http://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 | | /* All symbols defined below should begin with yy or YY, to avoid |
38 | | infringing on user name space. This should be done even for local |
39 | | variables, as they might otherwise be expanded by user macros. |
40 | | There are some unavoidable exceptions within include files to |
41 | | define necessary library symbols; they are noted "INFRINGES ON |
42 | | USER NAME SPACE" below. */ |
43 | | |
44 | | /* Undocumented macros, especially those whose name start with YY_, |
45 | | are private implementation details. Do not rely on them. */ |
46 | | |
47 | | /* Identify Bison output. */ |
48 | | #define YYBISON 1 |
49 | | |
50 | | /* Bison version. */ |
51 | | #define YYBISON_VERSION "3.5.1" |
52 | | |
53 | | /* Skeleton name. */ |
54 | | #define YYSKELETON_NAME "yacc.c" |
55 | | |
56 | | /* Pure parsers. */ |
57 | | #define YYPURE 2 |
58 | | |
59 | | /* Push parsers. */ |
60 | | #define YYPUSH 0 |
61 | | |
62 | | /* Pull parsers. */ |
63 | | #define YYPULL 1 |
64 | | |
65 | | /* Substitute the type names. */ |
66 | | #define YYSTYPE CMD_YYSTYPE |
67 | | #define YYLTYPE CMD_YYLTYPE |
68 | | /* Substitute the variable and function names. */ |
69 | | #define yyparse cmd_yyparse |
70 | 0 | #define yylex cmd_yylex |
71 | 0 | #define yyerror cmd_yyerror |
72 | 0 | #define yydebug cmd_yydebug |
73 | 0 | #define yynerrs cmd_yynerrs |
74 | | |
75 | | /* First part of user prologue. */ |
76 | | #line 9 "lib/command_parse.y" |
77 | | |
78 | | // compile with debugging facilities |
79 | | #define YYDEBUG 1 |
80 | | |
81 | | #line 82 "lib/command_parse.c" |
82 | | |
83 | | # ifndef YY_CAST |
84 | | # ifdef __cplusplus |
85 | | # define YY_CAST(Type, Val) static_cast<Type> (Val) |
86 | | # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val) |
87 | | # else |
88 | 0 | # define YY_CAST(Type, Val) ((Type) (Val)) |
89 | | # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) |
90 | | # endif |
91 | | # endif |
92 | | # ifndef YY_NULLPTR |
93 | | # if defined __cplusplus |
94 | | # if 201103L <= __cplusplus |
95 | | # define YY_NULLPTR nullptr |
96 | | # else |
97 | | # define YY_NULLPTR 0 |
98 | | # endif |
99 | | # else |
100 | 0 | # define YY_NULLPTR ((void*)0) |
101 | | # endif |
102 | | # endif |
103 | | |
104 | | /* Enabling verbose error messages. */ |
105 | | #ifdef YYERROR_VERBOSE |
106 | | # undef YYERROR_VERBOSE |
107 | | # define YYERROR_VERBOSE 1 |
108 | | #else |
109 | | # define YYERROR_VERBOSE 1 |
110 | | #endif |
111 | | |
112 | | /* Use api.header.include to #include this header |
113 | | instead of duplicating it here. */ |
114 | | #ifndef YY_CMD_YY_LIB_COMMAND_PARSE_H_INCLUDED |
115 | | # define YY_CMD_YY_LIB_COMMAND_PARSE_H_INCLUDED |
116 | | /* Debug traces. */ |
117 | | #ifndef CMD_YYDEBUG |
118 | | # if defined YYDEBUG |
119 | | #if YYDEBUG |
120 | | # define CMD_YYDEBUG 1 |
121 | | # else |
122 | | # define CMD_YYDEBUG 0 |
123 | | # endif |
124 | | # else /* ! defined YYDEBUG */ |
125 | | # define CMD_YYDEBUG 0 |
126 | | # endif /* ! defined YYDEBUG */ |
127 | | #endif /* ! defined CMD_YYDEBUG */ |
128 | | #if CMD_YYDEBUG |
129 | | extern int cmd_yydebug; |
130 | | #endif |
131 | | /* "%code requires" blocks. */ |
132 | | #line 30 "lib/command_parse.y" |
133 | | |
134 | | #include "config.h" |
135 | | |
136 | | #include <stdbool.h> |
137 | | #include <stdlib.h> |
138 | | #include <string.h> |
139 | | #include <ctype.h> |
140 | | |
141 | | #include "command_graph.h" |
142 | | #include "log.h" |
143 | | |
144 | | DECLARE_MTYPE(LEX); |
145 | | |
146 | 0 | #define YYSTYPE CMD_YYSTYPE |
147 | 0 | #define YYLTYPE CMD_YYLTYPE |
148 | | struct parser_ctx; |
149 | | |
150 | | /* subgraph semantic value */ |
151 | | struct subgraph { |
152 | | struct graph_node *start, *end; |
153 | | }; |
154 | | |
155 | | #line 156 "lib/command_parse.c" |
156 | | |
157 | | /* Token type. */ |
158 | | #ifndef CMD_YYTOKENTYPE |
159 | | # define CMD_YYTOKENTYPE |
160 | | enum cmd_yytokentype |
161 | | { |
162 | | WORD = 258, |
163 | | IPV4 = 259, |
164 | | IPV4_PREFIX = 260, |
165 | | IPV6 = 261, |
166 | | IPV6_PREFIX = 262, |
167 | | VARIABLE = 263, |
168 | | RANGE = 264, |
169 | | MAC = 265, |
170 | | MAC_PREFIX = 266, |
171 | | ASNUM = 267, |
172 | | EXCL_BRACKET = 268 |
173 | | }; |
174 | | #endif |
175 | | /* Tokens. */ |
176 | | #define WORD 258 |
177 | | #define IPV4 259 |
178 | | #define IPV4_PREFIX 260 |
179 | | #define IPV6 261 |
180 | | #define IPV6_PREFIX 262 |
181 | | #define VARIABLE 263 |
182 | | #define RANGE 264 |
183 | | #define MAC 265 |
184 | | #define MAC_PREFIX 266 |
185 | | #define ASNUM 267 |
186 | | #define EXCL_BRACKET 268 |
187 | | |
188 | | /* Value type. */ |
189 | | #if ! defined CMD_YYSTYPE && ! defined CMD_YYSTYPE_IS_DECLARED |
190 | | union CMD_YYSTYPE |
191 | | { |
192 | | #line 53 "lib/command_parse.y" |
193 | | |
194 | | long long number; |
195 | | char *string; |
196 | | struct graph_node *node; |
197 | | struct subgraph subgraph; |
198 | | |
199 | | #line 200 "lib/command_parse.c" |
200 | | |
201 | | }; |
202 | | typedef union CMD_YYSTYPE CMD_YYSTYPE; |
203 | | # define CMD_YYSTYPE_IS_TRIVIAL 1 |
204 | | # define CMD_YYSTYPE_IS_DECLARED 1 |
205 | | #endif |
206 | | |
207 | | /* Location type. */ |
208 | | #if ! defined CMD_YYLTYPE && ! defined CMD_YYLTYPE_IS_DECLARED |
209 | | typedef struct CMD_YYLTYPE CMD_YYLTYPE; |
210 | | struct CMD_YYLTYPE |
211 | | { |
212 | | int first_line; |
213 | | int first_column; |
214 | | int last_line; |
215 | | int last_column; |
216 | | }; |
217 | | # define CMD_YYLTYPE_IS_DECLARED 1 |
218 | | # define CMD_YYLTYPE_IS_TRIVIAL 1 |
219 | | #endif |
220 | | |
221 | | |
222 | | |
223 | | int cmd_yyparse (struct parser_ctx *ctx); |
224 | | /* "%code provides" blocks. */ |
225 | | #line 60 "lib/command_parse.y" |
226 | | |
227 | | #ifndef FLEX_SCANNER |
228 | | #include "lib/command_lex.h" |
229 | | #endif |
230 | | |
231 | | extern void set_lexer_string (yyscan_t *scn, const char *string); |
232 | | extern void cleanup_lexer (yyscan_t *scn); |
233 | | |
234 | | struct parser_ctx { |
235 | | yyscan_t scanner; |
236 | | |
237 | | const struct cmd_element *el; |
238 | | |
239 | | struct graph *graph; |
240 | | struct graph_node *currnode; |
241 | | |
242 | | /* pointers to copy of command docstring */ |
243 | | char *docstr_start, *docstr; |
244 | | }; |
245 | | |
246 | | #line 247 "lib/command_parse.c" |
247 | | |
248 | | #endif /* !YY_CMD_YY_LIB_COMMAND_PARSE_H_INCLUDED */ |
249 | | |
250 | | |
251 | | /* Unqualified %code blocks. */ |
252 | | #line 109 "lib/command_parse.y" |
253 | | |
254 | | |
255 | | /* bison declarations */ |
256 | | void |
257 | | cmd_yyerror (CMD_YYLTYPE *locp, struct parser_ctx *ctx, char const *msg); |
258 | | |
259 | | /* helper functions for parser */ |
260 | | static const char * |
261 | | doc_next (struct parser_ctx *ctx); |
262 | | |
263 | | static struct graph_node * |
264 | | new_token_node (struct parser_ctx *, |
265 | | enum cmd_token_type type, |
266 | | const char *text, |
267 | | const char *doc); |
268 | | |
269 | | static void |
270 | | terminate_graph (CMD_YYLTYPE *locp, struct parser_ctx *ctx, |
271 | | struct graph_node *); |
272 | | |
273 | | static void |
274 | | cleanup (struct parser_ctx *ctx); |
275 | | |
276 | | static void loopcheck(struct parser_ctx *ctx, struct subgraph *sg); |
277 | | |
278 | 0 | #define scanner ctx->scanner |
279 | | |
280 | | #line 281 "lib/command_parse.c" |
281 | | |
282 | | #ifdef short |
283 | | # undef short |
284 | | #endif |
285 | | |
286 | | /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure |
287 | | <limits.h> and (if available) <stdint.h> are included |
288 | | so that the code can choose integer types of a good width. */ |
289 | | |
290 | | #ifndef __PTRDIFF_MAX__ |
291 | | # include <limits.h> /* INFRINGES ON USER NAME SPACE */ |
292 | | # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ |
293 | | # include <stdint.h> /* INFRINGES ON USER NAME SPACE */ |
294 | | # define YY_STDINT_H |
295 | | # endif |
296 | | #endif |
297 | | |
298 | | /* Narrow types that promote to a signed type and that can represent a |
299 | | signed or unsigned integer of at least N bits. In tables they can |
300 | | save space and decrease cache pressure. Promoting to a signed type |
301 | | helps avoid bugs in integer arithmetic. */ |
302 | | |
303 | | #ifdef __INT_LEAST8_MAX__ |
304 | | typedef __INT_LEAST8_TYPE__ yytype_int8; |
305 | | #elif defined YY_STDINT_H |
306 | | typedef int_least8_t yytype_int8; |
307 | | #else |
308 | | typedef signed char yytype_int8; |
309 | | #endif |
310 | | |
311 | | #ifdef __INT_LEAST16_MAX__ |
312 | | typedef __INT_LEAST16_TYPE__ yytype_int16; |
313 | | #elif defined YY_STDINT_H |
314 | | typedef int_least16_t yytype_int16; |
315 | | #else |
316 | | typedef short yytype_int16; |
317 | | #endif |
318 | | |
319 | | #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ |
320 | | typedef __UINT_LEAST8_TYPE__ yytype_uint8; |
321 | | #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ |
322 | | && UINT_LEAST8_MAX <= INT_MAX) |
323 | | typedef uint_least8_t yytype_uint8; |
324 | | #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX |
325 | | typedef unsigned char yytype_uint8; |
326 | | #else |
327 | | typedef short yytype_uint8; |
328 | | #endif |
329 | | |
330 | | #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ |
331 | | typedef __UINT_LEAST16_TYPE__ yytype_uint16; |
332 | | #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ |
333 | | && UINT_LEAST16_MAX <= INT_MAX) |
334 | | typedef uint_least16_t yytype_uint16; |
335 | | #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX |
336 | | typedef unsigned short yytype_uint16; |
337 | | #else |
338 | | typedef int yytype_uint16; |
339 | | #endif |
340 | | |
341 | | #ifndef YYPTRDIFF_T |
342 | | # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ |
343 | 0 | # define YYPTRDIFF_T __PTRDIFF_TYPE__ |
344 | | # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ |
345 | | # elif defined PTRDIFF_MAX |
346 | | # ifndef ptrdiff_t |
347 | | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
348 | | # endif |
349 | | # define YYPTRDIFF_T ptrdiff_t |
350 | | # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX |
351 | | # else |
352 | | # define YYPTRDIFF_T long |
353 | | # define YYPTRDIFF_MAXIMUM LONG_MAX |
354 | | # endif |
355 | | #endif |
356 | | |
357 | | #ifndef YYSIZE_T |
358 | | # ifdef __SIZE_TYPE__ |
359 | | # define YYSIZE_T __SIZE_TYPE__ |
360 | | # elif defined size_t |
361 | | # define YYSIZE_T size_t |
362 | | # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ |
363 | | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
364 | | # define YYSIZE_T size_t |
365 | | # else |
366 | | # define YYSIZE_T unsigned |
367 | | # endif |
368 | | #endif |
369 | | |
370 | | #define YYSIZE_MAXIMUM \ |
371 | 0 | YY_CAST (YYPTRDIFF_T, \ |
372 | | (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ |
373 | | ? YYPTRDIFF_MAXIMUM \ |
374 | | : YY_CAST (YYSIZE_T, -1))) |
375 | | |
376 | 0 | #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) |
377 | | |
378 | | /* Stored state numbers (used for stacks). */ |
379 | | typedef yytype_int8 yy_state_t; |
380 | | |
381 | | /* State numbers in computations. */ |
382 | | typedef int yy_state_fast_t; |
383 | | |
384 | | #ifndef YY_ |
385 | | # if defined YYENABLE_NLS && YYENABLE_NLS |
386 | | # if ENABLE_NLS |
387 | | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
388 | | # define YY_(Msgid) dgettext ("bison-runtime", Msgid) |
389 | | # endif |
390 | | # endif |
391 | | # ifndef YY_ |
392 | 0 | # define YY_(Msgid) Msgid |
393 | | # endif |
394 | | #endif |
395 | | |
396 | | #ifndef YY_ATTRIBUTE_PURE |
397 | | # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) |
398 | | # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) |
399 | | # else |
400 | | # define YY_ATTRIBUTE_PURE |
401 | | # endif |
402 | | #endif |
403 | | |
404 | | #ifndef YY_ATTRIBUTE_UNUSED |
405 | | # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) |
406 | | # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) |
407 | | # else |
408 | | # define YY_ATTRIBUTE_UNUSED |
409 | | # endif |
410 | | #endif |
411 | | |
412 | | /* Suppress unused-variable warnings by "using" E. */ |
413 | | #if ! defined lint || defined __GNUC__ |
414 | 0 | # define YYUSE(E) ((void) (E)) |
415 | | #else |
416 | | # define YYUSE(E) /* empty */ |
417 | | #endif |
418 | | |
419 | | #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ |
420 | | /* Suppress an incorrect diagnostic about yylval being uninitialized. */ |
421 | | # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ |
422 | | _Pragma ("GCC diagnostic push") \ |
423 | | _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ |
424 | | _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") |
425 | | # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ |
426 | | _Pragma ("GCC diagnostic pop") |
427 | | #else |
428 | 0 | # define YY_INITIAL_VALUE(Value) Value |
429 | | #endif |
430 | | #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
431 | | # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
432 | | # define YY_IGNORE_MAYBE_UNINITIALIZED_END |
433 | | #endif |
434 | | #ifndef YY_INITIAL_VALUE |
435 | | # define YY_INITIAL_VALUE(Value) /* Nothing. */ |
436 | | #endif |
437 | | |
438 | | #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ |
439 | | # define YY_IGNORE_USELESS_CAST_BEGIN \ |
440 | | _Pragma ("GCC diagnostic push") \ |
441 | | _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") |
442 | | # define YY_IGNORE_USELESS_CAST_END \ |
443 | | _Pragma ("GCC diagnostic pop") |
444 | | #endif |
445 | | #ifndef YY_IGNORE_USELESS_CAST_BEGIN |
446 | | # define YY_IGNORE_USELESS_CAST_BEGIN |
447 | | # define YY_IGNORE_USELESS_CAST_END |
448 | | #endif |
449 | | |
450 | | |
451 | 0 | #define YY_ASSERT(E) ((void) (0 && (E))) |
452 | | |
453 | | #if ! defined yyoverflow || YYERROR_VERBOSE |
454 | | |
455 | | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
456 | | |
457 | | # ifdef YYSTACK_USE_ALLOCA |
458 | | # if YYSTACK_USE_ALLOCA |
459 | | # ifdef __GNUC__ |
460 | | # define YYSTACK_ALLOC __builtin_alloca |
461 | | # elif defined __BUILTIN_VA_ARG_INCR |
462 | | # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ |
463 | | # elif defined _AIX |
464 | | # define YYSTACK_ALLOC __alloca |
465 | | # elif defined _MSC_VER |
466 | | # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ |
467 | | # define alloca _alloca |
468 | | # else |
469 | | # define YYSTACK_ALLOC alloca |
470 | | # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS |
471 | | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
472 | | /* Use EXIT_SUCCESS as a witness for stdlib.h. */ |
473 | | # ifndef EXIT_SUCCESS |
474 | | # define EXIT_SUCCESS 0 |
475 | | # endif |
476 | | # endif |
477 | | # endif |
478 | | # endif |
479 | | # endif |
480 | | |
481 | | # ifdef YYSTACK_ALLOC |
482 | | /* Pacify GCC's 'empty if-body' warning. */ |
483 | | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) |
484 | | # ifndef YYSTACK_ALLOC_MAXIMUM |
485 | | /* The OS might guarantee only one guard page at the bottom of the stack, |
486 | | and a page size can be as small as 4096 bytes. So we cannot safely |
487 | | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
488 | | to allow for a few compiler-allocated temporary stack slots. */ |
489 | | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ |
490 | | # endif |
491 | | # else |
492 | | # define YYSTACK_ALLOC YYMALLOC |
493 | 0 | # define YYSTACK_FREE YYFREE |
494 | | # ifndef YYSTACK_ALLOC_MAXIMUM |
495 | 0 | # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
496 | | # endif |
497 | | # if (defined __cplusplus && ! defined EXIT_SUCCESS \ |
498 | | && ! ((defined YYMALLOC || defined malloc) \ |
499 | | && (defined YYFREE || defined free))) |
500 | | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
501 | | # ifndef EXIT_SUCCESS |
502 | | # define EXIT_SUCCESS 0 |
503 | | # endif |
504 | | # endif |
505 | | # ifndef YYMALLOC |
506 | | # define YYMALLOC malloc |
507 | | # if ! defined malloc && ! defined EXIT_SUCCESS |
508 | | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
509 | | # endif |
510 | | # endif |
511 | | # ifndef YYFREE |
512 | 0 | # define YYFREE free |
513 | | # if ! defined free && ! defined EXIT_SUCCESS |
514 | | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
515 | | # endif |
516 | | # endif |
517 | | # endif |
518 | | #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ |
519 | | |
520 | | |
521 | | #if (! defined yyoverflow \ |
522 | | && (! defined __cplusplus \ |
523 | | || (defined CMD_YYLTYPE_IS_TRIVIAL && CMD_YYLTYPE_IS_TRIVIAL \ |
524 | | && defined CMD_YYSTYPE_IS_TRIVIAL && CMD_YYSTYPE_IS_TRIVIAL))) |
525 | | |
526 | | /* A type that is properly aligned for any stack member. */ |
527 | | union yyalloc |
528 | | { |
529 | | yy_state_t yyss_alloc; |
530 | | YYSTYPE yyvs_alloc; |
531 | | YYLTYPE yyls_alloc; |
532 | | }; |
533 | | |
534 | | /* The size of the maximum gap between one aligned stack and the next. */ |
535 | 0 | # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) |
536 | | |
537 | | /* The size of an array large to enough to hold all stacks, each with |
538 | | N elements. */ |
539 | | # define YYSTACK_BYTES(N) \ |
540 | | ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \ |
541 | | + YYSIZEOF (YYLTYPE)) \ |
542 | | + 2 * YYSTACK_GAP_MAXIMUM) |
543 | | |
544 | | # define YYCOPY_NEEDED 1 |
545 | | |
546 | | /* Relocate STACK from its old location to the new one. The |
547 | | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
548 | | elements in the stack, and YYPTR gives the new location of the |
549 | | stack. Advance YYPTR to a properly aligned location for the next |
550 | | stack. */ |
551 | | # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ |
552 | 0 | do \ |
553 | 0 | { \ |
554 | 0 | YYPTRDIFF_T yynewbytes; \ |
555 | 0 | YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ |
556 | 0 | Stack = &yyptr->Stack_alloc; \ |
557 | 0 | yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
558 | 0 | yyptr += yynewbytes / YYSIZEOF (*yyptr); \ |
559 | 0 | } \ |
560 | 0 | while (0) |
561 | | |
562 | | #endif |
563 | | |
564 | | #if defined YYCOPY_NEEDED && YYCOPY_NEEDED |
565 | | /* Copy COUNT objects from SRC to DST. The source and destination do |
566 | | not overlap. */ |
567 | | # ifndef YYCOPY |
568 | | # if defined __GNUC__ && 1 < __GNUC__ |
569 | | # define YYCOPY(Dst, Src, Count) \ |
570 | 0 | __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) |
571 | | # else |
572 | | # define YYCOPY(Dst, Src, Count) \ |
573 | | do \ |
574 | | { \ |
575 | | YYPTRDIFF_T yyi; \ |
576 | | for (yyi = 0; yyi < (Count); yyi++) \ |
577 | | (Dst)[yyi] = (Src)[yyi]; \ |
578 | | } \ |
579 | | while (0) |
580 | | # endif |
581 | | # endif |
582 | | #endif /* !YYCOPY_NEEDED */ |
583 | | |
584 | | /* YYFINAL -- State number of the termination state. */ |
585 | 0 | #define YYFINAL 3 |
586 | | /* YYLAST -- Last index in YYTABLE. */ |
587 | 0 | #define YYLAST 41 |
588 | | |
589 | | /* YYNTOKENS -- Number of terminals. */ |
590 | 0 | #define YYNTOKENS 23 |
591 | | /* YYNNTS -- Number of nonterminals. */ |
592 | | #define YYNNTS 13 |
593 | | /* YYNRULES -- Number of rules. */ |
594 | | #define YYNRULES 32 |
595 | | /* YYNSTATES -- Number of states. */ |
596 | | #define YYNSTATES 51 |
597 | | |
598 | 0 | #define YYUNDEFTOK 2 |
599 | 0 | #define YYMAXUTOK 268 |
600 | | |
601 | | |
602 | | /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM |
603 | | as returned by yylex, with out-of-bounds checking. */ |
604 | | #define YYTRANSLATE(YYX) \ |
605 | 0 | (0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
606 | | |
607 | | /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM |
608 | | as returned by yylex. */ |
609 | | static const yytype_int8 yytranslate[] = |
610 | | { |
611 | | 0, 2, 2, 2, 2, 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, 15, 2, 2, 2, |
615 | | 2, 2, 2, 2, 2, 2, 14, 2, 2, 2, |
616 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
617 | | 16, 2, 17, 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, 21, 2, 22, 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, 19, 18, 20, 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, 2, 2, 2, 2, |
633 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
634 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
635 | | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
636 | | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
637 | | 5, 6, 7, 8, 9, 10, 11, 12, 13 |
638 | | }; |
639 | | |
640 | | #if CMD_YYDEBUG |
641 | | /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ |
642 | | static const yytype_int16 yyrline[] = |
643 | | { |
644 | | 0, 164, 164, 169, 185, 190, 195, 197, 201, 207, |
645 | | 216, 217, 220, 230, 235, 240, 245, 250, 255, 271, |
646 | | 276, 281, 288, 297, 305, 311, 324, 342, 346, 350, |
647 | | 357, 361, 371 |
648 | | }; |
649 | | #endif |
650 | | |
651 | | #if CMD_YYDEBUG || YYERROR_VERBOSE || 1 |
652 | | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
653 | | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
654 | | static const char *const yytname[] = |
655 | | { |
656 | | "$end", "error", "$undefined", "WORD", "IPV4", "IPV4_PREFIX", "IPV6", |
657 | | "IPV6_PREFIX", "VARIABLE", "RANGE", "MAC", "MAC_PREFIX", "ASNUM", |
658 | | "EXCL_BRACKET", "'.'", "'$'", "'<'", "'>'", "'|'", "'{'", "'}'", "'['", |
659 | | "']'", "$accept", "start", "varname_token", "cmd_token_seq", "cmd_token", |
660 | | "simple_token", "literal_token", "placeholder_token_real", |
661 | | "placeholder_token", "selector", "selector_seq_seq", "selector_token", |
662 | | "selector_token_seq", YY_NULLPTR |
663 | | }; |
664 | | #endif |
665 | | |
666 | | # ifdef YYPRINT |
667 | | /* YYTOKNUM[NUM] -- (External) token number corresponding to the |
668 | | (internal) symbol number NUM (which must be that of a token). */ |
669 | | static const yytype_int16 yytoknum[] = |
670 | | { |
671 | | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
672 | | 265, 266, 267, 268, 46, 36, 60, 62, 124, 123, |
673 | | 125, 91, 93 |
674 | | }; |
675 | | # endif |
676 | | |
677 | 0 | #define YYPACT_NINF (-22) |
678 | | |
679 | | #define yypact_value_is_default(Yyn) \ |
680 | 0 | ((Yyn) == YYPACT_NINF) |
681 | | |
682 | | #define YYTABLE_NINF (-1) |
683 | | |
684 | | #define yytable_value_is_error(Yyn) \ |
685 | 0 | 0 |
686 | | |
687 | | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
688 | | STATE-NUM. */ |
689 | | static const yytype_int8 yypact[] = |
690 | | { |
691 | | -22, 16, -2, -22, 10, -22, -22, -22, -22, -22, |
692 | | -22, -22, -22, -22, -2, -2, -2, -2, -22, -22, |
693 | | -22, 10, 20, -22, 32, -22, -22, -22, -22, 5, |
694 | | -22, -2, 15, -5, 6, -22, 22, -22, -2, 10, |
695 | | -22, 10, 10, 10, 23, -2, -22, -22, -22, -22, |
696 | | -22 |
697 | | }; |
698 | | |
699 | | /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. |
700 | | Performed when YYTABLE does not specify something else to do. Zero |
701 | | means the default is an error. */ |
702 | | static const yytype_int8 yydefact[] = |
703 | | { |
704 | | 6, 0, 2, 1, 5, 13, 14, 15, 16, 17, |
705 | | 18, 19, 20, 21, 0, 0, 0, 0, 7, 8, |
706 | | 10, 5, 11, 9, 0, 12, 27, 11, 28, 0, |
707 | | 30, 25, 0, 0, 0, 22, 0, 4, 0, 5, |
708 | | 29, 5, 5, 5, 0, 24, 32, 23, 26, 31, |
709 | | 3 |
710 | | }; |
711 | | |
712 | | /* YYPGOTO[NTERM-NUM]. */ |
713 | | static const yytype_int8 yypgoto[] = |
714 | | { |
715 | | -22, -22, -21, -22, -22, 36, -22, -22, 37, 38, |
716 | | 14, -19, 3 |
717 | | }; |
718 | | |
719 | | /* YYDEFGOTO[NTERM-NUM]. */ |
720 | | static const yytype_int8 yydefgoto[] = |
721 | | { |
722 | | -1, 1, 25, 2, 18, 26, 20, 21, 27, 28, |
723 | | 29, 30, 31 |
724 | | }; |
725 | | |
726 | | /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If |
727 | | positive, shift that token. If negative, reduce the rule whose |
728 | | number is the opposite. If YYTABLE_NINF, syntax error. */ |
729 | | static const yytype_int8 yytable[] = |
730 | | { |
731 | | 35, 4, 5, 6, 7, 8, 9, 10, 11, 12, |
732 | | 13, 14, 40, 38, 15, 42, 3, 16, 46, 17, |
733 | | 47, 48, 49, 38, 38, 24, 40, 39, 43, 32, |
734 | | 33, 34, 41, 38, 36, 37, 44, 50, 19, 22, |
735 | | 23, 45 |
736 | | }; |
737 | | |
738 | | static const yytype_int8 yycheck[] = |
739 | | { |
740 | | 21, 3, 4, 5, 6, 7, 8, 9, 10, 11, |
741 | | 12, 13, 31, 18, 16, 20, 0, 19, 39, 21, |
742 | | 41, 42, 43, 18, 18, 15, 45, 22, 22, 15, |
743 | | 16, 17, 17, 18, 14, 3, 14, 14, 2, 2, |
744 | | 2, 38 |
745 | | }; |
746 | | |
747 | | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
748 | | symbol of state STATE-NUM. */ |
749 | | static const yytype_int8 yystos[] = |
750 | | { |
751 | | 0, 24, 26, 0, 3, 4, 5, 6, 7, 8, |
752 | | 9, 10, 11, 12, 13, 16, 19, 21, 27, 28, |
753 | | 29, 30, 31, 32, 15, 25, 28, 31, 32, 33, |
754 | | 34, 35, 33, 33, 33, 25, 14, 3, 18, 22, |
755 | | 34, 17, 20, 22, 14, 35, 25, 25, 25, 25, |
756 | | 14 |
757 | | }; |
758 | | |
759 | | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
760 | | static const yytype_int8 yyr1[] = |
761 | | { |
762 | | 0, 23, 24, 24, 25, 25, 26, 26, 27, 27, |
763 | | 28, 28, 29, 30, 30, 30, 30, 30, 30, 30, |
764 | | 30, 30, 31, 32, 33, 33, 32, 34, 34, 35, |
765 | | 35, 32, 32 |
766 | | }; |
767 | | |
768 | | /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ |
769 | | static const yytype_int8 yyr2[] = |
770 | | { |
771 | | 0, 2, 1, 5, 2, 0, 0, 2, 1, 1, |
772 | | 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, |
773 | | 1, 1, 2, 4, 3, 1, 4, 1, 1, 2, |
774 | | 1, 4, 4 |
775 | | }; |
776 | | |
777 | | |
778 | | #define yyerrok (yyerrstatus = 0) |
779 | | #define yyclearin (yychar = YYEMPTY) |
780 | 0 | #define YYEMPTY (-2) |
781 | 0 | #define YYEOF 0 |
782 | | |
783 | 0 | #define YYACCEPT goto yyacceptlab |
784 | 0 | #define YYABORT goto yyabortlab |
785 | 0 | #define YYERROR goto yyerrorlab |
786 | | |
787 | | |
788 | | #define YYRECOVERING() (!!yyerrstatus) |
789 | | |
790 | | #define YYBACKUP(Token, Value) \ |
791 | | do \ |
792 | | if (yychar == YYEMPTY) \ |
793 | | { \ |
794 | | yychar = (Token); \ |
795 | | yylval = (Value); \ |
796 | | YYPOPSTACK (yylen); \ |
797 | | yystate = *yyssp; \ |
798 | | goto yybackup; \ |
799 | | } \ |
800 | | else \ |
801 | | { \ |
802 | | yyerror (&yylloc, ctx, YY_("syntax error: cannot back up")); \ |
803 | | YYERROR; \ |
804 | | } \ |
805 | | while (0) |
806 | | |
807 | | /* Error token number */ |
808 | 0 | #define YYTERROR 1 |
809 | | #define YYERRCODE 256 |
810 | | |
811 | | |
812 | | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
813 | | If N is 0, then set CURRENT to the empty location which ends |
814 | | the previous symbol: RHS[0] (always defined). */ |
815 | | |
816 | | #ifndef YYLLOC_DEFAULT |
817 | | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
818 | 0 | do \ |
819 | 0 | if (N) \ |
820 | 0 | { \ |
821 | 0 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
822 | 0 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
823 | 0 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
824 | 0 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
825 | 0 | } \ |
826 | 0 | else \ |
827 | 0 | { \ |
828 | 0 | (Current).first_line = (Current).last_line = \ |
829 | 0 | YYRHSLOC (Rhs, 0).last_line; \ |
830 | 0 | (Current).first_column = (Current).last_column = \ |
831 | 0 | YYRHSLOC (Rhs, 0).last_column; \ |
832 | 0 | } \ |
833 | 0 | while (0) |
834 | | #endif |
835 | | |
836 | 0 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
837 | | |
838 | | |
839 | | /* Enable debugging if requested. */ |
840 | | #if CMD_YYDEBUG |
841 | | |
842 | | # ifndef YYFPRINTF |
843 | | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
844 | 0 | # define YYFPRINTF fprintf |
845 | | # endif |
846 | | |
847 | 0 | # define YYDPRINTF(Args) \ |
848 | 0 | do { \ |
849 | 0 | if (yydebug) \ |
850 | 0 | YYFPRINTF Args; \ |
851 | 0 | } while (0) |
852 | | |
853 | | |
854 | | /* YY_LOCATION_PRINT -- Print the location on the stream. |
855 | | This macro was not mandated originally: define only if we know |
856 | | we won't break user code: when these are the locations we know. */ |
857 | | |
858 | | #ifndef YY_LOCATION_PRINT |
859 | | # if defined CMD_YYLTYPE_IS_TRIVIAL && CMD_YYLTYPE_IS_TRIVIAL |
860 | | |
861 | | /* Print *YYLOCP on YYO. Private, do not rely on its existence. */ |
862 | | |
863 | | YY_ATTRIBUTE_UNUSED |
864 | | static int |
865 | | yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) |
866 | 0 | { |
867 | 0 | int res = 0; |
868 | 0 | int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0; |
869 | 0 | if (0 <= yylocp->first_line) |
870 | 0 | { |
871 | 0 | res += YYFPRINTF (yyo, "%d", yylocp->first_line); |
872 | 0 | if (0 <= yylocp->first_column) |
873 | 0 | res += YYFPRINTF (yyo, ".%d", yylocp->first_column); |
874 | 0 | } |
875 | 0 | if (0 <= yylocp->last_line) |
876 | 0 | { |
877 | 0 | if (yylocp->first_line < yylocp->last_line) |
878 | 0 | { |
879 | 0 | res += YYFPRINTF (yyo, "-%d", yylocp->last_line); |
880 | 0 | if (0 <= end_col) |
881 | 0 | res += YYFPRINTF (yyo, ".%d", end_col); |
882 | 0 | } |
883 | 0 | else if (0 <= end_col && yylocp->first_column < end_col) |
884 | 0 | res += YYFPRINTF (yyo, "-%d", end_col); |
885 | 0 | } |
886 | 0 | return res; |
887 | 0 | } |
888 | | |
889 | | # define YY_LOCATION_PRINT(File, Loc) \ |
890 | 0 | yy_location_print_ (File, &(Loc)) |
891 | | |
892 | | # else |
893 | | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
894 | | # endif |
895 | | #endif |
896 | | |
897 | | |
898 | 0 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
899 | 0 | do { \ |
900 | 0 | if (yydebug) \ |
901 | 0 | { \ |
902 | 0 | YYFPRINTF (stderr, "%s ", Title); \ |
903 | 0 | yy_symbol_print (stderr, \ |
904 | 0 | Type, Value, Location, ctx); \ |
905 | 0 | YYFPRINTF (stderr, "\n"); \ |
906 | 0 | } \ |
907 | 0 | } while (0) |
908 | | |
909 | | |
910 | | /*-----------------------------------. |
911 | | | Print this symbol's value on YYO. | |
912 | | `-----------------------------------*/ |
913 | | |
914 | | static void |
915 | | yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct parser_ctx *ctx) |
916 | 0 | { |
917 | 0 | FILE *yyoutput = yyo; |
918 | 0 | YYUSE (yyoutput); |
919 | 0 | YYUSE (yylocationp); |
920 | 0 | YYUSE (ctx); |
921 | 0 | if (!yyvaluep) |
922 | 0 | return; |
923 | | # ifdef YYPRINT |
924 | | if (yytype < YYNTOKENS) |
925 | | YYPRINT (yyo, yytoknum[yytype], *yyvaluep); |
926 | | # endif |
927 | 0 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
928 | 0 | YYUSE (yytype); |
929 | 0 | YY_IGNORE_MAYBE_UNINITIALIZED_END |
930 | 0 | } |
931 | | |
932 | | |
933 | | /*---------------------------. |
934 | | | Print this symbol on YYO. | |
935 | | `---------------------------*/ |
936 | | |
937 | | static void |
938 | | yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, struct parser_ctx *ctx) |
939 | 0 | { |
940 | 0 | YYFPRINTF (yyo, "%s %s (", |
941 | 0 | yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); |
942 | |
|
943 | 0 | YY_LOCATION_PRINT (yyo, *yylocationp); |
944 | 0 | YYFPRINTF (yyo, ": "); |
945 | 0 | yy_symbol_value_print (yyo, yytype, yyvaluep, yylocationp, ctx); |
946 | 0 | YYFPRINTF (yyo, ")"); |
947 | 0 | } |
948 | | |
949 | | /*------------------------------------------------------------------. |
950 | | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
951 | | | TOP (included). | |
952 | | `------------------------------------------------------------------*/ |
953 | | |
954 | | static void |
955 | | yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) |
956 | 0 | { |
957 | 0 | YYFPRINTF (stderr, "Stack now"); |
958 | 0 | for (; yybottom <= yytop; yybottom++) |
959 | 0 | { |
960 | 0 | int yybot = *yybottom; |
961 | 0 | YYFPRINTF (stderr, " %d", yybot); |
962 | 0 | } |
963 | 0 | YYFPRINTF (stderr, "\n"); |
964 | 0 | } |
965 | | |
966 | 0 | # define YY_STACK_PRINT(Bottom, Top) \ |
967 | 0 | do { \ |
968 | 0 | if (yydebug) \ |
969 | 0 | yy_stack_print ((Bottom), (Top)); \ |
970 | 0 | } while (0) |
971 | | |
972 | | |
973 | | /*------------------------------------------------. |
974 | | | Report that the YYRULE is going to be reduced. | |
975 | | `------------------------------------------------*/ |
976 | | |
977 | | static void |
978 | | yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, struct parser_ctx *ctx) |
979 | 0 | { |
980 | 0 | int yylno = yyrline[yyrule]; |
981 | 0 | int yynrhs = yyr2[yyrule]; |
982 | 0 | int yyi; |
983 | 0 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", |
984 | 0 | yyrule - 1, yylno); |
985 | | /* The symbols being reduced. */ |
986 | 0 | for (yyi = 0; yyi < yynrhs; yyi++) |
987 | 0 | { |
988 | 0 | YYFPRINTF (stderr, " $%d = ", yyi + 1); |
989 | 0 | yy_symbol_print (stderr, |
990 | 0 | yystos[+yyssp[yyi + 1 - yynrhs]], |
991 | 0 | &yyvsp[(yyi + 1) - (yynrhs)] |
992 | 0 | , &(yylsp[(yyi + 1) - (yynrhs)]) , ctx); |
993 | 0 | YYFPRINTF (stderr, "\n"); |
994 | 0 | } |
995 | 0 | } |
996 | | |
997 | 0 | # define YY_REDUCE_PRINT(Rule) \ |
998 | 0 | do { \ |
999 | 0 | if (yydebug) \ |
1000 | 0 | yy_reduce_print (yyssp, yyvsp, yylsp, Rule, ctx); \ |
1001 | 0 | } while (0) |
1002 | | |
1003 | | /* Nonzero means print parse trace. It is left uninitialized so that |
1004 | | multiple parsers can coexist. */ |
1005 | | int yydebug; |
1006 | | #else /* !CMD_YYDEBUG */ |
1007 | | # define YYDPRINTF(Args) |
1008 | | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
1009 | | # define YY_STACK_PRINT(Bottom, Top) |
1010 | | # define YY_REDUCE_PRINT(Rule) |
1011 | | #endif /* !CMD_YYDEBUG */ |
1012 | | |
1013 | | |
1014 | | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
1015 | | #ifndef YYINITDEPTH |
1016 | 0 | # define YYINITDEPTH 200 |
1017 | | #endif |
1018 | | |
1019 | | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
1020 | | if the built-in stack extension method is used). |
1021 | | |
1022 | | Do not make this value too large; the results are undefined if |
1023 | | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
1024 | | evaluated with infinite-precision integer arithmetic. */ |
1025 | | |
1026 | | #ifndef YYMAXDEPTH |
1027 | 0 | # define YYMAXDEPTH 10000 |
1028 | | #endif |
1029 | | |
1030 | | |
1031 | | #if YYERROR_VERBOSE |
1032 | | |
1033 | | # ifndef yystrlen |
1034 | | # if defined __GLIBC__ && defined _STRING_H |
1035 | 0 | # define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S))) |
1036 | | # else |
1037 | | /* Return the length of YYSTR. */ |
1038 | | static YYPTRDIFF_T |
1039 | | yystrlen (const char *yystr) |
1040 | | { |
1041 | | YYPTRDIFF_T yylen; |
1042 | | for (yylen = 0; yystr[yylen]; yylen++) |
1043 | | continue; |
1044 | | return yylen; |
1045 | | } |
1046 | | # endif |
1047 | | # endif |
1048 | | |
1049 | | # ifndef yystpcpy |
1050 | | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE |
1051 | 0 | # define yystpcpy stpcpy |
1052 | | # else |
1053 | | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
1054 | | YYDEST. */ |
1055 | | static char * |
1056 | | yystpcpy (char *yydest, const char *yysrc) |
1057 | | { |
1058 | | char *yyd = yydest; |
1059 | | const char *yys = yysrc; |
1060 | | |
1061 | | while ((*yyd++ = *yys++) != '\0') |
1062 | | continue; |
1063 | | |
1064 | | return yyd - 1; |
1065 | | } |
1066 | | # endif |
1067 | | # endif |
1068 | | |
1069 | | # ifndef yytnamerr |
1070 | | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
1071 | | quotes and backslashes, so that it's suitable for yyerror. The |
1072 | | heuristic is that double-quoting is unnecessary unless the string |
1073 | | contains an apostrophe, a comma, or backslash (other than |
1074 | | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
1075 | | null, do not copy; instead, return the length of what the result |
1076 | | would have been. */ |
1077 | | static YYPTRDIFF_T |
1078 | | yytnamerr (char *yyres, const char *yystr) |
1079 | 0 | { |
1080 | 0 | if (*yystr == '"') |
1081 | 0 | { |
1082 | 0 | YYPTRDIFF_T yyn = 0; |
1083 | 0 | char const *yyp = yystr; |
1084 | |
|
1085 | 0 | for (;;) |
1086 | 0 | switch (*++yyp) |
1087 | 0 | { |
1088 | 0 | case '\'': |
1089 | 0 | case ',': |
1090 | 0 | goto do_not_strip_quotes; |
1091 | | |
1092 | 0 | case '\\': |
1093 | 0 | if (*++yyp != '\\') |
1094 | 0 | goto do_not_strip_quotes; |
1095 | 0 | else |
1096 | 0 | goto append; |
1097 | | |
1098 | 0 | append: |
1099 | 0 | default: |
1100 | 0 | if (yyres) |
1101 | 0 | yyres[yyn] = *yyp; |
1102 | 0 | yyn++; |
1103 | 0 | break; |
1104 | | |
1105 | 0 | case '"': |
1106 | 0 | if (yyres) |
1107 | 0 | yyres[yyn] = '\0'; |
1108 | 0 | return yyn; |
1109 | 0 | } |
1110 | 0 | do_not_strip_quotes: ; |
1111 | 0 | } |
1112 | | |
1113 | 0 | if (yyres) |
1114 | 0 | return yystpcpy (yyres, yystr) - yyres; |
1115 | 0 | else |
1116 | 0 | return yystrlen (yystr); |
1117 | 0 | } |
1118 | | # endif |
1119 | | |
1120 | | /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message |
1121 | | about the unexpected token YYTOKEN for the state stack whose top is |
1122 | | YYSSP. |
1123 | | |
1124 | | Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is |
1125 | | not large enough to hold the message. In that case, also set |
1126 | | *YYMSG_ALLOC to the required number of bytes. Return 2 if the |
1127 | | required number of bytes is too large to store. */ |
1128 | | static int |
1129 | | yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg, |
1130 | | yy_state_t *yyssp, int yytoken) |
1131 | 0 | { |
1132 | 0 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; |
1133 | | /* Internationalized format string. */ |
1134 | 0 | const char *yyformat = YY_NULLPTR; |
1135 | | /* Arguments of yyformat: reported tokens (one for the "unexpected", |
1136 | | one per "expected"). */ |
1137 | 0 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
1138 | | /* Actual size of YYARG. */ |
1139 | 0 | int yycount = 0; |
1140 | | /* Cumulated lengths of YYARG. */ |
1141 | 0 | YYPTRDIFF_T yysize = 0; |
1142 | | |
1143 | | /* There are many possibilities here to consider: |
1144 | | - If this state is a consistent state with a default action, then |
1145 | | the only way this function was invoked is if the default action |
1146 | | is an error action. In that case, don't check for expected |
1147 | | tokens because there are none. |
1148 | | - The only way there can be no lookahead present (in yychar) is if |
1149 | | this state is a consistent state with a default action. Thus, |
1150 | | detecting the absence of a lookahead is sufficient to determine |
1151 | | that there is no unexpected or expected token to report. In that |
1152 | | case, just report a simple "syntax error". |
1153 | | - Don't assume there isn't a lookahead just because this state is a |
1154 | | consistent state with a default action. There might have been a |
1155 | | previous inconsistent state, consistent state with a non-default |
1156 | | action, or user semantic action that manipulated yychar. |
1157 | | - Of course, the expected token list depends on states to have |
1158 | | correct lookahead information, and it depends on the parser not |
1159 | | to perform extra reductions after fetching a lookahead from the |
1160 | | scanner and before detecting a syntax error. Thus, state merging |
1161 | | (from LALR or IELR) and default reductions corrupt the expected |
1162 | | token list. However, the list is correct for canonical LR with |
1163 | | one exception: it will still contain any token that will not be |
1164 | | accepted due to an error action in a later state. |
1165 | | */ |
1166 | 0 | if (yytoken != YYEMPTY) |
1167 | 0 | { |
1168 | 0 | int yyn = yypact[+*yyssp]; |
1169 | 0 | YYPTRDIFF_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); |
1170 | 0 | yysize = yysize0; |
1171 | 0 | yyarg[yycount++] = yytname[yytoken]; |
1172 | 0 | if (!yypact_value_is_default (yyn)) |
1173 | 0 | { |
1174 | | /* Start YYX at -YYN if negative to avoid negative indexes in |
1175 | | YYCHECK. In other words, skip the first -YYN actions for |
1176 | | this state because they are default actions. */ |
1177 | 0 | int yyxbegin = yyn < 0 ? -yyn : 0; |
1178 | | /* Stay within bounds of both yycheck and yytname. */ |
1179 | 0 | int yychecklim = YYLAST - yyn + 1; |
1180 | 0 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
1181 | 0 | int yyx; |
1182 | |
|
1183 | 0 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
1184 | 0 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR |
1185 | 0 | && !yytable_value_is_error (yytable[yyx + yyn])) |
1186 | 0 | { |
1187 | 0 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
1188 | 0 | { |
1189 | 0 | yycount = 1; |
1190 | 0 | yysize = yysize0; |
1191 | 0 | break; |
1192 | 0 | } |
1193 | 0 | yyarg[yycount++] = yytname[yyx]; |
1194 | 0 | { |
1195 | 0 | YYPTRDIFF_T yysize1 |
1196 | 0 | = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); |
1197 | 0 | if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) |
1198 | 0 | yysize = yysize1; |
1199 | 0 | else |
1200 | 0 | return 2; |
1201 | 0 | } |
1202 | 0 | } |
1203 | 0 | } |
1204 | 0 | } |
1205 | | |
1206 | 0 | switch (yycount) |
1207 | 0 | { |
1208 | 0 | # define YYCASE_(N, S) \ |
1209 | 0 | case N: \ |
1210 | 0 | yyformat = S; \ |
1211 | 0 | break |
1212 | 0 | default: /* Avoid compiler warnings. */ |
1213 | 0 | YYCASE_(0, YY_("syntax error")); |
1214 | 0 | YYCASE_(1, YY_("syntax error, unexpected %s")); |
1215 | 0 | YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); |
1216 | 0 | YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); |
1217 | 0 | YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); |
1218 | 0 | YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); |
1219 | 0 | # undef YYCASE_ |
1220 | 0 | } |
1221 | | |
1222 | 0 | { |
1223 | | /* Don't count the "%s"s in the final size, but reserve room for |
1224 | | the terminator. */ |
1225 | 0 | YYPTRDIFF_T yysize1 = yysize + (yystrlen (yyformat) - 2 * yycount) + 1; |
1226 | 0 | if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) |
1227 | 0 | yysize = yysize1; |
1228 | 0 | else |
1229 | 0 | return 2; |
1230 | 0 | } |
1231 | | |
1232 | 0 | if (*yymsg_alloc < yysize) |
1233 | 0 | { |
1234 | 0 | *yymsg_alloc = 2 * yysize; |
1235 | 0 | if (! (yysize <= *yymsg_alloc |
1236 | 0 | && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) |
1237 | 0 | *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; |
1238 | 0 | return 1; |
1239 | 0 | } |
1240 | | |
1241 | | /* Avoid sprintf, as that infringes on the user's name space. |
1242 | | Don't have undefined behavior even if the translation |
1243 | | produced a string with the wrong number of "%s"s. */ |
1244 | 0 | { |
1245 | 0 | char *yyp = *yymsg; |
1246 | 0 | int yyi = 0; |
1247 | 0 | while ((*yyp = *yyformat) != '\0') |
1248 | 0 | if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) |
1249 | 0 | { |
1250 | 0 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
1251 | 0 | yyformat += 2; |
1252 | 0 | } |
1253 | 0 | else |
1254 | 0 | { |
1255 | 0 | ++yyp; |
1256 | 0 | ++yyformat; |
1257 | 0 | } |
1258 | 0 | } |
1259 | 0 | return 0; |
1260 | 0 | } |
1261 | | #endif /* YYERROR_VERBOSE */ |
1262 | | |
1263 | | /*-----------------------------------------------. |
1264 | | | Release the memory associated to this symbol. | |
1265 | | `-----------------------------------------------*/ |
1266 | | |
1267 | | static void |
1268 | | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, struct parser_ctx *ctx) |
1269 | 0 | { |
1270 | 0 | YYUSE (yyvaluep); |
1271 | 0 | YYUSE (yylocationp); |
1272 | 0 | YYUSE (ctx); |
1273 | 0 | if (!yymsg) |
1274 | 0 | yymsg = "Deleting"; |
1275 | 0 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
1276 | |
|
1277 | 0 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
1278 | 0 | YYUSE (yytype); |
1279 | 0 | YY_IGNORE_MAYBE_UNINITIALIZED_END |
1280 | 0 | } |
1281 | | |
1282 | | |
1283 | | |
1284 | | |
1285 | | /*----------. |
1286 | | | yyparse. | |
1287 | | `----------*/ |
1288 | | |
1289 | | int |
1290 | | yyparse (struct parser_ctx *ctx) |
1291 | 0 | { |
1292 | | /* The lookahead symbol. */ |
1293 | 0 | int yychar; |
1294 | | |
1295 | | |
1296 | | /* The semantic value of the lookahead symbol. */ |
1297 | | /* Default value used for initialization, for pacifying older GCCs |
1298 | | or non-GCC compilers. */ |
1299 | 0 | YY_INITIAL_VALUE (static YYSTYPE yyval_default;) |
1300 | 0 | YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); |
1301 | | |
1302 | | /* Location data for the lookahead symbol. */ |
1303 | 0 | static YYLTYPE yyloc_default |
1304 | 0 | # if defined CMD_YYLTYPE_IS_TRIVIAL && CMD_YYLTYPE_IS_TRIVIAL |
1305 | 0 | = { 1, 1, 1, 1 } |
1306 | 0 | # endif |
1307 | 0 | ; |
1308 | 0 | YYLTYPE yylloc = yyloc_default; |
1309 | | |
1310 | | /* Number of syntax errors so far. */ |
1311 | 0 | int yynerrs; |
1312 | |
|
1313 | 0 | yy_state_fast_t yystate; |
1314 | | /* Number of tokens to shift before error messages enabled. */ |
1315 | 0 | int yyerrstatus; |
1316 | | |
1317 | | /* The stacks and their tools: |
1318 | | 'yyss': related to states. |
1319 | | 'yyvs': related to semantic values. |
1320 | | 'yyls': related to locations. |
1321 | | |
1322 | | Refer to the stacks through separate pointers, to allow yyoverflow |
1323 | | to reallocate them elsewhere. */ |
1324 | | |
1325 | | /* The state stack. */ |
1326 | 0 | yy_state_t yyssa[YYINITDEPTH]; |
1327 | 0 | yy_state_t *yyss; |
1328 | 0 | yy_state_t *yyssp; |
1329 | | |
1330 | | /* The semantic value stack. */ |
1331 | 0 | YYSTYPE yyvsa[YYINITDEPTH]; |
1332 | 0 | YYSTYPE *yyvs; |
1333 | 0 | YYSTYPE *yyvsp; |
1334 | | |
1335 | | /* The location stack. */ |
1336 | 0 | YYLTYPE yylsa[YYINITDEPTH]; |
1337 | 0 | YYLTYPE *yyls; |
1338 | 0 | YYLTYPE *yylsp; |
1339 | | |
1340 | | /* The locations where the error started and ended. */ |
1341 | 0 | YYLTYPE yyerror_range[3]; |
1342 | |
|
1343 | 0 | YYPTRDIFF_T yystacksize; |
1344 | |
|
1345 | 0 | int yyn; |
1346 | 0 | int yyresult; |
1347 | | /* Lookahead token as an internal (translated) token number. */ |
1348 | 0 | int yytoken = 0; |
1349 | | /* The variables used to return semantic value and location from the |
1350 | | action routines. */ |
1351 | 0 | YYSTYPE yyval; |
1352 | 0 | YYLTYPE yyloc; |
1353 | |
|
1354 | 0 | #if YYERROR_VERBOSE |
1355 | | /* Buffer for error messages, and its allocated size. */ |
1356 | 0 | char yymsgbuf[128]; |
1357 | 0 | char *yymsg = yymsgbuf; |
1358 | 0 | YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf; |
1359 | 0 | #endif |
1360 | |
|
1361 | 0 | #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) |
1362 | | |
1363 | | /* The number of symbols on the RHS of the reduced rule. |
1364 | | Keep to zero when no symbol should be popped. */ |
1365 | 0 | int yylen = 0; |
1366 | |
|
1367 | 0 | yyssp = yyss = yyssa; |
1368 | 0 | yyvsp = yyvs = yyvsa; |
1369 | 0 | yylsp = yyls = yylsa; |
1370 | 0 | yystacksize = YYINITDEPTH; |
1371 | |
|
1372 | 0 | YYDPRINTF ((stderr, "Starting parse\n")); |
1373 | |
|
1374 | 0 | yystate = 0; |
1375 | 0 | yyerrstatus = 0; |
1376 | 0 | yynerrs = 0; |
1377 | 0 | yychar = YYEMPTY; /* Cause a token to be read. */ |
1378 | | |
1379 | | /* User initialization code. */ |
1380 | 0 | #line 142 "lib/command_parse.y" |
1381 | 0 | { |
1382 | | /* clear state pointers */ |
1383 | 0 | ctx->currnode = vector_slot (ctx->graph->nodes, 0); |
1384 | | |
1385 | | /* copy docstring and keep a pointer to the copy */ |
1386 | 0 | if (ctx->el->doc) |
1387 | 0 | { |
1388 | | // allocate a new buffer, making room for a flag |
1389 | 0 | size_t length = (size_t) strlen (ctx->el->doc) + 2; |
1390 | 0 | ctx->docstr = malloc (length); |
1391 | 0 | memcpy (ctx->docstr, ctx->el->doc, strlen (ctx->el->doc)); |
1392 | | // set the flag so doc_next knows when to print a warning |
1393 | 0 | ctx->docstr[length - 2] = 0x03; |
1394 | | // null terminate |
1395 | 0 | ctx->docstr[length - 1] = 0x00; |
1396 | 0 | } |
1397 | 0 | ctx->docstr_start = ctx->docstr; |
1398 | 0 | } |
1399 | |
|
1400 | 0 | #line 1401 "lib/command_parse.c" |
1401 | |
|
1402 | 0 | yylsp[0] = yylloc; |
1403 | 0 | goto yysetstate; |
1404 | | |
1405 | | |
1406 | | /*------------------------------------------------------------. |
1407 | | | yynewstate -- push a new state, which is found in yystate. | |
1408 | | `------------------------------------------------------------*/ |
1409 | 0 | yynewstate: |
1410 | | /* In all cases, when you get here, the value and location stacks |
1411 | | have just been pushed. So pushing a state here evens the stacks. */ |
1412 | 0 | yyssp++; |
1413 | | |
1414 | | |
1415 | | /*--------------------------------------------------------------------. |
1416 | | | yysetstate -- set current state (the top of the stack) to yystate. | |
1417 | | `--------------------------------------------------------------------*/ |
1418 | 0 | yysetstate: |
1419 | 0 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
1420 | 0 | YY_ASSERT (0 <= yystate && yystate < YYNSTATES); |
1421 | 0 | YY_IGNORE_USELESS_CAST_BEGIN |
1422 | 0 | *yyssp = YY_CAST (yy_state_t, yystate); |
1423 | 0 | YY_IGNORE_USELESS_CAST_END |
1424 | |
|
1425 | 0 | if (yyss + yystacksize - 1 <= yyssp) |
1426 | | #if !defined yyoverflow && !defined YYSTACK_RELOCATE |
1427 | | goto yyexhaustedlab; |
1428 | | #else |
1429 | 0 | { |
1430 | | /* Get the current used size of the three stacks, in elements. */ |
1431 | 0 | YYPTRDIFF_T yysize = yyssp - yyss + 1; |
1432 | |
|
1433 | | # if defined yyoverflow |
1434 | | { |
1435 | | /* Give user a chance to reallocate the stack. Use copies of |
1436 | | these so that the &'s don't force the real ones into |
1437 | | memory. */ |
1438 | | yy_state_t *yyss1 = yyss; |
1439 | | YYSTYPE *yyvs1 = yyvs; |
1440 | | YYLTYPE *yyls1 = yyls; |
1441 | | |
1442 | | /* Each stack pointer address is followed by the size of the |
1443 | | data in use in that stack, in bytes. This used to be a |
1444 | | conditional around just the two extra args, but that might |
1445 | | be undefined if yyoverflow is a macro. */ |
1446 | | yyoverflow (YY_("memory exhausted"), |
1447 | | &yyss1, yysize * YYSIZEOF (*yyssp), |
1448 | | &yyvs1, yysize * YYSIZEOF (*yyvsp), |
1449 | | &yyls1, yysize * YYSIZEOF (*yylsp), |
1450 | | &yystacksize); |
1451 | | yyss = yyss1; |
1452 | | yyvs = yyvs1; |
1453 | | yyls = yyls1; |
1454 | | } |
1455 | | # else /* defined YYSTACK_RELOCATE */ |
1456 | | /* Extend the stack our own way. */ |
1457 | 0 | if (YYMAXDEPTH <= yystacksize) |
1458 | 0 | goto yyexhaustedlab; |
1459 | 0 | yystacksize *= 2; |
1460 | 0 | if (YYMAXDEPTH < yystacksize) |
1461 | 0 | yystacksize = YYMAXDEPTH; |
1462 | |
|
1463 | 0 | { |
1464 | 0 | yy_state_t *yyss1 = yyss; |
1465 | 0 | union yyalloc *yyptr = |
1466 | 0 | YY_CAST (union yyalloc *, |
1467 | 0 | YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); |
1468 | 0 | if (! yyptr) |
1469 | 0 | goto yyexhaustedlab; |
1470 | 0 | YYSTACK_RELOCATE (yyss_alloc, yyss); |
1471 | 0 | YYSTACK_RELOCATE (yyvs_alloc, yyvs); |
1472 | 0 | YYSTACK_RELOCATE (yyls_alloc, yyls); |
1473 | 0 | # undef YYSTACK_RELOCATE |
1474 | 0 | if (yyss1 != yyssa) |
1475 | 0 | YYSTACK_FREE (yyss1); |
1476 | 0 | } |
1477 | 0 | # endif |
1478 | | |
1479 | 0 | yyssp = yyss + yysize - 1; |
1480 | 0 | yyvsp = yyvs + yysize - 1; |
1481 | 0 | yylsp = yyls + yysize - 1; |
1482 | |
|
1483 | 0 | YY_IGNORE_USELESS_CAST_BEGIN |
1484 | 0 | YYDPRINTF ((stderr, "Stack size increased to %ld\n", |
1485 | 0 | YY_CAST (long, yystacksize))); |
1486 | 0 | YY_IGNORE_USELESS_CAST_END |
1487 | |
|
1488 | 0 | if (yyss + yystacksize - 1 <= yyssp) |
1489 | 0 | YYABORT; |
1490 | 0 | } |
1491 | 0 | #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ |
1492 | | |
1493 | 0 | if (yystate == YYFINAL) |
1494 | 0 | YYACCEPT; |
1495 | | |
1496 | 0 | goto yybackup; |
1497 | | |
1498 | | |
1499 | | /*-----------. |
1500 | | | yybackup. | |
1501 | | `-----------*/ |
1502 | 0 | yybackup: |
1503 | | /* Do appropriate processing given the current state. Read a |
1504 | | lookahead token if we need one and don't already have one. */ |
1505 | | |
1506 | | /* First try to decide what to do without reference to lookahead token. */ |
1507 | 0 | yyn = yypact[yystate]; |
1508 | 0 | if (yypact_value_is_default (yyn)) |
1509 | 0 | goto yydefault; |
1510 | | |
1511 | | /* Not known => get a lookahead token if don't already have one. */ |
1512 | | |
1513 | | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ |
1514 | 0 | if (yychar == YYEMPTY) |
1515 | 0 | { |
1516 | 0 | YYDPRINTF ((stderr, "Reading a token: ")); |
1517 | 0 | yychar = yylex (&yylval, &yylloc, scanner); |
1518 | 0 | } |
1519 | |
|
1520 | 0 | if (yychar <= YYEOF) |
1521 | 0 | { |
1522 | 0 | yychar = yytoken = YYEOF; |
1523 | 0 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
1524 | 0 | } |
1525 | 0 | else |
1526 | 0 | { |
1527 | 0 | yytoken = YYTRANSLATE (yychar); |
1528 | 0 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
1529 | 0 | } |
1530 | | |
1531 | | /* If the proper action on seeing token YYTOKEN is to reduce or to |
1532 | | detect an error, take that action. */ |
1533 | 0 | yyn += yytoken; |
1534 | 0 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
1535 | 0 | goto yydefault; |
1536 | 0 | yyn = yytable[yyn]; |
1537 | 0 | if (yyn <= 0) |
1538 | 0 | { |
1539 | 0 | if (yytable_value_is_error (yyn)) |
1540 | 0 | goto yyerrlab; |
1541 | 0 | yyn = -yyn; |
1542 | 0 | goto yyreduce; |
1543 | 0 | } |
1544 | | |
1545 | | /* Count tokens shifted since error; after three, turn off error |
1546 | | status. */ |
1547 | 0 | if (yyerrstatus) |
1548 | 0 | yyerrstatus--; |
1549 | | |
1550 | | /* Shift the lookahead token. */ |
1551 | 0 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
1552 | 0 | yystate = yyn; |
1553 | 0 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
1554 | 0 | *++yyvsp = yylval; |
1555 | 0 | YY_IGNORE_MAYBE_UNINITIALIZED_END |
1556 | 0 | *++yylsp = yylloc; |
1557 | | |
1558 | | /* Discard the shifted token. */ |
1559 | 0 | yychar = YYEMPTY; |
1560 | 0 | goto yynewstate; |
1561 | | |
1562 | | |
1563 | | /*-----------------------------------------------------------. |
1564 | | | yydefault -- do the default action for the current state. | |
1565 | | `-----------------------------------------------------------*/ |
1566 | 0 | yydefault: |
1567 | 0 | yyn = yydefact[yystate]; |
1568 | 0 | if (yyn == 0) |
1569 | 0 | goto yyerrlab; |
1570 | 0 | goto yyreduce; |
1571 | | |
1572 | | |
1573 | | /*-----------------------------. |
1574 | | | yyreduce -- do a reduction. | |
1575 | | `-----------------------------*/ |
1576 | 0 | yyreduce: |
1577 | | /* yyn is the number of a rule to reduce with. */ |
1578 | 0 | yylen = yyr2[yyn]; |
1579 | | |
1580 | | /* If YYLEN is nonzero, implement the default value of the action: |
1581 | | '$$ = $1'. |
1582 | | |
1583 | | Otherwise, the following line sets YYVAL to garbage. |
1584 | | This behavior is undocumented and Bison |
1585 | | users should not rely upon it. Assigning to YYVAL |
1586 | | unconditionally makes the parser a bit smaller, and it avoids a |
1587 | | GCC warning that YYVAL may be used uninitialized. */ |
1588 | 0 | yyval = yyvsp[1-yylen]; |
1589 | | |
1590 | | /* Default location. */ |
1591 | 0 | YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); |
1592 | 0 | yyerror_range[1] = yyloc; |
1593 | 0 | YY_REDUCE_PRINT (yyn); |
1594 | 0 | switch (yyn) |
1595 | 0 | { |
1596 | 0 | case 2: |
1597 | 0 | #line 165 "lib/command_parse.y" |
1598 | 0 | { |
1599 | | // tack on the command element |
1600 | 0 | terminate_graph (&(yylsp[0]), ctx, ctx->currnode); |
1601 | 0 | } |
1602 | 0 | #line 1603 "lib/command_parse.c" |
1603 | 0 | break; |
1604 | | |
1605 | 0 | case 3: |
1606 | 0 | #line 170 "lib/command_parse.y" |
1607 | 0 | { |
1608 | 0 | if ((ctx->currnode = graph_add_edge (ctx->currnode, (yyvsp[-3].node))) != (yyvsp[-3].node)) |
1609 | 0 | graph_delete_node (ctx->graph, (yyvsp[-3].node)); |
1610 | |
|
1611 | 0 | ((struct cmd_token *)ctx->currnode->data)->allowrepeat = 1; |
1612 | | |
1613 | | // adding a node as a child of itself accepts any number |
1614 | | // of the same token, which is what we want for variadics |
1615 | 0 | graph_add_edge (ctx->currnode, ctx->currnode); |
1616 | | |
1617 | | // tack on the command element |
1618 | 0 | terminate_graph (&(yylsp[-4]), ctx, ctx->currnode); |
1619 | 0 | } |
1620 | 0 | #line 1621 "lib/command_parse.c" |
1621 | 0 | break; |
1622 | | |
1623 | 0 | case 4: |
1624 | 0 | #line 186 "lib/command_parse.y" |
1625 | 0 | { |
1626 | 0 | (yyval.string) = (yyvsp[0].string); |
1627 | 0 | } |
1628 | 0 | #line 1629 "lib/command_parse.c" |
1629 | 0 | break; |
1630 | | |
1631 | 0 | case 5: |
1632 | 0 | #line 190 "lib/command_parse.y" |
1633 | 0 | { |
1634 | 0 | (yyval.string) = NULL; |
1635 | 0 | } |
1636 | 0 | #line 1637 "lib/command_parse.c" |
1637 | 0 | break; |
1638 | | |
1639 | 0 | case 8: |
1640 | 0 | #line 202 "lib/command_parse.y" |
1641 | 0 | { |
1642 | 0 | if ((ctx->currnode = graph_add_edge (ctx->currnode, (yyvsp[0].node))) != (yyvsp[0].node)) |
1643 | 0 | graph_delete_node (ctx->graph, (yyvsp[0].node)); |
1644 | 0 | cmd_token_varname_seqappend((yyvsp[0].node)); |
1645 | 0 | } |
1646 | 0 | #line 1647 "lib/command_parse.c" |
1647 | 0 | break; |
1648 | | |
1649 | 0 | case 9: |
1650 | 0 | #line 208 "lib/command_parse.y" |
1651 | 0 | { |
1652 | 0 | graph_add_edge (ctx->currnode, (yyvsp[0].subgraph).start); |
1653 | 0 | cmd_token_varname_seqappend((yyvsp[0].subgraph).start); |
1654 | 0 | ctx->currnode = (yyvsp[0].subgraph).end; |
1655 | 0 | } |
1656 | 0 | #line 1657 "lib/command_parse.c" |
1657 | 0 | break; |
1658 | | |
1659 | 0 | case 12: |
1660 | 0 | #line 221 "lib/command_parse.y" |
1661 | 0 | { |
1662 | 0 | (yyval.node) = new_token_node (ctx, WORD_TKN, (yyvsp[-1].string), doc_next(ctx)); |
1663 | 0 | cmd_token_varname_set ((yyval.node)->data, (yyvsp[0].string)); |
1664 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1665 | 0 | XFREE (MTYPE_LEX, (yyvsp[-1].string)); |
1666 | 0 | } |
1667 | 0 | #line 1668 "lib/command_parse.c" |
1668 | 0 | break; |
1669 | | |
1670 | 0 | case 13: |
1671 | 0 | #line 231 "lib/command_parse.y" |
1672 | 0 | { |
1673 | 0 | (yyval.node) = new_token_node (ctx, IPV4_TKN, (yyvsp[0].string), doc_next(ctx)); |
1674 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1675 | 0 | } |
1676 | 0 | #line 1677 "lib/command_parse.c" |
1677 | 0 | break; |
1678 | | |
1679 | 0 | case 14: |
1680 | 0 | #line 236 "lib/command_parse.y" |
1681 | 0 | { |
1682 | 0 | (yyval.node) = new_token_node (ctx, IPV4_PREFIX_TKN, (yyvsp[0].string), doc_next(ctx)); |
1683 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1684 | 0 | } |
1685 | 0 | #line 1686 "lib/command_parse.c" |
1686 | 0 | break; |
1687 | | |
1688 | 0 | case 15: |
1689 | 0 | #line 241 "lib/command_parse.y" |
1690 | 0 | { |
1691 | 0 | (yyval.node) = new_token_node (ctx, IPV6_TKN, (yyvsp[0].string), doc_next(ctx)); |
1692 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1693 | 0 | } |
1694 | 0 | #line 1695 "lib/command_parse.c" |
1695 | 0 | break; |
1696 | | |
1697 | 0 | case 16: |
1698 | 0 | #line 246 "lib/command_parse.y" |
1699 | 0 | { |
1700 | 0 | (yyval.node) = new_token_node (ctx, IPV6_PREFIX_TKN, (yyvsp[0].string), doc_next(ctx)); |
1701 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1702 | 0 | } |
1703 | 0 | #line 1704 "lib/command_parse.c" |
1704 | 0 | break; |
1705 | | |
1706 | 0 | case 17: |
1707 | 0 | #line 251 "lib/command_parse.y" |
1708 | 0 | { |
1709 | 0 | (yyval.node) = new_token_node (ctx, VARIABLE_TKN, (yyvsp[0].string), doc_next(ctx)); |
1710 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1711 | 0 | } |
1712 | 0 | #line 1713 "lib/command_parse.c" |
1713 | 0 | break; |
1714 | | |
1715 | 0 | case 18: |
1716 | 0 | #line 256 "lib/command_parse.y" |
1717 | 0 | { |
1718 | 0 | (yyval.node) = new_token_node (ctx, RANGE_TKN, (yyvsp[0].string), doc_next(ctx)); |
1719 | 0 | struct cmd_token *token = (yyval.node)->data; |
1720 | | |
1721 | | // get the numbers out |
1722 | 0 | yylval.string++; |
1723 | 0 | token->min = strtoll (yylval.string, &yylval.string, 10); |
1724 | 0 | strsep (&yylval.string, "-"); |
1725 | 0 | token->max = strtoll (yylval.string, &yylval.string, 10); |
1726 | | |
1727 | | // validate range |
1728 | 0 | if (token->min > token->max) cmd_yyerror (&(yylsp[0]), ctx, "Invalid range."); |
1729 | |
|
1730 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1731 | 0 | } |
1732 | 0 | #line 1733 "lib/command_parse.c" |
1733 | 0 | break; |
1734 | | |
1735 | 0 | case 19: |
1736 | 0 | #line 272 "lib/command_parse.y" |
1737 | 0 | { |
1738 | 0 | (yyval.node) = new_token_node (ctx, MAC_TKN, (yyvsp[0].string), doc_next(ctx)); |
1739 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1740 | 0 | } |
1741 | 0 | #line 1742 "lib/command_parse.c" |
1742 | 0 | break; |
1743 | | |
1744 | 0 | case 20: |
1745 | 0 | #line 277 "lib/command_parse.y" |
1746 | 0 | { |
1747 | 0 | (yyval.node) = new_token_node (ctx, MAC_PREFIX_TKN, (yyvsp[0].string), doc_next(ctx)); |
1748 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1749 | 0 | } |
1750 | 0 | #line 1751 "lib/command_parse.c" |
1751 | 0 | break; |
1752 | | |
1753 | 0 | case 21: |
1754 | 0 | #line 282 "lib/command_parse.y" |
1755 | 0 | { |
1756 | 0 | (yyval.node) = new_token_node (ctx, ASNUM_TKN, (yyvsp[0].string), doc_next(ctx)); |
1757 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1758 | 0 | } |
1759 | 0 | #line 1760 "lib/command_parse.c" |
1760 | 0 | break; |
1761 | | |
1762 | 0 | case 22: |
1763 | 0 | #line 289 "lib/command_parse.y" |
1764 | 0 | { |
1765 | 0 | (yyval.node) = (yyvsp[-1].node); |
1766 | 0 | cmd_token_varname_set ((yyval.node)->data, (yyvsp[0].string)); |
1767 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1768 | 0 | } |
1769 | 0 | #line 1770 "lib/command_parse.c" |
1770 | 0 | break; |
1771 | | |
1772 | 0 | case 23: |
1773 | 0 | #line 298 "lib/command_parse.y" |
1774 | 0 | { |
1775 | 0 | (yyval.subgraph) = (yyvsp[-2].subgraph); |
1776 | 0 | cmd_token_varname_join ((yyvsp[-2].subgraph).end, (yyvsp[0].string)); |
1777 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1778 | 0 | } |
1779 | 0 | #line 1780 "lib/command_parse.c" |
1780 | 0 | break; |
1781 | | |
1782 | 0 | case 24: |
1783 | 0 | #line 306 "lib/command_parse.y" |
1784 | 0 | { |
1785 | 0 | (yyval.subgraph) = (yyvsp[-2].subgraph); |
1786 | 0 | graph_add_edge ((yyval.subgraph).start, (yyvsp[0].subgraph).start); |
1787 | 0 | graph_add_edge ((yyvsp[0].subgraph).end, (yyval.subgraph).end); |
1788 | 0 | } |
1789 | 0 | #line 1790 "lib/command_parse.c" |
1790 | 0 | break; |
1791 | | |
1792 | 0 | case 25: |
1793 | 0 | #line 312 "lib/command_parse.y" |
1794 | 0 | { |
1795 | 0 | (yyval.subgraph).start = new_token_node (ctx, FORK_TKN, NULL, NULL); |
1796 | 0 | (yyval.subgraph).end = new_token_node (ctx, JOIN_TKN, NULL, NULL); |
1797 | 0 | ((struct cmd_token *)(yyval.subgraph).start->data)->forkjoin = (yyval.subgraph).end; |
1798 | 0 | ((struct cmd_token *)(yyval.subgraph).end->data)->forkjoin = (yyval.subgraph).start; |
1799 | |
|
1800 | 0 | graph_add_edge ((yyval.subgraph).start, (yyvsp[0].subgraph).start); |
1801 | 0 | graph_add_edge ((yyvsp[0].subgraph).end, (yyval.subgraph).end); |
1802 | 0 | } |
1803 | 0 | #line 1804 "lib/command_parse.c" |
1804 | 0 | break; |
1805 | | |
1806 | 0 | case 26: |
1807 | 0 | #line 325 "lib/command_parse.y" |
1808 | 0 | { |
1809 | 0 | (yyval.subgraph) = (yyvsp[-2].subgraph); |
1810 | 0 | graph_add_edge ((yyval.subgraph).end, (yyval.subgraph).start); |
1811 | | /* there is intentionally no start->end link, for two reasons: |
1812 | | * 1) this allows "at least 1 of" semantics, which are otherwise impossible |
1813 | | * 2) this would add a start->end->start loop in the graph that the current |
1814 | | * loop-avoidal fails to handle |
1815 | | * just use [{a|b}] if necessary, that will work perfectly fine, and reason |
1816 | | * #1 is good enough to keep it this way. */ |
1817 | |
|
1818 | 0 | loopcheck(ctx, &(yyval.subgraph)); |
1819 | 0 | cmd_token_varname_join ((yyvsp[-2].subgraph).end, (yyvsp[0].string)); |
1820 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1821 | 0 | } |
1822 | 0 | #line 1823 "lib/command_parse.c" |
1823 | 0 | break; |
1824 | | |
1825 | 0 | case 27: |
1826 | 0 | #line 343 "lib/command_parse.y" |
1827 | 0 | { |
1828 | 0 | (yyval.subgraph).start = (yyval.subgraph).end = (yyvsp[0].node); |
1829 | 0 | } |
1830 | 0 | #line 1831 "lib/command_parse.c" |
1831 | 0 | break; |
1832 | | |
1833 | 0 | case 29: |
1834 | 0 | #line 351 "lib/command_parse.y" |
1835 | 0 | { |
1836 | 0 | graph_add_edge ((yyvsp[-1].subgraph).end, (yyvsp[0].subgraph).start); |
1837 | 0 | cmd_token_varname_seqappend((yyvsp[0].subgraph).start); |
1838 | 0 | (yyval.subgraph).start = (yyvsp[-1].subgraph).start; |
1839 | 0 | (yyval.subgraph).end = (yyvsp[0].subgraph).end; |
1840 | 0 | } |
1841 | 0 | #line 1842 "lib/command_parse.c" |
1842 | 0 | break; |
1843 | | |
1844 | 0 | case 31: |
1845 | 0 | #line 362 "lib/command_parse.y" |
1846 | 0 | { |
1847 | 0 | (yyval.subgraph) = (yyvsp[-2].subgraph); |
1848 | 0 | graph_add_edge ((yyval.subgraph).start, (yyval.subgraph).end); |
1849 | 0 | cmd_token_varname_join ((yyvsp[-2].subgraph).end, (yyvsp[0].string)); |
1850 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1851 | 0 | } |
1852 | 0 | #line 1853 "lib/command_parse.c" |
1853 | 0 | break; |
1854 | | |
1855 | 0 | case 32: |
1856 | 0 | #line 372 "lib/command_parse.y" |
1857 | 0 | { |
1858 | 0 | struct graph_node *neg_only = new_token_node (ctx, NEG_ONLY_TKN, NULL, NULL); |
1859 | |
|
1860 | 0 | (yyval.subgraph) = (yyvsp[-2].subgraph); |
1861 | 0 | graph_add_edge ((yyval.subgraph).start, neg_only); |
1862 | 0 | graph_add_edge (neg_only, (yyval.subgraph).end); |
1863 | 0 | cmd_token_varname_join ((yyvsp[-2].subgraph).end, (yyvsp[0].string)); |
1864 | 0 | XFREE (MTYPE_LEX, (yyvsp[0].string)); |
1865 | 0 | } |
1866 | 0 | #line 1867 "lib/command_parse.c" |
1867 | 0 | break; |
1868 | | |
1869 | | |
1870 | 0 | #line 1871 "lib/command_parse.c" |
1871 | | |
1872 | 0 | default: break; |
1873 | 0 | } |
1874 | | /* User semantic actions sometimes alter yychar, and that requires |
1875 | | that yytoken be updated with the new translation. We take the |
1876 | | approach of translating immediately before every use of yytoken. |
1877 | | One alternative is translating here after every semantic action, |
1878 | | but that translation would be missed if the semantic action invokes |
1879 | | YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or |
1880 | | if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an |
1881 | | incorrect destructor might then be invoked immediately. In the |
1882 | | case of YYERROR or YYBACKUP, subsequent parser actions might lead |
1883 | | to an incorrect destructor call or verbose syntax error message |
1884 | | before the lookahead is translated. */ |
1885 | 0 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); |
1886 | |
|
1887 | 0 | YYPOPSTACK (yylen); |
1888 | 0 | yylen = 0; |
1889 | 0 | YY_STACK_PRINT (yyss, yyssp); |
1890 | |
|
1891 | 0 | *++yyvsp = yyval; |
1892 | 0 | *++yylsp = yyloc; |
1893 | | |
1894 | | /* Now 'shift' the result of the reduction. Determine what state |
1895 | | that goes to, based on the state we popped back to and the rule |
1896 | | number reduced by. */ |
1897 | 0 | { |
1898 | 0 | const int yylhs = yyr1[yyn] - YYNTOKENS; |
1899 | 0 | const int yyi = yypgoto[yylhs] + *yyssp; |
1900 | 0 | yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp |
1901 | 0 | ? yytable[yyi] |
1902 | 0 | : yydefgoto[yylhs]); |
1903 | 0 | } |
1904 | |
|
1905 | 0 | goto yynewstate; |
1906 | | |
1907 | | |
1908 | | /*--------------------------------------. |
1909 | | | yyerrlab -- here on detecting error. | |
1910 | | `--------------------------------------*/ |
1911 | 0 | yyerrlab: |
1912 | | /* Make sure we have latest lookahead translation. See comments at |
1913 | | user semantic actions for why this is necessary. */ |
1914 | 0 | yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); |
1915 | | |
1916 | | /* If not already recovering from an error, report this error. */ |
1917 | 0 | if (!yyerrstatus) |
1918 | 0 | { |
1919 | 0 | ++yynerrs; |
1920 | | #if ! YYERROR_VERBOSE |
1921 | | yyerror (&yylloc, ctx, YY_("syntax error")); |
1922 | | #else |
1923 | 0 | # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ |
1924 | 0 | yyssp, yytoken) |
1925 | 0 | { |
1926 | 0 | char const *yymsgp = YY_("syntax error"); |
1927 | 0 | int yysyntax_error_status; |
1928 | 0 | yysyntax_error_status = YYSYNTAX_ERROR; |
1929 | 0 | if (yysyntax_error_status == 0) |
1930 | 0 | yymsgp = yymsg; |
1931 | 0 | else if (yysyntax_error_status == 1) |
1932 | 0 | { |
1933 | 0 | if (yymsg != yymsgbuf) |
1934 | 0 | YYSTACK_FREE (yymsg); |
1935 | 0 | yymsg = YY_CAST (char *, YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc))); |
1936 | 0 | if (!yymsg) |
1937 | 0 | { |
1938 | 0 | yymsg = yymsgbuf; |
1939 | 0 | yymsg_alloc = sizeof yymsgbuf; |
1940 | 0 | yysyntax_error_status = 2; |
1941 | 0 | } |
1942 | 0 | else |
1943 | 0 | { |
1944 | 0 | yysyntax_error_status = YYSYNTAX_ERROR; |
1945 | 0 | yymsgp = yymsg; |
1946 | 0 | } |
1947 | 0 | } |
1948 | 0 | yyerror (&yylloc, ctx, yymsgp); |
1949 | 0 | if (yysyntax_error_status == 2) |
1950 | 0 | goto yyexhaustedlab; |
1951 | 0 | } |
1952 | 0 | # undef YYSYNTAX_ERROR |
1953 | 0 | #endif |
1954 | 0 | } |
1955 | | |
1956 | 0 | yyerror_range[1] = yylloc; |
1957 | |
|
1958 | 0 | if (yyerrstatus == 3) |
1959 | 0 | { |
1960 | | /* If just tried and failed to reuse lookahead token after an |
1961 | | error, discard it. */ |
1962 | |
|
1963 | 0 | if (yychar <= YYEOF) |
1964 | 0 | { |
1965 | | /* Return failure if at end of input. */ |
1966 | 0 | if (yychar == YYEOF) |
1967 | 0 | YYABORT; |
1968 | 0 | } |
1969 | 0 | else |
1970 | 0 | { |
1971 | 0 | yydestruct ("Error: discarding", |
1972 | 0 | yytoken, &yylval, &yylloc, ctx); |
1973 | 0 | yychar = YYEMPTY; |
1974 | 0 | } |
1975 | 0 | } |
1976 | | |
1977 | | /* Else will try to reuse lookahead token after shifting the error |
1978 | | token. */ |
1979 | 0 | goto yyerrlab1; |
1980 | | |
1981 | | |
1982 | | /*---------------------------------------------------. |
1983 | | | yyerrorlab -- error raised explicitly by YYERROR. | |
1984 | | `---------------------------------------------------*/ |
1985 | 0 | yyerrorlab: |
1986 | | /* Pacify compilers when the user code never invokes YYERROR and the |
1987 | | label yyerrorlab therefore never appears in user code. */ |
1988 | 0 | if (0) |
1989 | 0 | YYERROR; |
1990 | | |
1991 | | /* Do not reclaim the symbols of the rule whose action triggered |
1992 | | this YYERROR. */ |
1993 | 0 | YYPOPSTACK (yylen); |
1994 | 0 | yylen = 0; |
1995 | 0 | YY_STACK_PRINT (yyss, yyssp); |
1996 | 0 | yystate = *yyssp; |
1997 | 0 | goto yyerrlab1; |
1998 | | |
1999 | | |
2000 | | /*-------------------------------------------------------------. |
2001 | | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
2002 | | `-------------------------------------------------------------*/ |
2003 | 0 | yyerrlab1: |
2004 | 0 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
2005 | |
|
2006 | 0 | for (;;) |
2007 | 0 | { |
2008 | 0 | yyn = yypact[yystate]; |
2009 | 0 | if (!yypact_value_is_default (yyn)) |
2010 | 0 | { |
2011 | 0 | yyn += YYTERROR; |
2012 | 0 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
2013 | 0 | { |
2014 | 0 | yyn = yytable[yyn]; |
2015 | 0 | if (0 < yyn) |
2016 | 0 | break; |
2017 | 0 | } |
2018 | 0 | } |
2019 | | |
2020 | | /* Pop the current state because it cannot handle the error token. */ |
2021 | 0 | if (yyssp == yyss) |
2022 | 0 | YYABORT; |
2023 | | |
2024 | 0 | yyerror_range[1] = *yylsp; |
2025 | 0 | yydestruct ("Error: popping", |
2026 | 0 | yystos[yystate], yyvsp, yylsp, ctx); |
2027 | 0 | YYPOPSTACK (1); |
2028 | 0 | yystate = *yyssp; |
2029 | 0 | YY_STACK_PRINT (yyss, yyssp); |
2030 | 0 | } |
2031 | | |
2032 | 0 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN |
2033 | 0 | *++yyvsp = yylval; |
2034 | 0 | YY_IGNORE_MAYBE_UNINITIALIZED_END |
2035 | |
|
2036 | 0 | yyerror_range[2] = yylloc; |
2037 | | /* Using YYLLOC is tempting, but would change the location of |
2038 | | the lookahead. YYLOC is available though. */ |
2039 | 0 | YYLLOC_DEFAULT (yyloc, yyerror_range, 2); |
2040 | 0 | *++yylsp = yyloc; |
2041 | | |
2042 | | /* Shift the error token. */ |
2043 | 0 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
2044 | |
|
2045 | 0 | yystate = yyn; |
2046 | 0 | goto yynewstate; |
2047 | | |
2048 | | |
2049 | | /*-------------------------------------. |
2050 | | | yyacceptlab -- YYACCEPT comes here. | |
2051 | | `-------------------------------------*/ |
2052 | 0 | yyacceptlab: |
2053 | 0 | yyresult = 0; |
2054 | 0 | goto yyreturn; |
2055 | | |
2056 | | |
2057 | | /*-----------------------------------. |
2058 | | | yyabortlab -- YYABORT comes here. | |
2059 | | `-----------------------------------*/ |
2060 | 0 | yyabortlab: |
2061 | 0 | yyresult = 1; |
2062 | 0 | goto yyreturn; |
2063 | | |
2064 | | |
2065 | 0 | #if !defined yyoverflow || YYERROR_VERBOSE |
2066 | | /*-------------------------------------------------. |
2067 | | | yyexhaustedlab -- memory exhaustion comes here. | |
2068 | | `-------------------------------------------------*/ |
2069 | 0 | yyexhaustedlab: |
2070 | 0 | yyerror (&yylloc, ctx, YY_("memory exhausted")); |
2071 | 0 | yyresult = 2; |
2072 | | /* Fall through. */ |
2073 | 0 | #endif |
2074 | | |
2075 | | |
2076 | | /*-----------------------------------------------------. |
2077 | | | yyreturn -- parsing is finished, return the result. | |
2078 | | `-----------------------------------------------------*/ |
2079 | 0 | yyreturn: |
2080 | 0 | if (yychar != YYEMPTY) |
2081 | 0 | { |
2082 | | /* Make sure we have latest lookahead translation. See comments at |
2083 | | user semantic actions for why this is necessary. */ |
2084 | 0 | yytoken = YYTRANSLATE (yychar); |
2085 | 0 | yydestruct ("Cleanup: discarding lookahead", |
2086 | 0 | yytoken, &yylval, &yylloc, ctx); |
2087 | 0 | } |
2088 | | /* Do not reclaim the symbols of the rule whose action triggered |
2089 | | this YYABORT or YYACCEPT. */ |
2090 | 0 | YYPOPSTACK (yylen); |
2091 | 0 | YY_STACK_PRINT (yyss, yyssp); |
2092 | 0 | while (yyssp != yyss) |
2093 | 0 | { |
2094 | 0 | yydestruct ("Cleanup: popping", |
2095 | 0 | yystos[+*yyssp], yyvsp, yylsp, ctx); |
2096 | 0 | YYPOPSTACK (1); |
2097 | 0 | } |
2098 | 0 | #ifndef yyoverflow |
2099 | 0 | if (yyss != yyssa) |
2100 | 0 | YYSTACK_FREE (yyss); |
2101 | 0 | #endif |
2102 | 0 | #if YYERROR_VERBOSE |
2103 | 0 | if (yymsg != yymsgbuf) |
2104 | 0 | YYSTACK_FREE (yymsg); |
2105 | 0 | #endif |
2106 | 0 | return yyresult; |
2107 | 0 | } |
2108 | | #line 383 "lib/command_parse.y" |
2109 | | |
2110 | | |
2111 | | #undef scanner |
2112 | | |
2113 | | DEFINE_MTYPE(LIB, LEX, "Lexer token (temporary)"); |
2114 | | |
2115 | | void |
2116 | | cmd_graph_parse (struct graph *graph, const struct cmd_element *cmd) |
2117 | 0 | { |
2118 | 0 | struct parser_ctx ctx = { .graph = graph, .el = cmd }; |
2119 | | |
2120 | | // set to 1 to enable parser traces |
2121 | 0 | yydebug = 0; |
2122 | |
|
2123 | 0 | set_lexer_string (&ctx.scanner, cmd->string); |
2124 | | |
2125 | | // parse command into DFA |
2126 | 0 | cmd_yyparse (&ctx); |
2127 | | |
2128 | | /* cleanup lexer */ |
2129 | 0 | cleanup_lexer (&ctx.scanner); |
2130 | | |
2131 | | // cleanup |
2132 | 0 | cleanup (&ctx); |
2133 | 0 | } |
2134 | | |
2135 | | /* parser helper functions */ |
2136 | | |
2137 | | static bool loopcheck_inner(struct graph_node *start, struct graph_node *node, |
2138 | | struct graph_node *end, size_t depth) |
2139 | 0 | { |
2140 | 0 | size_t i; |
2141 | 0 | bool ret; |
2142 | | |
2143 | | /* safety check */ |
2144 | 0 | if (depth++ == 64) |
2145 | 0 | return true; |
2146 | | |
2147 | 0 | for (i = 0; i < vector_active(node->to); i++) { |
2148 | 0 | struct graph_node *next = vector_slot(node->to, i); |
2149 | 0 | struct cmd_token *tok = next->data; |
2150 | |
|
2151 | 0 | if (next == end || next == start) |
2152 | 0 | return true; |
2153 | 0 | if (tok->type < SPECIAL_TKN) |
2154 | 0 | continue; |
2155 | 0 | ret = loopcheck_inner(start, next, end, depth); |
2156 | 0 | if (ret) |
2157 | 0 | return true; |
2158 | 0 | } |
2159 | 0 | return false; |
2160 | 0 | } |
2161 | | |
2162 | | static void loopcheck(struct parser_ctx *ctx, struct subgraph *sg) |
2163 | 0 | { |
2164 | 0 | if (loopcheck_inner(sg->start, sg->start, sg->end, 0)) |
2165 | 0 | zlog_err("FATAL: '%s': {} contains an empty path! Use [{...}]", |
2166 | 0 | ctx->el->string); |
2167 | 0 | } |
2168 | | |
2169 | | void |
2170 | | yyerror (CMD_YYLTYPE *loc, struct parser_ctx *ctx, char const *msg) |
2171 | 0 | { |
2172 | 0 | char *tmpstr = strdup(ctx->el->string); |
2173 | 0 | char *line, *eol; |
2174 | 0 | char spacing[256]; |
2175 | 0 | int lineno = 0; |
2176 | |
|
2177 | 0 | zlog_notice ("%s: FATAL parse error: %s", __func__, msg); |
2178 | 0 | zlog_notice ("%s: %d:%d-%d of this command definition:", __func__, loc->first_line, loc->first_column, loc->last_column); |
2179 | |
|
2180 | 0 | line = tmpstr; |
2181 | 0 | do { |
2182 | 0 | lineno++; |
2183 | 0 | eol = strchr(line, '\n'); |
2184 | 0 | if (eol) |
2185 | 0 | *eol++ = '\0'; |
2186 | |
|
2187 | 0 | zlog_notice ("%s: | %s", __func__, line); |
2188 | 0 | if (lineno == loc->first_line && lineno == loc->last_line |
2189 | 0 | && loc->first_column < (int)sizeof(spacing) - 1 |
2190 | 0 | && loc->last_column < (int)sizeof(spacing) - 1) { |
2191 | |
|
2192 | 0 | int len = loc->last_column - loc->first_column; |
2193 | 0 | if (len == 0) |
2194 | 0 | len = 1; |
2195 | |
|
2196 | 0 | memset(spacing, ' ', loc->first_column - 1); |
2197 | 0 | memset(spacing + loc->first_column - 1, '^', len); |
2198 | 0 | spacing[loc->first_column - 1 + len] = '\0'; |
2199 | 0 | zlog_notice ("%s: | %s", __func__, spacing); |
2200 | 0 | } |
2201 | 0 | } while ((line = eol)); |
2202 | 0 | free(tmpstr); |
2203 | 0 | } |
2204 | | |
2205 | | static void |
2206 | | cleanup (struct parser_ctx *ctx) |
2207 | 0 | { |
2208 | | /* free resources */ |
2209 | 0 | free (ctx->docstr_start); |
2210 | | |
2211 | | /* clear state pointers */ |
2212 | 0 | ctx->currnode = NULL; |
2213 | 0 | ctx->docstr_start = ctx->docstr = NULL; |
2214 | 0 | } |
2215 | | |
2216 | | static void |
2217 | | terminate_graph (CMD_YYLTYPE *locp, struct parser_ctx *ctx, |
2218 | | struct graph_node *finalnode) |
2219 | 0 | { |
2220 | | // end of graph should look like this |
2221 | | // * -> finalnode -> END_TKN -> cmd_element |
2222 | 0 | const struct cmd_element *element = ctx->el; |
2223 | 0 | struct graph_node *end_token_node = |
2224 | 0 | new_token_node (ctx, END_TKN, CMD_CR_TEXT, ""); |
2225 | 0 | struct graph_node *end_element_node = |
2226 | 0 | graph_new_node (ctx->graph, (void *)element, NULL); |
2227 | |
|
2228 | 0 | if (ctx->docstr && strlen (ctx->docstr) > 1) { |
2229 | 0 | zlog_err ("Excessive docstring while parsing '%s'", ctx->el->string); |
2230 | 0 | zlog_err ("----------"); |
2231 | 0 | while (ctx->docstr && ctx->docstr[1] != '\0') |
2232 | 0 | zlog_err ("%s", strsep(&ctx->docstr, "\n")); |
2233 | 0 | zlog_err ("----------"); |
2234 | 0 | } |
2235 | |
|
2236 | 0 | graph_add_edge (finalnode, end_token_node); |
2237 | 0 | graph_add_edge (end_token_node, end_element_node); |
2238 | 0 | } |
2239 | | |
2240 | | static const char * |
2241 | | doc_next (struct parser_ctx *ctx) |
2242 | 0 | { |
2243 | 0 | const char *piece = ctx->docstr ? strsep (&ctx->docstr, "\n") : ""; |
2244 | 0 | if (*piece == 0x03) |
2245 | 0 | { |
2246 | 0 | zlog_err ("Ran out of docstring while parsing '%s'", ctx->el->string); |
2247 | 0 | piece = ""; |
2248 | 0 | } |
2249 | |
|
2250 | 0 | return piece; |
2251 | 0 | } |
2252 | | |
2253 | | static struct graph_node * |
2254 | | new_token_node (struct parser_ctx *ctx, enum cmd_token_type type, |
2255 | | const char *text, const char *doc) |
2256 | 0 | { |
2257 | 0 | struct cmd_token *token = cmd_token_new (type, ctx->el->attr, text, doc); |
2258 | 0 | return graph_new_node (ctx->graph, token, (void (*)(void *)) &cmd_token_del); |
2259 | 0 | } |