Commit for Maxim <3
[build.git] / parse.c
blob825551dddc3ee3ad0fdbfee93a82ebdcf655fef8
1 /* A Bison parser, made by GNU Bison 3.8.2. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6 Inc.
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.
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.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <https://www.gnu.org/licenses/>. */
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.
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
37 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 especially those whose name start with YY_ or yy_. They are
39 private implementation details that can be changed or removed. */
41 /* All symbols defined below should begin with yy or YY, to avoid
42 infringing on user name space. This should be done even for local
43 variables, as they might otherwise be expanded by user macros.
44 There are some unavoidable exceptions within include files to
45 define necessary library symbols; they are noted "INFRINGES ON
46 USER NAME SPACE" below. */
48 /* Identify Bison output, and Bison version. */
49 #define YYBISON 30802
51 /* Bison version string. */
52 #define YYBISON_VERSION "3.8.2"
54 /* Skeleton name. */
55 #define YYSKELETON_NAME "yacc.c"
57 /* Pure parsers. */
58 #define YYPURE 2
60 /* Push parsers. */
61 #define YYPUSH 0
63 /* Pull parsers. */
64 #define YYPULL 1
69 /* First part of user prologue. */
70 #line 22 "parse.y"
72 #include <stdarg.h>
73 #include <stdio.h>
74 #include <stdlib.h>
75 #include <limits.h>
77 #line 78 "parse.c"
79 # ifndef YY_CAST
80 # ifdef __cplusplus
81 # define YY_CAST(Type, Val) static_cast<Type> (Val)
82 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
83 # else
84 # define YY_CAST(Type, Val) ((Type) (Val))
85 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
86 # endif
87 # endif
88 # ifndef YY_NULLPTR
89 # if defined __cplusplus
90 # if 201103L <= __cplusplus
91 # define YY_NULLPTR nullptr
92 # else
93 # define YY_NULLPTR 0
94 # endif
95 # else
96 # define YY_NULLPTR ((void*)0)
97 # endif
98 # endif
100 #include "parse.h"
101 /* Symbol kind. */
102 enum yysymbol_kind_t
104 YYSYMBOL_YYEMPTY = -2,
105 YYSYMBOL_YYEOF = 0, /* "end of input" */
106 YYSYMBOL_YYerror = 1, /* error */
107 YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
108 YYSYMBOL_STRING = 3, /* "string" */
109 YYSYMBOL_NAME = 4, /* "name" */
110 YYSYMBOL_VALUE = 5, /* "value" */
111 YYSYMBOL_6_ = 6, /* ':' */
112 YYSYMBOL_7_ = 7, /* '{' */
113 YYSYMBOL_8_ = 8, /* '}' */
114 YYSYMBOL_9_ = 9, /* '[' */
115 YYSYMBOL_10_ = 10, /* ']' */
116 YYSYMBOL_11_ = 11, /* '@' */
117 YYSYMBOL_ARROW = 12, /* "->" */
118 YYSYMBOL_CATENATE = 13, /* "+=" */
119 YYSYMBOL_DESCRIPTION = 14, /* "'description' keyword" */
120 YYSYMBOL_RULE = 15, /* "'rule' keyword" */
121 YYSYMBOL_TARGET = 16, /* "'target' keyword" */
122 YYSYMBOL_VARIABLE = 17, /* "'variable' keyword" */
123 YYSYMBOL_VIRTUAL = 18, /* "'virtual' keyword" */
124 YYSYMBOL_19_ = 19, /* '=' */
125 YYSYMBOL_YYACCEPT = 20, /* $accept */
126 YYSYMBOL_program = 21, /* program */
127 YYSYMBOL_name = 22, /* name */
128 YYSYMBOL_string = 23, /* string */
129 YYSYMBOL_strings_or_nothing = 24, /* strings_or_nothing */
130 YYSYMBOL_variable = 25, /* variable */
131 YYSYMBOL_description = 26, /* description */
132 YYSYMBOL_rule = 27, /* rule */
133 YYSYMBOL_out = 28, /* out */
134 YYSYMBOL_in = 29, /* in */
135 YYSYMBOL_apply_rule = 30, /* apply_rule */
136 YYSYMBOL_value = 31, /* value */
137 YYSYMBOL_strings = 32, /* strings */
138 YYSYMBOL_apply_rules = 33, /* apply_rules */
139 YYSYMBOL_apply_rules_or_nothing = 34, /* apply_rules_or_nothing */
140 YYSYMBOL_dependencies = 35, /* dependencies */
141 YYSYMBOL_files = 36, /* files */
142 YYSYMBOL_target_name = 37, /* target_name */
143 YYSYMBOL_virtual_target_name = 38, /* virtual_target_name */
144 YYSYMBOL_virtual_target = 39, /* virtual_target */
145 YYSYMBOL_target = 40 /* target */
147 typedef enum yysymbol_kind_t yysymbol_kind_t;
151 /* Unqualified %code blocks. */
152 #line 143 "parse.y"
154 #include <assert.h>
155 #include <stdio.h>
156 #include <string.h>
158 #include "build.h"
159 #include "diagnostic.h"
160 #include "libquote/quote.h"
161 #include "system.h"
163 #define ARRAY_DUPLICATE(a0, a1) \
164 do \
166 (a0).count = (a1).count; \
167 (a0).array = malloc ((a0).count * sizeof (*(a0).array)); \
169 if (UNLIKELY ((a0).array == NULL)) \
170 YYNOMEM; \
172 memcpy ((a0).array, (a1).array, \
173 (a0).count * sizeof (*(a0).array)); \
175 while (0)
177 #define ARRAY_INITIALIZE_EMPTY(a0) \
178 do \
180 (a0).count = 0; \
181 (a0).array = NULL; \
183 while (0)
185 #define ARRAY_INITIALIZE(a0, a1) \
186 do \
188 (a0).count = 0; \
189 (a0).array = malloc (sizeof (*(a0).array)); \
191 if (UNLIKELY ((a0).array == NULL)) \
192 YYNOMEM; \
194 (a0).array[(a0).count++] = (a1); \
196 while (0)
198 #define ARRAY_EXPAND(a0, a1) \
199 do \
201 void *t; \
203 t = realloc ((a0).array, \
204 ((a0).count + 1) * sizeof (*(a0).array)); \
206 if (UNLIKELY (t == NULL)) \
208 free ((a0).array); \
209 YYNOMEM; \
212 (a0).array = t; \
213 (a0).array[(a0).count++] = (a1); \
215 while (0)
217 #define ARRAY_CATENATE(a0, a1) \
218 do \
220 void *t; \
222 t = realloc ((a0).array, \
223 ((a0).count + (a1).count) * sizeof (*(a0).array)); \
225 if (UNLIKELY (t == NULL)) \
227 free ((a0).array); \
228 YYNOMEM; \
231 (a0).array = t; \
232 memcpy ((a0).array + (a0).count, (a1).array, \
233 (a1).count * sizeof (*(a0).array)); \
234 (a0).count += (a1).count; \
236 while (0)
238 #define VARIABLE_FIND(variable, name) \
239 do \
241 variable = HashFind (&context->variables, \
242 name, uniqstr_len (name)); \
244 if (UNLIKELY (variable == NULL)) \
246 warning_at (yylocation, \
247 _("variable is not declared: %s"), \
248 quote (yyget_extra (yyscanner)->qs, name)); \
249 YYABORT; \
252 while (0)
254 #define VARIABLE_INSERT(variable) \
255 do \
257 if (UNLIKELY (HashInsert (&context->variables, \
258 variable.name, \
259 uniqstr_len (variable.name), \
260 &variable) == NULL)) \
261 YYNOMEM; \
263 while (0)
265 #define VARIABLE_REMOVE(variable) \
266 do \
268 if (LIKELY (variable.name != NULL)) \
270 HashRemove (&context->variables, \
271 variable.name, \
272 uniqstr_len (variable.name)); \
274 /* Do not 'free (variable.value.array);' \
275 since this array used by target_create(). */ \
277 memset (&variable, '\0', sizeof (variable)); \
280 while (0)
282 #define VARIABLE_TEMPORARY_DEFINE(variable, string, val) \
283 do \
285 variable.name = uniqstr_new_from_literal_string (string); \
286 variable.value = val; \
287 VARIABLE_INSERT (variable); \
289 while (0)
291 #line 292 "parse.c"
293 #ifdef short
294 # undef short
295 #endif
297 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
298 <limits.h> and (if available) <stdint.h> are included
299 so that the code can choose integer types of a good width. */
301 #ifndef __PTRDIFF_MAX__
302 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
303 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
304 # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
305 # define YY_STDINT_H
306 # endif
307 #endif
309 /* Narrow types that promote to a signed type and that can represent a
310 signed or unsigned integer of at least N bits. In tables they can
311 save space and decrease cache pressure. Promoting to a signed type
312 helps avoid bugs in integer arithmetic. */
314 #ifdef __INT_LEAST8_MAX__
315 typedef __INT_LEAST8_TYPE__ yytype_int8;
316 #elif defined YY_STDINT_H
317 typedef int_least8_t yytype_int8;
318 #else
319 typedef signed char yytype_int8;
320 #endif
322 #ifdef __INT_LEAST16_MAX__
323 typedef __INT_LEAST16_TYPE__ yytype_int16;
324 #elif defined YY_STDINT_H
325 typedef int_least16_t yytype_int16;
326 #else
327 typedef short yytype_int16;
328 #endif
330 /* Work around bug in HP-UX 11.23, which defines these macros
331 incorrectly for preprocessor constants. This workaround can likely
332 be removed in 2023, as HPE has promised support for HP-UX 11.23
333 (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
334 <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
335 #ifdef __hpux
336 # undef UINT_LEAST8_MAX
337 # undef UINT_LEAST16_MAX
338 # define UINT_LEAST8_MAX 255
339 # define UINT_LEAST16_MAX 65535
340 #endif
342 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
343 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
344 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
345 && UINT_LEAST8_MAX <= INT_MAX)
346 typedef uint_least8_t yytype_uint8;
347 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
348 typedef unsigned char yytype_uint8;
349 #else
350 typedef short yytype_uint8;
351 #endif
353 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
354 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
355 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
356 && UINT_LEAST16_MAX <= INT_MAX)
357 typedef uint_least16_t yytype_uint16;
358 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
359 typedef unsigned short yytype_uint16;
360 #else
361 typedef int yytype_uint16;
362 #endif
364 #ifndef YYPTRDIFF_T
365 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
366 # define YYPTRDIFF_T __PTRDIFF_TYPE__
367 # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
368 # elif defined PTRDIFF_MAX
369 # ifndef ptrdiff_t
370 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
371 # endif
372 # define YYPTRDIFF_T ptrdiff_t
373 # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
374 # else
375 # define YYPTRDIFF_T long
376 # define YYPTRDIFF_MAXIMUM LONG_MAX
377 # endif
378 #endif
380 #ifndef YYSIZE_T
381 # ifdef __SIZE_TYPE__
382 # define YYSIZE_T __SIZE_TYPE__
383 # elif defined size_t
384 # define YYSIZE_T size_t
385 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
386 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
387 # define YYSIZE_T size_t
388 # else
389 # define YYSIZE_T unsigned
390 # endif
391 #endif
393 #define YYSIZE_MAXIMUM \
394 YY_CAST (YYPTRDIFF_T, \
395 (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
396 ? YYPTRDIFF_MAXIMUM \
397 : YY_CAST (YYSIZE_T, -1)))
399 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
402 /* Stored state numbers (used for stacks). */
403 typedef yytype_int8 yy_state_t;
405 /* State numbers in computations. */
406 typedef int yy_state_fast_t;
408 #ifndef YY_
409 # if defined YYENABLE_NLS && YYENABLE_NLS
410 # if ENABLE_NLS
411 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
412 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
413 # endif
414 # endif
415 # ifndef YY_
416 # define YY_(Msgid) Msgid
417 # endif
418 #endif
420 #ifndef N_
421 # define N_(Msgid) Msgid
422 #endif
425 #ifndef YY_ATTRIBUTE_PURE
426 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
427 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
428 # else
429 # define YY_ATTRIBUTE_PURE
430 # endif
431 #endif
433 #ifndef YY_ATTRIBUTE_UNUSED
434 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
435 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
436 # else
437 # define YY_ATTRIBUTE_UNUSED
438 # endif
439 #endif
441 /* Suppress unused-variable warnings by "using" E. */
442 #if ! defined lint || defined __GNUC__
443 # define YY_USE(E) ((void) (E))
444 #else
445 # define YY_USE(E) /* empty */
446 #endif
448 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
449 #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
450 # if __GNUC__ * 100 + __GNUC_MINOR__ < 407
451 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
452 _Pragma ("GCC diagnostic push") \
453 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
454 # else
455 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
456 _Pragma ("GCC diagnostic push") \
457 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
458 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
459 # endif
460 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
461 _Pragma ("GCC diagnostic pop")
462 #else
463 # define YY_INITIAL_VALUE(Value) Value
464 #endif
465 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
466 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
467 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
468 #endif
469 #ifndef YY_INITIAL_VALUE
470 # define YY_INITIAL_VALUE(Value) /* Nothing. */
471 #endif
473 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
474 # define YY_IGNORE_USELESS_CAST_BEGIN \
475 _Pragma ("GCC diagnostic push") \
476 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
477 # define YY_IGNORE_USELESS_CAST_END \
478 _Pragma ("GCC diagnostic pop")
479 #endif
480 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
481 # define YY_IGNORE_USELESS_CAST_BEGIN
482 # define YY_IGNORE_USELESS_CAST_END
483 #endif
486 #define YY_ASSERT(E) ((void) (0 && (E)))
488 #if 1
490 /* The parser invokes alloca or malloc; define the necessary symbols. */
492 # ifdef YYSTACK_ALLOC
493 /* Pacify GCC's 'empty if-body' warning. */
494 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
495 # ifndef YYSTACK_ALLOC_MAXIMUM
496 /* The OS might guarantee only one guard page at the bottom of the stack,
497 and a page size can be as small as 4096 bytes. So we cannot safely
498 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
499 to allow for a few compiler-allocated temporary stack slots. */
500 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
501 # endif
502 # else
503 # define YYSTACK_ALLOC YYMALLOC
504 # define YYSTACK_FREE YYFREE
505 # ifndef YYSTACK_ALLOC_MAXIMUM
506 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
507 # endif
508 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
509 && ! ((defined YYMALLOC || defined malloc) \
510 && (defined YYFREE || defined free)))
511 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
512 # ifndef EXIT_SUCCESS
513 # define EXIT_SUCCESS 0
514 # endif
515 # endif
516 # ifndef YYMALLOC
517 # define YYMALLOC malloc
518 # if ! defined malloc && ! defined EXIT_SUCCESS
519 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
520 # endif
521 # endif
522 # ifndef YYFREE
523 # define YYFREE free
524 # if ! defined free && ! defined EXIT_SUCCESS
525 void free (void *); /* INFRINGES ON USER NAME SPACE */
526 # endif
527 # endif
528 # endif
529 # define YYCOPY_NEEDED 1
530 #endif /* 1 */
532 #if (! defined yyoverflow \
533 && (! defined __cplusplus \
534 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
536 /* A type that is properly aligned for any stack member. */
537 union yyalloc
539 yy_state_t yyss_alloc;
540 YYSTYPE yyvs_alloc;
543 /* The size of the maximum gap between one aligned stack and the next. */
544 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
546 /* The size of an array large to enough to hold all stacks, each with
547 N elements. */
548 # define YYSTACK_BYTES(N) \
549 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
550 + YYSTACK_GAP_MAXIMUM)
552 # define YYCOPY_NEEDED 1
554 /* Relocate STACK from its old location to the new one. The
555 local variables YYSIZE and YYSTACKSIZE give the old and new number of
556 elements in the stack, and YYPTR gives the new location of the
557 stack. Advance YYPTR to a properly aligned location for the next
558 stack. */
559 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
560 do \
562 YYPTRDIFF_T yynewbytes; \
563 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
564 Stack = &yyptr->Stack_alloc; \
565 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
566 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
568 while (0)
570 #endif
572 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
573 /* Copy COUNT objects from SRC to DST. The source and destination do
574 not overlap. */
575 # ifndef YYCOPY
576 # if defined __GNUC__ && 1 < __GNUC__
577 # define YYCOPY(Dst, Src, Count) \
578 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
579 # else
580 # define YYCOPY(Dst, Src, Count) \
581 do \
583 YYPTRDIFF_T yyi; \
584 for (yyi = 0; yyi < (Count); yyi++) \
585 (Dst)[yyi] = (Src)[yyi]; \
587 while (0)
588 # endif
589 # endif
590 #endif /* !YYCOPY_NEEDED */
592 /* YYFINAL -- State number of the termination state. */
593 #define YYFINAL 2
594 /* YYLAST -- Last index in YYTABLE. */
595 #define YYLAST 66
597 /* YYNTOKENS -- Number of terminals. */
598 #define YYNTOKENS 20
599 /* YYNNTS -- Number of nonterminals. */
600 #define YYNNTS 21
601 /* YYNRULES -- Number of rules. */
602 #define YYNRULES 40
603 /* YYNSTATES -- Number of states. */
604 #define YYNSTATES 71
606 /* YYMAXUTOK -- Last valid token kind. */
607 #define YYMAXUTOK 267
610 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
611 as returned by yylex, with out-of-bounds checking. */
612 #define YYTRANSLATE(YYX) \
613 (0 <= (YYX) && (YYX) <= YYMAXUTOK \
614 ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
615 : YYSYMBOL_YYUNDEF)
617 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
618 as returned by yylex. */
619 static const yytype_int8 yytranslate[] =
621 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
622 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
623 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
624 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
625 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
626 2, 2, 2, 2, 2, 2, 2, 2, 6, 2,
627 2, 19, 2, 2, 11, 2, 2, 2, 2, 2,
628 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
629 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
630 2, 9, 2, 10, 2, 2, 2, 2, 2, 2,
631 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
632 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
633 2, 2, 2, 7, 2, 8, 2, 2, 2, 2,
634 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
635 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
636 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
637 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
638 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
639 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
640 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
641 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
642 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
643 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
644 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
645 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
646 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
647 5, 12, 13, 14, 15, 16, 17, 18
650 #if YYDEBUG
651 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
652 static const yytype_int16 yyrline[] =
654 0, 317, 317, 318, 319, 320, 321, 322, 325, 331,
655 335, 348, 352, 358, 364, 372, 382, 386, 392, 403,
656 407, 413, 417, 423, 431, 440, 444, 448, 452, 458,
657 462, 469, 473, 479, 484, 492, 497, 505, 517, 544,
660 #endif
662 /** Accessing symbol of state STATE. */
663 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
665 #if 1
666 /* The user-facing name of the symbol whose (internal) number is
667 YYSYMBOL. No bounds checking. */
668 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
670 static const char *
671 yysymbol_name (yysymbol_kind_t yysymbol)
673 static const char *const yy_sname[] =
675 N_("end of input"), N_("error"), N_("invalid token"), N_("string"),
676 N_("name"), N_("value"), "':'", "'{'", "'}'", "'['", "']'", "'@'", "->",
677 "+=", N_("'description' keyword"), N_("'rule' keyword"),
678 N_("'target' keyword"), N_("'variable' keyword"),
679 N_("'virtual' keyword"), "'='", "$accept", "program", "name", "string",
680 "strings_or_nothing", "variable", "description", "rule", "out", "in",
681 "apply_rule", "value", "strings", "apply_rules",
682 "apply_rules_or_nothing", "dependencies", "files", "target_name",
683 "virtual_target_name", "virtual_target", "target", YY_NULLPTR
685 /* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
686 internationalizable. */
687 static yytype_int8 yytranslatable[] =
689 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
690 0, 0, 0, 0, 1, 1, 1, 1, 1, 0
692 return (yysymbol < YYNTOKENS && yytranslatable[yysymbol]
693 ? _(yy_sname[yysymbol])
694 : yy_sname[yysymbol]);
696 #endif
698 #define YYPACT_NINF (-26)
700 #define yypact_value_is_default(Yyn) \
701 ((Yyn) == YYPACT_NINF)
703 #define YYTABLE_NINF (-17)
705 #define yytable_value_is_error(Yyn) \
708 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
709 STATE-NUM. */
710 static const yytype_int8 yypact[] =
712 -26, 25, -26, -26, -26, -2, 19, 13, 12, -9,
713 -26, 16, -26, -26, -26, 24, -26, -26, -26, -26,
714 29, 26, 19, 42, 45, 13, 19, 33, 39, 46,
715 -26, 29, 33, 33, 47, 48, -26, -26, 43, 33,
716 49, 33, 39, 3, 52, 43, 33, -26, -26, -26,
717 43, 13, -26, 53, 49, -26, -26, 10, 33, -26,
718 15, -26, -26, -26, 51, 43, -26, -26, 19, -26,
722 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
723 Performed when YYTABLE does not specify something else to do. Zero
724 means the default is an error. */
725 static const yytype_int8 yydefact[] =
727 2, 0, 1, 7, 8, 0, 0, 0, 0, 0,
728 6, 0, 3, 5, 4, 0, 9, 24, 37, 10,
729 33, 0, 0, 0, 0, 0, 0, 0, 35, 0,
730 38, 33, 0, 11, 0, 0, 25, 26, 34, 0,
731 31, 11, 35, 0, 0, 12, 0, 17, 27, 28,
732 36, 0, 40, 0, 31, 15, 14, 0, 21, 29,
733 0, 13, 39, 18, 19, 22, 32, 30, 0, 23,
737 /* YYPGOTO[NTERM-NUM]. */
738 static const yytype_int8 yypgoto[] =
740 -26, -26, 2, -21, 14, -26, -26, -26, -26, -26,
741 -3, -6, -25, -26, 11, 35, 22, -26, -26, -26,
745 /* YYDEFGOTO[NTERM-NUM]. */
746 static const yytype_int8 yydefgoto[] =
748 0, 1, 58, 18, 44, 10, 11, 12, 69, 64,
749 59, 37, 45, 60, 52, 28, 40, 20, 31, 13,
753 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
754 positive, shift that token. If negative, reduce the rule whose
755 number is the opposite. If YYTABLE_NINF, syntax error. */
756 static const yytype_int8 yytable[] =
758 19, 30, 38, 9, 23, 35, 48, 43, 17, 21,
759 24, 55, 15, 48, 50, 17, 19, 4, 63, 4,
760 19, 57, 16, 66, 17, 2, 3, 34, 22, 4,
761 26, 25, 49, 65, 5, 27, 36, 49, 17, 49,
762 -16, 6, 7, 8, 49, 29, 48, 70, 17, 32,
763 39, 49, 33, 41, 46, 53, 51, 67, 47, 49,
764 56, 61, 19, 68, 54, 62, 42
767 static const yytype_int8 yycheck[] =
769 6, 22, 27, 1, 13, 26, 3, 32, 5, 7,
770 19, 8, 14, 3, 39, 5, 22, 4, 8, 4,
771 26, 46, 3, 8, 5, 0, 1, 25, 16, 4,
772 6, 15, 38, 58, 9, 6, 3, 43, 5, 45,
773 15, 16, 17, 18, 50, 19, 3, 68, 5, 7,
774 11, 57, 7, 7, 7, 41, 7, 60, 10, 65,
775 8, 8, 68, 12, 42, 54, 31
778 /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
779 state STATE-NUM. */
780 static const yytype_int8 yystos[] =
782 0, 21, 0, 1, 4, 9, 16, 17, 18, 22,
783 25, 26, 27, 39, 40, 14, 3, 5, 23, 31,
784 37, 22, 16, 13, 19, 15, 6, 6, 35, 19,
785 23, 38, 7, 7, 22, 23, 3, 31, 32, 11,
786 36, 7, 35, 32, 24, 32, 7, 10, 3, 31,
787 32, 7, 34, 24, 36, 8, 8, 32, 22, 30,
788 33, 8, 34, 8, 29, 32, 8, 30, 12, 28,
792 /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
793 static const yytype_int8 yyr1[] =
795 0, 20, 21, 21, 21, 21, 21, 21, 22, 23,
796 23, 24, 24, 25, 25, 25, 26, 26, 27, 28,
797 28, 29, 29, 30, 31, 32, 32, 32, 32, 33,
798 33, 34, 34, 35, 35, 36, 36, 37, 38, 39,
802 /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
803 static const yytype_int8 yyr2[] =
805 0, 2, 0, 2, 2, 2, 2, 2, 1, 1,
806 1, 0, 1, 6, 5, 5, 0, 5, 6, 0,
807 2, 0, 1, 3, 1, 1, 1, 2, 2, 1,
808 2, 0, 3, 0, 2, 0, 2, 1, 1, 6,
813 enum { YYENOMEM = -2 };
815 #define yyerrok (yyerrstatus = 0)
816 #define yyclearin (yychar = YYTOKEN_YYEMPTY)
818 #define YYACCEPT goto yyacceptlab
819 #define YYABORT goto yyabortlab
820 #define YYERROR goto yyerrorlab
821 #define YYNOMEM goto yyexhaustedlab
824 #define YYRECOVERING() (!!yyerrstatus)
826 #define YYBACKUP(Token, Value) \
827 do \
828 if (yychar == YYTOKEN_YYEMPTY) \
830 yychar = (Token); \
831 yylval = (Value); \
832 YYPOPSTACK (yylen); \
833 yystate = *yyssp; \
834 YY_LAC_DISCARD ("YYBACKUP"); \
835 goto yybackup; \
837 else \
839 yyerror (yylocation, yyscanner, context, YY_("syntax error: cannot back up")); \
840 YYERROR; \
842 while (0)
844 /* Backward compatibility with an undocumented macro.
845 Use YYTOKEN_YYerror or YYTOKEN_YYUNDEF. */
846 #define YYERRCODE YYTOKEN_YYUNDEF
849 /* Enable debugging if requested. */
850 #if YYDEBUG
852 # ifndef YYFPRINTF
853 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
854 # define YYFPRINTF fprintf
855 # endif
857 # define YYDPRINTF(Args) \
858 do { \
859 if (yydebug) \
860 YYFPRINTF Args; \
861 } while (0)
866 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
867 do { \
868 if (yydebug) \
870 YYFPRINTF (stderr, "%s ", Title); \
871 yy_symbol_print (stderr, \
872 Kind, Value, yylocation, yyscanner, context); \
873 YYFPRINTF (stderr, "\n"); \
875 } while (0)
878 /*-----------------------------------.
879 | Print this symbol's value on YYO. |
880 `-----------------------------------*/
882 static void
883 yy_symbol_value_print (FILE *yyo,
884 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE *yylocation, yyscan_t yyscanner, struct build_context *context)
886 FILE *yyoutput = yyo;
887 YY_USE (yyoutput);
888 YY_USE (yylocation);
889 YY_USE (yyscanner);
890 YY_USE (context);
891 if (!yyvaluep)
892 return;
893 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
894 YY_USE (yykind);
895 YY_IGNORE_MAYBE_UNINITIALIZED_END
899 /*---------------------------.
900 | Print this symbol on YYO. |
901 `---------------------------*/
903 static void
904 yy_symbol_print (FILE *yyo,
905 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE *yylocation, yyscan_t yyscanner, struct build_context *context)
907 YYFPRINTF (yyo, "%s %s (",
908 yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
910 yy_symbol_value_print (yyo, yykind, yyvaluep, yylocation, yyscanner, context);
911 YYFPRINTF (yyo, ")");
914 /*------------------------------------------------------------------.
915 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
916 | TOP (included). |
917 `------------------------------------------------------------------*/
919 static void
920 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
922 YYFPRINTF (stderr, "Stack now");
923 for (; yybottom <= yytop; yybottom++)
925 int yybot = *yybottom;
926 YYFPRINTF (stderr, " %d", yybot);
928 YYFPRINTF (stderr, "\n");
931 # define YY_STACK_PRINT(Bottom, Top) \
932 do { \
933 if (yydebug) \
934 yy_stack_print ((Bottom), (Top)); \
935 } while (0)
938 /*------------------------------------------------.
939 | Report that the YYRULE is going to be reduced. |
940 `------------------------------------------------*/
942 static void
943 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
944 int yyrule, YYLTYPE *yylocation, yyscan_t yyscanner, struct build_context *context)
946 int yylno = yyrline[yyrule];
947 int yynrhs = yyr2[yyrule];
948 int yyi;
949 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
950 yyrule - 1, yylno);
951 /* The symbols being reduced. */
952 for (yyi = 0; yyi < yynrhs; yyi++)
954 YYFPRINTF (stderr, " $%d = ", yyi + 1);
955 yy_symbol_print (stderr,
956 YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
957 &yyvsp[(yyi + 1) - (yynrhs)], yylocation, yyscanner, context);
958 YYFPRINTF (stderr, "\n");
962 # define YY_REDUCE_PRINT(Rule) \
963 do { \
964 if (yydebug) \
965 yy_reduce_print (yyssp, yyvsp, Rule, yylocation, yyscanner, context); \
966 } while (0)
968 /* Nonzero means print parse trace. It is left uninitialized so that
969 multiple parsers can coexist. */
970 int yydebug;
971 #else /* !YYDEBUG */
972 # define YYDPRINTF(Args) ((void) 0)
973 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
974 # define YY_STACK_PRINT(Bottom, Top)
975 # define YY_REDUCE_PRINT(Rule)
976 #endif /* !YYDEBUG */
979 /* YYINITDEPTH -- initial size of the parser's stacks. */
980 #ifndef YYINITDEPTH
981 # define YYINITDEPTH 200
982 #endif
984 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
985 if the built-in stack extension method is used).
987 Do not make this value too large; the results are undefined if
988 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
989 evaluated with infinite-precision integer arithmetic. */
991 #ifndef YYMAXDEPTH
992 # define YYMAXDEPTH 10000
993 #endif
996 /* Given a state stack such that *YYBOTTOM is its bottom, such that
997 *YYTOP is either its top or is YYTOP_EMPTY to indicate an empty
998 stack, and such that *YYCAPACITY is the maximum number of elements it
999 can hold without a reallocation, make sure there is enough room to
1000 store YYADD more elements. If not, allocate a new stack using
1001 YYSTACK_ALLOC, copy the existing elements, and adjust *YYBOTTOM,
1002 *YYTOP, and *YYCAPACITY to reflect the new capacity and memory
1003 location. If *YYBOTTOM != YYBOTTOM_NO_FREE, then free the old stack
1004 using YYSTACK_FREE. Return 0 if successful or if no reallocation is
1005 required. Return YYENOMEM if memory is exhausted. */
1006 static int
1007 yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
1008 #if YYDEBUG
1009 char const *yydebug_prefix,
1010 char const *yydebug_suffix,
1011 #endif
1012 yy_state_t **yybottom,
1013 yy_state_t *yybottom_no_free,
1014 yy_state_t **yytop, yy_state_t *yytop_empty)
1016 YYPTRDIFF_T yysize_old =
1017 *yytop == yytop_empty ? 0 : *yytop - *yybottom + 1;
1018 YYPTRDIFF_T yysize_new = yysize_old + yyadd;
1019 if (*yycapacity < yysize_new)
1021 YYPTRDIFF_T yyalloc = 2 * yysize_new;
1022 yy_state_t *yybottom_new;
1023 /* Use YYMAXDEPTH for maximum stack size given that the stack
1024 should never need to grow larger than the main state stack
1025 needs to grow without LAC. */
1026 if (YYMAXDEPTH < yysize_new)
1028 YYDPRINTF ((stderr, "%smax size exceeded%s", yydebug_prefix,
1029 yydebug_suffix));
1030 return YYENOMEM;
1032 if (YYMAXDEPTH < yyalloc)
1033 yyalloc = YYMAXDEPTH;
1034 yybottom_new =
1035 YY_CAST (yy_state_t *,
1036 YYSTACK_ALLOC (YY_CAST (YYSIZE_T,
1037 yyalloc * YYSIZEOF (*yybottom_new))));
1038 if (!yybottom_new)
1040 YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix,
1041 yydebug_suffix));
1042 return YYENOMEM;
1044 if (*yytop != yytop_empty)
1046 YYCOPY (yybottom_new, *yybottom, yysize_old);
1047 *yytop = yybottom_new + (yysize_old - 1);
1049 if (*yybottom != yybottom_no_free)
1050 YYSTACK_FREE (*yybottom);
1051 *yybottom = yybottom_new;
1052 *yycapacity = yyalloc;
1054 return 0;
1057 /* Establish the initial context for the current lookahead if no initial
1058 context is currently established.
1060 We define a context as a snapshot of the parser stacks. We define
1061 the initial context for a lookahead as the context in which the
1062 parser initially examines that lookahead in order to select a
1063 syntactic action. Thus, if the lookahead eventually proves
1064 syntactically unacceptable (possibly in a later context reached via a
1065 series of reductions), the initial context can be used to determine
1066 the exact set of tokens that would be syntactically acceptable in the
1067 lookahead's place. Moreover, it is the context after which any
1068 further semantic actions would be erroneous because they would be
1069 determined by a syntactically unacceptable token.
1071 YY_LAC_ESTABLISH should be invoked when a reduction is about to be
1072 performed in an inconsistent state (which, for the purposes of LAC,
1073 includes consistent states that don't know they're consistent because
1074 their default reductions have been disabled). Iff there is a
1075 lookahead token, it should also be invoked before reporting a syntax
1076 error. This latter case is for the sake of the debugging output.
1078 For parse.lac=full, the implementation of YY_LAC_ESTABLISH is as
1079 follows. If no initial context is currently established for the
1080 current lookahead, then check if that lookahead can eventually be
1081 shifted if syntactic actions continue from the current context.
1082 Report a syntax error if it cannot. */
1083 #define YY_LAC_ESTABLISH \
1084 do { \
1085 if (!yy_lac_established) \
1087 YYDPRINTF ((stderr, \
1088 "LAC: initial context established for %s\n", \
1089 yysymbol_name (yytoken))); \
1090 yy_lac_established = 1; \
1091 switch (yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken)) \
1093 case YYENOMEM: \
1094 YYNOMEM; \
1095 case 1: \
1096 goto yyerrlab; \
1099 } while (0)
1101 /* Discard any previous initial lookahead context because of Event,
1102 which may be a lookahead change or an invalidation of the currently
1103 established initial context for the current lookahead.
1105 The most common example of a lookahead change is a shift. An example
1106 of both cases is syntax error recovery. That is, a syntax error
1107 occurs when the lookahead is syntactically erroneous for the
1108 currently established initial context, so error recovery manipulates
1109 the parser stacks to try to find a new initial context in which the
1110 current lookahead is syntactically acceptable. If it fails to find
1111 such a context, it discards the lookahead. */
1112 #if YYDEBUG
1113 # define YY_LAC_DISCARD(Event) \
1114 do { \
1115 if (yy_lac_established) \
1117 YYDPRINTF ((stderr, "LAC: initial context discarded due to " \
1118 Event "\n")); \
1119 yy_lac_established = 0; \
1121 } while (0)
1122 #else
1123 # define YY_LAC_DISCARD(Event) yy_lac_established = 0
1124 #endif
1126 /* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can
1127 eventually (after perhaps some reductions) be shifted, return 1 if
1128 not, or return YYENOMEM if memory is exhausted. As preconditions and
1129 postconditions: *YYES_CAPACITY is the allocated size of the array to
1130 which *YYES points, and either *YYES = YYESA or *YYES points to an
1131 array allocated with YYSTACK_ALLOC. yy_lac may overwrite the
1132 contents of either array, alter *YYES and *YYES_CAPACITY, and free
1133 any old *YYES other than YYESA. */
1134 static int
1135 yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
1136 YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, yysymbol_kind_t yytoken)
1138 yy_state_t *yyes_prev = yyssp;
1139 yy_state_t *yyesp = yyes_prev;
1140 /* Reduce until we encounter a shift and thereby accept the token. */
1141 YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yysymbol_name (yytoken)));
1142 if (yytoken == YYSYMBOL_YYUNDEF)
1144 YYDPRINTF ((stderr, " Always Err\n"));
1145 return 1;
1147 while (1)
1149 int yyrule = yypact[+*yyesp];
1150 if (yypact_value_is_default (yyrule)
1151 || (yyrule += yytoken) < 0 || YYLAST < yyrule
1152 || yycheck[yyrule] != yytoken)
1154 /* Use the default action. */
1155 yyrule = yydefact[+*yyesp];
1156 if (yyrule == 0)
1158 YYDPRINTF ((stderr, " Err\n"));
1159 return 1;
1162 else
1164 /* Use the action from yytable. */
1165 yyrule = yytable[yyrule];
1166 if (yytable_value_is_error (yyrule))
1168 YYDPRINTF ((stderr, " Err\n"));
1169 return 1;
1171 if (0 < yyrule)
1173 YYDPRINTF ((stderr, " S%d\n", yyrule));
1174 return 0;
1176 yyrule = -yyrule;
1178 /* By now we know we have to simulate a reduce. */
1179 YYDPRINTF ((stderr, " R%d", yyrule - 1));
1181 /* Pop the corresponding number of values from the stack. */
1182 YYPTRDIFF_T yylen = yyr2[yyrule];
1183 /* First pop from the LAC stack as many tokens as possible. */
1184 if (yyesp != yyes_prev)
1186 YYPTRDIFF_T yysize = yyesp - *yyes + 1;
1187 if (yylen < yysize)
1189 yyesp -= yylen;
1190 yylen = 0;
1192 else
1194 yyesp = yyes_prev;
1195 yylen -= yysize;
1198 /* Only afterwards look at the main stack. */
1199 if (yylen)
1200 yyesp = yyes_prev -= yylen;
1202 /* Push the resulting state of the reduction. */
1204 yy_state_fast_t yystate;
1206 const int yylhs = yyr1[yyrule] - YYNTOKENS;
1207 const int yyi = yypgoto[yylhs] + *yyesp;
1208 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyesp
1209 ? yytable[yyi]
1210 : yydefgoto[yylhs]);
1212 if (yyesp == yyes_prev)
1214 yyesp = *yyes;
1215 YY_IGNORE_USELESS_CAST_BEGIN
1216 *yyesp = YY_CAST (yy_state_t, yystate);
1217 YY_IGNORE_USELESS_CAST_END
1219 else
1221 if (yy_lac_stack_realloc (yyes_capacity, 1,
1222 #if YYDEBUG
1223 " (", ")",
1224 #endif
1225 yyes, yyesa, &yyesp, yyes_prev))
1227 YYDPRINTF ((stderr, "\n"));
1228 return YYENOMEM;
1230 YY_IGNORE_USELESS_CAST_BEGIN
1231 *++yyesp = YY_CAST (yy_state_t, yystate);
1232 YY_IGNORE_USELESS_CAST_END
1234 YYDPRINTF ((stderr, " G%d", yystate));
1239 /* Context of a parse error. */
1240 typedef struct
1242 yy_state_t *yyssp;
1243 yy_state_t *yyesa;
1244 yy_state_t **yyes;
1245 YYPTRDIFF_T *yyes_capacity;
1246 yysymbol_kind_t yytoken;
1247 } yypcontext_t;
1249 /* Put in YYARG at most YYARGN of the expected tokens given the
1250 current YYCTX, and return the number of tokens stored in YYARG. If
1251 YYARG is null, return the number of expected tokens (guaranteed to
1252 be less than YYNTOKENS). Return YYENOMEM on memory exhaustion.
1253 Return 0 if there are more than YYARGN expected tokens, yet fill
1254 YYARG up to YYARGN. */
1255 static int
1256 yypcontext_expected_tokens (const yypcontext_t *yyctx,
1257 yysymbol_kind_t yyarg[], int yyargn)
1259 /* Actual size of YYARG. */
1260 int yycount = 0;
1262 int yyx;
1263 for (yyx = 0; yyx < YYNTOKENS; ++yyx)
1265 yysymbol_kind_t yysym = YY_CAST (yysymbol_kind_t, yyx);
1266 if (yysym != YYSYMBOL_YYerror && yysym != YYSYMBOL_YYUNDEF)
1267 switch (yy_lac (yyctx->yyesa, yyctx->yyes, yyctx->yyes_capacity, yyctx->yyssp, yysym))
1269 case YYENOMEM:
1270 return YYENOMEM;
1271 case 1:
1272 continue;
1273 default:
1274 if (!yyarg)
1275 ++yycount;
1276 else if (yycount == yyargn)
1277 return 0;
1278 else
1279 yyarg[yycount++] = yysym;
1282 if (yyarg && yycount == 0 && 0 < yyargn)
1283 yyarg[0] = YYSYMBOL_YYEMPTY;
1284 return yycount;
1290 /* The kind of the lookahead of this context. */
1291 static yysymbol_kind_t
1292 yypcontext_token (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED;
1294 static yysymbol_kind_t
1295 yypcontext_token (const yypcontext_t *yyctx)
1297 return yyctx->yytoken;
1302 /* User defined function to report a syntax error. */
1303 static int
1304 yyreport_syntax_error (const yypcontext_t *yyctx, YYLTYPE *yylocation, yyscan_t yyscanner, struct build_context *context);
1306 /*-----------------------------------------------.
1307 | Release the memory associated to this symbol. |
1308 `-----------------------------------------------*/
1310 static void
1311 yydestruct (const char *yymsg,
1312 yysymbol_kind_t yykind, YYSTYPE *yyvaluep, YYLTYPE *yylocation, yyscan_t yyscanner, struct build_context *context)
1314 YY_USE (yyvaluep);
1315 YY_USE (yylocation);
1316 YY_USE (yyscanner);
1317 YY_USE (context);
1318 if (!yymsg)
1319 yymsg = "Deleting";
1320 YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1322 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1323 YY_USE (yykind);
1324 YY_IGNORE_MAYBE_UNINITIALIZED_END
1332 /*----------.
1333 | yyparse. |
1334 `----------*/
1337 yyparse (YYLTYPE *yylocation, yyscan_t yyscanner, struct build_context *context)
1339 /* Lookahead token kind. */
1340 int yychar;
1343 /* The semantic value of the lookahead symbol. */
1344 /* Default value used for initialization, for pacifying older GCCs
1345 or non-GCC compilers. */
1346 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1347 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1349 /* Number of syntax errors so far. */
1350 int yynerrs = 0;
1352 yy_state_fast_t yystate = 0;
1353 /* Number of tokens to shift before error messages enabled. */
1354 int yyerrstatus = 0;
1356 /* Refer to the stacks through separate pointers, to allow yyoverflow
1357 to reallocate them elsewhere. */
1359 /* Their size. */
1360 YYPTRDIFF_T yystacksize = YYINITDEPTH;
1362 /* The state stack: array, bottom, top. */
1363 yy_state_t yyssa[YYINITDEPTH];
1364 yy_state_t *yyss = yyssa;
1365 yy_state_t *yyssp = yyss;
1367 /* The semantic value stack: array, bottom, top. */
1368 YYSTYPE yyvsa[YYINITDEPTH];
1369 YYSTYPE *yyvs = yyvsa;
1370 YYSTYPE *yyvsp = yyvs;
1372 yy_state_t yyesa[20];
1373 yy_state_t *yyes = yyesa;
1374 YYPTRDIFF_T yyes_capacity = 20 < YYMAXDEPTH ? 20 : YYMAXDEPTH;
1376 /* Whether LAC context is established. A Boolean. */
1377 int yy_lac_established = 0;
1378 int yyn;
1379 /* The return value of yyparse. */
1380 int yyresult;
1381 /* Lookahead symbol kind. */
1382 yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1383 /* The variables used to return semantic value and location from the
1384 action routines. */
1385 YYSTYPE yyval;
1389 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1391 /* The number of symbols on the RHS of the reduced rule.
1392 Keep to zero when no symbol should be popped. */
1393 int yylen = 0;
1395 YYDPRINTF ((stderr, "Starting parse\n"));
1397 yychar = YYTOKEN_YYEMPTY; /* Cause a token to be read. */
1399 goto yysetstate;
1402 /*------------------------------------------------------------.
1403 | yynewstate -- push a new state, which is found in yystate. |
1404 `------------------------------------------------------------*/
1405 yynewstate:
1406 /* In all cases, when you get here, the value and location stacks
1407 have just been pushed. So pushing a state here evens the stacks. */
1408 yyssp++;
1411 /*--------------------------------------------------------------------.
1412 | yysetstate -- set current state (the top of the stack) to yystate. |
1413 `--------------------------------------------------------------------*/
1414 yysetstate:
1415 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1416 YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1417 YY_IGNORE_USELESS_CAST_BEGIN
1418 *yyssp = YY_CAST (yy_state_t, yystate);
1419 YY_IGNORE_USELESS_CAST_END
1420 YY_STACK_PRINT (yyss, yyssp);
1422 if (yyss + yystacksize - 1 <= yyssp)
1423 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1424 YYNOMEM;
1425 #else
1427 /* Get the current used size of the three stacks, in elements. */
1428 YYPTRDIFF_T yysize = yyssp - yyss + 1;
1430 # if defined yyoverflow
1432 /* Give user a chance to reallocate the stack. Use copies of
1433 these so that the &'s don't force the real ones into
1434 memory. */
1435 yy_state_t *yyss1 = yyss;
1436 YYSTYPE *yyvs1 = yyvs;
1438 /* Each stack pointer address is followed by the size of the
1439 data in use in that stack, in bytes. This used to be a
1440 conditional around just the two extra args, but that might
1441 be undefined if yyoverflow is a macro. */
1442 yyoverflow (YY_("memory exhausted"),
1443 &yyss1, yysize * YYSIZEOF (*yyssp),
1444 &yyvs1, yysize * YYSIZEOF (*yyvsp),
1445 &yystacksize);
1446 yyss = yyss1;
1447 yyvs = yyvs1;
1449 # else /* defined YYSTACK_RELOCATE */
1450 /* Extend the stack our own way. */
1451 if (YYMAXDEPTH <= yystacksize)
1452 YYNOMEM;
1453 yystacksize *= 2;
1454 if (YYMAXDEPTH < yystacksize)
1455 yystacksize = YYMAXDEPTH;
1458 yy_state_t *yyss1 = yyss;
1459 union yyalloc *yyptr =
1460 YY_CAST (union yyalloc *,
1461 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1462 if (! yyptr)
1463 YYNOMEM;
1464 YYSTACK_RELOCATE (yyss_alloc, yyss);
1465 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1466 # undef YYSTACK_RELOCATE
1467 if (yyss1 != yyssa)
1468 YYSTACK_FREE (yyss1);
1470 # endif
1472 yyssp = yyss + yysize - 1;
1473 yyvsp = yyvs + yysize - 1;
1475 YY_IGNORE_USELESS_CAST_BEGIN
1476 YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1477 YY_CAST (long, yystacksize)));
1478 YY_IGNORE_USELESS_CAST_END
1480 if (yyss + yystacksize - 1 <= yyssp)
1481 YYABORT;
1483 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1486 if (yystate == YYFINAL)
1487 YYACCEPT;
1489 goto yybackup;
1492 /*-----------.
1493 | yybackup. |
1494 `-----------*/
1495 yybackup:
1496 /* Do appropriate processing given the current state. Read a
1497 lookahead token if we need one and don't already have one. */
1499 /* First try to decide what to do without reference to lookahead token. */
1500 yyn = yypact[yystate];
1501 if (yypact_value_is_default (yyn))
1502 goto yydefault;
1504 /* Not known => get a lookahead token if don't already have one. */
1506 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1507 if (yychar == YYTOKEN_YYEMPTY)
1509 YYDPRINTF ((stderr, "Reading a token\n"));
1510 yychar = yylex (&yylval, yylocation, yyscanner);
1513 if (yychar <= YYTOKEN_END)
1515 yychar = YYTOKEN_END;
1516 yytoken = YYSYMBOL_YYEOF;
1517 YYDPRINTF ((stderr, "Now at end of input.\n"));
1519 else if (yychar == YYTOKEN_YYerror)
1521 /* The scanner already issued an error message, process directly
1522 to error recovery. But do not keep the error token as
1523 lookahead, it is too special and may lead us to an endless
1524 loop in error recovery. */
1525 yychar = YYTOKEN_YYUNDEF;
1526 yytoken = YYSYMBOL_YYerror;
1527 goto yyerrlab1;
1529 else
1531 yytoken = YYTRANSLATE (yychar);
1532 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1535 /* If the proper action on seeing token YYTOKEN is to reduce or to
1536 detect an error, take that action. */
1537 yyn += yytoken;
1538 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1540 YY_LAC_ESTABLISH;
1541 goto yydefault;
1543 yyn = yytable[yyn];
1544 if (yyn <= 0)
1546 if (yytable_value_is_error (yyn))
1547 goto yyerrlab;
1548 yyn = -yyn;
1549 YY_LAC_ESTABLISH;
1550 goto yyreduce;
1553 /* Count tokens shifted since error; after three, turn off error
1554 status. */
1555 if (yyerrstatus)
1556 yyerrstatus--;
1558 /* Shift the lookahead token. */
1559 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1560 yystate = yyn;
1561 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1562 *++yyvsp = yylval;
1563 YY_IGNORE_MAYBE_UNINITIALIZED_END
1565 /* Discard the shifted token. */
1566 yychar = YYTOKEN_YYEMPTY;
1567 YY_LAC_DISCARD ("shift");
1568 goto yynewstate;
1571 /*-----------------------------------------------------------.
1572 | yydefault -- do the default action for the current state. |
1573 `-----------------------------------------------------------*/
1574 yydefault:
1575 yyn = yydefact[yystate];
1576 if (yyn == 0)
1577 goto yyerrlab;
1578 goto yyreduce;
1581 /*-----------------------------.
1582 | yyreduce -- do a reduction. |
1583 `-----------------------------*/
1584 yyreduce:
1585 /* yyn is the number of a rule to reduce with. */
1586 yylen = yyr2[yyn];
1588 /* If YYLEN is nonzero, implement the default value of the action:
1589 '$$ = $1'.
1591 Otherwise, the following line sets YYVAL to garbage.
1592 This behavior is undocumented and Bison
1593 users should not rely upon it. Assigning to YYVAL
1594 unconditionally makes the parser a bit smaller, and it avoids a
1595 GCC warning that YYVAL may be used uninitialized. */
1596 yyval = yyvsp[1-yylen];
1599 YY_REDUCE_PRINT (yyn);
1601 int yychar_backup = yychar;
1602 switch (yyn)
1604 case 7: /* program: program error */
1605 #line 322 "parse.y"
1606 { YYABORT; }
1607 #line 1608 "parse.c"
1608 break;
1610 case 8: /* name: "name" */
1611 #line 326 "parse.y"
1613 (yyval.string) = (yyvsp[0].string);
1615 #line 1616 "parse.c"
1616 break;
1618 case 9: /* string: "string" */
1619 #line 332 "parse.y"
1621 (yyval.string) = (yyvsp[0].string);
1623 #line 1624 "parse.c"
1624 break;
1626 case 10: /* string: value */
1627 #line 336 "parse.y"
1629 if (UNLIKELY ((yyvsp[0].strings).count != 1))
1631 warning_at (yylocation, _("unexpected string array, expecting string"));
1632 YYABORT;
1635 (yyval.string) = (yyvsp[0].strings).array[0];
1637 #line 1638 "parse.c"
1638 break;
1640 case 11: /* strings_or_nothing: %empty */
1641 #line 349 "parse.y"
1643 ARRAY_INITIALIZE_EMPTY ((yyval.strings));
1645 #line 1646 "parse.c"
1646 break;
1648 case 12: /* strings_or_nothing: strings */
1649 #line 353 "parse.y"
1651 (yyval.strings) = (yyvsp[0].strings);
1653 #line 1654 "parse.c"
1654 break;
1656 case 13: /* variable: "'variable' keyword" name '=' '{' strings_or_nothing '}' */
1657 #line 359 "parse.y"
1659 if (UNLIKELY (!variable_create (&context->variables, (yyvsp[-4].string),
1660 &(yyvsp[-1].strings))))
1661 YYABORT;
1663 #line 1664 "parse.c"
1664 break;
1666 case 14: /* variable: name '=' '{' strings_or_nothing '}' */
1667 #line 365 "parse.y"
1669 struct variable *variable;
1671 VARIABLE_FIND (variable, (yyvsp[-4].string));
1672 free (variable->value.array);
1673 variable->value = (yyvsp[-1].strings);
1675 #line 1676 "parse.c"
1676 break;
1678 case 15: /* variable: name "+=" '{' strings '}' */
1679 #line 373 "parse.y"
1681 struct variable *variable;
1683 VARIABLE_FIND (variable, (yyvsp[-4].string));
1684 ARRAY_CATENATE (variable->value, (yyvsp[-1].strings));
1685 free ((yyvsp[-1].strings).array);
1687 #line 1688 "parse.c"
1688 break;
1690 case 16: /* description: %empty */
1691 #line 383 "parse.y"
1693 (yyval.string) = NULL;
1695 #line 1696 "parse.c"
1696 break;
1698 case 17: /* description: '[' "'description' keyword" ':' string ']' */
1699 #line 387 "parse.y"
1701 (yyval.string) = (yyvsp[-1].string);
1703 #line 1704 "parse.c"
1704 break;
1706 case 18: /* rule: description "'rule' keyword" name '{' strings '}' */
1707 #line 393 "parse.y"
1709 if (UNLIKELY (!rule_create (&context->rules,
1710 (yyvsp[-3].string),
1711 (yyvsp[-5].string),
1712 &(yyvsp[-1].strings),
1713 &context->variables)))
1714 YYABORT;
1716 #line 1717 "parse.c"
1717 break;
1719 case 19: /* out: %empty */
1720 #line 404 "parse.y"
1722 (yyval.string) = NULL;
1724 #line 1725 "parse.c"
1725 break;
1727 case 20: /* out: "->" string */
1728 #line 408 "parse.y"
1730 (yyval.string) = (yyvsp[0].string);
1732 #line 1733 "parse.c"
1733 break;
1735 case 21: /* in: %empty */
1736 #line 414 "parse.y"
1738 ARRAY_INITIALIZE_EMPTY ((yyval.strings));
1740 #line 1741 "parse.c"
1741 break;
1743 case 22: /* in: strings */
1744 #line 418 "parse.y"
1746 (yyval.strings) = (yyvsp[0].strings);
1748 #line 1749 "parse.c"
1749 break;
1751 case 23: /* apply_rule: name in out */
1752 #line 424 "parse.y"
1754 (yyval.apply_rule).name = (yyvsp[-2].string);
1755 (yyval.apply_rule).in = (yyvsp[-1].strings);
1756 (yyval.apply_rule).out = (yyvsp[0].string);
1758 #line 1759 "parse.c"
1759 break;
1761 case 24: /* value: "value" */
1762 #line 432 "parse.y"
1764 struct variable *variable;
1766 VARIABLE_FIND (variable, (yyvsp[0].string));
1767 (yyval.strings) = variable->value;
1769 #line 1770 "parse.c"
1770 break;
1772 case 25: /* strings: "string" */
1773 #line 441 "parse.y"
1775 ARRAY_INITIALIZE ((yyval.strings), (yyvsp[0].string));
1777 #line 1778 "parse.c"
1778 break;
1780 case 26: /* strings: value */
1781 #line 445 "parse.y"
1783 ARRAY_DUPLICATE ((yyval.strings), (yyvsp[0].strings));
1785 #line 1786 "parse.c"
1786 break;
1788 case 27: /* strings: strings "string" */
1789 #line 449 "parse.y"
1791 ARRAY_EXPAND ((yyval.strings), (yyvsp[0].string));
1793 #line 1794 "parse.c"
1794 break;
1796 case 28: /* strings: strings value */
1797 #line 453 "parse.y"
1799 ARRAY_CATENATE ((yyval.strings), (yyvsp[0].strings));
1801 #line 1802 "parse.c"
1802 break;
1804 case 29: /* apply_rules: apply_rule */
1805 #line 459 "parse.y"
1807 ARRAY_INITIALIZE ((yyval.apply_rules), (yyvsp[0].apply_rule));
1809 #line 1810 "parse.c"
1810 break;
1812 case 30: /* apply_rules: apply_rules apply_rule */
1813 #line 463 "parse.y"
1815 ARRAY_EXPAND ((yyval.apply_rules), (yyvsp[0].apply_rule));
1817 #line 1818 "parse.c"
1818 break;
1820 case 31: /* apply_rules_or_nothing: %empty */
1821 #line 470 "parse.y"
1823 ARRAY_INITIALIZE_EMPTY ((yyval.apply_rules));
1825 #line 1826 "parse.c"
1826 break;
1828 case 32: /* apply_rules_or_nothing: '{' apply_rules '}' */
1829 #line 474 "parse.y"
1831 (yyval.apply_rules) = (yyvsp[-1].apply_rules);
1833 #line 1834 "parse.c"
1834 break;
1836 case 33: /* dependencies: %empty */
1837 #line 480 "parse.y"
1839 ARRAY_INITIALIZE_EMPTY ((yyval.strings));
1840 memset (&context->dependencies, '\0', sizeof (context->dependencies));
1842 #line 1843 "parse.c"
1843 break;
1845 case 34: /* dependencies: ':' strings */
1846 #line 485 "parse.y"
1848 VARIABLE_TEMPORARY_DEFINE (context->dependencies,
1849 "dependencies", (yyvsp[0].strings));
1850 (yyval.strings) = (yyvsp[0].strings);
1852 #line 1853 "parse.c"
1853 break;
1855 case 35: /* files: %empty */
1856 #line 493 "parse.y"
1858 ARRAY_INITIALIZE_EMPTY ((yyval.strings));
1859 memset (&context->files, '\0', sizeof (context->files));
1861 #line 1862 "parse.c"
1862 break;
1864 case 36: /* files: '@' strings */
1865 #line 498 "parse.y"
1867 VARIABLE_TEMPORARY_DEFINE (context->files,
1868 "files", (yyvsp[0].strings));
1869 (yyval.strings) = (yyvsp[0].strings);
1871 #line 1872 "parse.c"
1872 break;
1874 case 37: /* target_name: string */
1875 #line 506 "parse.y"
1877 VARIABLE_TEMPORARY_DEFINE (context->target,
1878 "target",
1879 ((struct uniqstr_array) {
1880 .count = 1,
1881 .array = &(yyvsp[0].string) }));
1882 (yyval.string) = (yyvsp[0].string);
1884 #line 1885 "parse.c"
1885 break;
1887 case 38: /* virtual_target_name: string */
1888 #line 518 "parse.y"
1890 void *p = uniqstr_chr ((yyvsp[0].string), '%');
1892 if (UNLIKELY (p == NULL))
1894 warning_at (yylocation,
1895 _("%s: '%%' character expected"),
1896 quote (yyget_extra (yyscanner)->qs,
1897 (yyvsp[0].string)));
1898 YYABORT;
1900 else if (UNLIKELY (memchr ((char *) p + 1, '%', uniqstr_len ((yyvsp[0].string)) - (size_t) (((char *) p + 1 - (yyvsp[0].string)))) != NULL))
1902 warning_at (yylocation, _("%s: found two or more '%%' characters, but only one allowed"), quote (yyget_extra (yyscanner)->qs, (yyvsp[0].string)));
1903 YYABORT;
1906 VARIABLE_TEMPORARY_DEFINE (context->target,
1907 "target",
1908 ((struct uniqstr_array) {
1909 .count = 1,
1910 .array = &(yyvsp[0].string) }));
1911 (yyval.string) = (yyvsp[0].string);
1913 #line 1914 "parse.c"
1914 break;
1916 case 39: /* virtual_target: "'virtual' keyword" "'target' keyword" virtual_target_name dependencies files apply_rules_or_nothing */
1917 #line 545 "parse.y"
1919 if (UNLIKELY (!target_create (NULL,
1920 &context->virtual_targets,
1921 (yyvsp[-3].string),
1922 &(yyvsp[-2].strings),
1923 &(yyvsp[-1].strings),
1924 &(yyvsp[0].apply_rules))))
1925 YYABORT;
1927 /* Target name is never NULL. */
1928 HashRemove (&context->variables,
1929 context->target.name,
1930 uniqstr_len (context->target.name));
1931 VARIABLE_REMOVE (context->files);
1932 VARIABLE_REMOVE (context->dependencies);
1934 #line 1935 "parse.c"
1935 break;
1937 case 40: /* target: "'target' keyword" target_name dependencies files apply_rules_or_nothing */
1938 #line 564 "parse.y"
1940 if (UNLIKELY (!target_create (NULL,
1941 &context->targets,
1942 (yyvsp[-3].string),
1943 &(yyvsp[-2].strings),
1944 &(yyvsp[-1].strings),
1945 &(yyvsp[0].apply_rules))))
1946 YYABORT;
1948 /* Target name is never NULL. */
1949 HashRemove (&context->variables,
1950 context->target.name,
1951 uniqstr_len (context->target.name));
1953 VARIABLE_REMOVE (context->files);
1954 VARIABLE_REMOVE (context->dependencies);
1956 #line 1957 "parse.c"
1957 break;
1960 #line 1961 "parse.c"
1962 default: break;
1964 if (yychar_backup != yychar)
1965 YY_LAC_DISCARD ("yychar change");
1967 /* User semantic actions sometimes alter yychar, and that requires
1968 that yytoken be updated with the new translation. We take the
1969 approach of translating immediately before every use of yytoken.
1970 One alternative is translating here after every semantic action,
1971 but that translation would be missed if the semantic action invokes
1972 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1973 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1974 incorrect destructor might then be invoked immediately. In the
1975 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1976 to an incorrect destructor call or verbose syntax error message
1977 before the lookahead is translated. */
1978 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1980 YYPOPSTACK (yylen);
1981 yylen = 0;
1983 *++yyvsp = yyval;
1985 /* Now 'shift' the result of the reduction. Determine what state
1986 that goes to, based on the state we popped back to and the rule
1987 number reduced by. */
1989 const int yylhs = yyr1[yyn] - YYNTOKENS;
1990 const int yyi = yypgoto[yylhs] + *yyssp;
1991 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1992 ? yytable[yyi]
1993 : yydefgoto[yylhs]);
1996 goto yynewstate;
1999 /*--------------------------------------.
2000 | yyerrlab -- here on detecting error. |
2001 `--------------------------------------*/
2002 yyerrlab:
2003 /* Make sure we have latest lookahead translation. See comments at
2004 user semantic actions for why this is necessary. */
2005 yytoken = yychar == YYTOKEN_YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
2006 /* If not already recovering from an error, report this error. */
2007 if (!yyerrstatus)
2009 ++yynerrs;
2011 yypcontext_t yyctx
2012 = {yyssp, yyesa, &yyes, &yyes_capacity, yytoken};
2013 if (yychar != YYTOKEN_YYEMPTY)
2014 YY_LAC_ESTABLISH;
2015 if (yyreport_syntax_error (&yyctx, yylocation, yyscanner, context) == 2)
2016 YYNOMEM;
2020 if (yyerrstatus == 3)
2022 /* If just tried and failed to reuse lookahead token after an
2023 error, discard it. */
2025 if (yychar <= YYTOKEN_END)
2027 /* Return failure if at end of input. */
2028 if (yychar == YYTOKEN_END)
2029 YYABORT;
2031 else
2033 yydestruct ("Error: discarding",
2034 yytoken, &yylval, yylocation, yyscanner, context);
2035 yychar = YYTOKEN_YYEMPTY;
2039 /* Else will try to reuse lookahead token after shifting the error
2040 token. */
2041 goto yyerrlab1;
2044 /*---------------------------------------------------.
2045 | yyerrorlab -- error raised explicitly by YYERROR. |
2046 `---------------------------------------------------*/
2047 yyerrorlab:
2048 /* Pacify compilers when the user code never invokes YYERROR and the
2049 label yyerrorlab therefore never appears in user code. */
2050 if (0)
2051 YYERROR;
2052 ++yynerrs;
2054 /* Do not reclaim the symbols of the rule whose action triggered
2055 this YYERROR. */
2056 YYPOPSTACK (yylen);
2057 yylen = 0;
2058 YY_STACK_PRINT (yyss, yyssp);
2059 yystate = *yyssp;
2060 goto yyerrlab1;
2063 /*-------------------------------------------------------------.
2064 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2065 `-------------------------------------------------------------*/
2066 yyerrlab1:
2067 yyerrstatus = 3; /* Each real token shifted decrements this. */
2069 /* Pop stack until we find a state that shifts the error token. */
2070 for (;;)
2072 yyn = yypact[yystate];
2073 if (!yypact_value_is_default (yyn))
2075 yyn += YYSYMBOL_YYerror;
2076 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
2078 yyn = yytable[yyn];
2079 if (0 < yyn)
2080 break;
2084 /* Pop the current state because it cannot handle the error token. */
2085 if (yyssp == yyss)
2086 YYABORT;
2089 yydestruct ("Error: popping",
2090 YY_ACCESSING_SYMBOL (yystate), yyvsp, yylocation, yyscanner, context);
2091 YYPOPSTACK (1);
2092 yystate = *yyssp;
2093 YY_STACK_PRINT (yyss, yyssp);
2096 /* If the stack popping above didn't lose the initial context for the
2097 current lookahead token, the shift below will for sure. */
2098 YY_LAC_DISCARD ("error recovery");
2100 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2101 *++yyvsp = yylval;
2102 YY_IGNORE_MAYBE_UNINITIALIZED_END
2105 /* Shift the error token. */
2106 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
2108 yystate = yyn;
2109 goto yynewstate;
2112 /*-------------------------------------.
2113 | yyacceptlab -- YYACCEPT comes here. |
2114 `-------------------------------------*/
2115 yyacceptlab:
2116 yyresult = 0;
2117 goto yyreturnlab;
2120 /*-----------------------------------.
2121 | yyabortlab -- YYABORT comes here. |
2122 `-----------------------------------*/
2123 yyabortlab:
2124 yyresult = 1;
2125 goto yyreturnlab;
2128 /*-----------------------------------------------------------.
2129 | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
2130 `-----------------------------------------------------------*/
2131 yyexhaustedlab:
2132 yyerror (yylocation, yyscanner, context, YY_("memory exhausted"));
2133 yyresult = 2;
2134 goto yyreturnlab;
2137 /*----------------------------------------------------------.
2138 | yyreturnlab -- parsing is finished, clean up and return. |
2139 `----------------------------------------------------------*/
2140 yyreturnlab:
2141 if (yychar != YYTOKEN_YYEMPTY)
2143 /* Make sure we have latest lookahead translation. See comments at
2144 user semantic actions for why this is necessary. */
2145 yytoken = YYTRANSLATE (yychar);
2146 yydestruct ("Cleanup: discarding lookahead",
2147 yytoken, &yylval, yylocation, yyscanner, context);
2149 /* Do not reclaim the symbols of the rule whose action triggered
2150 this YYABORT or YYACCEPT. */
2151 YYPOPSTACK (yylen);
2152 YY_STACK_PRINT (yyss, yyssp);
2153 while (yyssp != yyss)
2155 yydestruct ("Cleanup: popping",
2156 YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, yylocation, yyscanner, context);
2157 YYPOPSTACK (1);
2159 #ifndef yyoverflow
2160 if (yyss != yyssa)
2161 YYSTACK_FREE (yyss);
2162 #endif
2163 if (yyes != yyesa)
2164 YYSTACK_FREE (yyes);
2166 return yyresult;
2169 #line 583 "parse.y"
2172 static inline const char *
2173 error_format_string (int argc)
2175 switch (argc)
2177 default: /* Avoid compiler warnings. */
2178 case 0: return _("%@: syntax error");
2179 case 1: return _("%@: syntax error: unexpected %u");
2180 /* TRANSLATORS: '%@' is a location in a file, '%u' is an
2181 "unexpected token", and '%0e', '%1e'... are expected tokens
2182 at this point.
2184 For instance on the expression "1 + * 2", you would get
2186 '1.5: syntax error: expected - or ( or number or function
2187 or variable before *'. */
2188 case 2: return _("%@: syntax error: expected %0e before %u");
2189 case 3: return _("%@: syntax error: expected %0e or %1e before %u");
2190 case 4: return _("%@: syntax error: expected %0e or %1e or %2e before %u");
2191 case 5: return _("%@: syntax error: expected %0e or %1e or %2e or %3e before %u");
2192 case 6: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e before %u");
2193 case 7: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e before %u");
2194 case 8: return _("%@: syntax error: expected %0e or %1e or %2e or %3e or %4e or %5e etc., before %u");
2198 /* Get line with number "number".
2199 line_offset (if not equal -1) is an
2200 offset of '\n' character before line we need. */
2201 static inline char *
2202 getlinebynumber (FILE *in, int number, off_t line_offset)
2204 off_t old_offset = ftello (in);
2205 char *line = NULL;
2206 size_t size = 0;
2207 int current = 1;
2209 if (UNLIKELY (old_offset < 0))
2210 return NULL;
2212 if (UNLIKELY (fseeko (in, line_offset >= 0 ? line_offset : 0, SEEK_SET) < 0))
2213 return NULL;
2215 if (UNLIKELY (line_offset < 0))
2217 /* Find required line by ourselves. */
2218 int c = '\0';
2220 while (current != number && (c = getc (in)) != EOF)
2221 if (c == '\n')
2222 current++;
2224 if (UNLIKELY (c == EOF))
2225 return NULL;
2228 if (UNLIKELY (getline (&line, &size, in) < 0))
2229 return NULL;
2231 if (UNLIKELY (fseeko (in, old_offset, SEEK_SET) < 0))
2233 free (line);
2234 return NULL;
2237 return line;
2240 /* Return the number of digits of 'x'
2241 when converted to string in radix 10. */
2242 static inline NODISCARD int CONST
2243 int_width (int x)
2245 assert (x >= 0);
2247 if (x < 10) return 1;
2248 if (x < 100) return 2;
2249 if (x < 1000) return 3;
2250 if (x < 10000) return 4;
2251 if (x < 100000) return 5;
2252 if (x < 1000000) return 6;
2253 if (x < 10000000) return 7;
2254 if (x < 100000000) return 8;
2255 if (x < 1000000000) return 9;
2256 static_assert (1000000000 < INT_MAX && INT_MAX < 10000000000,
2257 "int is not 32-bit");
2258 return 10;
2261 static int
2262 yyreport_syntax_error (const yypcontext_t *yyctx,
2263 YYLTYPE *yylocation,
2264 yyscan_t yyscanner,
2265 UNUSED struct build_context *context)
2267 enum { ARGS_MAX = 6 };
2268 yysymbol_kind_t arg[ARGS_MAX];
2269 int argsize = yypcontext_expected_tokens (yyctx, arg, ARGS_MAX);
2270 char *line;
2271 bool too_many_expected_tokens;
2273 if (UNLIKELY (argsize < 0))
2274 return argsize;
2276 too_many_expected_tokens = argsize == 0 && arg[0] != YYSYMBOL_YYEMPTY;
2278 if (UNLIKELY (too_many_expected_tokens))
2279 argsize = ARGS_MAX;
2281 const char *format = error_format_string (1 + argsize + (too_many_expected_tokens ? 1 : 0));
2282 const char *p = format;
2283 const char *s = format;
2284 size_t n = strlen (format);
2285 const char *const end = format + n;
2287 while ((s = memchr (s, '%', n)) != NULL)
2289 if (LIKELY (s != p))
2290 fwrite (p, sizeof (char), (size_t) (s - p), stderr);
2292 s++;
2294 if (s[0] == '@')
2295 { /* %@: location. */
2296 yylocation_print (stderr, yylocation);
2297 s += 1;
2299 else if (s[0] == 'u')
2300 { /* %u: unexpected token. */
2301 fputs (yysymbol_name (yypcontext_token (yyctx)), stderr);
2302 s += 1;
2304 else if (s[0] >= '0' && s[0] <= '9' && s[1] == 'e' && ((s[0] - '0') < argsize))
2305 { /* %0e, %1e...: expected token. */
2306 fputs (yysymbol_name (arg[s[0] - '0']), stderr);
2307 s += 2;
2310 n -= (size_t) (s - p);
2311 p = s;
2314 if (p != end)
2315 fwrite (p, sizeof (char), (size_t) (end - p), stderr);
2317 fputc ('\n', stderr);
2319 /* Quote the source line. */
2320 line = getlinebynumber (yyget_in (yyscanner), yylocation->first_line,
2321 yylocation->newline_offset);
2323 if (LIKELY (line != NULL))
2325 const int width = int_width (yylocation->first_line);
2326 const int offset = yylocation->first_column;
2328 fprintf (stderr, " %*d | %s", width, yylocation->first_line, line);
2329 fprintf (stderr, " %*s | %*s", width, "", offset, "^");
2330 free (line);
2332 for (int i = yylocation->last_column - offset - 1; i > 0; i--)
2333 fputc ('~', stderr);
2335 fputc ('\n', stderr);
2338 return 0;