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