1 /* A Bison parser, made by GNU Bison 3.0.4. */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
29
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
35
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
42
43 /* Identify Bison output. */
44 #define YYBISON 1
45
46 /* Bison version. */
47 #define YYBISON_VERSION "3.0.4"
48
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers. */
53 #define YYPURE 1
54
55 /* Push parsers. */
56 #define YYPUSH 0
57
58 /* Pull parsers. */
59 #define YYPULL 1
60
61
62 /* Substitute the variable and function names. */
63 #define yyparse KFG_parse
64 #define yylex KFG_lex
65 #define yyerror KFG_error
66 #define yydebug KFG_debug
67 #define yynerrs KFG_nerrs
68
69
70 /* Copy the first part of user declarations. */
71
72
73 #include "kfg-parse.h"
74 #include <sysalloc.h>
75 #include <klib/rc.h>
76 #include <klib/namelist.h>
77
78 #define YYSTYPE_IS_DECLARED
79 #define YYSTYPE KFGSymbol
80 #include "config-tokens.h"
81
82 #define KFG_lex KFGScan_yylex
83
84 /* required parameter to VNamelistMake */
85 #define NAMELIST_ALLOC_BLKSIZE 10
86
87 static void ReportRc(KFGParseBlock* pb, KFGScanBlock* sb, rc_t rc);
88 static void AppendName(KFGScanBlock* sb, VNamelist*, const KFGToken*);
89 static void KFG_error(KFGParseBlock* pb, KFGScanBlock* sb, const char* msg);
90
91
92
93 # ifndef YY_NULLPTR
94 # if defined __cplusplus && 201103L <= __cplusplus
95 # define YY_NULLPTR nullptr
96 # else
97 # define YY_NULLPTR 0
98 # endif
99 # endif
100
101 /* Enabling verbose error messages. */
102 #ifdef YYERROR_VERBOSE
103 # undef YYERROR_VERBOSE
104 # define YYERROR_VERBOSE 1
105 #else
106 # define YYERROR_VERBOSE 0
107 #endif
108
109 /* In a future release of Bison, this section will be replaced
110 by #include "config-tokens.h". */
111 #ifndef YY_KFG_HOME_BOSHKINS_NCBI_DEVEL_NCBI_VDB_LIBS_KFG_CONFIG_TOKENS_H_INCLUDED
112 # define YY_KFG_HOME_BOSHKINS_NCBI_DEVEL_NCBI_VDB_LIBS_KFG_CONFIG_TOKENS_H_INCLUDED
113 /* Debug traces. */
114 #ifndef YYDEBUG
115 # define YYDEBUG 0
116 #endif
117 #if YYDEBUG
118 extern int KFG_debug;
119 #endif
120
121 /* Token type. */
122 #ifndef YYTOKENTYPE
123 # define YYTOKENTYPE
124 enum yytokentype
125 {
126 kfgEND_INPUT = 0,
127 kfgEND_LINE = 258,
128 kfgUNTERM_STRING = 259,
129 kfgUNTERM_ESCAPED_STRING = 260,
130 kfgUNRECOGNIZED = 261,
131 kfgVAR_REF = 262,
132 kfgUNTERM_VAR_REF = 263,
133 kfgASSIGN = 264,
134 kfgSTRING = 265,
135 kfgESCAPED_STRING = 266,
136 kfgABS_PATH = 267,
137 kfgREL_PATH = 268
138 };
139 #endif
140
141 /* Value type. */
142 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
143
144 union YYSTYPE
145 {
146
147
148 KFGToken pb;
149 const struct VNamelist* namelist;
150
151
152 };
153
154 typedef union YYSTYPE YYSTYPE;
155 # define YYSTYPE_IS_TRIVIAL 1
156 # define YYSTYPE_IS_DECLARED 1
157 #endif
158
159
160
161 int KFG_parse (KFGParseBlock* pb, KFGScanBlock* sb);
162
163 #endif /* !YY_KFG_HOME_BOSHKINS_NCBI_DEVEL_NCBI_VDB_LIBS_KFG_CONFIG_TOKENS_H_INCLUDED */
164
165 /* Copy the second part of user declarations. */
166
167
168
169 #ifdef short
170 # undef short
171 #endif
172
173 #ifdef YYTYPE_UINT8
174 typedef YYTYPE_UINT8 yytype_uint8;
175 #else
176 typedef unsigned char yytype_uint8;
177 #endif
178
179 #ifdef YYTYPE_INT8
180 typedef YYTYPE_INT8 yytype_int8;
181 #else
182 typedef signed char yytype_int8;
183 #endif
184
185 #ifdef YYTYPE_UINT16
186 typedef YYTYPE_UINT16 yytype_uint16;
187 #else
188 typedef unsigned short int yytype_uint16;
189 #endif
190
191 #ifdef YYTYPE_INT16
192 typedef YYTYPE_INT16 yytype_int16;
193 #else
194 typedef short int yytype_int16;
195 #endif
196
197 #ifndef YYSIZE_T
198 # ifdef __SIZE_TYPE__
199 # define YYSIZE_T __SIZE_TYPE__
200 # elif defined size_t
201 # define YYSIZE_T size_t
202 # elif ! defined YYSIZE_T
203 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
204 # define YYSIZE_T size_t
205 # else
206 # define YYSIZE_T unsigned int
207 # endif
208 #endif
209
210 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
211
212 #ifndef YY_
213 # if defined YYENABLE_NLS && YYENABLE_NLS
214 # if ENABLE_NLS
215 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
216 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
217 # endif
218 # endif
219 # ifndef YY_
220 # define YY_(Msgid) Msgid
221 # endif
222 #endif
223
224 #ifndef YY_ATTRIBUTE
225 # if (defined __GNUC__ \
226 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
227 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
228 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
229 # else
230 # define YY_ATTRIBUTE(Spec) /* empty */
231 # endif
232 #endif
233
234 #ifndef YY_ATTRIBUTE_PURE
235 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
236 #endif
237
238 #ifndef YY_ATTRIBUTE_UNUSED
239 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
240 #endif
241
242 #if !defined _Noreturn \
243 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
244 # if defined _MSC_VER && 1200 <= _MSC_VER
245 # define _Noreturn __declspec (noreturn)
246 # else
247 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
248 # endif
249 #endif
250
251 /* Suppress unused-variable warnings by "using" E. */
252 #if ! defined lint || defined __GNUC__
253 # define YYUSE(E) ((void) (E))
254 #else
255 # define YYUSE(E) /* empty */
256 #endif
257
258 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
259 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
260 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
261 _Pragma ("GCC diagnostic push") \
262 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
263 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
264 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
265 _Pragma ("GCC diagnostic pop")
266 #else
267 # define YY_INITIAL_VALUE(Value) Value
268 #endif
269 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
270 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
271 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
272 #endif
273 #ifndef YY_INITIAL_VALUE
274 # define YY_INITIAL_VALUE(Value) /* Nothing. */
275 #endif
276
277
278 #if ! defined yyoverflow || YYERROR_VERBOSE
279
280 /* The parser invokes alloca or malloc; define the necessary symbols. */
281
282 # ifdef YYSTACK_USE_ALLOCA
283 # if YYSTACK_USE_ALLOCA
284 # ifdef __GNUC__
285 # define YYSTACK_ALLOC __builtin_alloca
286 # elif defined __BUILTIN_VA_ARG_INCR
287 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
288 # elif defined _AIX
289 # define YYSTACK_ALLOC __alloca
290 # elif defined _MSC_VER
291 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
292 # define alloca _alloca
293 # else
294 # define YYSTACK_ALLOC alloca
295 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
296 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
297 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
298 # ifndef EXIT_SUCCESS
299 # define EXIT_SUCCESS 0
300 # endif
301 # endif
302 # endif
303 # endif
304 # endif
305
306 # ifdef YYSTACK_ALLOC
307 /* Pacify GCC's 'empty if-body' warning. */
308 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
309 # ifndef YYSTACK_ALLOC_MAXIMUM
310 /* The OS might guarantee only one guard page at the bottom of the stack,
311 and a page size can be as small as 4096 bytes. So we cannot safely
312 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
313 to allow for a few compiler-allocated temporary stack slots. */
314 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
315 # endif
316 # else
317 # define YYSTACK_ALLOC YYMALLOC
318 # define YYSTACK_FREE YYFREE
319 # ifndef YYSTACK_ALLOC_MAXIMUM
320 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
321 # endif
322 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
323 && ! ((defined YYMALLOC || defined malloc) \
324 && (defined YYFREE || defined free)))
325 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
326 # ifndef EXIT_SUCCESS
327 # define EXIT_SUCCESS 0
328 # endif
329 # endif
330 # ifndef YYMALLOC
331 # define YYMALLOC malloc
332 # if ! defined malloc && ! defined EXIT_SUCCESS
333 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
334 # endif
335 # endif
336 # ifndef YYFREE
337 # define YYFREE free
338 # if ! defined free && ! defined EXIT_SUCCESS
339 void free (void *); /* INFRINGES ON USER NAME SPACE */
340 # endif
341 # endif
342 # endif
343 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
344
345
346 #if (! defined yyoverflow \
347 && (! defined __cplusplus \
348 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
349
350 /* A type that is properly aligned for any stack member. */
351 union yyalloc
352 {
353 yytype_int16 yyss_alloc;
354 YYSTYPE yyvs_alloc;
355 };
356
357 /* The size of the maximum gap between one aligned stack and the next. */
358 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
359
360 /* The size of an array large to enough to hold all stacks, each with
361 N elements. */
362 # define YYSTACK_BYTES(N) \
363 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
364 + YYSTACK_GAP_MAXIMUM)
365
366 # define YYCOPY_NEEDED 1
367
368 /* Relocate STACK from its old location to the new one. The
369 local variables YYSIZE and YYSTACKSIZE give the old and new number of
370 elements in the stack, and YYPTR gives the new location of the
371 stack. Advance YYPTR to a properly aligned location for the next
372 stack. */
373 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
374 do \
375 { \
376 YYSIZE_T yynewbytes; \
377 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
378 Stack = &yyptr->Stack_alloc; \
379 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
380 yyptr += yynewbytes / sizeof (*yyptr); \
381 } \
382 while (0)
383
384 #endif
385
386 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
387 /* Copy COUNT objects from SRC to DST. The source and destination do
388 not overlap. */
389 # ifndef YYCOPY
390 # if defined __GNUC__ && 1 < __GNUC__
391 # define YYCOPY(Dst, Src, Count) \
392 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
393 # else
394 # define YYCOPY(Dst, Src, Count) \
395 do \
396 { \
397 YYSIZE_T yyi; \
398 for (yyi = 0; yyi < (Count); yyi++) \
399 (Dst)[yyi] = (Src)[yyi]; \
400 } \
401 while (0)
402 # endif
403 # endif
404 #endif /* !YYCOPY_NEEDED */
405
406 /* YYFINAL -- State number of the termination state. */
407 #define YYFINAL 13
408 /* YYLAST -- Last index in YYTABLE. */
409 #define YYLAST 21
410
411 /* YYNTOKENS -- Number of terminals. */
412 #define YYNTOKENS 14
413 /* YYNNTS -- Number of nonterminals. */
414 #define YYNNTS 8
415 /* YYNRULES -- Number of rules. */
416 #define YYNRULES 17
417 /* YYNSTATES -- Number of states. */
418 #define YYNSTATES 23
419
420 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
421 by yylex, with out-of-bounds checking. */
422 #define YYUNDEFTOK 2
423 #define YYMAXUTOK 268
424
425 #define YYTRANSLATE(YYX) \
426 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
427
428 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
429 as returned by yylex, without out-of-bounds checking. */
430 static const yytype_uint8 yytranslate[] =
431 {
432 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
433 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
434 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
435 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
436 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
437 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
438 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
439 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
440 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
441 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
442 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
443 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
444 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
445 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
446 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
447 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
448 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
449 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
450 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
451 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
452 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
453 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
454 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
455 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
456 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
457 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
458 5, 6, 7, 8, 9, 10, 11, 12, 13
459 };
460
461 #if YYDEBUG
462 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
463 static const yytype_uint8 yyrline[] =
464 {
465 0, 85, 85, 86, 90, 91, 95, 104, 105, 109,
466 110, 114, 118, 119, 120, 121, 125, 126
467 };
468 #endif
469
470 #if YYDEBUG || YYERROR_VERBOSE || 0
471 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
472 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
473 static const char *const yytname[] =
474 {
475 "kfgEND_INPUT", "error", "$undefined", "kfgEND_LINE",
476 "kfgUNTERM_STRING", "kfgUNTERM_ESCAPED_STRING", "kfgUNRECOGNIZED",
477 "kfgVAR_REF", "kfgUNTERM_VAR_REF", "kfgASSIGN", "kfgSTRING",
478 "kfgESCAPED_STRING", "kfgABS_PATH", "kfgREL_PATH", "$accept", "config",
479 "name_value_pairs", "name_value_pair", "pathname", "assign_op", "value",
480 "line_end", YY_NULLPTR
481 };
482 #endif
483
484 # ifdef YYPRINT
485 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
486 (internal) symbol number NUM (which must be that of a token). */
487 static const yytype_uint16 yytoknum[] =
488 {
489 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
490 265, 266, 267, 268
491 };
492 # endif
493
494 #define YYPACT_NINF -5
495
496 #define yypact_value_is_default(Yystate) \
497 (!!((Yystate) == (-5)))
498
499 #define YYTABLE_NINF -3
500
501 #define yytable_value_is_error(Yytable_value) \
502 0
503
504 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
505 STATE-NUM. */
506 static const yytype_int8 yypact[] =
507 {
508 0, -5, 6, -5, -5, -5, 2, 4, -5, 1,
509 -5, -5, -5, -5, -5, -5, 10, -5, -5, 8,
510 -5, -5, -5
511 };
512
513 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
514 Performed when YYTABLE does not specify something else to do. Zero
515 means the default is an error. */
516 static const yytype_uint8 yydefact[] =
517 {
518 0, 3, 0, 7, 9, 10, 0, 0, 4, 0,
519 17, 16, 8, 1, 5, 11, 0, 12, 13, 0,
520 14, 15, 6
521 };
522
523 /* YYPGOTO[NTERM-NUM]. */
524 static const yytype_int8 yypgoto[] =
525 {
526 -5, -5, -5, 7, -5, -5, -5, -4
527 };
528
529 /* YYDEFGOTO[NTERM-NUM]. */
530 static const yytype_int8 yydefgoto[] =
531 {
532 -1, 6, 7, 8, 9, 16, 19, 12
533 };
534
535 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
536 positive, shift that token. If negative, reduce the rule whose
537 number is the opposite. If YYTABLE_NINF, syntax error. */
538 static const yytype_int8 yytable[] =
539 {
540 1, 2, 13, 3, -2, 2, 10, 3, 10, 11,
541 15, 11, 4, 5, 14, 22, 4, 5, 20, 21,
542 17, 18
543 };
544
545 static const yytype_uint8 yycheck[] =
546 {
547 0, 1, 0, 3, 0, 1, 0, 3, 0, 3,
548 9, 3, 12, 13, 7, 19, 12, 13, 10, 11,
549 10, 11
550 };
551
552 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
553 symbol of state STATE-NUM. */
554 static const yytype_uint8 yystos[] =
555 {
556 0, 0, 1, 3, 12, 13, 15, 16, 17, 18,
557 0, 3, 21, 0, 17, 9, 19, 10, 11, 20,
558 10, 11, 21
559 };
560
561 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
562 static const yytype_uint8 yyr1[] =
563 {
564 0, 14, 15, 15, 16, 16, 17, 17, 17, 18,
565 18, 19, 20, 20, 20, 20, 21, 21
566 };
567
568 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
569 static const yytype_uint8 yyr2[] =
570 {
571 0, 2, 1, 1, 1, 2, 4, 1, 2, 1,
572 1, 1, 1, 1, 2, 2, 1, 1
573 };
574
575
576 #define yyerrok (yyerrstatus = 0)
577 #define yyclearin (yychar = YYEMPTY)
578 #define YYEMPTY (-2)
579 #define YYEOF 0
580
581 #define YYACCEPT goto yyacceptlab
582 #define YYABORT goto yyabortlab
583 #define YYERROR goto yyerrorlab
584
585
586 #define YYRECOVERING() (!!yyerrstatus)
587
588 #define YYBACKUP(Token, Value) \
589 do \
590 if (yychar == YYEMPTY) \
591 { \
592 yychar = (Token); \
593 yylval = (Value); \
594 YYPOPSTACK (yylen); \
595 yystate = *yyssp; \
596 goto yybackup; \
597 } \
598 else \
599 { \
600 yyerror (pb, sb, YY_("syntax error: cannot back up")); \
601 YYERROR; \
602 } \
603 while (0)
604
605 /* Error token number */
606 #define YYTERROR 1
607 #define YYERRCODE 256
608
609
610
611 /* Enable debugging if requested. */
612 #if YYDEBUG
613
614 # ifndef YYFPRINTF
615 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
616 # define YYFPRINTF fprintf
617 # endif
618
619 # define YYDPRINTF(Args) \
620 do { \
621 if (yydebug) \
622 YYFPRINTF Args; \
623 } while (0)
624
625 /* This macro is provided for backward compatibility. */
626 #ifndef YY_LOCATION_PRINT
627 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
628 #endif
629
630
631 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
632 do { \
633 if (yydebug) \
634 { \
635 YYFPRINTF (stderr, "%s ", Title); \
636 yy_symbol_print (stderr, \
637 Type, Value, pb, sb); \
638 YYFPRINTF (stderr, "\n"); \
639 } \
640 } while (0)
641
642
643 /*----------------------------------------.
644 | Print this symbol's value on YYOUTPUT. |
645 `----------------------------------------*/
646
647 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep,KFGParseBlock * pb,KFGScanBlock * sb)648 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, KFGParseBlock* pb, KFGScanBlock* sb)
649 {
650 FILE *yyo = yyoutput;
651 YYUSE (yyo);
652 YYUSE (pb);
653 YYUSE (sb);
654 if (!yyvaluep)
655 return;
656 # ifdef YYPRINT
657 if (yytype < YYNTOKENS)
658 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
659 # endif
660 YYUSE (yytype);
661 }
662
663
664 /*--------------------------------.
665 | Print this symbol on YYOUTPUT. |
666 `--------------------------------*/
667
668 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep,KFGParseBlock * pb,KFGScanBlock * sb)669 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, KFGParseBlock* pb, KFGScanBlock* sb)
670 {
671 YYFPRINTF (yyoutput, "%s %s (",
672 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
673
674 yy_symbol_value_print (yyoutput, yytype, yyvaluep, pb, sb);
675 YYFPRINTF (yyoutput, ")");
676 }
677
678 /*------------------------------------------------------------------.
679 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
680 | TOP (included). |
681 `------------------------------------------------------------------*/
682
683 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)684 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
685 {
686 YYFPRINTF (stderr, "Stack now");
687 for (; yybottom <= yytop; yybottom++)
688 {
689 int yybot = *yybottom;
690 YYFPRINTF (stderr, " %d", yybot);
691 }
692 YYFPRINTF (stderr, "\n");
693 }
694
695 # define YY_STACK_PRINT(Bottom, Top) \
696 do { \
697 if (yydebug) \
698 yy_stack_print ((Bottom), (Top)); \
699 } while (0)
700
701
702 /*------------------------------------------------.
703 | Report that the YYRULE is going to be reduced. |
704 `------------------------------------------------*/
705
706 static void
yy_reduce_print(yytype_int16 * yyssp,YYSTYPE * yyvsp,int yyrule,KFGParseBlock * pb,KFGScanBlock * sb)707 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, KFGParseBlock* pb, KFGScanBlock* sb)
708 {
709 unsigned long int yylno = yyrline[yyrule];
710 int yynrhs = yyr2[yyrule];
711 int yyi;
712 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
713 yyrule - 1, yylno);
714 /* The symbols being reduced. */
715 for (yyi = 0; yyi < yynrhs; yyi++)
716 {
717 YYFPRINTF (stderr, " $%d = ", yyi + 1);
718 yy_symbol_print (stderr,
719 yystos[yyssp[yyi + 1 - yynrhs]],
720 &(yyvsp[(yyi + 1) - (yynrhs)])
721 , pb, sb);
722 YYFPRINTF (stderr, "\n");
723 }
724 }
725
726 # define YY_REDUCE_PRINT(Rule) \
727 do { \
728 if (yydebug) \
729 yy_reduce_print (yyssp, yyvsp, Rule, pb, sb); \
730 } while (0)
731
732 /* Nonzero means print parse trace. It is left uninitialized so that
733 multiple parsers can coexist. */
734 int yydebug;
735 #else /* !YYDEBUG */
736 # define YYDPRINTF(Args)
737 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
738 # define YY_STACK_PRINT(Bottom, Top)
739 # define YY_REDUCE_PRINT(Rule)
740 #endif /* !YYDEBUG */
741
742
743 /* YYINITDEPTH -- initial size of the parser's stacks. */
744 #ifndef YYINITDEPTH
745 # define YYINITDEPTH 200
746 #endif
747
748 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
749 if the built-in stack extension method is used).
750
751 Do not make this value too large; the results are undefined if
752 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
753 evaluated with infinite-precision integer arithmetic. */
754
755 #ifndef YYMAXDEPTH
756 # define YYMAXDEPTH 10000
757 #endif
758
759
760 #if YYERROR_VERBOSE
761
762 # ifndef yystrlen
763 # if defined __GLIBC__ && defined _STRING_H
764 # define yystrlen strlen
765 # else
766 /* Return the length of YYSTR. */
767 static YYSIZE_T
yystrlen(const char * yystr)768 yystrlen (const char *yystr)
769 {
770 YYSIZE_T yylen;
771 for (yylen = 0; yystr[yylen]; yylen++)
772 continue;
773 return yylen;
774 }
775 # endif
776 # endif
777
778 # ifndef yystpcpy
779 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
780 # define yystpcpy stpcpy
781 # else
782 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
783 YYDEST. */
784 static char *
yystpcpy(char * yydest,const char * yysrc)785 yystpcpy (char *yydest, const char *yysrc)
786 {
787 char *yyd = yydest;
788 const char *yys = yysrc;
789
790 while ((*yyd++ = *yys++) != '\0')
791 continue;
792
793 return yyd - 1;
794 }
795 # endif
796 # endif
797
798 # ifndef yytnamerr
799 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
800 quotes and backslashes, so that it's suitable for yyerror. The
801 heuristic is that double-quoting is unnecessary unless the string
802 contains an apostrophe, a comma, or backslash (other than
803 backslash-backslash). YYSTR is taken from yytname. If YYRES is
804 null, do not copy; instead, return the length of what the result
805 would have been. */
806 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)807 yytnamerr (char *yyres, const char *yystr)
808 {
809 if (*yystr == '"')
810 {
811 YYSIZE_T yyn = 0;
812 char const *yyp = yystr;
813
814 for (;;)
815 switch (*++yyp)
816 {
817 case '\'':
818 case ',':
819 goto do_not_strip_quotes;
820
821 case '\\':
822 if (*++yyp != '\\')
823 goto do_not_strip_quotes;
824 /* Fall through. */
825 default:
826 if (yyres)
827 yyres[yyn] = *yyp;
828 yyn++;
829 break;
830
831 case '"':
832 if (yyres)
833 yyres[yyn] = '\0';
834 return yyn;
835 }
836 do_not_strip_quotes: ;
837 }
838
839 if (! yyres)
840 return yystrlen (yystr);
841
842 return yystpcpy (yyres, yystr) - yyres;
843 }
844 # endif
845
846 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
847 about the unexpected token YYTOKEN for the state stack whose top is
848 YYSSP.
849
850 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
851 not large enough to hold the message. In that case, also set
852 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
853 required number of bytes is too large to store. */
854 static int
yysyntax_error(YYSIZE_T * yymsg_alloc,char ** yymsg,yytype_int16 * yyssp,int yytoken)855 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
856 yytype_int16 *yyssp, int yytoken)
857 {
858 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
859 YYSIZE_T yysize = yysize0;
860 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
861 /* Internationalized format string. */
862 const char *yyformat = YY_NULLPTR;
863 /* Arguments of yyformat. */
864 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
865 /* Number of reported tokens (one for the "unexpected", one per
866 "expected"). */
867 int yycount = 0;
868
869 /* There are many possibilities here to consider:
870 - If this state is a consistent state with a default action, then
871 the only way this function was invoked is if the default action
872 is an error action. In that case, don't check for expected
873 tokens because there are none.
874 - The only way there can be no lookahead present (in yychar) is if
875 this state is a consistent state with a default action. Thus,
876 detecting the absence of a lookahead is sufficient to determine
877 that there is no unexpected or expected token to report. In that
878 case, just report a simple "syntax error".
879 - Don't assume there isn't a lookahead just because this state is a
880 consistent state with a default action. There might have been a
881 previous inconsistent state, consistent state with a non-default
882 action, or user semantic action that manipulated yychar.
883 - Of course, the expected token list depends on states to have
884 correct lookahead information, and it depends on the parser not
885 to perform extra reductions after fetching a lookahead from the
886 scanner and before detecting a syntax error. Thus, state merging
887 (from LALR or IELR) and default reductions corrupt the expected
888 token list. However, the list is correct for canonical LR with
889 one exception: it will still contain any token that will not be
890 accepted due to an error action in a later state.
891 */
892 if (yytoken != YYEMPTY)
893 {
894 int yyn = yypact[*yyssp];
895 yyarg[yycount++] = yytname[yytoken];
896 if (!yypact_value_is_default (yyn))
897 {
898 /* Start YYX at -YYN if negative to avoid negative indexes in
899 YYCHECK. In other words, skip the first -YYN actions for
900 this state because they are default actions. */
901 int yyxbegin = yyn < 0 ? -yyn : 0;
902 /* Stay within bounds of both yycheck and yytname. */
903 int yychecklim = YYLAST - yyn + 1;
904 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
905 int yyx;
906
907 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
908 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
909 && !yytable_value_is_error (yytable[yyx + yyn]))
910 {
911 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
912 {
913 yycount = 1;
914 yysize = yysize0;
915 break;
916 }
917 yyarg[yycount++] = yytname[yyx];
918 {
919 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
920 if (! (yysize <= yysize1
921 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
922 return 2;
923 yysize = yysize1;
924 }
925 }
926 }
927 }
928
929 switch (yycount)
930 {
931 # define YYCASE_(N, S) \
932 case N: \
933 yyformat = S; \
934 break
935 YYCASE_(0, YY_("syntax error"));
936 YYCASE_(1, YY_("syntax error, unexpected %s"));
937 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
938 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
939 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
940 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
941 # undef YYCASE_
942 }
943
944 {
945 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
946 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
947 return 2;
948 yysize = yysize1;
949 }
950
951 if (*yymsg_alloc < yysize)
952 {
953 *yymsg_alloc = 2 * yysize;
954 if (! (yysize <= *yymsg_alloc
955 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
956 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
957 return 1;
958 }
959
960 /* Avoid sprintf, as that infringes on the user's name space.
961 Don't have undefined behavior even if the translation
962 produced a string with the wrong number of "%s"s. */
963 {
964 char *yyp = *yymsg;
965 int yyi = 0;
966 while ((*yyp = *yyformat) != '\0')
967 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
968 {
969 yyp += yytnamerr (yyp, yyarg[yyi++]);
970 yyformat += 2;
971 }
972 else
973 {
974 yyp++;
975 yyformat++;
976 }
977 }
978 return 0;
979 }
980 #endif /* YYERROR_VERBOSE */
981
982 /*-----------------------------------------------.
983 | Release the memory associated to this symbol. |
984 `-----------------------------------------------*/
985
986 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep,KFGParseBlock * pb,KFGScanBlock * sb)987 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, KFGParseBlock* pb, KFGScanBlock* sb)
988 {
989 YYUSE (yyvaluep);
990 YYUSE (pb);
991 YYUSE (sb);
992 if (!yymsg)
993 yymsg = "Deleting";
994 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
995
996 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
997 switch (yytype)
998 {
999 case 20: /* value */
1000
1001 {
1002 VNamelistRelease(((*yyvaluep).namelist));
1003 }
1004
1005 break;
1006
1007
1008 default:
1009 break;
1010 }
1011 YY_IGNORE_MAYBE_UNINITIALIZED_END
1012 }
1013
1014
1015
1016
1017 /*----------.
1018 | yyparse. |
1019 `----------*/
1020
1021 int
yyparse(KFGParseBlock * pb,KFGScanBlock * sb)1022 yyparse (KFGParseBlock* pb, KFGScanBlock* sb)
1023 {
1024 /* The lookahead symbol. */
1025 int yychar;
1026
1027
1028 /* The semantic value of the lookahead symbol. */
1029 /* Default value used for initialization, for pacifying older GCCs
1030 or non-GCC compilers. */
1031 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1032 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1033
1034 /* Number of syntax errors so far. */
1035 int yynerrs;
1036
1037 int yystate;
1038 /* Number of tokens to shift before error messages enabled. */
1039 int yyerrstatus;
1040
1041 /* The stacks and their tools:
1042 'yyss': related to states.
1043 'yyvs': related to semantic values.
1044
1045 Refer to the stacks through separate pointers, to allow yyoverflow
1046 to reallocate them elsewhere. */
1047
1048 /* The state stack. */
1049 yytype_int16 yyssa[YYINITDEPTH];
1050 yytype_int16 *yyss;
1051 yytype_int16 *yyssp;
1052
1053 /* The semantic value stack. */
1054 YYSTYPE yyvsa[YYINITDEPTH];
1055 YYSTYPE *yyvs;
1056 YYSTYPE *yyvsp;
1057
1058 YYSIZE_T yystacksize;
1059
1060 int yyn;
1061 int yyresult;
1062 /* Lookahead token as an internal (translated) token number. */
1063 int yytoken = 0;
1064 /* The variables used to return semantic value and location from the
1065 action routines. */
1066 YYSTYPE yyval;
1067
1068 #if YYERROR_VERBOSE
1069 /* Buffer for error messages, and its allocated size. */
1070 char yymsgbuf[128];
1071 char *yymsg = yymsgbuf;
1072 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1073 #endif
1074
1075 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1076
1077 /* The number of symbols on the RHS of the reduced rule.
1078 Keep to zero when no symbol should be popped. */
1079 int yylen = 0;
1080
1081 yyssp = yyss = yyssa;
1082 yyvsp = yyvs = yyvsa;
1083 yystacksize = YYINITDEPTH;
1084
1085 YYDPRINTF ((stderr, "Starting parse\n"));
1086
1087 yystate = 0;
1088 yyerrstatus = 0;
1089 yynerrs = 0;
1090 yychar = YYEMPTY; /* Cause a token to be read. */
1091 goto yysetstate;
1092
1093 /*------------------------------------------------------------.
1094 | yynewstate -- Push a new state, which is found in yystate. |
1095 `------------------------------------------------------------*/
1096 yynewstate:
1097 /* In all cases, when you get here, the value and location stacks
1098 have just been pushed. So pushing a state here evens the stacks. */
1099 yyssp++;
1100
1101 yysetstate:
1102 *yyssp = yystate;
1103
1104 if (yyss + yystacksize - 1 <= yyssp)
1105 {
1106 /* Get the current used size of the three stacks, in elements. */
1107 YYSIZE_T yysize = yyssp - yyss + 1;
1108
1109 #ifdef yyoverflow
1110 {
1111 /* Give user a chance to reallocate the stack. Use copies of
1112 these so that the &'s don't force the real ones into
1113 memory. */
1114 YYSTYPE *yyvs1 = yyvs;
1115 yytype_int16 *yyss1 = yyss;
1116
1117 /* Each stack pointer address is followed by the size of the
1118 data in use in that stack, in bytes. This used to be a
1119 conditional around just the two extra args, but that might
1120 be undefined if yyoverflow is a macro. */
1121 yyoverflow (YY_("memory exhausted"),
1122 &yyss1, yysize * sizeof (*yyssp),
1123 &yyvs1, yysize * sizeof (*yyvsp),
1124 &yystacksize);
1125
1126 yyss = yyss1;
1127 yyvs = yyvs1;
1128 }
1129 #else /* no yyoverflow */
1130 # ifndef YYSTACK_RELOCATE
1131 goto yyexhaustedlab;
1132 # else
1133 /* Extend the stack our own way. */
1134 if (YYMAXDEPTH <= yystacksize)
1135 goto yyexhaustedlab;
1136 yystacksize *= 2;
1137 if (YYMAXDEPTH < yystacksize)
1138 yystacksize = YYMAXDEPTH;
1139
1140 {
1141 yytype_int16 *yyss1 = yyss;
1142 union yyalloc *yyptr =
1143 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1144 if (! yyptr)
1145 goto yyexhaustedlab;
1146 YYSTACK_RELOCATE (yyss_alloc, yyss);
1147 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1148 # undef YYSTACK_RELOCATE
1149 if (yyss1 != yyssa)
1150 YYSTACK_FREE (yyss1);
1151 }
1152 # endif
1153 #endif /* no yyoverflow */
1154
1155 yyssp = yyss + yysize - 1;
1156 yyvsp = yyvs + yysize - 1;
1157
1158 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1159 (unsigned long int) yystacksize));
1160
1161 if (yyss + yystacksize - 1 <= yyssp)
1162 YYABORT;
1163 }
1164
1165 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1166
1167 if (yystate == YYFINAL)
1168 YYACCEPT;
1169
1170 goto yybackup;
1171
1172 /*-----------.
1173 | yybackup. |
1174 `-----------*/
1175 yybackup:
1176
1177 /* Do appropriate processing given the current state. Read a
1178 lookahead token if we need one and don't already have one. */
1179
1180 /* First try to decide what to do without reference to lookahead token. */
1181 yyn = yypact[yystate];
1182 if (yypact_value_is_default (yyn))
1183 goto yydefault;
1184
1185 /* Not known => get a lookahead token if don't already have one. */
1186
1187 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1188 if (yychar == YYEMPTY)
1189 {
1190 YYDPRINTF ((stderr, "Reading a token: "));
1191 yychar = yylex (&yylval, sb);
1192 }
1193
1194 if (yychar <= YYEOF)
1195 {
1196 yychar = yytoken = YYEOF;
1197 YYDPRINTF ((stderr, "Now at end of input.\n"));
1198 }
1199 else
1200 {
1201 yytoken = YYTRANSLATE (yychar);
1202 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1203 }
1204
1205 /* If the proper action on seeing token YYTOKEN is to reduce or to
1206 detect an error, take that action. */
1207 yyn += yytoken;
1208 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1209 goto yydefault;
1210 yyn = yytable[yyn];
1211 if (yyn <= 0)
1212 {
1213 if (yytable_value_is_error (yyn))
1214 goto yyerrlab;
1215 yyn = -yyn;
1216 goto yyreduce;
1217 }
1218
1219 /* Count tokens shifted since error; after three, turn off error
1220 status. */
1221 if (yyerrstatus)
1222 yyerrstatus--;
1223
1224 /* Shift the lookahead token. */
1225 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1226
1227 /* Discard the shifted token. */
1228 yychar = YYEMPTY;
1229
1230 yystate = yyn;
1231 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1232 *++yyvsp = yylval;
1233 YY_IGNORE_MAYBE_UNINITIALIZED_END
1234
1235 goto yynewstate;
1236
1237
1238 /*-----------------------------------------------------------.
1239 | yydefault -- do the default action for the current state. |
1240 `-----------------------------------------------------------*/
1241 yydefault:
1242 yyn = yydefact[yystate];
1243 if (yyn == 0)
1244 goto yyerrlab;
1245 goto yyreduce;
1246
1247
1248 /*-----------------------------.
1249 | yyreduce -- Do a reduction. |
1250 `-----------------------------*/
1251 yyreduce:
1252 /* yyn is the number of a rule to reduce with. */
1253 yylen = yyr2[yyn];
1254
1255 /* If YYLEN is nonzero, implement the default value of the action:
1256 '$$ = $1'.
1257
1258 Otherwise, the following line sets YYVAL to garbage.
1259 This behavior is undocumented and Bison
1260 users should not rely upon it. Assigning to YYVAL
1261 unconditionally makes the parser a bit smaller, and it avoids a
1262 GCC warning that YYVAL may be used uninitialized. */
1263 yyval = yyvsp[1-yylen];
1264
1265
1266 YY_REDUCE_PRINT (yyn);
1267 switch (yyn)
1268 {
1269 case 6:
1270
1271 {
1272 rc_t rc=pb->write_nvp(sb->self, (yyvsp[-3].pb).tokenText, (yyvsp[-3].pb).tokenLength, (yyvsp[-1].namelist));
1273 if (rc != 0)
1274 {
1275 ReportRc(pb, sb, rc);
1276 }
1277 VNamelistRelease((yyvsp[-1].namelist));
1278 }
1279
1280 break;
1281
1282 case 12:
1283
1284 { VNamelistMake(&(yyval.namelist), NAMELIST_ALLOC_BLKSIZE); AppendName(sb, (yyval.namelist), &(yyvsp[0].pb)); }
1285
1286 break;
1287
1288 case 13:
1289
1290 { VNamelistMake(&(yyval.namelist), NAMELIST_ALLOC_BLKSIZE); AppendName(sb, (yyval.namelist), &(yyvsp[0].pb)); }
1291
1292 break;
1293
1294 case 14:
1295
1296 { AppendName(sb, (yyvsp[-1].namelist), &(yyvsp[0].pb)); (yyval.namelist)=(yyvsp[-1].namelist); }
1297
1298 break;
1299
1300 case 15:
1301
1302 { AppendName(sb, (yyvsp[-1].namelist), &(yyvsp[0].pb)); (yyval.namelist)=(yyvsp[-1].namelist); }
1303
1304 break;
1305
1306
1307
1308 default: break;
1309 }
1310 /* User semantic actions sometimes alter yychar, and that requires
1311 that yytoken be updated with the new translation. We take the
1312 approach of translating immediately before every use of yytoken.
1313 One alternative is translating here after every semantic action,
1314 but that translation would be missed if the semantic action invokes
1315 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1316 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1317 incorrect destructor might then be invoked immediately. In the
1318 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1319 to an incorrect destructor call or verbose syntax error message
1320 before the lookahead is translated. */
1321 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1322
1323 YYPOPSTACK (yylen);
1324 yylen = 0;
1325 YY_STACK_PRINT (yyss, yyssp);
1326
1327 *++yyvsp = yyval;
1328
1329 /* Now 'shift' the result of the reduction. Determine what state
1330 that goes to, based on the state we popped back to and the rule
1331 number reduced by. */
1332
1333 yyn = yyr1[yyn];
1334
1335 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1336 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1337 yystate = yytable[yystate];
1338 else
1339 yystate = yydefgoto[yyn - YYNTOKENS];
1340
1341 goto yynewstate;
1342
1343
1344 /*--------------------------------------.
1345 | yyerrlab -- here on detecting error. |
1346 `--------------------------------------*/
1347 yyerrlab:
1348 /* Make sure we have latest lookahead translation. See comments at
1349 user semantic actions for why this is necessary. */
1350 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1351
1352 /* If not already recovering from an error, report this error. */
1353 if (!yyerrstatus)
1354 {
1355 ++yynerrs;
1356 #if ! YYERROR_VERBOSE
1357 yyerror (pb, sb, YY_("syntax error"));
1358 #else
1359 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1360 yyssp, yytoken)
1361 {
1362 char const *yymsgp = YY_("syntax error");
1363 int yysyntax_error_status;
1364 yysyntax_error_status = YYSYNTAX_ERROR;
1365 if (yysyntax_error_status == 0)
1366 yymsgp = yymsg;
1367 else if (yysyntax_error_status == 1)
1368 {
1369 if (yymsg != yymsgbuf)
1370 YYSTACK_FREE (yymsg);
1371 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1372 if (!yymsg)
1373 {
1374 yymsg = yymsgbuf;
1375 yymsg_alloc = sizeof yymsgbuf;
1376 yysyntax_error_status = 2;
1377 }
1378 else
1379 {
1380 yysyntax_error_status = YYSYNTAX_ERROR;
1381 yymsgp = yymsg;
1382 }
1383 }
1384 yyerror (pb, sb, yymsgp);
1385 if (yysyntax_error_status == 2)
1386 goto yyexhaustedlab;
1387 }
1388 # undef YYSYNTAX_ERROR
1389 #endif
1390 }
1391
1392
1393
1394 if (yyerrstatus == 3)
1395 {
1396 /* If just tried and failed to reuse lookahead token after an
1397 error, discard it. */
1398
1399 if (yychar <= YYEOF)
1400 {
1401 /* Return failure if at end of input. */
1402 if (yychar == YYEOF)
1403 YYABORT;
1404 }
1405 else
1406 {
1407 yydestruct ("Error: discarding",
1408 yytoken, &yylval, pb, sb);
1409 yychar = YYEMPTY;
1410 }
1411 }
1412
1413 /* Else will try to reuse lookahead token after shifting the error
1414 token. */
1415 goto yyerrlab1;
1416
1417
1418 /*---------------------------------------------------.
1419 | yyerrorlab -- error raised explicitly by YYERROR. |
1420 `---------------------------------------------------*/
1421 yyerrorlab:
1422
1423 /* Pacify compilers like GCC when the user code never invokes
1424 YYERROR and the label yyerrorlab therefore never appears in user
1425 code. */
1426 if (/*CONSTCOND*/ 0)
1427 goto yyerrorlab;
1428
1429 /* Do not reclaim the symbols of the rule whose action triggered
1430 this YYERROR. */
1431 YYPOPSTACK (yylen);
1432 yylen = 0;
1433 YY_STACK_PRINT (yyss, yyssp);
1434 yystate = *yyssp;
1435 goto yyerrlab1;
1436
1437
1438 /*-------------------------------------------------------------.
1439 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1440 `-------------------------------------------------------------*/
1441 yyerrlab1:
1442 yyerrstatus = 3; /* Each real token shifted decrements this. */
1443
1444 for (;;)
1445 {
1446 yyn = yypact[yystate];
1447 if (!yypact_value_is_default (yyn))
1448 {
1449 yyn += YYTERROR;
1450 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1451 {
1452 yyn = yytable[yyn];
1453 if (0 < yyn)
1454 break;
1455 }
1456 }
1457
1458 /* Pop the current state because it cannot handle the error token. */
1459 if (yyssp == yyss)
1460 YYABORT;
1461
1462
1463 yydestruct ("Error: popping",
1464 yystos[yystate], yyvsp, pb, sb);
1465 YYPOPSTACK (1);
1466 yystate = *yyssp;
1467 YY_STACK_PRINT (yyss, yyssp);
1468 }
1469
1470 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1471 *++yyvsp = yylval;
1472 YY_IGNORE_MAYBE_UNINITIALIZED_END
1473
1474
1475 /* Shift the error token. */
1476 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1477
1478 yystate = yyn;
1479 goto yynewstate;
1480
1481
1482 /*-------------------------------------.
1483 | yyacceptlab -- YYACCEPT comes here. |
1484 `-------------------------------------*/
1485 yyacceptlab:
1486 yyresult = 0;
1487 goto yyreturn;
1488
1489 /*-----------------------------------.
1490 | yyabortlab -- YYABORT comes here. |
1491 `-----------------------------------*/
1492 yyabortlab:
1493 yyresult = 1;
1494 goto yyreturn;
1495
1496 #if !defined yyoverflow || YYERROR_VERBOSE
1497 /*-------------------------------------------------.
1498 | yyexhaustedlab -- memory exhaustion comes here. |
1499 `-------------------------------------------------*/
1500 yyexhaustedlab:
1501 yyerror (pb, sb, YY_("memory exhausted"));
1502 yyresult = 2;
1503 /* Fall through. */
1504 #endif
1505
1506 yyreturn:
1507 if (yychar != YYEMPTY)
1508 {
1509 /* Make sure we have latest lookahead translation. See comments at
1510 user semantic actions for why this is necessary. */
1511 yytoken = YYTRANSLATE (yychar);
1512 yydestruct ("Cleanup: discarding lookahead",
1513 yytoken, &yylval, pb, sb);
1514 }
1515 /* Do not reclaim the symbols of the rule whose action triggered
1516 this YYABORT or YYACCEPT. */
1517 YYPOPSTACK (yylen);
1518 YY_STACK_PRINT (yyss, yyssp);
1519 while (yyssp != yyss)
1520 {
1521 yydestruct ("Cleanup: popping",
1522 yystos[*yyssp], yyvsp, pb, sb);
1523 YYPOPSTACK (1);
1524 }
1525 #ifndef yyoverflow
1526 if (yyss != yyssa)
1527 YYSTACK_FREE (yyss);
1528 #endif
1529 #if YYERROR_VERBOSE
1530 if (yymsg != yymsgbuf)
1531 YYSTACK_FREE (yymsg);
1532 #endif
1533 return yyresult;
1534 }
1535
1536
1537
1538 #include <assert.h>
1539 #include <klib/token.h>
1540 #include <klib/writer.h>
1541
KFG_error(KFGParseBlock * pb,KFGScanBlock * sb,const char * msg)1542 void KFG_error(KFGParseBlock* pb, KFGScanBlock* sb, const char* msg)
1543 {
1544 sb->report_error(sb, msg);
1545 }
1546
ReportRc(KFGParseBlock * pb,KFGScanBlock * sb,rc_t rc)1547 void ReportRc(KFGParseBlock* pb, KFGScanBlock* sb, rc_t rc)
1548 {
1549 char buf[1025];
1550 size_t num_writ;
1551 RCExplain(rc, buf, 1024, &num_writ);
1552 buf[1024]=0;
1553 yyerror(0, sb, buf);
1554 }
1555
AppendName(KFGScanBlock * sb,VNamelist * nl,const KFGToken * pb)1556 void AppendName(KFGScanBlock* sb, VNamelist* nl, const KFGToken* pb)
1557 { /* pb represents either a kfgSTRING or a kfgESCAPED_STRING with opening and closed quotes clipped */
1558 rc_t rc;
1559 KToken t;
1560 size_t value_size;
1561 char* buf;
1562
1563 if (pb->tokenLength == 0)
1564 {
1565 return;
1566 }
1567
1568 t.id= pb->tokenId == kfgESCAPED_STRING ? eEscapedString : eString;
1569 StringInit(&t.str, pb->tokenText-1, pb->tokenLength+2, (uint32_t) (pb->tokenLength + 2) ); /* compensate for clipped quotes in order to use KTokenToString */
1570 buf=(char*)malloc(t.str.size);
1571
1572 /* KTokenToString removes opening and closing quotes and handles escapes if present */
1573 rc = KTokenToString (&t, buf, t.str.size, &value_size);
1574 if (rc != 0)
1575 {
1576 ReportRc(0, sb, rc);
1577 }
1578 else
1579 {
1580 assert(value_size < t.str.size);
1581 buf[value_size]=0;
1582 rc = VNamelistAppend(nl, buf);
1583 if (rc != 0)
1584 {
1585 ReportRc(0, sb, rc);
1586 }
1587 }
1588 free(buf);
1589 }
1590
1591
1592
1593