1 /* A Bison parser, made by GNU Bison 2.3. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, 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 2, or (at your option)
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, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
39 /* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
46 /* Identify Bison output. */
50 #define YYBISON_VERSION "2.3"
53 #define YYSKELETON_NAME "yacc.c"
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
61 /* Substitute the variable and function names. */
62 #define yyparse _lc_opt_parse
63 #define yylex _lc_opt_lex
64 #define yyerror _lc_opt_error
65 #define yylval _lc_opt_lval
66 #define yychar _lc_opt_char
67 #define yydebug _lc_opt_debug
68 #define yynerrs _lc_opt_nerrs
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
90 /* Copy the first part of user declarations. */
95 libcore: library for basic data structures and algorithms.
96 Copyright (C) 2005 IPD Goos, Universit"at Karlsruhe, Germany
98 This library is free software; you can redistribute it and/or
99 modify it under the terms of the GNU Lesser General Public
100 License as published by the Free Software Foundation; either
101 version 2.1 of the License, or (at your option) any later version.
103 This library is distributed in the hope that it will be useful,
104 but WITHOUT ANY WARRANTY; without even the implied warranty of
105 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
106 Lesser General Public License for more details.
108 You should have received a copy of the GNU Lesser General Public
109 License along with this library; if not, write to the Free Software
110 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
116 #include "lc_opts_t.h"
117 #include "lc_parser_t.h"
119 static void group_open(void);
120 static void group_close(void);
121 static void lc_opt_set(void);
122 static void path_push(text_t text);
124 void PMANGLE(error)(const char *str);
129 /* Enabling traces. */
134 /* Enabling verbose error messages. */
135 #ifdef YYERROR_VERBOSE
136 # undef YYERROR_VERBOSE
137 # define YYERROR_VERBOSE 1
139 # define YYERROR_VERBOSE 0
142 /* Enabling the token table. */
143 #ifndef YYTOKEN_TABLE
144 # define YYTOKEN_TABLE 0
147 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
148 typedef union YYSTYPE
154 /* Line 187 of yacc.c. */
157 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
158 # define YYSTYPE_IS_DECLARED 1
159 # define YYSTYPE_IS_TRIVIAL 1
164 /* Copy the second part of user declarations. */
167 /* Line 216 of yacc.c. */
175 typedef YYTYPE_UINT8 yytype_uint8;
177 typedef unsigned char yytype_uint8;
181 typedef YYTYPE_INT8 yytype_int8;
182 #elif (defined __STDC__ || defined __C99__FUNC__ \
183 || defined __cplusplus || defined _MSC_VER)
184 typedef signed char yytype_int8;
186 typedef short int yytype_int8;
190 typedef YYTYPE_UINT16 yytype_uint16;
192 typedef unsigned short int yytype_uint16;
196 typedef YYTYPE_INT16 yytype_int16;
198 typedef short int yytype_int16;
202 # ifdef __SIZE_TYPE__
203 # define YYSIZE_T __SIZE_TYPE__
204 # elif defined size_t
205 # define YYSIZE_T size_t
206 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
207 || defined __cplusplus || defined _MSC_VER)
208 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
209 # define YYSIZE_T size_t
211 # define YYSIZE_T unsigned int
215 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
220 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
221 # define YY_(msgid) dgettext ("bison-runtime", msgid)
225 # define YY_(msgid) msgid
229 /* Suppress unused-variable warnings by "using" E. */
230 #if ! defined lint || defined __GNUC__
231 # define YYUSE(e) ((void) (e))
233 # define YYUSE(e) /* empty */
236 /* Identity function, used to suppress warnings about constant conditions. */
240 #if (defined __STDC__ || defined __C99__FUNC__ \
241 || defined __cplusplus || defined _MSC_VER)
242 static int YYID(int i)
252 #if ! defined yyoverflow || YYERROR_VERBOSE
254 /* The parser invokes alloca or malloc; define the necessary symbols. */
256 # ifdef YYSTACK_USE_ALLOCA
257 # if YYSTACK_USE_ALLOCA
259 # define YYSTACK_ALLOC __builtin_alloca
260 # elif defined __BUILTIN_VA_ARG_INCR
261 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
263 # define YYSTACK_ALLOC __alloca
264 # elif defined _MSC_VER
265 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
266 # define alloca _alloca
268 # define YYSTACK_ALLOC alloca
269 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
270 || defined __cplusplus || defined _MSC_VER)
271 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
280 # ifdef YYSTACK_ALLOC
281 /* Pacify GCC's `empty if-body' warning. */
282 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
283 # ifndef YYSTACK_ALLOC_MAXIMUM
284 /* The OS might guarantee only one guard page at the bottom of the stack,
285 and a page size can be as small as 4096 bytes. So we cannot safely
286 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
287 to allow for a few compiler-allocated temporary stack slots. */
288 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
291 # define YYSTACK_ALLOC YYMALLOC
292 # define YYSTACK_FREE YYFREE
293 # ifndef YYSTACK_ALLOC_MAXIMUM
294 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
296 # if (defined __cplusplus && ! defined _STDLIB_H \
297 && ! ((defined YYMALLOC || defined malloc) \
298 && (defined YYFREE || defined free)))
299 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
305 # define YYMALLOC malloc
306 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
307 || defined __cplusplus || defined _MSC_VER)
308 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
313 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
314 || defined __cplusplus || defined _MSC_VER)
315 void free (void *); /* INFRINGES ON USER NAME SPACE */
319 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
322 #if (! defined yyoverflow \
323 && (! defined __cplusplus \
324 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
326 /* A type that is properly aligned for any stack member. */
333 /* The size of the maximum gap between one aligned stack and the next. */
334 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
336 /* The size of an array large to enough to hold all stacks, each with
338 # define YYSTACK_BYTES(N) \
339 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
340 + YYSTACK_GAP_MAXIMUM)
342 /* Copy COUNT objects from FROM to TO. The source and destination do
345 # if defined __GNUC__ && 1 < __GNUC__
346 # define YYCOPY(To, From, Count) \
347 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
349 # define YYCOPY(To, From, Count) \
353 for (yyi = 0; yyi < (Count); yyi++) \
354 (To)[yyi] = (From)[yyi]; \
360 /* Relocate STACK from its old location to the new one. The
361 local variables YYSIZE and YYSTACKSIZE give the old and new number of
362 elements in the stack, and YYPTR gives the new location of the
363 stack. Advance YYPTR to a properly aligned location for the next
365 # define YYSTACK_RELOCATE(Stack) \
368 YYSIZE_T yynewbytes; \
369 YYCOPY (&yyptr->Stack, Stack, yysize); \
370 Stack = &yyptr->Stack; \
371 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
372 yyptr += yynewbytes / sizeof (*yyptr); \
378 /* YYFINAL -- State number of the termination state. */
380 /* YYLAST -- Last index in YYTABLE. */
383 /* YYNTOKENS -- Number of terminals. */
385 /* YYNNTS -- Number of nonterminals. */
387 /* YYNRULES -- Number of rules. */
389 /* YYNRULES -- Number of states. */
392 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
394 #define YYMAXUTOK 260
396 #define YYTRANSLATE(YYX) \
397 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
399 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
400 static const yytype_uint8 yytranslate[] =
402 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
403 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
404 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
405 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
406 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
407 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
408 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
409 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
410 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
411 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
412 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
414 2, 2, 2, 6, 2, 7, 2, 2, 2, 2,
415 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
422 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
425 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
427 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
432 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
434 static const yytype_uint8 yyprhs[] =
436 0, 0, 3, 5, 7, 9, 12, 14, 16, 17,
440 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
441 static const yytype_int8 yyrhs[] =
443 9, 0, -1, 12, -1, 13, -1, 15, -1, 11,
444 10, -1, 10, -1, 11, -1, -1, -1, 16, 14,
445 6, 12, 7, -1, 16, 4, -1, 16, 3, 5,
449 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
450 static const yytype_uint8 yyrline[] =
452 0, 53, 53, 55, 56, 59, 60, 63, 63, 65,
457 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
458 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
459 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
460 static const char *const yytname[] =
462 "$end", "error", "$undefined", "SEP", "DATA", "IDENT", "'{'", "'}'",
463 "$accept", "main", "decl", "decls", "dseq", "group", "@1", "option",
469 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
471 static const yytype_uint16 yytoknum[] =
473 0, 256, 257, 258, 259, 260, 123, 125
477 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
478 static const yytype_uint8 yyr1[] =
480 0, 8, 9, 10, 10, 11, 11, 12, 12, 14,
484 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
485 static const yytype_uint8 yyr2[] =
487 0, 2, 1, 1, 1, 2, 1, 1, 0, 0,
491 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
492 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
493 means the default is an error. */
494 static const yytype_uint8 yydefact[] =
496 8, 13, 0, 6, 7, 2, 3, 4, 9, 1,
497 5, 0, 11, 0, 12, 8, 0, 10
500 /* YYDEFGOTO[NTERM-NUM]. */
501 static const yytype_int8 yydefgoto[] =
503 -1, 2, 3, 4, 5, 6, 13, 7, 8
506 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
508 #define YYPACT_NINF -11
509 static const yytype_int8 yypact[] =
511 -2, -11, 2, -11, -2, -11, -11, -11, -3, -11,
512 -11, -1, -11, 0, -11, -2, 1, -11
515 /* YYPGOTO[NTERM-NUM]. */
516 static const yytype_int8 yypgoto[] =
518 -11, -11, 3, -11, -10, -11, -11, -11, -11
521 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
522 positive, shift that token. If negative, reduce the rule which
523 number is the opposite. If zero, do what YYDEFACT says.
524 If YYTABLE_NINF, syntax error. */
525 #define YYTABLE_NINF -1
526 static const yytype_uint8 yytable[] =
528 11, 12, 9, 1, 14, 16, 15, 10, 17
531 static const yytype_uint8 yycheck[] =
533 3, 4, 0, 5, 5, 15, 6, 4, 7
536 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
537 symbol of state STATE-NUM. */
538 static const yytype_uint8 yystos[] =
540 0, 5, 9, 10, 11, 12, 13, 15, 16, 0,
541 10, 3, 4, 14, 5, 6, 12, 7
544 #define yyerrok (yyerrstatus = 0)
545 #define yyclearin (yychar = YYEMPTY)
549 #define YYACCEPT goto yyacceptlab
550 #define YYABORT goto yyabortlab
551 #define YYERROR goto yyerrorlab
554 /* Like YYERROR except do call yyerror. This remains here temporarily
555 to ease the transition to the new meaning of YYERROR, for GCC.
556 Once GCC version 2 has supplanted version 1, this can go. */
558 #define YYFAIL goto yyerrlab
560 #define YYRECOVERING() (!!yyerrstatus)
562 #define YYBACKUP(Token, Value) \
564 if (yychar == YYEMPTY && yylen == 1) \
568 yytoken = YYTRANSLATE (yychar); \
574 yyerror (YY_("syntax error: cannot back up")); \
581 #define YYERRCODE 256
584 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
585 If N is 0, then set CURRENT to the empty location which ends
586 the previous symbol: RHS[0] (always defined). */
588 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
589 #ifndef YYLLOC_DEFAULT
590 # define YYLLOC_DEFAULT(Current, Rhs, N) \
594 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
595 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
596 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
597 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
601 (Current).first_line = (Current).last_line = \
602 YYRHSLOC (Rhs, 0).last_line; \
603 (Current).first_column = (Current).last_column = \
604 YYRHSLOC (Rhs, 0).last_column; \
610 /* YY_LOCATION_PRINT -- Print the location on the stream.
611 This macro was not mandated originally: define only if we know
612 we won't break user code: when these are the locations we know. */
614 #ifndef YY_LOCATION_PRINT
615 # if YYLTYPE_IS_TRIVIAL
616 # define YY_LOCATION_PRINT(File, Loc) \
617 fprintf (File, "%d.%d-%d.%d", \
618 (Loc).first_line, (Loc).first_column, \
619 (Loc).last_line, (Loc).last_column)
621 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
626 /* YYLEX -- calling `yylex' with the right arguments. */
629 # define YYLEX yylex (YYLEX_PARAM)
631 # define YYLEX yylex ()
634 /* Enable debugging if requested. */
638 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
639 # define YYFPRINTF fprintf
642 # define YYDPRINTF(Args) \
648 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
652 YYFPRINTF (stderr, "%s ", Title); \
653 yy_symbol_print (stderr, \
655 YYFPRINTF (stderr, "\n"); \
660 /*--------------------------------.
661 | Print this symbol on YYOUTPUT. |
662 `--------------------------------*/
665 #if (defined __STDC__ || defined __C99__FUNC__ \
666 || defined __cplusplus || defined _MSC_VER)
667 static void yy_symbol_value_print(FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
669 static void yy_symbol_value_print(yyoutput, yytype, yyvaluep)
672 YYSTYPE const * const yyvaluep;
678 if (yytype < YYNTOKENS)
679 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
691 /*--------------------------------.
692 | Print this symbol on YYOUTPUT. |
693 `--------------------------------*/
695 #if (defined __STDC__ || defined __C99__FUNC__ \
696 || defined __cplusplus || defined _MSC_VER)
697 static void yy_symbol_print(FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
699 static void yy_symbol_print(yyoutput, yytype, yyvaluep)
702 YYSTYPE const * const yyvaluep;
705 if (yytype < YYNTOKENS)
706 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
708 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
710 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
711 YYFPRINTF (yyoutput, ")");
714 /*------------------------------------------------------------------.
715 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
717 `------------------------------------------------------------------*/
719 #if (defined __STDC__ || defined __C99__FUNC__ \
720 || defined __cplusplus || defined _MSC_VER)
721 static void yy_stack_print(yytype_int16 *bottom, yytype_int16 *top)
723 static void yy_stack_print(bottom, top)
724 yytype_int16 *bottom;
728 YYFPRINTF (stderr, "Stack now");
729 for (; bottom <= top; ++bottom)
730 YYFPRINTF (stderr, " %d", *bottom);
731 YYFPRINTF (stderr, "\n");
734 # define YY_STACK_PRINT(Bottom, Top) \
737 yy_stack_print ((Bottom), (Top)); \
741 /*------------------------------------------------.
742 | Report that the YYRULE is going to be reduced. |
743 `------------------------------------------------*/
745 #if (defined __STDC__ || defined __C99__FUNC__ \
746 || defined __cplusplus || defined _MSC_VER)
747 static void yy_reduce_print(YYSTYPE *yyvsp, int yyrule)
749 static void yy_reduce_print(yyvsp, yyrule)
754 int yynrhs = yyr2[yyrule];
756 unsigned long int yylno = yyrline[yyrule];
757 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
759 /* The symbols being reduced. */
760 for (yyi = 0; yyi < yynrhs; yyi++)
762 fprintf (stderr, " $%d = ", yyi + 1);
763 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
764 &(yyvsp[(yyi + 1) - (yynrhs)])
766 fprintf (stderr, "\n");
770 # define YY_REDUCE_PRINT(Rule) \
773 yy_reduce_print (yyvsp, Rule); \
776 /* Nonzero means print parse trace. It is left uninitialized so that
777 multiple parsers can coexist. */
780 # define YYDPRINTF(Args)
781 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
782 # define YY_STACK_PRINT(Bottom, Top)
783 # define YY_REDUCE_PRINT(Rule)
784 #endif /* !YYDEBUG */
787 /* YYINITDEPTH -- initial size of the parser's stacks. */
789 # define YYINITDEPTH 200
792 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
793 if the built-in stack extension method is used).
795 Do not make this value too large; the results are undefined if
796 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
797 evaluated with infinite-precision integer arithmetic. */
800 # define YYMAXDEPTH 10000
808 # if defined __GLIBC__ && defined _STRING_H
809 # define yystrlen strlen
811 /* Return the length of YYSTR. */
812 #if (defined __STDC__ || defined __C99__FUNC__ \
813 || defined __cplusplus || defined _MSC_VER)
814 static YYSIZE_T yystrlen(const char *yystr)
816 static YYSIZE_T yystrlen(yystr)
821 for (yylen = 0; yystr[yylen]; yylen++)
829 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
830 # define yystpcpy stpcpy
832 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
834 #if (defined __STDC__ || defined __C99__FUNC__ \
835 || defined __cplusplus || defined _MSC_VER)
836 static char *yystpcpy(char *yydest, const char *yysrc)
838 static char *yystpcpy(yydest, yysrc)
844 const char *yys = yysrc;
846 while ((*yyd++ = *yys++) != '\0')
855 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
856 quotes and backslashes, so that it's suitable for yyerror. The
857 heuristic is that double-quoting is unnecessary unless the string
858 contains an apostrophe, a comma, or backslash (other than
859 backslash-backslash). YYSTR is taken from yytname. If YYRES is
860 null, do not copy; instead, return the length of what the result
862 static YYSIZE_T yytnamerr(char *yyres, const char *yystr)
867 char const *yyp = yystr;
874 goto do_not_strip_quotes;
878 goto do_not_strip_quotes;
891 do_not_strip_quotes: ;
895 return yystrlen (yystr);
897 return yystpcpy (yyres, yystr) - yyres;
901 /* Copy into YYRESULT an error message about the unexpected token
902 YYCHAR while in state YYSTATE. Return the number of bytes copied,
903 including the terminating null byte. If YYRESULT is null, do not
904 copy anything; just return the number of bytes that would be
905 copied. As a special case, return 0 if an ordinary "syntax error"
906 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
908 static YYSIZE_T yysyntax_error(char *yyresult, int yystate, int yychar)
910 int yyn = yypact[yystate];
912 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
916 int yytype = YYTRANSLATE (yychar);
917 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
918 YYSIZE_T yysize = yysize0;
920 int yysize_overflow = 0;
921 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
922 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
926 /* This is so xgettext sees the translatable formats that are
927 constructed on the fly. */
928 YY_("syntax error, unexpected %s");
929 YY_("syntax error, unexpected %s, expecting %s");
930 YY_("syntax error, unexpected %s, expecting %s or %s");
931 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
932 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
936 static char const yyunexpected[] = "syntax error, unexpected %s";
937 static char const yyexpecting[] = ", expecting %s";
938 static char const yyor[] = " or %s";
939 char yyformat[sizeof yyunexpected
940 + sizeof yyexpecting - 1
941 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
942 * (sizeof yyor - 1))];
943 char const *yyprefix = yyexpecting;
945 /* Start YYX at -YYN if negative to avoid negative indexes in
947 int yyxbegin = yyn < 0 ? -yyn : 0;
949 /* Stay within bounds of both yycheck and yytname. */
950 int yychecklim = YYLAST - yyn + 1;
951 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
954 yyarg[0] = yytname[yytype];
955 yyfmt = yystpcpy (yyformat, yyunexpected);
957 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
958 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
960 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
964 yyformat[sizeof yyunexpected - 1] = '\0';
967 yyarg[yycount++] = yytname[yyx];
968 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
969 yysize_overflow |= (yysize1 < yysize);
971 yyfmt = yystpcpy (yyfmt, yyprefix);
976 yysize1 = yysize + yystrlen (yyf);
977 yysize_overflow |= (yysize1 < yysize);
981 return YYSIZE_MAXIMUM;
985 /* Avoid sprintf, as that infringes on the user's name space.
986 Don't have undefined behavior even if the translation
987 produced a string with the wrong number of "%s"s. */
988 char *yyp = yyresult;
990 while ((*yyp = *yyf) != '\0')
992 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
994 yyp += yytnamerr (yyp, yyarg[yyi++]);
1007 #endif /* YYERROR_VERBOSE */
1010 /*-----------------------------------------------.
1011 | Release the memory associated to this symbol. |
1012 `-----------------------------------------------*/
1015 #if (defined __STDC__ || defined __C99__FUNC__ \
1016 || defined __cplusplus || defined _MSC_VER)
1017 static void yydestruct(const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1019 static void yydestruct(yymsg, yytype, yyvaluep)
1029 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1040 /* Prevent warnings from -Wmissing-prototypes. */
1042 #ifdef YYPARSE_PARAM
1043 #if defined __STDC__ || defined __cplusplus
1044 int yyparse (void *YYPARSE_PARAM);
1048 #else /* ! YYPARSE_PARAM */
1049 #if defined __STDC__ || defined __cplusplus
1054 #endif /* ! YYPARSE_PARAM */
1058 /* The look-ahead symbol. */
1061 /* The semantic value of the look-ahead symbol. */
1064 /* Number of syntax errors so far. */
1073 #ifdef YYPARSE_PARAM
1074 #if (defined __STDC__ || defined __C99__FUNC__ \
1075 || defined __cplusplus || defined _MSC_VER)
1076 int yyparse (void *YYPARSE_PARAM)
1078 int yyparse (YYPARSE_PARAM)
1079 void *YYPARSE_PARAM;
1081 #else /* ! YYPARSE_PARAM */
1082 #if (defined __STDC__ || defined __C99__FUNC__ \
1083 || defined __cplusplus || defined _MSC_VER)
1095 /* Number of tokens to shift before error messages enabled. */
1097 /* Look-ahead token as an internal (translated) token number. */
1100 /* Buffer for error messages, and its allocated size. */
1102 char *yymsg = yymsgbuf;
1103 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1106 /* Three stacks and their tools:
1107 `yyss': related to states,
1108 `yyvs': related to semantic values,
1109 `yyls': related to locations.
1111 Refer to the stacks thru separate pointers, to allow yyoverflow
1112 to reallocate them elsewhere. */
1114 /* The state stack. */
1115 yytype_int16 yyssa[YYINITDEPTH];
1116 yytype_int16 *yyss = yyssa;
1117 yytype_int16 *yyssp;
1119 /* The semantic value stack. */
1120 YYSTYPE yyvsa[YYINITDEPTH];
1121 YYSTYPE *yyvs = yyvsa;
1126 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1128 YYSIZE_T yystacksize = YYINITDEPTH;
1130 /* The variables used to return semantic value and location from the
1135 /* The number of symbols on the RHS of the reduced rule.
1136 Keep to zero when no symbol should be popped. */
1139 YYDPRINTF ((stderr, "Starting parse\n"));
1144 yychar = YYEMPTY; /* Cause a token to be read. */
1146 /* Initialize stack pointers.
1147 Waste one element of value and location stack
1148 so that they stay on the same level as the state stack.
1149 The wasted elements are never initialized. */
1156 /*------------------------------------------------------------.
1157 | yynewstate -- Push a new state, which is found in yystate. |
1158 `------------------------------------------------------------*/
1160 /* In all cases, when you get here, the value and location stacks
1161 have just been pushed. So pushing a state here evens the stacks. */
1167 if (yyss + yystacksize - 1 <= yyssp)
1169 /* Get the current used size of the three stacks, in elements. */
1170 YYSIZE_T yysize = yyssp - yyss + 1;
1174 /* Give user a chance to reallocate the stack. Use copies of
1175 these so that the &'s don't force the real ones into
1177 YYSTYPE *yyvs1 = yyvs;
1178 yytype_int16 *yyss1 = yyss;
1181 /* Each stack pointer address is followed by the size of the
1182 data in use in that stack, in bytes. This used to be a
1183 conditional around just the two extra args, but that might
1184 be undefined if yyoverflow is a macro. */
1185 yyoverflow (YY_("memory exhausted"),
1186 &yyss1, yysize * sizeof (*yyssp),
1187 &yyvs1, yysize * sizeof (*yyvsp),
1194 #else /* no yyoverflow */
1195 # ifndef YYSTACK_RELOCATE
1196 goto yyexhaustedlab;
1198 /* Extend the stack our own way. */
1199 if (YYMAXDEPTH <= yystacksize)
1200 goto yyexhaustedlab;
1202 if (YYMAXDEPTH < yystacksize)
1203 yystacksize = YYMAXDEPTH;
1206 yytype_int16 *yyss1 = yyss;
1207 union yyalloc *yyptr =
1208 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1210 goto yyexhaustedlab;
1211 YYSTACK_RELOCATE (yyss);
1212 YYSTACK_RELOCATE (yyvs);
1214 # undef YYSTACK_RELOCATE
1216 YYSTACK_FREE (yyss1);
1219 #endif /* no yyoverflow */
1221 yyssp = yyss + yysize - 1;
1222 yyvsp = yyvs + yysize - 1;
1225 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1226 (unsigned long int) yystacksize));
1228 if (yyss + yystacksize - 1 <= yyssp)
1232 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1241 /* Do appropriate processing given the current state. Read a
1242 look-ahead token if we need one and don't already have one. */
1244 /* First try to decide what to do without reference to look-ahead token. */
1245 yyn = yypact[yystate];
1246 if (yyn == YYPACT_NINF)
1249 /* Not known => get a look-ahead token if don't already have one. */
1251 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1252 if (yychar == YYEMPTY)
1254 YYDPRINTF ((stderr, "Reading a token: "));
1258 if (yychar <= YYEOF)
1260 yychar = yytoken = YYEOF;
1261 YYDPRINTF ((stderr, "Now at end of input.\n"));
1265 yytoken = YYTRANSLATE (yychar);
1266 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1269 /* If the proper action on seeing token YYTOKEN is to reduce or to
1270 detect an error, take that action. */
1272 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1277 if (yyn == 0 || yyn == YYTABLE_NINF)
1286 /* Count tokens shifted since error; after three, turn off error
1291 /* Shift the look-ahead token. */
1292 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1294 /* Discard the shifted token unless it is eof. */
1295 if (yychar != YYEOF)
1304 /*-----------------------------------------------------------.
1305 | yydefault -- do the default action for the current state. |
1306 `-----------------------------------------------------------*/
1308 yyn = yydefact[yystate];
1314 /*-----------------------------.
1315 | yyreduce -- Do a reduction. |
1316 `-----------------------------*/
1318 /* yyn is the number of a rule to reduce with. */
1321 /* If YYLEN is nonzero, implement the default value of the action:
1324 Otherwise, the following line sets YYVAL to garbage.
1325 This behavior is undocumented and Bison
1326 users should not rely upon it. Assigning to YYVAL
1327 unconditionally makes the parser a bit smaller, and it avoids a
1328 GCC warning that YYVAL may be used uninitialized. */
1329 yyval = yyvsp[1-yylen];
1332 YY_REDUCE_PRINT (yyn);
1352 { path_push((yyvsp[(3) - (3)].text)); ;}
1357 { path_push((yyvsp[(1) - (1)].text)); ;}
1361 /* Line 1267 of yacc.c. */
1365 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1369 YY_STACK_PRINT (yyss, yyssp);
1374 /* Now `shift' the result of the reduction. Determine what state
1375 that goes to, based on the state we popped back to and the rule
1376 number reduced by. */
1380 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1381 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1382 yystate = yytable[yystate];
1384 yystate = yydefgoto[yyn - YYNTOKENS];
1389 /*------------------------------------.
1390 | yyerrlab -- here on detecting error |
1391 `------------------------------------*/
1393 /* If not already recovering from an error, report this error. */
1397 #if ! YYERROR_VERBOSE
1398 yyerror (YY_("syntax error"));
1401 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1402 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1404 YYSIZE_T yyalloc = 2 * yysize;
1405 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1406 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1407 if (yymsg != yymsgbuf)
1408 YYSTACK_FREE (yymsg);
1409 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1411 yymsg_alloc = yyalloc;
1415 yymsg_alloc = sizeof yymsgbuf;
1419 if (0 < yysize && yysize <= yymsg_alloc)
1421 (void) yysyntax_error (yymsg, yystate, yychar);
1426 yyerror (YY_("syntax error"));
1428 goto yyexhaustedlab;
1436 if (yyerrstatus == 3)
1438 /* If just tried and failed to reuse look-ahead token after an
1439 error, discard it. */
1441 if (yychar <= YYEOF)
1443 /* Return failure if at end of input. */
1444 if (yychar == YYEOF)
1449 yydestruct ("Error: discarding",
1455 /* Else will try to reuse look-ahead token after shifting the error
1460 /*---------------------------------------------------.
1461 | yyerrorlab -- error raised explicitly by YYERROR. |
1462 `---------------------------------------------------*/
1465 /* Pacify compilers like GCC when the user code never invokes
1466 YYERROR and the label yyerrorlab therefore never appears in user
1468 if (/*CONSTCOND*/ 0)
1471 /* Do not reclaim the symbols of the rule which action triggered
1475 YY_STACK_PRINT (yyss, yyssp);
1480 /*-------------------------------------------------------------.
1481 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1482 `-------------------------------------------------------------*/
1484 yyerrstatus = 3; /* Each real token shifted decrements this. */
1488 yyn = yypact[yystate];
1489 if (yyn != YYPACT_NINF)
1492 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1500 /* Pop the current state because it cannot handle the error token. */
1505 yydestruct ("Error: popping",
1506 yystos[yystate], yyvsp);
1509 YY_STACK_PRINT (yyss, yyssp);
1518 /* Shift the error token. */
1519 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1525 /*-------------------------------------.
1526 | yyacceptlab -- YYACCEPT comes here. |
1527 `-------------------------------------*/
1532 /*-----------------------------------.
1533 | yyabortlab -- YYABORT comes here. |
1534 `-----------------------------------*/
1540 /*-------------------------------------------------.
1541 | yyexhaustedlab -- memory exhaustion comes here. |
1542 `-------------------------------------------------*/
1544 yyerror (YY_("memory exhausted"));
1550 if (yychar != YYEOF && yychar != YYEMPTY)
1551 yydestruct ("Cleanup: discarding lookahead",
1553 /* Do not reclaim the symbols of the rule which action triggered
1554 this YYABORT or YYACCEPT. */
1556 YY_STACK_PRINT (yyss, yyssp);
1557 while (yyssp != yyss)
1559 yydestruct ("Cleanup: popping",
1560 yystos[*yyssp], yyvsp);
1565 YYSTACK_FREE (yyss);
1568 if (yymsg != yymsgbuf)
1569 YYSTACK_FREE (yymsg);
1571 /* Make sure YYID is used. */
1572 return YYID (yyresult);
1579 static lc_opt_error_handler_t *handler;
1580 static struct obstack obst;
1581 const char *optfilename = "";
1583 void PMANGLE(error)(const char *str)
1585 fprintf(stderr, "At line %d: %s\n", PMANGLE(linenr), str);
1588 static const char *path_stack[128];
1589 static int path_sp = 0;
1591 static lc_opt_entry_t *grp_stack[128];
1592 static int grp_sp = 0;
1593 #define CURR_GRP (grp_stack[grp_sp - 1])
1595 void lc_opt_init_parser(const char *filename, lc_opt_error_handler_t *err_handler)
1597 PMANGLE(linenr) = 1;
1598 obstack_init(&obst);
1599 handler = err_handler;
1600 optfilename = filename;
1601 grp_stack[grp_sp++] = lc_opt_root_grp();
1604 void _lc_opt_add_to_data_char(char c)
1606 obstack_1grow(&obst, c);
1609 static void path_push(text_t text)
1611 obstack_grow0(&obst, text.str, text.len);
1612 path_stack[path_sp++] = obstack_finish(&obst);
1615 static void path_free(void)
1617 obstack_free(&obst, (void *) path_stack[0]);
1621 static void group_open(void)
1623 lc_opt_err_info_t err;
1624 lc_opt_entry_t *grp = lc_opt_resolve_grp(CURR_GRP, path_stack, path_sp, &err);
1628 grp_stack[grp_sp++] = grp;
1631 static void group_close(void)
1636 static void lc_opt_set(void)
1638 char *str = obstack_finish(&obst);
1640 lc_opt_err_info_t err;
1641 lc_opt_entry_t *opt = lc_opt_resolve_opt(CURR_GRP, path_stack, path_sp, &err);
1642 lc_opt_raise_error(&err, handler, "At %s(%d): ", optfilename, PMANGLE(linenr));
1644 lc_opt_occurs(opt, str, &err);
1645 lc_opt_raise_error(&err, handler, "At %s(%d): ", optfilename, PMANGLE(linenr));
1647 obstack_free(&obst, str);