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