2 /* A Bison parser, made by GNU Bison 2.4.1. */
4 /* Skeleton implementation for Bison's Yacc-like parsers in C
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7 Free Software Foundation, Inc.
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 /* As a special exception, you may create a larger work that contains
23 part or all of the Bison parser skeleton and distribute that work
24 under terms of your choice, so long as that work isn't itself a
25 parser generator using the skeleton or a modified version thereof
26 as a parser skeleton. Alternatively, if you modify or redistribute
27 the parser skeleton itself, you may (at your option) remove this
28 special exception, which will cause the skeleton and the resulting
29 Bison output files to be licensed under the GNU General Public
30 License without this special exception.
32 This special exception was added by the Free Software Foundation in
33 version 2.2 of Bison. */
35 /* C LALR(1) parser skeleton written by Richard Stallman, by
36 simplifying the original so-called "semantic" parser. */
38 /* All symbols defined below should begin with yy or YY, to avoid
39 infringing on user name space. This should be done even for local
40 variables, as they might otherwise be expanded by user macros.
41 There are some unavoidable exceptions within include files to
42 define necessary library symbols; they are noted "INFRINGES ON
43 USER NAME SPACE" below. */
45 /* Identify Bison output. */
49 #define YYBISON_VERSION "2.4.1"
52 #define YYSKELETON_NAME "yacc.c"
63 /* Using locations. */
64 #define YYLSP_NEEDED 0
66 /* Substitute the variable and function names. */
67 #define yyparse _lc_opt_parse
68 #define yylex _lc_opt_lex
69 #define yyerror _lc_opt_error
70 #define yylval _lc_opt_lval
71 #define yychar _lc_opt_char
72 #define yydebug _lc_opt_debug
73 #define yynerrs _lc_opt_nerrs
76 /* Copy the first part of user declarations. */
81 libcore: library for basic data structures and algorithms.
82 Copyright (C) 2005 IPD Goos, Universit"at Karlsruhe, Germany
84 This library is free software; you can redistribute it and/or
85 modify it under the terms of the GNU Lesser General Public
86 License as published by the Free Software Foundation; either
87 version 2.1 of the License, or (at your option) any later version.
89 This library is distributed in the hope that it will be useful,
90 but WITHOUT ANY WARRANTY; without even the implied warranty of
91 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
92 Lesser General Public License for more details.
94 You should have received a copy of the GNU Lesser General Public
95 License along with this library; if not, write to the Free Software
96 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
104 #include "lc_opts_t.h"
105 #include "lc_parser_t.h"
107 static void group_open(void);
108 static void group_close(void);
109 static void lc_opt_set(void);
110 static void path_push(text_t text);
112 void PMANGLE(error)(const char *str);
118 /* Enabling traces. */
123 /* Enabling verbose error messages. */
124 #ifdef YYERROR_VERBOSE
125 # undef YYERROR_VERBOSE
126 # define YYERROR_VERBOSE 1
128 # define YYERROR_VERBOSE 0
131 /* Enabling the token table. */
132 #ifndef YYTOKEN_TABLE
133 # define YYTOKEN_TABLE 0
140 /* Put the tokens into the symbol table, so that GDB and other debuggers
151 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
152 typedef union YYSTYPE
162 # define YYSTYPE_IS_TRIVIAL 1
163 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
164 # define YYSTYPE_IS_DECLARED 1
168 /* Copy the second part of user declarations. */
177 typedef YYTYPE_UINT8 yytype_uint8;
179 typedef unsigned char yytype_uint8;
183 typedef YYTYPE_INT8 yytype_int8;
184 #elif (defined __STDC__ || defined __C99__FUNC__ \
185 || defined __cplusplus || defined _MSC_VER)
186 typedef signed char yytype_int8;
188 typedef short int yytype_int8;
192 typedef YYTYPE_UINT16 yytype_uint16;
194 typedef unsigned short int yytype_uint16;
198 typedef YYTYPE_INT16 yytype_int16;
200 typedef short int yytype_int16;
204 # ifdef __SIZE_TYPE__
205 # define YYSIZE_T __SIZE_TYPE__
206 # elif defined size_t
207 # define YYSIZE_T size_t
208 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
209 || defined __cplusplus || defined _MSC_VER)
210 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
211 # define YYSIZE_T size_t
213 # define YYSIZE_T unsigned int
217 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
222 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
223 # define YY_(msgid) dgettext ("bison-runtime", msgid)
227 # define YY_(msgid) msgid
231 /* Suppress unused-variable warnings by "using" E. */
232 #if ! defined lint || defined __GNUC__
233 # define YYUSE(e) ((void) (e))
235 # define YYUSE(e) /* empty */
238 /* Identity function, used to suppress warnings about constant conditions. */
242 #if (defined __STDC__ || defined __C99__FUNC__ \
243 || defined __cplusplus || defined _MSC_VER)
256 #if ! defined yyoverflow || YYERROR_VERBOSE
258 /* The parser invokes alloca or malloc; define the necessary symbols. */
260 # ifdef YYSTACK_USE_ALLOCA
261 # if YYSTACK_USE_ALLOCA
263 # define YYSTACK_ALLOC __builtin_alloca
264 # elif defined __BUILTIN_VA_ARG_INCR
265 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
267 # define YYSTACK_ALLOC __alloca
268 # elif defined _MSC_VER
269 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
270 # define alloca _alloca
272 # define YYSTACK_ALLOC alloca
273 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
274 || defined __cplusplus || defined _MSC_VER)
275 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
284 # ifdef YYSTACK_ALLOC
285 /* Pacify GCC's `empty if-body' warning. */
286 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
287 # ifndef YYSTACK_ALLOC_MAXIMUM
288 /* The OS might guarantee only one guard page at the bottom of the stack,
289 and a page size can be as small as 4096 bytes. So we cannot safely
290 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
291 to allow for a few compiler-allocated temporary stack slots. */
292 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
295 # define YYSTACK_ALLOC YYMALLOC
296 # define YYSTACK_FREE YYFREE
297 # ifndef YYSTACK_ALLOC_MAXIMUM
298 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
300 # if (defined __cplusplus && ! defined _STDLIB_H \
301 && ! ((defined YYMALLOC || defined malloc) \
302 && (defined YYFREE || defined free)))
303 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
309 # define YYMALLOC malloc
310 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
311 || defined __cplusplus || defined _MSC_VER)
312 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
317 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
318 || defined __cplusplus || defined _MSC_VER)
319 void free (void *); /* INFRINGES ON USER NAME SPACE */
323 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
326 #if (! defined yyoverflow \
327 && (! defined __cplusplus \
328 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
330 /* A type that is properly aligned for any stack member. */
333 yytype_int16 yyss_alloc;
337 /* The size of the maximum gap between one aligned stack and the next. */
338 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
340 /* The size of an array large to enough to hold all stacks, each with
342 # define YYSTACK_BYTES(N) \
343 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
344 + YYSTACK_GAP_MAXIMUM)
346 /* Copy COUNT objects from FROM to TO. The source and destination do
349 # if defined __GNUC__ && 1 < __GNUC__
350 # define YYCOPY(To, From, Count) \
351 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
353 # define YYCOPY(To, From, Count) \
357 for (yyi = 0; yyi < (Count); yyi++) \
358 (To)[yyi] = (From)[yyi]; \
364 /* Relocate STACK from its old location to the new one. The
365 local variables YYSIZE and YYSTACKSIZE give the old and new number of
366 elements in the stack, and YYPTR gives the new location of the
367 stack. Advance YYPTR to a properly aligned location for the next
369 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
372 YYSIZE_T yynewbytes; \
373 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
374 Stack = &yyptr->Stack_alloc; \
375 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
376 yyptr += yynewbytes / sizeof (*yyptr); \
382 /* YYFINAL -- State number of the termination state. */
384 /* YYLAST -- Last index in YYTABLE. */
387 /* YYNTOKENS -- Number of terminals. */
389 /* YYNNTS -- Number of nonterminals. */
391 /* YYNRULES -- Number of rules. */
393 /* YYNRULES -- Number of states. */
396 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
398 #define YYMAXUTOK 260
400 #define YYTRANSLATE(YYX) \
401 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
403 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
404 static const yytype_uint8 yytranslate[] =
406 0, 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, 2, 2, 2, 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, 6, 2, 7, 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, 2, 2, 2, 2,
428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
431 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
436 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
438 static const yytype_uint8 yyprhs[] =
440 0, 0, 3, 5, 7, 9, 12, 14, 16, 17,
444 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
445 static const yytype_int8 yyrhs[] =
447 9, 0, -1, 12, -1, 13, -1, 15, -1, 11,
448 10, -1, 10, -1, 11, -1, -1, -1, 16, 14,
449 6, 12, 7, -1, 16, 4, -1, 16, 3, 5,
453 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
454 static const yytype_uint8 yyrline[] =
456 0, 53, 53, 55, 56, 59, 60, 63, 63, 65,
461 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
462 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
463 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
464 static const char *const yytname[] =
466 "$end", "error", "$undefined", "SEP", "DATA", "IDENT", "'{'", "'}'",
467 "$accept", "main", "decl", "decls", "dseq", "group", "$@1", "option",
473 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
475 static const yytype_uint16 yytoknum[] =
477 0, 256, 257, 258, 259, 260, 123, 125
481 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
482 static const yytype_uint8 yyr1[] =
484 0, 8, 9, 10, 10, 11, 11, 12, 12, 14,
488 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
489 static const yytype_uint8 yyr2[] =
491 0, 2, 1, 1, 1, 2, 1, 1, 0, 0,
495 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
496 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
497 means the default is an error. */
498 static const yytype_uint8 yydefact[] =
500 8, 13, 0, 6, 7, 2, 3, 4, 9, 1,
501 5, 0, 11, 0, 12, 8, 0, 10
504 /* YYDEFGOTO[NTERM-NUM]. */
505 static const yytype_int8 yydefgoto[] =
507 -1, 2, 3, 4, 5, 6, 13, 7, 8
510 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
512 #define YYPACT_NINF -11
513 static const yytype_int8 yypact[] =
515 -2, -11, 2, -11, -2, -11, -11, -11, -3, -11,
516 -11, -1, -11, 0, -11, -2, 1, -11
519 /* YYPGOTO[NTERM-NUM]. */
520 static const yytype_int8 yypgoto[] =
522 -11, -11, 3, -11, -10, -11, -11, -11, -11
525 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
526 positive, shift that token. If negative, reduce the rule which
527 number is the opposite. If zero, do what YYDEFACT says.
528 If YYTABLE_NINF, syntax error. */
529 #define YYTABLE_NINF -1
530 static const yytype_uint8 yytable[] =
532 11, 12, 9, 1, 14, 16, 15, 10, 17
535 static const yytype_uint8 yycheck[] =
537 3, 4, 0, 5, 5, 15, 6, 4, 7
540 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
541 symbol of state STATE-NUM. */
542 static const yytype_uint8 yystos[] =
544 0, 5, 9, 10, 11, 12, 13, 15, 16, 0,
545 10, 3, 4, 14, 5, 6, 12, 7
548 #define yyerrok (yyerrstatus = 0)
549 #define yyclearin (yychar = YYEMPTY)
553 #define YYACCEPT goto yyacceptlab
554 #define YYABORT goto yyabortlab
555 #define YYERROR goto yyerrorlab
558 /* Like YYERROR except do call yyerror. This remains here temporarily
559 to ease the transition to the new meaning of YYERROR, for GCC.
560 Once GCC version 2 has supplanted version 1, this can go. */
562 #define YYFAIL goto yyerrlab
564 #define YYRECOVERING() (!!yyerrstatus)
566 #define YYBACKUP(Token, Value) \
568 if (yychar == YYEMPTY && yylen == 1) \
572 yytoken = YYTRANSLATE (yychar); \
578 yyerror (YY_("syntax error: cannot back up")); \
585 #define YYERRCODE 256
588 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
589 If N is 0, then set CURRENT to the empty location which ends
590 the previous symbol: RHS[0] (always defined). */
592 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
593 #ifndef YYLLOC_DEFAULT
594 # define YYLLOC_DEFAULT(Current, Rhs, N) \
598 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
599 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
600 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
601 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
605 (Current).first_line = (Current).last_line = \
606 YYRHSLOC (Rhs, 0).last_line; \
607 (Current).first_column = (Current).last_column = \
608 YYRHSLOC (Rhs, 0).last_column; \
614 /* YY_LOCATION_PRINT -- Print the location on the stream.
615 This macro was not mandated originally: define only if we know
616 we won't break user code: when these are the locations we know. */
618 #ifndef YY_LOCATION_PRINT
619 # if YYLTYPE_IS_TRIVIAL
620 # define YY_LOCATION_PRINT(File, Loc) \
621 fprintf (File, "%d.%d-%d.%d", \
622 (Loc).first_line, (Loc).first_column, \
623 (Loc).last_line, (Loc).last_column)
625 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
630 /* YYLEX -- calling `yylex' with the right arguments. */
633 # define YYLEX yylex (YYLEX_PARAM)
635 # define YYLEX yylex ()
638 /* Enable debugging if requested. */
642 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
643 # define YYFPRINTF fprintf
646 # define YYDPRINTF(Args) \
652 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
656 YYFPRINTF (stderr, "%s ", Title); \
657 yy_symbol_print (stderr, \
659 YYFPRINTF (stderr, "\n"); \
664 /*--------------------------------.
665 | Print this symbol on YYOUTPUT. |
666 `--------------------------------*/
669 #if (defined __STDC__ || defined __C99__FUNC__ \
670 || defined __cplusplus || defined _MSC_VER)
672 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
675 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
678 YYSTYPE const * const yyvaluep;
684 if (yytype < YYNTOKENS)
685 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
697 /*--------------------------------.
698 | Print this symbol on YYOUTPUT. |
699 `--------------------------------*/
701 #if (defined __STDC__ || defined __C99__FUNC__ \
702 || defined __cplusplus || defined _MSC_VER)
704 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
707 yy_symbol_print (yyoutput, yytype, yyvaluep)
710 YYSTYPE const * const yyvaluep;
713 if (yytype < YYNTOKENS)
714 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
716 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
718 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
719 YYFPRINTF (yyoutput, ")");
722 /*------------------------------------------------------------------.
723 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
725 `------------------------------------------------------------------*/
727 #if (defined __STDC__ || defined __C99__FUNC__ \
728 || defined __cplusplus || defined _MSC_VER)
730 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
733 yy_stack_print (yybottom, yytop)
734 yytype_int16 *yybottom;
738 YYFPRINTF (stderr, "Stack now");
739 for (; yybottom <= yytop; yybottom++)
741 int yybot = *yybottom;
742 YYFPRINTF (stderr, " %d", yybot);
744 YYFPRINTF (stderr, "\n");
747 # define YY_STACK_PRINT(Bottom, Top) \
750 yy_stack_print ((Bottom), (Top)); \
754 /*------------------------------------------------.
755 | Report that the YYRULE is going to be reduced. |
756 `------------------------------------------------*/
758 #if (defined __STDC__ || defined __C99__FUNC__ \
759 || defined __cplusplus || defined _MSC_VER)
761 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
764 yy_reduce_print (yyvsp, yyrule)
769 int yynrhs = yyr2[yyrule];
771 unsigned long int yylno = yyrline[yyrule];
772 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
774 /* The symbols being reduced. */
775 for (yyi = 0; yyi < yynrhs; yyi++)
777 YYFPRINTF (stderr, " $%d = ", yyi + 1);
778 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
779 &(yyvsp[(yyi + 1) - (yynrhs)])
781 YYFPRINTF (stderr, "\n");
785 # define YY_REDUCE_PRINT(Rule) \
788 yy_reduce_print (yyvsp, Rule); \
791 /* Nonzero means print parse trace. It is left uninitialized so that
792 multiple parsers can coexist. */
795 # define YYDPRINTF(Args)
796 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
797 # define YY_STACK_PRINT(Bottom, Top)
798 # define YY_REDUCE_PRINT(Rule)
799 #endif /* !YYDEBUG */
802 /* YYINITDEPTH -- initial size of the parser's stacks. */
804 # define YYINITDEPTH 200
807 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
808 if the built-in stack extension method is used).
810 Do not make this value too large; the results are undefined if
811 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
812 evaluated with infinite-precision integer arithmetic. */
815 # define YYMAXDEPTH 10000
823 # if defined __GLIBC__ && defined _STRING_H
824 # define yystrlen strlen
826 /* Return the length of YYSTR. */
827 #if (defined __STDC__ || defined __C99__FUNC__ \
828 || defined __cplusplus || defined _MSC_VER)
830 yystrlen (const char *yystr)
838 for (yylen = 0; yystr[yylen]; yylen++)
846 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
847 # define yystpcpy stpcpy
849 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
851 #if (defined __STDC__ || defined __C99__FUNC__ \
852 || defined __cplusplus || defined _MSC_VER)
854 yystpcpy (char *yydest, const char *yysrc)
857 yystpcpy (yydest, yysrc)
863 const char *yys = yysrc;
865 while ((*yyd++ = *yys++) != '\0')
874 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
875 quotes and backslashes, so that it's suitable for yyerror. The
876 heuristic is that double-quoting is unnecessary unless the string
877 contains an apostrophe, a comma, or backslash (other than
878 backslash-backslash). YYSTR is taken from yytname. If YYRES is
879 null, do not copy; instead, return the length of what the result
882 yytnamerr (char *yyres, const char *yystr)
887 char const *yyp = yystr;
894 goto do_not_strip_quotes;
898 goto do_not_strip_quotes;
911 do_not_strip_quotes: ;
915 return yystrlen (yystr);
917 return yystpcpy (yyres, yystr) - yyres;
921 /* Copy into YYRESULT an error message about the unexpected token
922 YYCHAR while in state YYSTATE. Return the number of bytes copied,
923 including the terminating null byte. If YYRESULT is null, do not
924 copy anything; just return the number of bytes that would be
925 copied. As a special case, return 0 if an ordinary "syntax error"
926 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
929 yysyntax_error (char *yyresult, int yystate, int yychar)
931 int yyn = yypact[yystate];
933 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
937 int yytype = YYTRANSLATE (yychar);
938 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
939 YYSIZE_T yysize = yysize0;
941 int yysize_overflow = 0;
942 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
943 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
947 /* This is so xgettext sees the translatable formats that are
948 constructed on the fly. */
949 YY_("syntax error, unexpected %s");
950 YY_("syntax error, unexpected %s, expecting %s");
951 YY_("syntax error, unexpected %s, expecting %s or %s");
952 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
953 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
957 static char const yyunexpected[] = "syntax error, unexpected %s";
958 static char const yyexpecting[] = ", expecting %s";
959 static char const yyor[] = " or %s";
960 char yyformat[sizeof yyunexpected
961 + sizeof yyexpecting - 1
962 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
963 * (sizeof yyor - 1))];
964 char const *yyprefix = yyexpecting;
966 /* Start YYX at -YYN if negative to avoid negative indexes in
968 int yyxbegin = yyn < 0 ? -yyn : 0;
970 /* Stay within bounds of both yycheck and yytname. */
971 int yychecklim = YYLAST - yyn + 1;
972 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
975 yyarg[0] = yytname[yytype];
976 yyfmt = yystpcpy (yyformat, yyunexpected);
978 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
979 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
981 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
985 yyformat[sizeof yyunexpected - 1] = '\0';
988 yyarg[yycount++] = yytname[yyx];
989 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
990 yysize_overflow |= (yysize1 < yysize);
992 yyfmt = yystpcpy (yyfmt, yyprefix);
997 yysize1 = yysize + yystrlen (yyf);
998 yysize_overflow |= (yysize1 < yysize);
1001 if (yysize_overflow)
1002 return YYSIZE_MAXIMUM;
1006 /* Avoid sprintf, as that infringes on the user's name space.
1007 Don't have undefined behavior even if the translation
1008 produced a string with the wrong number of "%s"s. */
1009 char *yyp = yyresult;
1011 while ((*yyp = *yyf) != '\0')
1013 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1015 yyp += yytnamerr (yyp, yyarg[yyi++]);
1028 #endif /* YYERROR_VERBOSE */
1031 /*-----------------------------------------------.
1032 | Release the memory associated to this symbol. |
1033 `-----------------------------------------------*/
1036 #if (defined __STDC__ || defined __C99__FUNC__ \
1037 || defined __cplusplus || defined _MSC_VER)
1039 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1042 yydestruct (yymsg, yytype, yyvaluep)
1052 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1062 /* Prevent warnings from -Wmissing-prototypes. */
1063 #ifdef YYPARSE_PARAM
1064 #if defined __STDC__ || defined __cplusplus
1065 int yyparse (void *YYPARSE_PARAM);
1069 #else /* ! YYPARSE_PARAM */
1070 #if defined __STDC__ || defined __cplusplus
1075 #endif /* ! YYPARSE_PARAM */
1078 /* The lookahead symbol. */
1081 /* The semantic value of the lookahead symbol. */
1084 /* Number of syntax errors so far. */
1089 /*-------------------------.
1090 | yyparse or yypush_parse. |
1091 `-------------------------*/
1093 #ifdef YYPARSE_PARAM
1094 #if (defined __STDC__ || defined __C99__FUNC__ \
1095 || defined __cplusplus || defined _MSC_VER)
1097 yyparse (void *YYPARSE_PARAM)
1100 yyparse (YYPARSE_PARAM)
1101 void *YYPARSE_PARAM;
1103 #else /* ! YYPARSE_PARAM */
1104 #if (defined __STDC__ || defined __C99__FUNC__ \
1105 || defined __cplusplus || defined _MSC_VER)
1118 /* Number of tokens to shift before error messages enabled. */
1121 /* The stacks and their tools:
1122 `yyss': related to states.
1123 `yyvs': related to semantic values.
1125 Refer to the stacks thru separate pointers, to allow yyoverflow
1126 to reallocate them elsewhere. */
1128 /* The state stack. */
1129 yytype_int16 yyssa[YYINITDEPTH];
1131 yytype_int16 *yyssp;
1133 /* The semantic value stack. */
1134 YYSTYPE yyvsa[YYINITDEPTH];
1138 YYSIZE_T yystacksize;
1142 /* Lookahead token as an internal (translated) token number. */
1144 /* The variables used to return semantic value and location from the
1149 /* Buffer for error messages, and its allocated size. */
1151 char *yymsg = yymsgbuf;
1152 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1155 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1157 /* The number of symbols on the RHS of the reduced rule.
1158 Keep to zero when no symbol should be popped. */
1164 yystacksize = YYINITDEPTH;
1166 YYDPRINTF ((stderr, "Starting parse\n"));
1171 yychar = YYEMPTY; /* Cause a token to be read. */
1173 /* Initialize stack pointers.
1174 Waste one element of value and location stack
1175 so that they stay on the same level as the state stack.
1176 The wasted elements are never initialized. */
1182 /*------------------------------------------------------------.
1183 | yynewstate -- Push a new state, which is found in yystate. |
1184 `------------------------------------------------------------*/
1186 /* In all cases, when you get here, the value and location stacks
1187 have just been pushed. So pushing a state here evens the stacks. */
1193 if (yyss + yystacksize - 1 <= yyssp)
1195 /* Get the current used size of the three stacks, in elements. */
1196 YYSIZE_T yysize = yyssp - yyss + 1;
1200 /* Give user a chance to reallocate the stack. Use copies of
1201 these so that the &'s don't force the real ones into
1203 YYSTYPE *yyvs1 = yyvs;
1204 yytype_int16 *yyss1 = yyss;
1206 /* Each stack pointer address is followed by the size of the
1207 data in use in that stack, in bytes. This used to be a
1208 conditional around just the two extra args, but that might
1209 be undefined if yyoverflow is a macro. */
1210 yyoverflow (YY_("memory exhausted"),
1211 &yyss1, yysize * sizeof (*yyssp),
1212 &yyvs1, yysize * sizeof (*yyvsp),
1218 #else /* no yyoverflow */
1219 # ifndef YYSTACK_RELOCATE
1220 goto yyexhaustedlab;
1222 /* Extend the stack our own way. */
1223 if (YYMAXDEPTH <= yystacksize)
1224 goto yyexhaustedlab;
1226 if (YYMAXDEPTH < yystacksize)
1227 yystacksize = YYMAXDEPTH;
1230 yytype_int16 *yyss1 = yyss;
1231 union yyalloc *yyptr =
1232 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1234 goto yyexhaustedlab;
1235 YYSTACK_RELOCATE (yyss_alloc, yyss);
1236 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1237 # undef YYSTACK_RELOCATE
1239 YYSTACK_FREE (yyss1);
1242 #endif /* no yyoverflow */
1244 yyssp = yyss + yysize - 1;
1245 yyvsp = yyvs + yysize - 1;
1247 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1248 (unsigned long int) yystacksize));
1250 if (yyss + yystacksize - 1 <= yyssp)
1254 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1256 if (yystate == YYFINAL)
1266 /* Do appropriate processing given the current state. Read a
1267 lookahead token if we need one and don't already have one. */
1269 /* First try to decide what to do without reference to lookahead token. */
1270 yyn = yypact[yystate];
1271 if (yyn == YYPACT_NINF)
1274 /* Not known => get a lookahead token if don't already have one. */
1276 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1277 if (yychar == YYEMPTY)
1279 YYDPRINTF ((stderr, "Reading a token: "));
1283 if (yychar <= YYEOF)
1285 yychar = yytoken = YYEOF;
1286 YYDPRINTF ((stderr, "Now at end of input.\n"));
1290 yytoken = YYTRANSLATE (yychar);
1291 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1294 /* If the proper action on seeing token YYTOKEN is to reduce or to
1295 detect an error, take that action. */
1297 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1302 if (yyn == 0 || yyn == YYTABLE_NINF)
1308 /* Count tokens shifted since error; after three, turn off error
1313 /* Shift the lookahead token. */
1314 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1316 /* Discard the shifted token. */
1325 /*-----------------------------------------------------------.
1326 | yydefault -- do the default action for the current state. |
1327 `-----------------------------------------------------------*/
1329 yyn = yydefact[yystate];
1335 /*-----------------------------.
1336 | yyreduce -- Do a reduction. |
1337 `-----------------------------*/
1339 /* yyn is the number of a rule to reduce with. */
1342 /* If YYLEN is nonzero, implement the default value of the action:
1345 Otherwise, the following line sets YYVAL to garbage.
1346 This behavior is undocumented and Bison
1347 users should not rely upon it. Assigning to YYVAL
1348 unconditionally makes the parser a bit smaller, and it avoids a
1349 GCC warning that YYVAL may be used uninitialized. */
1350 yyval = yyvsp[1-yylen];
1353 YY_REDUCE_PRINT (yyn);
1373 { path_push((yyvsp[(3) - (3)].text)); ;}
1378 { path_push((yyvsp[(1) - (1)].text)); ;}
1385 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1389 YY_STACK_PRINT (yyss, yyssp);
1393 /* Now `shift' the result of the reduction. Determine what state
1394 that goes to, based on the state we popped back to and the rule
1395 number reduced by. */
1399 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1400 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1401 yystate = yytable[yystate];
1403 yystate = yydefgoto[yyn - YYNTOKENS];
1408 /*------------------------------------.
1409 | yyerrlab -- here on detecting error |
1410 `------------------------------------*/
1412 /* If not already recovering from an error, report this error. */
1416 #if ! YYERROR_VERBOSE
1417 yyerror (YY_("syntax error"));
1420 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1421 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1423 YYSIZE_T yyalloc = 2 * yysize;
1424 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1425 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1426 if (yymsg != yymsgbuf)
1427 YYSTACK_FREE (yymsg);
1428 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1430 yymsg_alloc = yyalloc;
1434 yymsg_alloc = sizeof yymsgbuf;
1438 if (0 < yysize && yysize <= yymsg_alloc)
1440 (void) yysyntax_error (yymsg, yystate, yychar);
1445 yyerror (YY_("syntax error"));
1447 goto yyexhaustedlab;
1455 if (yyerrstatus == 3)
1457 /* If just tried and failed to reuse lookahead token after an
1458 error, discard it. */
1460 if (yychar <= YYEOF)
1462 /* Return failure if at end of input. */
1463 if (yychar == YYEOF)
1468 yydestruct ("Error: discarding",
1474 /* Else will try to reuse lookahead token after shifting the error
1479 /*---------------------------------------------------.
1480 | yyerrorlab -- error raised explicitly by YYERROR. |
1481 `---------------------------------------------------*/
1484 /* Pacify compilers like GCC when the user code never invokes
1485 YYERROR and the label yyerrorlab therefore never appears in user
1487 if (/*CONSTCOND*/ 0)
1490 /* Do not reclaim the symbols of the rule which action triggered
1494 YY_STACK_PRINT (yyss, yyssp);
1499 /*-------------------------------------------------------------.
1500 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1501 `-------------------------------------------------------------*/
1503 yyerrstatus = 3; /* Each real token shifted decrements this. */
1507 yyn = yypact[yystate];
1508 if (yyn != YYPACT_NINF)
1511 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1519 /* Pop the current state because it cannot handle the error token. */
1524 yydestruct ("Error: popping",
1525 yystos[yystate], yyvsp);
1528 YY_STACK_PRINT (yyss, yyssp);
1534 /* Shift the error token. */
1535 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1541 /*-------------------------------------.
1542 | yyacceptlab -- YYACCEPT comes here. |
1543 `-------------------------------------*/
1548 /*-----------------------------------.
1549 | yyabortlab -- YYABORT comes here. |
1550 `-----------------------------------*/
1555 #if !defined(yyoverflow) || YYERROR_VERBOSE
1556 /*-------------------------------------------------.
1557 | yyexhaustedlab -- memory exhaustion comes here. |
1558 `-------------------------------------------------*/
1560 yyerror (YY_("memory exhausted"));
1566 if (yychar != YYEMPTY)
1567 yydestruct ("Cleanup: discarding lookahead",
1569 /* Do not reclaim the symbols of the rule which action triggered
1570 this YYABORT or YYACCEPT. */
1572 YY_STACK_PRINT (yyss, yyssp);
1573 while (yyssp != yyss)
1575 yydestruct ("Cleanup: popping",
1576 yystos[*yyssp], yyvsp);
1581 YYSTACK_FREE (yyss);
1584 if (yymsg != yymsgbuf)
1585 YYSTACK_FREE (yymsg);
1587 /* Make sure YYID is used. */
1588 return YYID (yyresult);
1595 static lc_opt_error_handler_t *handler;
1596 static struct obstack obst;
1597 const char *optfilename = "";
1599 void PMANGLE(error)(const char *str)
1601 fprintf(stderr, "At line %d: %s\n", PMANGLE(linenr), str);
1604 static const char *path_stack[128];
1605 static int path_sp = 0;
1607 static lc_opt_entry_t *grp_stack[128];
1608 static int grp_sp = 0;
1609 #define CURR_GRP (grp_stack[grp_sp - 1])
1611 void lc_opt_init_parser(const char *filename, lc_opt_error_handler_t *err_handler)
1613 PMANGLE(linenr) = 1;
1614 obstack_init(&obst);
1615 handler = err_handler;
1616 optfilename = filename;
1617 grp_stack[grp_sp++] = lc_opt_root_grp();
1620 void _lc_opt_add_to_data_char(char c)
1622 obstack_1grow(&obst, c);
1625 static void path_push(text_t text)
1627 obstack_grow0(&obst, text.str, text.len);
1628 path_stack[path_sp++] = (const char*)obstack_finish(&obst);
1631 static void path_free(void)
1633 obstack_free(&obst, (void *) path_stack[0]);
1637 static void group_open(void)
1639 lc_opt_err_info_t err;
1640 lc_opt_entry_t *grp = lc_opt_resolve_grp(CURR_GRP, path_stack, path_sp, &err);
1644 grp_stack[grp_sp++] = grp;
1647 static void group_close(void)
1652 static void lc_opt_set(void)
1654 char *str = (char*)obstack_finish(&obst);
1656 lc_opt_err_info_t err;
1657 lc_opt_entry_t *opt = lc_opt_resolve_opt(CURR_GRP, path_stack, path_sp, &err);
1658 lc_opt_raise_error(&err, handler, "At %s(%d): ", optfilename, PMANGLE(linenr));
1660 lc_opt_occurs(opt, str, &err);
1661 lc_opt_raise_error(&err, handler, "At %s(%d): ", optfilename, PMANGLE(linenr));
1663 obstack_free(&obst, str);