1178825Sdfr/* A Bison parser, made by GNU Bison 2.3.  */
2178825Sdfr
3178825Sdfr/* Skeleton implementation for Bison's Yacc-like parsers in C
4178825Sdfr
5178825Sdfr   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6178825Sdfr   Free Software Foundation, Inc.
7178825Sdfr
8178825Sdfr   This program is free software; you can redistribute it and/or modify
9178825Sdfr   it under the terms of the GNU General Public License as published by
10178825Sdfr   the Free Software Foundation; either version 2, or (at your option)
11178825Sdfr   any later version.
12178825Sdfr
13178825Sdfr   This program is distributed in the hope that it will be useful,
14178825Sdfr   but WITHOUT ANY WARRANTY; without even the implied warranty of
15178825Sdfr   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16178825Sdfr   GNU General Public License for more details.
17178825Sdfr
18178825Sdfr   You should have received a copy of the GNU General Public License
19178825Sdfr   along with this program; if not, write to the Free Software
20178825Sdfr   Foundation, Inc., 51 Franklin Street, Fifth Floor,
21178825Sdfr   Boston, MA 02110-1301, USA.  */
22178825Sdfr
23178825Sdfr/* As a special exception, you may create a larger work that contains
24178825Sdfr   part or all of the Bison parser skeleton and distribute that work
25178825Sdfr   under terms of your choice, so long as that work isn't itself a
26178825Sdfr   parser generator using the skeleton or a modified version thereof
27178825Sdfr   as a parser skeleton.  Alternatively, if you modify or redistribute
28178825Sdfr   the parser skeleton itself, you may (at your option) remove this
29178825Sdfr   special exception, which will cause the skeleton and the resulting
30178825Sdfr   Bison output files to be licensed under the GNU General Public
31178825Sdfr   License without this special exception.
32178825Sdfr
33178825Sdfr   This special exception was added by the Free Software Foundation in
34178825Sdfr   version 2.2 of Bison.  */
35178825Sdfr
36178825Sdfr/* C LALR(1) parser skeleton written by Richard Stallman, by
37178825Sdfr   simplifying the original so-called "semantic" parser.  */
38178825Sdfr
39178825Sdfr/* All symbols defined below should begin with yy or YY, to avoid
40178825Sdfr   infringing on user name space.  This should be done even for local
41178825Sdfr   variables, as they might otherwise be expanded by user macros.
42178825Sdfr   There are some unavoidable exceptions within include files to
43178825Sdfr   define necessary library symbols; they are noted "INFRINGES ON
44178825Sdfr   USER NAME SPACE" below.  */
45178825Sdfr
46178825Sdfr/* Identify Bison output.  */
47178825Sdfr#define YYBISON 1
48178825Sdfr
49178825Sdfr/* Bison version.  */
50178825Sdfr#define YYBISON_VERSION "2.3"
51178825Sdfr
52178825Sdfr/* Skeleton name.  */
53178825Sdfr#define YYSKELETON_NAME "yacc.c"
54178825Sdfr
55178825Sdfr/* Pure parsers.  */
56178825Sdfr#define YYPURE 0
57178825Sdfr
58178825Sdfr/* Using locations.  */
59178825Sdfr#define YYLSP_NEEDED 0
60178825Sdfr
61178825Sdfr
62178825Sdfr
63178825Sdfr/* Tokens.  */
64178825Sdfr#ifndef YYTOKENTYPE
65178825Sdfr# define YYTOKENTYPE
66178825Sdfr   /* Put the tokens into the symbol table, so that GDB and other debuggers
67178825Sdfr      know about them.  */
68178825Sdfr   enum yytokentype {
69178825Sdfr     LITERAL = 258,
70178825Sdfr     STRING = 259
71178825Sdfr   };
72178825Sdfr#endif
73178825Sdfr/* Tokens.  */
74178825Sdfr#define LITERAL 258
75178825Sdfr#define STRING 259
76178825Sdfr
77178825Sdfr
78178825Sdfr
79178825Sdfr
80178825Sdfr/* Copy the first part of user declarations.  */
81178825Sdfr#line 1 "slc-gram.y"
82178825Sdfr
83178825Sdfr/*
84178825Sdfr * Copyright (c) 2004-2006 Kungliga Tekniska H�gskolan
85178825Sdfr * (Royal Institute of Technology, Stockholm, Sweden).
86178825Sdfr * All rights reserved.
87178825Sdfr *
88178825Sdfr * Redistribution and use in source and binary forms, with or without
89178825Sdfr * modification, are permitted provided that the following conditions
90178825Sdfr * are met:
91178825Sdfr *
92178825Sdfr * 1. Redistributions of source code must retain the above copyright
93178825Sdfr *    notice, this list of conditions and the following disclaimer.
94178825Sdfr *
95178825Sdfr * 2. Redistributions in binary form must reproduce the above copyright
96178825Sdfr *    notice, this list of conditions and the following disclaimer in the
97178825Sdfr *    documentation and/or other materials provided with the distribution.
98178825Sdfr *
99178825Sdfr * 3. Neither the name of the Institute nor the names of its contributors
100178825Sdfr *    may be used to endorse or promote products derived from this software
101178825Sdfr *    without specific prior written permission.
102178825Sdfr *
103178825Sdfr * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
104178825Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
105178825Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
106178825Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
107178825Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
108178825Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
109178825Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
110178825Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
111178825Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
112178825Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
113178825Sdfr * SUCH DAMAGE.
114178825Sdfr */
115178825Sdfr
116178825Sdfr#ifdef HAVE_CONFIG_H
117178825Sdfr#include <config.h>
118178825SdfrRCSID("$Id: slc-gram.y 20767 2007-06-01 11:24:52Z lha $");
119178825Sdfr#endif
120178825Sdfr
121178825Sdfr#include <stdio.h>
122178825Sdfr#include <stdlib.h>
123178825Sdfr#include <err.h>
124178825Sdfr#include <ctype.h>
125178825Sdfr#include <limits.h>
126178825Sdfr#include <getarg.h>
127178825Sdfr#include <vers.h>
128178825Sdfr#include <roken.h>
129178825Sdfr
130178825Sdfr#include "slc.h"
131178825Sdfrextern FILE *yyin;
132178825Sdfrextern struct assignment *assignment;
133178825Sdfr
134178825Sdfr
135178825Sdfr/* Enabling traces.  */
136178825Sdfr#ifndef YYDEBUG
137178825Sdfr# define YYDEBUG 0
138178825Sdfr#endif
139178825Sdfr
140178825Sdfr/* Enabling verbose error messages.  */
141178825Sdfr#ifdef YYERROR_VERBOSE
142178825Sdfr# undef YYERROR_VERBOSE
143178825Sdfr# define YYERROR_VERBOSE 1
144178825Sdfr#else
145178825Sdfr# define YYERROR_VERBOSE 0
146178825Sdfr#endif
147178825Sdfr
148178825Sdfr/* Enabling the token table.  */
149178825Sdfr#ifndef YYTOKEN_TABLE
150178825Sdfr# define YYTOKEN_TABLE 0
151178825Sdfr#endif
152178825Sdfr
153178825Sdfr#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
154178825Sdfrtypedef union YYSTYPE
155178825Sdfr#line 54 "slc-gram.y"
156178825Sdfr{
157178825Sdfr	char *string;
158178825Sdfr	struct assignment *assignment;
159178825Sdfr}
160178825Sdfr/* Line 193 of yacc.c.  */
161178825Sdfr#line 162 "slc-gram.c"
162178825Sdfr	YYSTYPE;
163178825Sdfr# define yystype YYSTYPE /* obsolescent; will be withdrawn */
164178825Sdfr# define YYSTYPE_IS_DECLARED 1
165178825Sdfr# define YYSTYPE_IS_TRIVIAL 1
166178825Sdfr#endif
167178825Sdfr
168178825Sdfr
169178825Sdfr
170178825Sdfr/* Copy the second part of user declarations.  */
171178825Sdfr
172178825Sdfr
173178825Sdfr/* Line 216 of yacc.c.  */
174178825Sdfr#line 175 "slc-gram.c"
175178825Sdfr
176178825Sdfr#ifdef short
177178825Sdfr# undef short
178178825Sdfr#endif
179178825Sdfr
180178825Sdfr#ifdef YYTYPE_UINT8
181178825Sdfrtypedef YYTYPE_UINT8 yytype_uint8;
182178825Sdfr#else
183178825Sdfrtypedef unsigned char yytype_uint8;
184178825Sdfr#endif
185178825Sdfr
186178825Sdfr#ifdef YYTYPE_INT8
187178825Sdfrtypedef YYTYPE_INT8 yytype_int8;
188178825Sdfr#elif (defined __STDC__ || defined __C99__FUNC__ \
189178825Sdfr     || defined __cplusplus || defined _MSC_VER)
190178825Sdfrtypedef signed char yytype_int8;
191178825Sdfr#else
192178825Sdfrtypedef short int yytype_int8;
193178825Sdfr#endif
194178825Sdfr
195178825Sdfr#ifdef YYTYPE_UINT16
196178825Sdfrtypedef YYTYPE_UINT16 yytype_uint16;
197178825Sdfr#else
198178825Sdfrtypedef unsigned short int yytype_uint16;
199178825Sdfr#endif
200178825Sdfr
201178825Sdfr#ifdef YYTYPE_INT16
202178825Sdfrtypedef YYTYPE_INT16 yytype_int16;
203178825Sdfr#else
204178825Sdfrtypedef short int yytype_int16;
205178825Sdfr#endif
206178825Sdfr
207178825Sdfr#ifndef YYSIZE_T
208178825Sdfr# ifdef __SIZE_TYPE__
209178825Sdfr#  define YYSIZE_T __SIZE_TYPE__
210178825Sdfr# elif defined size_t
211178825Sdfr#  define YYSIZE_T size_t
212178825Sdfr# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
213178825Sdfr     || defined __cplusplus || defined _MSC_VER)
214178825Sdfr#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
215178825Sdfr#  define YYSIZE_T size_t
216178825Sdfr# else
217178825Sdfr#  define YYSIZE_T unsigned int
218178825Sdfr# endif
219178825Sdfr#endif
220178825Sdfr
221178825Sdfr#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
222178825Sdfr
223178825Sdfr#ifndef YY_
224178825Sdfr# if defined YYENABLE_NLS && YYENABLE_NLS
225178825Sdfr#  if ENABLE_NLS
226178825Sdfr#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
227178825Sdfr#   define YY_(msgid) dgettext ("bison-runtime", msgid)
228178825Sdfr#  endif
229178825Sdfr# endif
230178825Sdfr# ifndef YY_
231178825Sdfr#  define YY_(msgid) msgid
232178825Sdfr# endif
233178825Sdfr#endif
234178825Sdfr
235178825Sdfr/* Suppress unused-variable warnings by "using" E.  */
236178825Sdfr#if ! defined lint || defined __GNUC__
237178825Sdfr# define YYUSE(e) ((void) (e))
238178825Sdfr#else
239178825Sdfr# define YYUSE(e) /* empty */
240178825Sdfr#endif
241178825Sdfr
242178825Sdfr/* Identity function, used to suppress warnings about constant conditions.  */
243178825Sdfr#ifndef lint
244178825Sdfr# define YYID(n) (n)
245178825Sdfr#else
246178825Sdfr#if (defined __STDC__ || defined __C99__FUNC__ \
247178825Sdfr     || defined __cplusplus || defined _MSC_VER)
248178825Sdfrstatic int
249178825SdfrYYID (int i)
250178825Sdfr#else
251178825Sdfrstatic int
252178825SdfrYYID (i)
253178825Sdfr    int i;
254178825Sdfr#endif
255178825Sdfr{
256178825Sdfr  return i;
257178825Sdfr}
258178825Sdfr#endif
259178825Sdfr
260178825Sdfr#if ! defined yyoverflow || YYERROR_VERBOSE
261178825Sdfr
262178825Sdfr/* The parser invokes alloca or malloc; define the necessary symbols.  */
263178825Sdfr
264178825Sdfr# ifdef YYSTACK_USE_ALLOCA
265178825Sdfr#  if YYSTACK_USE_ALLOCA
266178825Sdfr#   ifdef __GNUC__
267178825Sdfr#    define YYSTACK_ALLOC __builtin_alloca
268178825Sdfr#   elif defined __BUILTIN_VA_ARG_INCR
269178825Sdfr#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
270178825Sdfr#   elif defined _AIX
271178825Sdfr#    define YYSTACK_ALLOC __alloca
272178825Sdfr#   elif defined _MSC_VER
273178825Sdfr#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
274178825Sdfr#    define alloca _alloca
275178825Sdfr#   else
276178825Sdfr#    define YYSTACK_ALLOC alloca
277178825Sdfr#    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
278178825Sdfr     || defined __cplusplus || defined _MSC_VER)
279178825Sdfr#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
280178825Sdfr#     ifndef _STDLIB_H
281178825Sdfr#      define _STDLIB_H 1
282178825Sdfr#     endif
283178825Sdfr#    endif
284178825Sdfr#   endif
285178825Sdfr#  endif
286178825Sdfr# endif
287178825Sdfr
288178825Sdfr# ifdef YYSTACK_ALLOC
289178825Sdfr   /* Pacify GCC's `empty if-body' warning.  */
290178825Sdfr#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
291178825Sdfr#  ifndef YYSTACK_ALLOC_MAXIMUM
292178825Sdfr    /* The OS might guarantee only one guard page at the bottom of the stack,
293178825Sdfr       and a page size can be as small as 4096 bytes.  So we cannot safely
294178825Sdfr       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
295178825Sdfr       to allow for a few compiler-allocated temporary stack slots.  */
296178825Sdfr#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
297178825Sdfr#  endif
298178825Sdfr# else
299178825Sdfr#  define YYSTACK_ALLOC YYMALLOC
300178825Sdfr#  define YYSTACK_FREE YYFREE
301178825Sdfr#  ifndef YYSTACK_ALLOC_MAXIMUM
302178825Sdfr#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
303178825Sdfr#  endif
304178825Sdfr#  if (defined __cplusplus && ! defined _STDLIB_H \
305178825Sdfr       && ! ((defined YYMALLOC || defined malloc) \
306178825Sdfr	     && (defined YYFREE || defined free)))
307178825Sdfr#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
308178825Sdfr#   ifndef _STDLIB_H
309178825Sdfr#    define _STDLIB_H 1
310178825Sdfr#   endif
311178825Sdfr#  endif
312178825Sdfr#  ifndef YYMALLOC
313178825Sdfr#   define YYMALLOC malloc
314178825Sdfr#   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
315178825Sdfr     || defined __cplusplus || defined _MSC_VER)
316178825Sdfrvoid *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
317178825Sdfr#   endif
318178825Sdfr#  endif
319178825Sdfr#  ifndef YYFREE
320178825Sdfr#   define YYFREE free
321178825Sdfr#   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
322178825Sdfr     || defined __cplusplus || defined _MSC_VER)
323178825Sdfrvoid free (void *); /* INFRINGES ON USER NAME SPACE */
324178825Sdfr#   endif
325178825Sdfr#  endif
326178825Sdfr# endif
327178825Sdfr#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
328178825Sdfr
329178825Sdfr
330178825Sdfr#if (! defined yyoverflow \
331178825Sdfr     && (! defined __cplusplus \
332178825Sdfr	 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
333178825Sdfr
334178825Sdfr/* A type that is properly aligned for any stack member.  */
335178825Sdfrunion yyalloc
336178825Sdfr{
337178825Sdfr  yytype_int16 yyss;
338178825Sdfr  YYSTYPE yyvs;
339178825Sdfr  };
340178825Sdfr
341178825Sdfr/* The size of the maximum gap between one aligned stack and the next.  */
342178825Sdfr# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
343178825Sdfr
344178825Sdfr/* The size of an array large to enough to hold all stacks, each with
345178825Sdfr   N elements.  */
346178825Sdfr# define YYSTACK_BYTES(N) \
347178825Sdfr     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
348178825Sdfr      + YYSTACK_GAP_MAXIMUM)
349178825Sdfr
350178825Sdfr/* Copy COUNT objects from FROM to TO.  The source and destination do
351178825Sdfr   not overlap.  */
352178825Sdfr# ifndef YYCOPY
353178825Sdfr#  if defined __GNUC__ && 1 < __GNUC__
354178825Sdfr#   define YYCOPY(To, From, Count) \
355178825Sdfr      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
356178825Sdfr#  else
357178825Sdfr#   define YYCOPY(To, From, Count)		\
358178825Sdfr      do					\
359178825Sdfr	{					\
360178825Sdfr	  YYSIZE_T yyi;				\
361178825Sdfr	  for (yyi = 0; yyi < (Count); yyi++)	\
362178825Sdfr	    (To)[yyi] = (From)[yyi];		\
363178825Sdfr	}					\
364178825Sdfr      while (YYID (0))
365178825Sdfr#  endif
366178825Sdfr# endif
367178825Sdfr
368178825Sdfr/* Relocate STACK from its old location to the new one.  The
369178825Sdfr   local variables YYSIZE and YYSTACKSIZE give the old and new number of
370178825Sdfr   elements in the stack, and YYPTR gives the new location of the
371178825Sdfr   stack.  Advance YYPTR to a properly aligned location for the next
372178825Sdfr   stack.  */
373178825Sdfr# define YYSTACK_RELOCATE(Stack)					\
374178825Sdfr    do									\
375178825Sdfr      {									\
376178825Sdfr	YYSIZE_T yynewbytes;						\
377178825Sdfr	YYCOPY (&yyptr->Stack, Stack, yysize);				\
378178825Sdfr	Stack = &yyptr->Stack;						\
379178825Sdfr	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
380178825Sdfr	yyptr += yynewbytes / sizeof (*yyptr);				\
381178825Sdfr      }									\
382178825Sdfr    while (YYID (0))
383178825Sdfr
384178825Sdfr#endif
385178825Sdfr
386178825Sdfr/* YYFINAL -- State number of the termination state.  */
387178825Sdfr#define YYFINAL  6
388178825Sdfr/* YYLAST -- Last index in YYTABLE.  */
389178825Sdfr#define YYLAST   7
390178825Sdfr
391178825Sdfr/* YYNTOKENS -- Number of terminals.  */
392178825Sdfr#define YYNTOKENS  8
393178825Sdfr/* YYNNTS -- Number of nonterminals.  */
394178825Sdfr#define YYNNTS  4
395178825Sdfr/* YYNRULES -- Number of rules.  */
396178825Sdfr#define YYNRULES  6
397178825Sdfr/* YYNRULES -- Number of states.  */
398178825Sdfr#define YYNSTATES  12
399178825Sdfr
400178825Sdfr/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
401178825Sdfr#define YYUNDEFTOK  2
402178825Sdfr#define YYMAXUTOK   259
403178825Sdfr
404178825Sdfr#define YYTRANSLATE(YYX)						\
405178825Sdfr  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
406178825Sdfr
407178825Sdfr/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
408178825Sdfrstatic const yytype_uint8 yytranslate[] =
409178825Sdfr{
410178825Sdfr       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
411178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
412178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
413178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
414178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
415178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
416178825Sdfr       2,     5,     2,     2,     2,     2,     2,     2,     2,     2,
417178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
418178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
419178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
420178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
421178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
422178825Sdfr       2,     2,     2,     6,     2,     7,     2,     2,     2,     2,
423178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
424178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
425178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
426178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
427178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
428178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
429178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
430178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
431178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
432178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
433178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
434178825Sdfr       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
435178825Sdfr       2,     2,     2,     2,     2,     2,     1,     2,     3,     4
436178825Sdfr};
437178825Sdfr
438178825Sdfr#if YYDEBUG
439178825Sdfr/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
440178825Sdfr   YYRHS.  */
441178825Sdfrstatic const yytype_uint8 yyprhs[] =
442178825Sdfr{
443178825Sdfr       0,     0,     3,     5,     8,    10,    14
444178825Sdfr};
445178825Sdfr
446178825Sdfr/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
447178825Sdfrstatic const yytype_int8 yyrhs[] =
448178825Sdfr{
449178825Sdfr       9,     0,    -1,    10,    -1,    11,    10,    -1,    11,    -1,
450178825Sdfr       3,     5,     4,    -1,     3,     5,     6,    10,     7,    -1
451178825Sdfr};
452178825Sdfr
453178825Sdfr/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
454178825Sdfrstatic const yytype_uint8 yyrline[] =
455178825Sdfr{
456178825Sdfr       0,    67,    67,    73,    78,    81,    90
457178825Sdfr};
458178825Sdfr#endif
459178825Sdfr
460178825Sdfr#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
461178825Sdfr/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
462178825Sdfr   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
463178825Sdfrstatic const char *const yytname[] =
464178825Sdfr{
465178825Sdfr  "$end", "error", "$undefined", "LITERAL", "STRING", "'='", "'{'", "'}'",
466178825Sdfr  "$accept", "start", "assignments", "assignment", 0
467178825Sdfr};
468178825Sdfr#endif
469178825Sdfr
470178825Sdfr# ifdef YYPRINT
471178825Sdfr/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
472178825Sdfr   token YYLEX-NUM.  */
473178825Sdfrstatic const yytype_uint16 yytoknum[] =
474178825Sdfr{
475178825Sdfr       0,   256,   257,   258,   259,    61,   123,   125
476178825Sdfr};
477178825Sdfr# endif
478178825Sdfr
479178825Sdfr/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
480178825Sdfrstatic const yytype_uint8 yyr1[] =
481178825Sdfr{
482178825Sdfr       0,     8,     9,    10,    10,    11,    11
483178825Sdfr};
484178825Sdfr
485178825Sdfr/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
486178825Sdfrstatic const yytype_uint8 yyr2[] =
487178825Sdfr{
488178825Sdfr       0,     2,     1,     2,     1,     3,     5
489178825Sdfr};
490178825Sdfr
491178825Sdfr/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
492178825Sdfr   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
493178825Sdfr   means the default is an error.  */
494178825Sdfrstatic const yytype_uint8 yydefact[] =
495178825Sdfr{
496178825Sdfr       0,     0,     0,     2,     4,     0,     1,     3,     5,     0,
497178825Sdfr       0,     6
498178825Sdfr};
499178825Sdfr
500178825Sdfr/* YYDEFGOTO[NTERM-NUM].  */
501178825Sdfrstatic const yytype_int8 yydefgoto[] =
502178825Sdfr{
503178825Sdfr      -1,     2,     3,     4
504178825Sdfr};
505178825Sdfr
506178825Sdfr/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
507178825Sdfr   STATE-NUM.  */
508178825Sdfr#define YYPACT_NINF -5
509178825Sdfrstatic const yytype_int8 yypact[] =
510178825Sdfr{
511178825Sdfr      -1,     1,     4,    -5,    -1,    -3,    -5,    -5,    -5,    -1,
512178825Sdfr       0,    -5
513178825Sdfr};
514178825Sdfr
515178825Sdfr/* YYPGOTO[NTERM-NUM].  */
516178825Sdfrstatic const yytype_int8 yypgoto[] =
517178825Sdfr{
518178825Sdfr      -5,    -5,    -4,    -5
519178825Sdfr};
520178825Sdfr
521178825Sdfr/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
522178825Sdfr   positive, shift that token.  If negative, reduce the rule which
523178825Sdfr   number is the opposite.  If zero, do what YYDEFACT says.
524178825Sdfr   If YYTABLE_NINF, syntax error.  */
525178825Sdfr#define YYTABLE_NINF -1
526178825Sdfrstatic const yytype_uint8 yytable[] =
527178825Sdfr{
528178825Sdfr       7,     8,     1,     9,     6,    10,     5,    11
529178825Sdfr};
530178825Sdfr
531178825Sdfrstatic const yytype_uint8 yycheck[] =
532178825Sdfr{
533178825Sdfr       4,     4,     3,     6,     0,     9,     5,     7
534178825Sdfr};
535178825Sdfr
536178825Sdfr/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
537178825Sdfr   symbol of state STATE-NUM.  */
538178825Sdfrstatic const yytype_uint8 yystos[] =
539178825Sdfr{
540178825Sdfr       0,     3,     9,    10,    11,     5,     0,    10,     4,     6,
541178825Sdfr      10,     7
542178825Sdfr};
543178825Sdfr
544178825Sdfr#define yyerrok		(yyerrstatus = 0)
545178825Sdfr#define yyclearin	(yychar = YYEMPTY)
546178825Sdfr#define YYEMPTY		(-2)
547178825Sdfr#define YYEOF		0
548178825Sdfr
549178825Sdfr#define YYACCEPT	goto yyacceptlab
550178825Sdfr#define YYABORT		goto yyabortlab
551178825Sdfr#define YYERROR		goto yyerrorlab
552178825Sdfr
553178825Sdfr
554178825Sdfr/* Like YYERROR except do call yyerror.  This remains here temporarily
555178825Sdfr   to ease the transition to the new meaning of YYERROR, for GCC.
556178825Sdfr   Once GCC version 2 has supplanted version 1, this can go.  */
557178825Sdfr
558178825Sdfr#define YYFAIL		goto yyerrlab
559178825Sdfr
560178825Sdfr#define YYRECOVERING()  (!!yyerrstatus)
561178825Sdfr
562178825Sdfr#define YYBACKUP(Token, Value)					\
563178825Sdfrdo								\
564178825Sdfr  if (yychar == YYEMPTY && yylen == 1)				\
565178825Sdfr    {								\
566178825Sdfr      yychar = (Token);						\
567178825Sdfr      yylval = (Value);						\
568178825Sdfr      yytoken = YYTRANSLATE (yychar);				\
569178825Sdfr      YYPOPSTACK (1);						\
570178825Sdfr      goto yybackup;						\
571178825Sdfr    }								\
572178825Sdfr  else								\
573178825Sdfr    {								\
574178825Sdfr      yyerror (YY_("syntax error: cannot back up")); \
575178825Sdfr      YYERROR;							\
576178825Sdfr    }								\
577178825Sdfrwhile (YYID (0))
578178825Sdfr
579178825Sdfr
580178825Sdfr#define YYTERROR	1
581178825Sdfr#define YYERRCODE	256
582178825Sdfr
583178825Sdfr
584178825Sdfr/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
585178825Sdfr   If N is 0, then set CURRENT to the empty location which ends
586178825Sdfr   the previous symbol: RHS[0] (always defined).  */
587178825Sdfr
588178825Sdfr#define YYRHSLOC(Rhs, K) ((Rhs)[K])
589178825Sdfr#ifndef YYLLOC_DEFAULT
590178825Sdfr# define YYLLOC_DEFAULT(Current, Rhs, N)				\
591178825Sdfr    do									\
592178825Sdfr      if (YYID (N))                                                    \
593178825Sdfr	{								\
594178825Sdfr	  (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;	\
595178825Sdfr	  (Current).first_column = YYRHSLOC (Rhs, 1).first_column;	\
596178825Sdfr	  (Current).last_line    = YYRHSLOC (Rhs, N).last_line;		\
597178825Sdfr	  (Current).last_column  = YYRHSLOC (Rhs, N).last_column;	\
598178825Sdfr	}								\
599178825Sdfr      else								\
600178825Sdfr	{								\
601178825Sdfr	  (Current).first_line   = (Current).last_line   =		\
602178825Sdfr	    YYRHSLOC (Rhs, 0).last_line;				\
603178825Sdfr	  (Current).first_column = (Current).last_column =		\
604178825Sdfr	    YYRHSLOC (Rhs, 0).last_column;				\
605178825Sdfr	}								\
606178825Sdfr    while (YYID (0))
607178825Sdfr#endif
608178825Sdfr
609178825Sdfr
610178825Sdfr/* YY_LOCATION_PRINT -- Print the location on the stream.
611178825Sdfr   This macro was not mandated originally: define only if we know
612178825Sdfr   we won't break user code: when these are the locations we know.  */
613178825Sdfr
614178825Sdfr#ifndef YY_LOCATION_PRINT
615178825Sdfr# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
616178825Sdfr#  define YY_LOCATION_PRINT(File, Loc)			\
617178825Sdfr     fprintf (File, "%d.%d-%d.%d",			\
618178825Sdfr	      (Loc).first_line, (Loc).first_column,	\
619178825Sdfr	      (Loc).last_line,  (Loc).last_column)
620178825Sdfr# else
621178825Sdfr#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
622178825Sdfr# endif
623178825Sdfr#endif
624178825Sdfr
625178825Sdfr
626178825Sdfr/* YYLEX -- calling `yylex' with the right arguments.  */
627178825Sdfr
628178825Sdfr#ifdef YYLEX_PARAM
629178825Sdfr# define YYLEX yylex (YYLEX_PARAM)
630178825Sdfr#else
631178825Sdfr# define YYLEX yylex ()
632178825Sdfr#endif
633178825Sdfr
634178825Sdfr/* Enable debugging if requested.  */
635178825Sdfr#if YYDEBUG
636178825Sdfr
637178825Sdfr# ifndef YYFPRINTF
638178825Sdfr#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
639178825Sdfr#  define YYFPRINTF fprintf
640178825Sdfr# endif
641178825Sdfr
642178825Sdfr# define YYDPRINTF(Args)			\
643178825Sdfrdo {						\
644178825Sdfr  if (yydebug)					\
645178825Sdfr    YYFPRINTF Args;				\
646178825Sdfr} while (YYID (0))
647178825Sdfr
648178825Sdfr# define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
649178825Sdfrdo {									  \
650178825Sdfr  if (yydebug)								  \
651178825Sdfr    {									  \
652178825Sdfr      YYFPRINTF (stderr, "%s ", Title);					  \
653178825Sdfr      yy_symbol_print (stderr,						  \
654178825Sdfr		  Type, Value); \
655178825Sdfr      YYFPRINTF (stderr, "\n");						  \
656178825Sdfr    }									  \
657178825Sdfr} while (YYID (0))
658178825Sdfr
659178825Sdfr
660178825Sdfr/*--------------------------------.
661178825Sdfr| Print this symbol on YYOUTPUT.  |
662178825Sdfr`--------------------------------*/
663178825Sdfr
664178825Sdfr/*ARGSUSED*/
665178825Sdfr#if (defined __STDC__ || defined __C99__FUNC__ \
666178825Sdfr     || defined __cplusplus || defined _MSC_VER)
667178825Sdfrstatic void
668178825Sdfryy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
669178825Sdfr#else
670178825Sdfrstatic void
671178825Sdfryy_symbol_value_print (yyoutput, yytype, yyvaluep)
672178825Sdfr    FILE *yyoutput;
673178825Sdfr    int yytype;
674178825Sdfr    YYSTYPE const * const yyvaluep;
675178825Sdfr#endif
676178825Sdfr{
677178825Sdfr  if (!yyvaluep)
678178825Sdfr    return;
679178825Sdfr# ifdef YYPRINT
680178825Sdfr  if (yytype < YYNTOKENS)
681178825Sdfr    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
682178825Sdfr# else
683178825Sdfr  YYUSE (yyoutput);
684178825Sdfr# endif
685178825Sdfr  switch (yytype)
686178825Sdfr    {
687178825Sdfr      default:
688178825Sdfr	break;
689178825Sdfr    }
690178825Sdfr}
691178825Sdfr
692178825Sdfr
693178825Sdfr/*--------------------------------.
694178825Sdfr| Print this symbol on YYOUTPUT.  |
695178825Sdfr`--------------------------------*/
696178825Sdfr
697178825Sdfr#if (defined __STDC__ || defined __C99__FUNC__ \
698178825Sdfr     || defined __cplusplus || defined _MSC_VER)
699178825Sdfrstatic void
700178825Sdfryy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
701178825Sdfr#else
702178825Sdfrstatic void
703178825Sdfryy_symbol_print (yyoutput, yytype, yyvaluep)
704178825Sdfr    FILE *yyoutput;
705178825Sdfr    int yytype;
706178825Sdfr    YYSTYPE const * const yyvaluep;
707178825Sdfr#endif
708178825Sdfr{
709178825Sdfr  if (yytype < YYNTOKENS)
710178825Sdfr    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
711178825Sdfr  else
712178825Sdfr    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
713178825Sdfr
714178825Sdfr  yy_symbol_value_print (yyoutput, yytype, yyvaluep);
715178825Sdfr  YYFPRINTF (yyoutput, ")");
716178825Sdfr}
717178825Sdfr
718178825Sdfr/*------------------------------------------------------------------.
719178825Sdfr| yy_stack_print -- Print the state stack from its BOTTOM up to its |
720178825Sdfr| TOP (included).                                                   |
721178825Sdfr`------------------------------------------------------------------*/
722178825Sdfr
723178825Sdfr#if (defined __STDC__ || defined __C99__FUNC__ \
724178825Sdfr     || defined __cplusplus || defined _MSC_VER)
725178825Sdfrstatic void
726178825Sdfryy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
727178825Sdfr#else
728178825Sdfrstatic void
729178825Sdfryy_stack_print (bottom, top)
730178825Sdfr    yytype_int16 *bottom;
731178825Sdfr    yytype_int16 *top;
732178825Sdfr#endif
733178825Sdfr{
734178825Sdfr  YYFPRINTF (stderr, "Stack now");
735178825Sdfr  for (; bottom <= top; ++bottom)
736178825Sdfr    YYFPRINTF (stderr, " %d", *bottom);
737178825Sdfr  YYFPRINTF (stderr, "\n");
738178825Sdfr}
739178825Sdfr
740178825Sdfr# define YY_STACK_PRINT(Bottom, Top)				\
741178825Sdfrdo {								\
742178825Sdfr  if (yydebug)							\
743178825Sdfr    yy_stack_print ((Bottom), (Top));				\
744178825Sdfr} while (YYID (0))
745178825Sdfr
746178825Sdfr
747178825Sdfr/*------------------------------------------------.
748178825Sdfr| Report that the YYRULE is going to be reduced.  |
749178825Sdfr`------------------------------------------------*/
750178825Sdfr
751178825Sdfr#if (defined __STDC__ || defined __C99__FUNC__ \
752178825Sdfr     || defined __cplusplus || defined _MSC_VER)
753178825Sdfrstatic void
754178825Sdfryy_reduce_print (YYSTYPE *yyvsp, int yyrule)
755178825Sdfr#else
756178825Sdfrstatic void
757178825Sdfryy_reduce_print (yyvsp, yyrule)
758178825Sdfr    YYSTYPE *yyvsp;
759178825Sdfr    int yyrule;
760178825Sdfr#endif
761178825Sdfr{
762178825Sdfr  int yynrhs = yyr2[yyrule];
763178825Sdfr  int yyi;
764178825Sdfr  unsigned long int yylno = yyrline[yyrule];
765178825Sdfr  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
766178825Sdfr	     yyrule - 1, yylno);
767178825Sdfr  /* The symbols being reduced.  */
768178825Sdfr  for (yyi = 0; yyi < yynrhs; yyi++)
769178825Sdfr    {
770178825Sdfr      fprintf (stderr, "   $%d = ", yyi + 1);
771178825Sdfr      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
772178825Sdfr		       &(yyvsp[(yyi + 1) - (yynrhs)])
773178825Sdfr		       		       );
774178825Sdfr      fprintf (stderr, "\n");
775178825Sdfr    }
776178825Sdfr}
777178825Sdfr
778178825Sdfr# define YY_REDUCE_PRINT(Rule)		\
779178825Sdfrdo {					\
780178825Sdfr  if (yydebug)				\
781178825Sdfr    yy_reduce_print (yyvsp, Rule); \
782178825Sdfr} while (YYID (0))
783178825Sdfr
784178825Sdfr/* Nonzero means print parse trace.  It is left uninitialized so that
785178825Sdfr   multiple parsers can coexist.  */
786178825Sdfrint yydebug;
787178825Sdfr#else /* !YYDEBUG */
788178825Sdfr# define YYDPRINTF(Args)
789178825Sdfr# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
790178825Sdfr# define YY_STACK_PRINT(Bottom, Top)
791178825Sdfr# define YY_REDUCE_PRINT(Rule)
792178825Sdfr#endif /* !YYDEBUG */
793178825Sdfr
794178825Sdfr
795178825Sdfr/* YYINITDEPTH -- initial size of the parser's stacks.  */
796178825Sdfr#ifndef	YYINITDEPTH
797178825Sdfr# define YYINITDEPTH 200
798178825Sdfr#endif
799178825Sdfr
800178825Sdfr/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
801178825Sdfr   if the built-in stack extension method is used).
802178825Sdfr
803178825Sdfr   Do not make this value too large; the results are undefined if
804178825Sdfr   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
805178825Sdfr   evaluated with infinite-precision integer arithmetic.  */
806178825Sdfr
807178825Sdfr#ifndef YYMAXDEPTH
808178825Sdfr# define YYMAXDEPTH 10000
809178825Sdfr#endif
810178825Sdfr
811178825Sdfr
812178825Sdfr
813178825Sdfr#if YYERROR_VERBOSE
814178825Sdfr
815178825Sdfr# ifndef yystrlen
816178825Sdfr#  if defined __GLIBC__ && defined _STRING_H
817178825Sdfr#   define yystrlen strlen
818178825Sdfr#  else
819178825Sdfr/* Return the length of YYSTR.  */
820178825Sdfr#if (defined __STDC__ || defined __C99__FUNC__ \
821178825Sdfr     || defined __cplusplus || defined _MSC_VER)
822178825Sdfrstatic YYSIZE_T
823178825Sdfryystrlen (const char *yystr)
824178825Sdfr#else
825178825Sdfrstatic YYSIZE_T
826178825Sdfryystrlen (yystr)
827178825Sdfr    const char *yystr;
828178825Sdfr#endif
829178825Sdfr{
830178825Sdfr  YYSIZE_T yylen;
831178825Sdfr  for (yylen = 0; yystr[yylen]; yylen++)
832178825Sdfr    continue;
833178825Sdfr  return yylen;
834178825Sdfr}
835178825Sdfr#  endif
836178825Sdfr# endif
837178825Sdfr
838178825Sdfr# ifndef yystpcpy
839178825Sdfr#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
840178825Sdfr#   define yystpcpy stpcpy
841178825Sdfr#  else
842178825Sdfr/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
843178825Sdfr   YYDEST.  */
844178825Sdfr#if (defined __STDC__ || defined __C99__FUNC__ \
845178825Sdfr     || defined __cplusplus || defined _MSC_VER)
846178825Sdfrstatic char *
847178825Sdfryystpcpy (char *yydest, const char *yysrc)
848178825Sdfr#else
849178825Sdfrstatic char *
850178825Sdfryystpcpy (yydest, yysrc)
851178825Sdfr    char *yydest;
852178825Sdfr    const char *yysrc;
853178825Sdfr#endif
854178825Sdfr{
855178825Sdfr  char *yyd = yydest;
856178825Sdfr  const char *yys = yysrc;
857178825Sdfr
858178825Sdfr  while ((*yyd++ = *yys++) != '\0')
859178825Sdfr    continue;
860178825Sdfr
861178825Sdfr  return yyd - 1;
862178825Sdfr}
863178825Sdfr#  endif
864178825Sdfr# endif
865178825Sdfr
866178825Sdfr# ifndef yytnamerr
867178825Sdfr/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
868178825Sdfr   quotes and backslashes, so that it's suitable for yyerror.  The
869178825Sdfr   heuristic is that double-quoting is unnecessary unless the string
870178825Sdfr   contains an apostrophe, a comma, or backslash (other than
871178825Sdfr   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
872178825Sdfr   null, do not copy; instead, return the length of what the result
873178825Sdfr   would have been.  */
874178825Sdfrstatic YYSIZE_T
875178825Sdfryytnamerr (char *yyres, const char *yystr)
876178825Sdfr{
877178825Sdfr  if (*yystr == '"')
878178825Sdfr    {
879178825Sdfr      YYSIZE_T yyn = 0;
880178825Sdfr      char const *yyp = yystr;
881178825Sdfr
882178825Sdfr      for (;;)
883178825Sdfr	switch (*++yyp)
884178825Sdfr	  {
885178825Sdfr	  case '\'':
886178825Sdfr	  case ',':
887178825Sdfr	    goto do_not_strip_quotes;
888178825Sdfr
889178825Sdfr	  case '\\':
890178825Sdfr	    if (*++yyp != '\\')
891178825Sdfr	      goto do_not_strip_quotes;
892178825Sdfr	    /* Fall through.  */
893178825Sdfr	  default:
894178825Sdfr	    if (yyres)
895178825Sdfr	      yyres[yyn] = *yyp;
896178825Sdfr	    yyn++;
897178825Sdfr	    break;
898178825Sdfr
899178825Sdfr	  case '"':
900178825Sdfr	    if (yyres)
901178825Sdfr	      yyres[yyn] = '\0';
902178825Sdfr	    return yyn;
903178825Sdfr	  }
904178825Sdfr    do_not_strip_quotes: ;
905178825Sdfr    }
906178825Sdfr
907178825Sdfr  if (! yyres)
908178825Sdfr    return yystrlen (yystr);
909178825Sdfr
910178825Sdfr  return yystpcpy (yyres, yystr) - yyres;
911178825Sdfr}
912178825Sdfr# endif
913178825Sdfr
914178825Sdfr/* Copy into YYRESULT an error message about the unexpected token
915178825Sdfr   YYCHAR while in state YYSTATE.  Return the number of bytes copied,
916178825Sdfr   including the terminating null byte.  If YYRESULT is null, do not
917178825Sdfr   copy anything; just return the number of bytes that would be
918178825Sdfr   copied.  As a special case, return 0 if an ordinary "syntax error"
919178825Sdfr   message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
920178825Sdfr   size calculation.  */
921178825Sdfrstatic YYSIZE_T
922178825Sdfryysyntax_error (char *yyresult, int yystate, int yychar)
923178825Sdfr{
924178825Sdfr  int yyn = yypact[yystate];
925178825Sdfr
926178825Sdfr  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
927178825Sdfr    return 0;
928178825Sdfr  else
929178825Sdfr    {
930178825Sdfr      int yytype = YYTRANSLATE (yychar);
931178825Sdfr      YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
932178825Sdfr      YYSIZE_T yysize = yysize0;
933178825Sdfr      YYSIZE_T yysize1;
934178825Sdfr      int yysize_overflow = 0;
935178825Sdfr      enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
936178825Sdfr      char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
937178825Sdfr      int yyx;
938178825Sdfr
939178825Sdfr# if 0
940178825Sdfr      /* This is so xgettext sees the translatable formats that are
941178825Sdfr	 constructed on the fly.  */
942178825Sdfr      YY_("syntax error, unexpected %s");
943178825Sdfr      YY_("syntax error, unexpected %s, expecting %s");
944178825Sdfr      YY_("syntax error, unexpected %s, expecting %s or %s");
945178825Sdfr      YY_("syntax error, unexpected %s, expecting %s or %s or %s");
946178825Sdfr      YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
947178825Sdfr# endif
948178825Sdfr      char *yyfmt;
949178825Sdfr      char const *yyf;
950178825Sdfr      static char const yyunexpected[] = "syntax error, unexpected %s";
951178825Sdfr      static char const yyexpecting[] = ", expecting %s";
952178825Sdfr      static char const yyor[] = " or %s";
953178825Sdfr      char yyformat[sizeof yyunexpected
954178825Sdfr		    + sizeof yyexpecting - 1
955178825Sdfr		    + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
956178825Sdfr		       * (sizeof yyor - 1))];
957178825Sdfr      char const *yyprefix = yyexpecting;
958178825Sdfr
959178825Sdfr      /* Start YYX at -YYN if negative to avoid negative indexes in
960178825Sdfr	 YYCHECK.  */
961178825Sdfr      int yyxbegin = yyn < 0 ? -yyn : 0;
962178825Sdfr
963178825Sdfr      /* Stay within bounds of both yycheck and yytname.  */
964178825Sdfr      int yychecklim = YYLAST - yyn + 1;
965178825Sdfr      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
966178825Sdfr      int yycount = 1;
967178825Sdfr
968178825Sdfr      yyarg[0] = yytname[yytype];
969178825Sdfr      yyfmt = yystpcpy (yyformat, yyunexpected);
970178825Sdfr
971178825Sdfr      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
972178825Sdfr	if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
973178825Sdfr	  {
974178825Sdfr	    if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
975178825Sdfr	      {
976178825Sdfr		yycount = 1;
977178825Sdfr		yysize = yysize0;
978178825Sdfr		yyformat[sizeof yyunexpected - 1] = '\0';
979178825Sdfr		break;
980178825Sdfr	      }
981178825Sdfr	    yyarg[yycount++] = yytname[yyx];
982178825Sdfr	    yysize1 = yysize + yytnamerr (0, yytname[yyx]);
983178825Sdfr	    yysize_overflow |= (yysize1 < yysize);
984178825Sdfr	    yysize = yysize1;
985178825Sdfr	    yyfmt = yystpcpy (yyfmt, yyprefix);
986178825Sdfr	    yyprefix = yyor;
987178825Sdfr	  }
988178825Sdfr
989178825Sdfr      yyf = YY_(yyformat);
990178825Sdfr      yysize1 = yysize + yystrlen (yyf);
991178825Sdfr      yysize_overflow |= (yysize1 < yysize);
992178825Sdfr      yysize = yysize1;
993178825Sdfr
994178825Sdfr      if (yysize_overflow)
995178825Sdfr	return YYSIZE_MAXIMUM;
996178825Sdfr
997178825Sdfr      if (yyresult)
998178825Sdfr	{
999178825Sdfr	  /* Avoid sprintf, as that infringes on the user's name space.
1000178825Sdfr	     Don't have undefined behavior even if the translation
1001178825Sdfr	     produced a string with the wrong number of "%s"s.  */
1002178825Sdfr	  char *yyp = yyresult;
1003178825Sdfr	  int yyi = 0;
1004178825Sdfr	  while ((*yyp = *yyf) != '\0')
1005178825Sdfr	    {
1006178825Sdfr	      if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1007178825Sdfr		{
1008178825Sdfr		  yyp += yytnamerr (yyp, yyarg[yyi++]);
1009178825Sdfr		  yyf += 2;
1010178825Sdfr		}
1011178825Sdfr	      else
1012178825Sdfr		{
1013178825Sdfr		  yyp++;
1014178825Sdfr		  yyf++;
1015178825Sdfr		}
1016178825Sdfr	    }
1017178825Sdfr	}
1018178825Sdfr      return yysize;
1019178825Sdfr    }
1020178825Sdfr}
1021178825Sdfr#endif /* YYERROR_VERBOSE */
1022178825Sdfr
1023178825Sdfr
1024178825Sdfr/*-----------------------------------------------.
1025178825Sdfr| Release the memory associated to this symbol.  |
1026178825Sdfr`-----------------------------------------------*/
1027178825Sdfr
1028178825Sdfr/*ARGSUSED*/
1029178825Sdfr#if (defined __STDC__ || defined __C99__FUNC__ \
1030178825Sdfr     || defined __cplusplus || defined _MSC_VER)
1031178825Sdfrstatic void
1032178825Sdfryydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1033178825Sdfr#else
1034178825Sdfrstatic void
1035178825Sdfryydestruct (yymsg, yytype, yyvaluep)
1036178825Sdfr    const char *yymsg;
1037178825Sdfr    int yytype;
1038178825Sdfr    YYSTYPE *yyvaluep;
1039178825Sdfr#endif
1040178825Sdfr{
1041178825Sdfr  YYUSE (yyvaluep);
1042178825Sdfr
1043178825Sdfr  if (!yymsg)
1044178825Sdfr    yymsg = "Deleting";
1045178825Sdfr  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1046178825Sdfr
1047178825Sdfr  switch (yytype)
1048178825Sdfr    {
1049178825Sdfr
1050178825Sdfr      default:
1051178825Sdfr	break;
1052178825Sdfr    }
1053178825Sdfr}
1054178825Sdfr
1055178825Sdfr
1056178825Sdfr/* Prevent warnings from -Wmissing-prototypes.  */
1057178825Sdfr
1058178825Sdfr#ifdef YYPARSE_PARAM
1059178825Sdfr#if defined __STDC__ || defined __cplusplus
1060178825Sdfrint yyparse (void *YYPARSE_PARAM);
1061178825Sdfr#else
1062178825Sdfrint yyparse ();
1063178825Sdfr#endif
1064178825Sdfr#else /* ! YYPARSE_PARAM */
1065178825Sdfr#if defined __STDC__ || defined __cplusplus
1066178825Sdfrint yyparse (void);
1067178825Sdfr#else
1068178825Sdfrint yyparse ();
1069178825Sdfr#endif
1070178825Sdfr#endif /* ! YYPARSE_PARAM */
1071178825Sdfr
1072178825Sdfr
1073178825Sdfr
1074178825Sdfr/* The look-ahead symbol.  */
1075178825Sdfrint yychar;
1076178825Sdfr
1077178825Sdfr/* The semantic value of the look-ahead symbol.  */
1078178825SdfrYYSTYPE yylval;
1079178825Sdfr
1080178825Sdfr/* Number of syntax errors so far.  */
1081178825Sdfrint yynerrs;
1082178825Sdfr
1083178825Sdfr
1084178825Sdfr
1085178825Sdfr/*----------.
1086178825Sdfr| yyparse.  |
1087178825Sdfr`----------*/
1088178825Sdfr
1089178825Sdfr#ifdef YYPARSE_PARAM
1090178825Sdfr#if (defined __STDC__ || defined __C99__FUNC__ \
1091178825Sdfr     || defined __cplusplus || defined _MSC_VER)
1092178825Sdfrint
1093178825Sdfryyparse (void *YYPARSE_PARAM)
1094178825Sdfr#else
1095178825Sdfrint
1096178825Sdfryyparse (YYPARSE_PARAM)
1097178825Sdfr    void *YYPARSE_PARAM;
1098178825Sdfr#endif
1099178825Sdfr#else /* ! YYPARSE_PARAM */
1100178825Sdfr#if (defined __STDC__ || defined __C99__FUNC__ \
1101178825Sdfr     || defined __cplusplus || defined _MSC_VER)
1102178825Sdfrint
1103178825Sdfryyparse (void)
1104178825Sdfr#else
1105178825Sdfrint
1106178825Sdfryyparse ()
1107178825Sdfr
1108178825Sdfr#endif
1109178825Sdfr#endif
1110178825Sdfr{
1111178825Sdfr
1112178825Sdfr  int yystate;
1113178825Sdfr  int yyn;
1114178825Sdfr  int yyresult;
1115178825Sdfr  /* Number of tokens to shift before error messages enabled.  */
1116178825Sdfr  int yyerrstatus;
1117178825Sdfr  /* Look-ahead token as an internal (translated) token number.  */
1118178825Sdfr  int yytoken = 0;
1119178825Sdfr#if YYERROR_VERBOSE
1120178825Sdfr  /* Buffer for error messages, and its allocated size.  */
1121178825Sdfr  char yymsgbuf[128];
1122178825Sdfr  char *yymsg = yymsgbuf;
1123178825Sdfr  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1124178825Sdfr#endif
1125178825Sdfr
1126178825Sdfr  /* Three stacks and their tools:
1127178825Sdfr     `yyss': related to states,
1128178825Sdfr     `yyvs': related to semantic values,
1129178825Sdfr     `yyls': related to locations.
1130178825Sdfr
1131178825Sdfr     Refer to the stacks thru separate pointers, to allow yyoverflow
1132178825Sdfr     to reallocate them elsewhere.  */
1133178825Sdfr
1134178825Sdfr  /* The state stack.  */
1135178825Sdfr  yytype_int16 yyssa[YYINITDEPTH];
1136178825Sdfr  yytype_int16 *yyss = yyssa;
1137178825Sdfr  yytype_int16 *yyssp;
1138178825Sdfr
1139178825Sdfr  /* The semantic value stack.  */
1140178825Sdfr  YYSTYPE yyvsa[YYINITDEPTH];
1141178825Sdfr  YYSTYPE *yyvs = yyvsa;
1142178825Sdfr  YYSTYPE *yyvsp;
1143178825Sdfr
1144178825Sdfr
1145178825Sdfr
1146178825Sdfr#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1147178825Sdfr
1148178825Sdfr  YYSIZE_T yystacksize = YYINITDEPTH;
1149178825Sdfr
1150178825Sdfr  /* The variables used to return semantic value and location from the
1151178825Sdfr     action routines.  */
1152178825Sdfr  YYSTYPE yyval;
1153178825Sdfr
1154178825Sdfr
1155178825Sdfr  /* The number of symbols on the RHS of the reduced rule.
1156178825Sdfr     Keep to zero when no symbol should be popped.  */
1157178825Sdfr  int yylen = 0;
1158178825Sdfr
1159178825Sdfr  YYDPRINTF ((stderr, "Starting parse\n"));
1160178825Sdfr
1161178825Sdfr  yystate = 0;
1162178825Sdfr  yyerrstatus = 0;
1163178825Sdfr  yynerrs = 0;
1164178825Sdfr  yychar = YYEMPTY;		/* Cause a token to be read.  */
1165178825Sdfr
1166178825Sdfr  /* Initialize stack pointers.
1167178825Sdfr     Waste one element of value and location stack
1168178825Sdfr     so that they stay on the same level as the state stack.
1169178825Sdfr     The wasted elements are never initialized.  */
1170178825Sdfr
1171178825Sdfr  yyssp = yyss;
1172178825Sdfr  yyvsp = yyvs;
1173178825Sdfr
1174178825Sdfr  goto yysetstate;
1175178825Sdfr
1176178825Sdfr/*------------------------------------------------------------.
1177178825Sdfr| yynewstate -- Push a new state, which is found in yystate.  |
1178178825Sdfr`------------------------------------------------------------*/
1179178825Sdfr yynewstate:
1180178825Sdfr  /* In all cases, when you get here, the value and location stacks
1181178825Sdfr     have just been pushed.  So pushing a state here evens the stacks.  */
1182178825Sdfr  yyssp++;
1183178825Sdfr
1184178825Sdfr yysetstate:
1185178825Sdfr  *yyssp = yystate;
1186178825Sdfr
1187178825Sdfr  if (yyss + yystacksize - 1 <= yyssp)
1188178825Sdfr    {
1189178825Sdfr      /* Get the current used size of the three stacks, in elements.  */
1190178825Sdfr      YYSIZE_T yysize = yyssp - yyss + 1;
1191178825Sdfr
1192178825Sdfr#ifdef yyoverflow
1193178825Sdfr      {
1194178825Sdfr	/* Give user a chance to reallocate the stack.  Use copies of
1195178825Sdfr	   these so that the &'s don't force the real ones into
1196178825Sdfr	   memory.  */
1197178825Sdfr	YYSTYPE *yyvs1 = yyvs;
1198178825Sdfr	yytype_int16 *yyss1 = yyss;
1199178825Sdfr
1200178825Sdfr
1201178825Sdfr	/* Each stack pointer address is followed by the size of the
1202178825Sdfr	   data in use in that stack, in bytes.  This used to be a
1203178825Sdfr	   conditional around just the two extra args, but that might
1204178825Sdfr	   be undefined if yyoverflow is a macro.  */
1205178825Sdfr	yyoverflow (YY_("memory exhausted"),
1206178825Sdfr		    &yyss1, yysize * sizeof (*yyssp),
1207178825Sdfr		    &yyvs1, yysize * sizeof (*yyvsp),
1208178825Sdfr
1209178825Sdfr		    &yystacksize);
1210178825Sdfr
1211178825Sdfr	yyss = yyss1;
1212178825Sdfr	yyvs = yyvs1;
1213178825Sdfr      }
1214178825Sdfr#else /* no yyoverflow */
1215178825Sdfr# ifndef YYSTACK_RELOCATE
1216178825Sdfr      goto yyexhaustedlab;
1217178825Sdfr# else
1218178825Sdfr      /* Extend the stack our own way.  */
1219178825Sdfr      if (YYMAXDEPTH <= yystacksize)
1220178825Sdfr	goto yyexhaustedlab;
1221178825Sdfr      yystacksize *= 2;
1222178825Sdfr      if (YYMAXDEPTH < yystacksize)
1223178825Sdfr	yystacksize = YYMAXDEPTH;
1224178825Sdfr
1225178825Sdfr      {
1226178825Sdfr	yytype_int16 *yyss1 = yyss;
1227178825Sdfr	union yyalloc *yyptr =
1228178825Sdfr	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1229178825Sdfr	if (! yyptr)
1230178825Sdfr	  goto yyexhaustedlab;
1231178825Sdfr	YYSTACK_RELOCATE (yyss);
1232178825Sdfr	YYSTACK_RELOCATE (yyvs);
1233178825Sdfr
1234178825Sdfr#  undef YYSTACK_RELOCATE
1235178825Sdfr	if (yyss1 != yyssa)
1236178825Sdfr	  YYSTACK_FREE (yyss1);
1237178825Sdfr      }
1238178825Sdfr# endif
1239178825Sdfr#endif /* no yyoverflow */
1240178825Sdfr
1241178825Sdfr      yyssp = yyss + yysize - 1;
1242178825Sdfr      yyvsp = yyvs + yysize - 1;
1243178825Sdfr
1244178825Sdfr
1245178825Sdfr      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1246178825Sdfr		  (unsigned long int) yystacksize));
1247178825Sdfr
1248178825Sdfr      if (yyss + yystacksize - 1 <= yyssp)
1249178825Sdfr	YYABORT;
1250178825Sdfr    }
1251178825Sdfr
1252178825Sdfr  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1253178825Sdfr
1254178825Sdfr  goto yybackup;
1255178825Sdfr
1256178825Sdfr/*-----------.
1257178825Sdfr| yybackup.  |
1258178825Sdfr`-----------*/
1259178825Sdfryybackup:
1260178825Sdfr
1261178825Sdfr  /* Do appropriate processing given the current state.  Read a
1262178825Sdfr     look-ahead token if we need one and don't already have one.  */
1263178825Sdfr
1264178825Sdfr  /* First try to decide what to do without reference to look-ahead token.  */
1265178825Sdfr  yyn = yypact[yystate];
1266178825Sdfr  if (yyn == YYPACT_NINF)
1267178825Sdfr    goto yydefault;
1268178825Sdfr
1269178825Sdfr  /* Not known => get a look-ahead token if don't already have one.  */
1270178825Sdfr
1271178825Sdfr  /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
1272178825Sdfr  if (yychar == YYEMPTY)
1273178825Sdfr    {
1274178825Sdfr      YYDPRINTF ((stderr, "Reading a token: "));
1275178825Sdfr      yychar = YYLEX;
1276178825Sdfr    }
1277178825Sdfr
1278178825Sdfr  if (yychar <= YYEOF)
1279178825Sdfr    {
1280178825Sdfr      yychar = yytoken = YYEOF;
1281178825Sdfr      YYDPRINTF ((stderr, "Now at end of input.\n"));
1282178825Sdfr    }
1283178825Sdfr  else
1284178825Sdfr    {
1285178825Sdfr      yytoken = YYTRANSLATE (yychar);
1286178825Sdfr      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1287178825Sdfr    }
1288178825Sdfr
1289178825Sdfr  /* If the proper action on seeing token YYTOKEN is to reduce or to
1290178825Sdfr     detect an error, take that action.  */
1291178825Sdfr  yyn += yytoken;
1292178825Sdfr  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1293178825Sdfr    goto yydefault;
1294178825Sdfr  yyn = yytable[yyn];
1295178825Sdfr  if (yyn <= 0)
1296178825Sdfr    {
1297178825Sdfr      if (yyn == 0 || yyn == YYTABLE_NINF)
1298178825Sdfr	goto yyerrlab;
1299178825Sdfr      yyn = -yyn;
1300178825Sdfr      goto yyreduce;
1301178825Sdfr    }
1302178825Sdfr
1303178825Sdfr  if (yyn == YYFINAL)
1304178825Sdfr    YYACCEPT;
1305178825Sdfr
1306178825Sdfr  /* Count tokens shifted since error; after three, turn off error
1307178825Sdfr     status.  */
1308178825Sdfr  if (yyerrstatus)
1309178825Sdfr    yyerrstatus--;
1310178825Sdfr
1311178825Sdfr  /* Shift the look-ahead token.  */
1312178825Sdfr  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1313178825Sdfr
1314178825Sdfr  /* Discard the shifted token unless it is eof.  */
1315178825Sdfr  if (yychar != YYEOF)
1316178825Sdfr    yychar = YYEMPTY;
1317178825Sdfr
1318178825Sdfr  yystate = yyn;
1319178825Sdfr  *++yyvsp = yylval;
1320178825Sdfr
1321178825Sdfr  goto yynewstate;
1322178825Sdfr
1323178825Sdfr
1324178825Sdfr/*-----------------------------------------------------------.
1325178825Sdfr| yydefault -- do the default action for the current state.  |
1326178825Sdfr`-----------------------------------------------------------*/
1327178825Sdfryydefault:
1328178825Sdfr  yyn = yydefact[yystate];
1329178825Sdfr  if (yyn == 0)
1330178825Sdfr    goto yyerrlab;
1331178825Sdfr  goto yyreduce;
1332178825Sdfr
1333178825Sdfr
1334178825Sdfr/*-----------------------------.
1335178825Sdfr| yyreduce -- Do a reduction.  |
1336178825Sdfr`-----------------------------*/
1337178825Sdfryyreduce:
1338178825Sdfr  /* yyn is the number of a rule to reduce with.  */
1339178825Sdfr  yylen = yyr2[yyn];
1340178825Sdfr
1341178825Sdfr  /* If YYLEN is nonzero, implement the default value of the action:
1342178825Sdfr     `$$ = $1'.
1343178825Sdfr
1344178825Sdfr     Otherwise, the following line sets YYVAL to garbage.
1345178825Sdfr     This behavior is undocumented and Bison
1346178825Sdfr     users should not rely upon it.  Assigning to YYVAL
1347178825Sdfr     unconditionally makes the parser a bit smaller, and it avoids a
1348178825Sdfr     GCC warning that YYVAL may be used uninitialized.  */
1349178825Sdfr  yyval = yyvsp[1-yylen];
1350178825Sdfr
1351178825Sdfr
1352178825Sdfr  YY_REDUCE_PRINT (yyn);
1353178825Sdfr  switch (yyn)
1354178825Sdfr    {
1355178825Sdfr        case 2:
1356178825Sdfr#line 68 "slc-gram.y"
1357178825Sdfr    {
1358178825Sdfr			assignment = (yyvsp[(1) - (1)].assignment);
1359178825Sdfr		}
1360178825Sdfr    break;
1361178825Sdfr
1362178825Sdfr  case 3:
1363178825Sdfr#line 74 "slc-gram.y"
1364178825Sdfr    {
1365178825Sdfr			(yyvsp[(1) - (2)].assignment)->next = (yyvsp[(2) - (2)].assignment);
1366178825Sdfr			(yyval.assignment) = (yyvsp[(1) - (2)].assignment);
1367178825Sdfr		}
1368178825Sdfr    break;
1369178825Sdfr
1370178825Sdfr  case 5:
1371178825Sdfr#line 82 "slc-gram.y"
1372178825Sdfr    {
1373178825Sdfr			(yyval.assignment) = malloc(sizeof(*(yyval.assignment)));
1374178825Sdfr			(yyval.assignment)->name = (yyvsp[(1) - (3)].string);
1375178825Sdfr			(yyval.assignment)->type = a_value;
1376178825Sdfr			(yyval.assignment)->lineno = lineno;
1377178825Sdfr			(yyval.assignment)->u.value = (yyvsp[(3) - (3)].string);
1378178825Sdfr			(yyval.assignment)->next = NULL;
1379178825Sdfr		}
1380178825Sdfr    break;
1381178825Sdfr
1382178825Sdfr  case 6:
1383178825Sdfr#line 91 "slc-gram.y"
1384178825Sdfr    {
1385178825Sdfr			(yyval.assignment) = malloc(sizeof(*(yyval.assignment)));
1386178825Sdfr			(yyval.assignment)->name = (yyvsp[(1) - (5)].string);
1387178825Sdfr			(yyval.assignment)->type = a_assignment;
1388178825Sdfr			(yyval.assignment)->lineno = lineno;
1389178825Sdfr			(yyval.assignment)->u.assignment = (yyvsp[(4) - (5)].assignment);
1390178825Sdfr			(yyval.assignment)->next = NULL;
1391178825Sdfr		}
1392178825Sdfr    break;
1393178825Sdfr
1394178825Sdfr
1395178825Sdfr/* Line 1267 of yacc.c.  */
1396178825Sdfr#line 1397 "slc-gram.c"
1397178825Sdfr      default: break;
1398178825Sdfr    }
1399178825Sdfr  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1400178825Sdfr
1401178825Sdfr  YYPOPSTACK (yylen);
1402178825Sdfr  yylen = 0;
1403178825Sdfr  YY_STACK_PRINT (yyss, yyssp);
1404178825Sdfr
1405178825Sdfr  *++yyvsp = yyval;
1406178825Sdfr
1407178825Sdfr
1408178825Sdfr  /* Now `shift' the result of the reduction.  Determine what state
1409178825Sdfr     that goes to, based on the state we popped back to and the rule
1410178825Sdfr     number reduced by.  */
1411178825Sdfr
1412178825Sdfr  yyn = yyr1[yyn];
1413178825Sdfr
1414178825Sdfr  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1415178825Sdfr  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1416178825Sdfr    yystate = yytable[yystate];
1417178825Sdfr  else
1418178825Sdfr    yystate = yydefgoto[yyn - YYNTOKENS];
1419178825Sdfr
1420178825Sdfr  goto yynewstate;
1421178825Sdfr
1422178825Sdfr
1423178825Sdfr/*------------------------------------.
1424178825Sdfr| yyerrlab -- here on detecting error |
1425178825Sdfr`------------------------------------*/
1426178825Sdfryyerrlab:
1427178825Sdfr  /* If not already recovering from an error, report this error.  */
1428178825Sdfr  if (!yyerrstatus)
1429178825Sdfr    {
1430178825Sdfr      ++yynerrs;
1431178825Sdfr#if ! YYERROR_VERBOSE
1432178825Sdfr      yyerror (YY_("syntax error"));
1433178825Sdfr#else
1434178825Sdfr      {
1435178825Sdfr	YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1436178825Sdfr	if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1437178825Sdfr	  {
1438178825Sdfr	    YYSIZE_T yyalloc = 2 * yysize;
1439178825Sdfr	    if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1440178825Sdfr	      yyalloc = YYSTACK_ALLOC_MAXIMUM;
1441178825Sdfr	    if (yymsg != yymsgbuf)
1442178825Sdfr	      YYSTACK_FREE (yymsg);
1443178825Sdfr	    yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1444178825Sdfr	    if (yymsg)
1445178825Sdfr	      yymsg_alloc = yyalloc;
1446178825Sdfr	    else
1447178825Sdfr	      {
1448178825Sdfr		yymsg = yymsgbuf;
1449178825Sdfr		yymsg_alloc = sizeof yymsgbuf;
1450178825Sdfr	      }
1451178825Sdfr	  }
1452178825Sdfr
1453178825Sdfr	if (0 < yysize && yysize <= yymsg_alloc)
1454178825Sdfr	  {
1455178825Sdfr	    (void) yysyntax_error (yymsg, yystate, yychar);
1456178825Sdfr	    yyerror (yymsg);
1457178825Sdfr	  }
1458178825Sdfr	else
1459178825Sdfr	  {
1460178825Sdfr	    yyerror (YY_("syntax error"));
1461178825Sdfr	    if (yysize != 0)
1462178825Sdfr	      goto yyexhaustedlab;
1463178825Sdfr	  }
1464178825Sdfr      }
1465178825Sdfr#endif
1466178825Sdfr    }
1467178825Sdfr
1468178825Sdfr
1469178825Sdfr
1470178825Sdfr  if (yyerrstatus == 3)
1471178825Sdfr    {
1472178825Sdfr      /* If just tried and failed to reuse look-ahead token after an
1473178825Sdfr	 error, discard it.  */
1474178825Sdfr
1475178825Sdfr      if (yychar <= YYEOF)
1476178825Sdfr	{
1477178825Sdfr	  /* Return failure if at end of input.  */
1478178825Sdfr	  if (yychar == YYEOF)
1479178825Sdfr	    YYABORT;
1480178825Sdfr	}
1481178825Sdfr      else
1482178825Sdfr	{
1483178825Sdfr	  yydestruct ("Error: discarding",
1484178825Sdfr		      yytoken, &yylval);
1485178825Sdfr	  yychar = YYEMPTY;
1486178825Sdfr	}
1487178825Sdfr    }
1488178825Sdfr
1489178825Sdfr  /* Else will try to reuse look-ahead token after shifting the error
1490178825Sdfr     token.  */
1491178825Sdfr  goto yyerrlab1;
1492178825Sdfr
1493178825Sdfr
1494178825Sdfr/*---------------------------------------------------.
1495178825Sdfr| yyerrorlab -- error raised explicitly by YYERROR.  |
1496178825Sdfr`---------------------------------------------------*/
1497178825Sdfryyerrorlab:
1498178825Sdfr
1499178825Sdfr  /* Pacify compilers like GCC when the user code never invokes
1500178825Sdfr     YYERROR and the label yyerrorlab therefore never appears in user
1501178825Sdfr     code.  */
1502178825Sdfr  if (/*CONSTCOND*/ 0)
1503178825Sdfr     goto yyerrorlab;
1504178825Sdfr
1505178825Sdfr  /* Do not reclaim the symbols of the rule which action triggered
1506178825Sdfr     this YYERROR.  */
1507178825Sdfr  YYPOPSTACK (yylen);
1508178825Sdfr  yylen = 0;
1509178825Sdfr  YY_STACK_PRINT (yyss, yyssp);
1510178825Sdfr  yystate = *yyssp;
1511178825Sdfr  goto yyerrlab1;
1512178825Sdfr
1513178825Sdfr
1514178825Sdfr/*-------------------------------------------------------------.
1515178825Sdfr| yyerrlab1 -- common code for both syntax error and YYERROR.  |
1516178825Sdfr`-------------------------------------------------------------*/
1517178825Sdfryyerrlab1:
1518178825Sdfr  yyerrstatus = 3;	/* Each real token shifted decrements this.  */
1519178825Sdfr
1520178825Sdfr  for (;;)
1521178825Sdfr    {
1522178825Sdfr      yyn = yypact[yystate];
1523178825Sdfr      if (yyn != YYPACT_NINF)
1524178825Sdfr	{
1525178825Sdfr	  yyn += YYTERROR;
1526178825Sdfr	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1527178825Sdfr	    {
1528178825Sdfr	      yyn = yytable[yyn];
1529178825Sdfr	      if (0 < yyn)
1530178825Sdfr		break;
1531178825Sdfr	    }
1532178825Sdfr	}
1533178825Sdfr
1534178825Sdfr      /* Pop the current state because it cannot handle the error token.  */
1535178825Sdfr      if (yyssp == yyss)
1536178825Sdfr	YYABORT;
1537178825Sdfr
1538178825Sdfr
1539178825Sdfr      yydestruct ("Error: popping",
1540178825Sdfr		  yystos[yystate], yyvsp);
1541178825Sdfr      YYPOPSTACK (1);
1542178825Sdfr      yystate = *yyssp;
1543178825Sdfr      YY_STACK_PRINT (yyss, yyssp);
1544178825Sdfr    }
1545178825Sdfr
1546178825Sdfr  if (yyn == YYFINAL)
1547178825Sdfr    YYACCEPT;
1548178825Sdfr
1549178825Sdfr  *++yyvsp = yylval;
1550178825Sdfr
1551178825Sdfr
1552178825Sdfr  /* Shift the error token.  */
1553178825Sdfr  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1554178825Sdfr
1555178825Sdfr  yystate = yyn;
1556178825Sdfr  goto yynewstate;
1557178825Sdfr
1558178825Sdfr
1559178825Sdfr/*-------------------------------------.
1560178825Sdfr| yyacceptlab -- YYACCEPT comes here.  |
1561178825Sdfr`-------------------------------------*/
1562178825Sdfryyacceptlab:
1563178825Sdfr  yyresult = 0;
1564178825Sdfr  goto yyreturn;
1565178825Sdfr
1566178825Sdfr/*-----------------------------------.
1567178825Sdfr| yyabortlab -- YYABORT comes here.  |
1568178825Sdfr`-----------------------------------*/
1569178825Sdfryyabortlab:
1570178825Sdfr  yyresult = 1;
1571178825Sdfr  goto yyreturn;
1572178825Sdfr
1573178825Sdfr#ifndef yyoverflow
1574178825Sdfr/*-------------------------------------------------.
1575178825Sdfr| yyexhaustedlab -- memory exhaustion comes here.  |
1576178825Sdfr`-------------------------------------------------*/
1577178825Sdfryyexhaustedlab:
1578178825Sdfr  yyerror (YY_("memory exhausted"));
1579178825Sdfr  yyresult = 2;
1580178825Sdfr  /* Fall through.  */
1581178825Sdfr#endif
1582178825Sdfr
1583178825Sdfryyreturn:
1584178825Sdfr  if (yychar != YYEOF && yychar != YYEMPTY)
1585178825Sdfr     yydestruct ("Cleanup: discarding lookahead",
1586178825Sdfr		 yytoken, &yylval);
1587178825Sdfr  /* Do not reclaim the symbols of the rule which action triggered
1588178825Sdfr     this YYABORT or YYACCEPT.  */
1589178825Sdfr  YYPOPSTACK (yylen);
1590178825Sdfr  YY_STACK_PRINT (yyss, yyssp);
1591178825Sdfr  while (yyssp != yyss)
1592178825Sdfr    {
1593178825Sdfr      yydestruct ("Cleanup: popping",
1594178825Sdfr		  yystos[*yyssp], yyvsp);
1595178825Sdfr      YYPOPSTACK (1);
1596178825Sdfr    }
1597178825Sdfr#ifndef yyoverflow
1598178825Sdfr  if (yyss != yyssa)
1599178825Sdfr    YYSTACK_FREE (yyss);
1600178825Sdfr#endif
1601178825Sdfr#if YYERROR_VERBOSE
1602178825Sdfr  if (yymsg != yymsgbuf)
1603178825Sdfr    YYSTACK_FREE (yymsg);
1604178825Sdfr#endif
1605178825Sdfr  /* Make sure YYID is used.  */
1606178825Sdfr  return YYID (yyresult);
1607178825Sdfr}
1608178825Sdfr
1609178825Sdfr
1610178825Sdfr#line 101 "slc-gram.y"
1611178825Sdfr
1612178825Sdfrchar *filename;
1613178825SdfrFILE *cfile, *hfile;
1614178825Sdfrint error_flag;
1615178825Sdfrstruct assignment *assignment;
1616178825Sdfr
1617178825Sdfr
1618178825Sdfrstatic void
1619178825Sdfrex(struct assignment *a, const char *fmt, ...)
1620178825Sdfr{
1621178825Sdfr    va_list ap;
1622178825Sdfr    fprintf(stderr, "%s:%d: ", a->name, a->lineno);
1623178825Sdfr    va_start(ap, fmt);
1624178825Sdfr    vfprintf(stderr, fmt, ap);
1625178825Sdfr    va_end(ap);
1626178825Sdfr    fprintf(stderr, "\n");
1627178825Sdfr}
1628178825Sdfr
1629178825Sdfr
1630178825Sdfr
1631178825Sdfrstatic int
1632178825Sdfrcheck_option(struct assignment *as)
1633178825Sdfr{
1634178825Sdfr    struct assignment *a;
1635178825Sdfr    int seen_long = 0;
1636178825Sdfr    int seen_short = 0;
1637178825Sdfr    int seen_type = 0;
1638178825Sdfr    int seen_argument = 0;
1639178825Sdfr    int seen_help = 0;
1640178825Sdfr    int seen_default = 0;
1641178825Sdfr    int ret = 0;
1642178825Sdfr
1643178825Sdfr    for(a = as; a != NULL; a = a->next) {
1644178825Sdfr	if(strcmp(a->name, "long") == 0)
1645178825Sdfr	    seen_long++;
1646178825Sdfr	else if(strcmp(a->name, "short") == 0)
1647178825Sdfr	    seen_short++;
1648178825Sdfr	else if(strcmp(a->name, "type") == 0)
1649178825Sdfr	    seen_type++;
1650178825Sdfr	else if(strcmp(a->name, "argument") == 0)
1651178825Sdfr	    seen_argument++;
1652178825Sdfr	else if(strcmp(a->name, "help") == 0)
1653178825Sdfr	    seen_help++;
1654178825Sdfr	else if(strcmp(a->name, "default") == 0)
1655178825Sdfr	    seen_default++;
1656178825Sdfr	else {
1657178825Sdfr	    ex(a, "unknown name");
1658178825Sdfr	    ret++;
1659178825Sdfr	}
1660178825Sdfr    }
1661178825Sdfr    if(seen_long == 0 && seen_short == 0) {
1662178825Sdfr	ex(as, "neither long nor short option");
1663178825Sdfr	ret++;
1664178825Sdfr    }
1665178825Sdfr    if(seen_long > 1) {
1666178825Sdfr	ex(as, "multiple long options");
1667178825Sdfr	ret++;
1668178825Sdfr    }
1669178825Sdfr    if(seen_short > 1) {
1670178825Sdfr	ex(as, "multiple short options");
1671178825Sdfr	ret++;
1672178825Sdfr    }
1673178825Sdfr    if(seen_type > 1) {
1674178825Sdfr	ex(as, "multiple types");
1675178825Sdfr	ret++;
1676178825Sdfr    }
1677178825Sdfr    if(seen_argument > 1) {
1678178825Sdfr	ex(as, "multiple arguments");
1679178825Sdfr	ret++;
1680178825Sdfr    }
1681178825Sdfr    if(seen_help > 1) {
1682178825Sdfr	ex(as, "multiple help strings");
1683178825Sdfr	ret++;
1684178825Sdfr    }
1685178825Sdfr    if(seen_default > 1) {
1686178825Sdfr	ex(as, "multiple default values");
1687178825Sdfr	ret++;
1688178825Sdfr    }
1689178825Sdfr    return ret;
1690178825Sdfr}
1691178825Sdfr
1692178825Sdfrstatic int
1693178825Sdfrcheck_command(struct assignment *as)
1694178825Sdfr{
1695178825Sdfr	struct assignment *a;
1696178825Sdfr	int seen_name = 0;
1697178825Sdfr	int seen_function = 0;
1698178825Sdfr	int seen_help = 0;
1699178825Sdfr	int seen_argument = 0;
1700178825Sdfr	int seen_minargs = 0;
1701178825Sdfr	int seen_maxargs = 0;
1702178825Sdfr	int ret = 0;
1703178825Sdfr	for(a = as; a != NULL; a = a->next) {
1704178825Sdfr		if(strcmp(a->name, "name") == 0)
1705178825Sdfr			seen_name++;
1706178825Sdfr		else if(strcmp(a->name, "function") == 0) {
1707178825Sdfr			seen_function++;
1708178825Sdfr		} else if(strcmp(a->name, "option") == 0)
1709178825Sdfr			ret += check_option(a->u.assignment);
1710178825Sdfr		else if(strcmp(a->name, "help") == 0) {
1711178825Sdfr			seen_help++;
1712178825Sdfr		} else if(strcmp(a->name, "argument") == 0) {
1713178825Sdfr			seen_argument++;
1714178825Sdfr		} else if(strcmp(a->name, "min_args") == 0) {
1715178825Sdfr			seen_minargs++;
1716178825Sdfr		} else if(strcmp(a->name, "max_args") == 0) {
1717178825Sdfr			seen_maxargs++;
1718178825Sdfr		} else {
1719178825Sdfr			ex(a, "unknown name");
1720178825Sdfr			ret++;
1721178825Sdfr		}
1722178825Sdfr	}
1723178825Sdfr	if(seen_name == 0) {
1724178825Sdfr		ex(as, "no command name");
1725178825Sdfr		ret++;
1726178825Sdfr	}
1727178825Sdfr	if(seen_function > 1) {
1728178825Sdfr		ex(as, "multiple function names");
1729178825Sdfr		ret++;
1730178825Sdfr	}
1731178825Sdfr	if(seen_help > 1) {
1732178825Sdfr		ex(as, "multiple help strings");
1733178825Sdfr		ret++;
1734178825Sdfr	}
1735178825Sdfr	if(seen_argument > 1) {
1736178825Sdfr		ex(as, "multiple argument strings");
1737178825Sdfr		ret++;
1738178825Sdfr	}
1739178825Sdfr	if(seen_minargs > 1) {
1740178825Sdfr		ex(as, "multiple min_args strings");
1741178825Sdfr		ret++;
1742178825Sdfr	}
1743178825Sdfr	if(seen_maxargs > 1) {
1744178825Sdfr		ex(as, "multiple max_args strings");
1745178825Sdfr		ret++;
1746178825Sdfr	}
1747178825Sdfr
1748178825Sdfr	return ret;
1749178825Sdfr}
1750178825Sdfr
1751178825Sdfrstatic int
1752178825Sdfrcheck(struct assignment *as)
1753178825Sdfr{
1754178825Sdfr    struct assignment *a;
1755178825Sdfr    int ret = 0;
1756178825Sdfr    for(a = as; a != NULL; a = a->next) {
1757178825Sdfr	if(strcmp(a->name, "command")) {
1758178825Sdfr	    fprintf(stderr, "unknown type %s line %d\n", a->name, a->lineno);
1759178825Sdfr	    ret++;
1760178825Sdfr	    continue;
1761178825Sdfr	}
1762178825Sdfr	if(a->type != a_assignment) {
1763178825Sdfr	    fprintf(stderr, "bad command definition %s line %d\n", a->name, a->lineno);
1764178825Sdfr	    ret++;
1765178825Sdfr	    continue;
1766178825Sdfr	}
1767178825Sdfr	ret += check_command(a->u.assignment);
1768178825Sdfr    }
1769178825Sdfr    return ret;
1770178825Sdfr}
1771178825Sdfr
1772178825Sdfrstatic struct assignment *
1773178825Sdfrfind_next(struct assignment *as, const char *name)
1774178825Sdfr{
1775178825Sdfr    for(as = as->next; as != NULL; as = as->next) {
1776178825Sdfr	if(strcmp(as->name, name) == 0)
1777178825Sdfr	    return as;
1778178825Sdfr    }
1779178825Sdfr    return NULL;
1780178825Sdfr}
1781178825Sdfr
1782178825Sdfrstatic struct assignment *
1783178825Sdfrfind(struct assignment *as, const char *name)
1784178825Sdfr{
1785178825Sdfr    for(; as != NULL; as = as->next) {
1786178825Sdfr	if(strcmp(as->name, name) == 0)
1787178825Sdfr	    return as;
1788178825Sdfr    }
1789178825Sdfr    return NULL;
1790178825Sdfr}
1791178825Sdfr
1792178825Sdfrstatic void
1793178825Sdfrspace(FILE *f, int level)
1794178825Sdfr{
1795178825Sdfr    fprintf(f, "%*.*s", level * 4, level * 4, " ");
1796178825Sdfr}
1797178825Sdfr
1798178825Sdfrstatic void
1799178825Sdfrcprint(int level, const char *fmt, ...)
1800178825Sdfr{
1801178825Sdfr    va_list ap;
1802178825Sdfr    va_start(ap, fmt);
1803178825Sdfr    space(cfile, level);
1804178825Sdfr    vfprintf(cfile, fmt, ap);
1805178825Sdfr    va_end(ap);
1806178825Sdfr}
1807178825Sdfr
1808178825Sdfrstatic void
1809178825Sdfrhprint(int level, const char *fmt, ...)
1810178825Sdfr{
1811178825Sdfr    va_list ap;
1812178825Sdfr    va_start(ap, fmt);
1813178825Sdfr    space(hfile, level);
1814178825Sdfr    vfprintf(hfile, fmt, ap);
1815178825Sdfr    va_end(ap);
1816178825Sdfr}
1817178825Sdfr
1818178825Sdfrstatic void gen_name(char *str);
1819178825Sdfr
1820178825Sdfrstatic void
1821178825Sdfrgen_command(struct assignment *as)
1822178825Sdfr{
1823178825Sdfr    struct assignment *a, *b;
1824178825Sdfr    char *f;
1825178825Sdfr    a = find(as, "name");
1826178825Sdfr    f = strdup(a->u.value);
1827178825Sdfr    gen_name(f);
1828178825Sdfr    cprint(1, "    { ");
1829178825Sdfr    fprintf(cfile, "\"%s\", ", a->u.value);
1830178825Sdfr    fprintf(cfile, "%s_wrap, ", f);
1831178825Sdfr    b = find(as, "argument");
1832178825Sdfr    if(b)
1833178825Sdfr	fprintf(cfile, "\"%s %s\", ", a->u.value, b->u.value);
1834178825Sdfr    else
1835178825Sdfr	fprintf(cfile, "\"%s\", ", a->u.value);
1836178825Sdfr    b = find(as, "help");
1837178825Sdfr    if(b)
1838178825Sdfr	fprintf(cfile, "\"%s\"", b->u.value);
1839178825Sdfr    else
1840178825Sdfr	fprintf(cfile, "NULL");
1841178825Sdfr    fprintf(cfile, " },\n");
1842178825Sdfr    for(a = a->next; a != NULL; a = a->next)
1843178825Sdfr	if(strcmp(a->name, "name") == 0)
1844178825Sdfr	    cprint(1, "    { \"%s\" },\n", a->u.value);
1845178825Sdfr    cprint(0, "\n");
1846178825Sdfr}
1847178825Sdfr
1848178825Sdfrstatic void
1849178825Sdfrgen_name(char *str)
1850178825Sdfr{
1851178825Sdfr    char *p;
1852178825Sdfr    for(p = str; *p != '\0'; p++)
1853178825Sdfr	if(!isalnum((unsigned char)*p))
1854178825Sdfr	    *p = '_';
1855178825Sdfr}
1856178825Sdfr
1857178825Sdfrstatic char *
1858178825Sdfrmake_name(struct assignment *as)
1859178825Sdfr{
1860178825Sdfr    struct assignment *lopt;
1861178825Sdfr    struct assignment *type;
1862178825Sdfr    char *s;
1863178825Sdfr
1864178825Sdfr    lopt = find(as, "long");
1865178825Sdfr    if(lopt == NULL)
1866178825Sdfr	lopt = find(as, "name");
1867178825Sdfr    if(lopt == NULL)
1868178825Sdfr	return NULL;
1869178825Sdfr
1870178825Sdfr    type = find(as, "type");
1871178825Sdfr    if(strcmp(type->u.value, "-flag") == 0)
1872178825Sdfr	asprintf(&s, "%s_flag", lopt->u.value);
1873178825Sdfr    else
1874178825Sdfr	asprintf(&s, "%s_%s", lopt->u.value, type->u.value);
1875178825Sdfr    gen_name(s);
1876178825Sdfr    return s;
1877178825Sdfr}
1878178825Sdfr
1879178825Sdfr
1880178825Sdfrstatic void defval_int(const char *name, struct assignment *defval)
1881178825Sdfr{
1882178825Sdfr    if(defval != NULL)
1883178825Sdfr	cprint(1, "opt.%s = %s;\n", name, defval->u.value);
1884178825Sdfr    else
1885178825Sdfr	cprint(1, "opt.%s = 0;\n", name);
1886178825Sdfr}
1887178825Sdfrstatic void defval_string(const char *name, struct assignment *defval)
1888178825Sdfr{
1889178825Sdfr    if(defval != NULL)
1890178825Sdfr	cprint(1, "opt.%s = \"%s\";\n", name, defval->u.value);
1891178825Sdfr    else
1892178825Sdfr	cprint(1, "opt.%s = NULL;\n", name);
1893178825Sdfr}
1894178825Sdfrstatic void defval_strings(const char *name, struct assignment *defval)
1895178825Sdfr{
1896178825Sdfr    cprint(1, "opt.%s.num_strings = 0;\n", name);
1897178825Sdfr    cprint(1, "opt.%s.strings = NULL;\n", name);
1898178825Sdfr}
1899178825Sdfr
1900178825Sdfrstatic void free_strings(const char *name)
1901178825Sdfr{
1902178825Sdfr    cprint(1, "free_getarg_strings (&opt.%s);\n", name);
1903178825Sdfr}
1904178825Sdfr
1905178825Sdfrstruct type_handler {
1906178825Sdfr    const char *typename;
1907178825Sdfr    const char *c_type;
1908178825Sdfr    const char *getarg_type;
1909178825Sdfr    void (*defval)(const char*, struct assignment*);
1910178825Sdfr    void (*free)(const char*);
1911178825Sdfr} type_handlers[] = {
1912178825Sdfr	{ "integer",
1913178825Sdfr	  "int",
1914178825Sdfr	  "arg_integer",
1915178825Sdfr	  defval_int,
1916178825Sdfr	  NULL
1917178825Sdfr	},
1918178825Sdfr	{ "string",
1919178825Sdfr	  "char*",
1920178825Sdfr	  "arg_string",
1921178825Sdfr	  defval_string,
1922178825Sdfr	  NULL
1923178825Sdfr	},
1924178825Sdfr	{ "strings",
1925178825Sdfr	  "struct getarg_strings",
1926178825Sdfr	  "arg_strings",
1927178825Sdfr	  defval_strings,
1928178825Sdfr	  free_strings
1929178825Sdfr	},
1930178825Sdfr	{ "flag",
1931178825Sdfr	  "int",
1932178825Sdfr	  "arg_flag",
1933178825Sdfr	  defval_int,
1934178825Sdfr	  NULL
1935178825Sdfr	},
1936178825Sdfr	{ "-flag",
1937178825Sdfr	  "int",
1938178825Sdfr	  "arg_negative_flag",
1939178825Sdfr	  defval_int,
1940178825Sdfr	  NULL
1941178825Sdfr	},
1942178825Sdfr	{ NULL }
1943178825Sdfr};
1944178825Sdfr
1945178825Sdfrstatic struct type_handler *find_handler(struct assignment *type)
1946178825Sdfr{
1947178825Sdfr    struct type_handler *th;
1948178825Sdfr    for(th = type_handlers; th->typename != NULL; th++)
1949178825Sdfr	if(strcmp(type->u.value, th->typename) == 0)
1950178825Sdfr	    return th;
1951178825Sdfr    ex(type, "unknown type \"%s\"", type->u.value);
1952178825Sdfr    exit(1);
1953178825Sdfr}
1954178825Sdfr
1955178825Sdfrstatic void
1956178825Sdfrgen_options(struct assignment *opt1, const char *name)
1957178825Sdfr{
1958178825Sdfr    struct assignment *tmp;
1959178825Sdfr
1960178825Sdfr    hprint(0, "struct %s_options {\n", name);
1961178825Sdfr
1962178825Sdfr    for(tmp = opt1;
1963178825Sdfr	tmp != NULL;
1964178825Sdfr	tmp = find_next(tmp, "option")) {
1965178825Sdfr	struct assignment *type;
1966178825Sdfr	struct type_handler *th;
1967178825Sdfr	char *s;
1968178825Sdfr
1969178825Sdfr	s = make_name(tmp->u.assignment);
1970178825Sdfr	type = find(tmp->u.assignment, "type");
1971178825Sdfr	th = find_handler(type);
1972178825Sdfr	hprint(1, "%s %s;\n", th->c_type, s);
1973178825Sdfr	free(s);
1974178825Sdfr    }
1975178825Sdfr    hprint(0, "};\n");
1976178825Sdfr}
1977178825Sdfr
1978178825Sdfrstatic void
1979178825Sdfrgen_wrapper(struct assignment *as)
1980178825Sdfr{
1981178825Sdfr    struct assignment *name;
1982178825Sdfr    struct assignment *arg;
1983178825Sdfr    struct assignment *opt1;
1984178825Sdfr    struct assignment *function;
1985178825Sdfr    struct assignment *tmp;
1986178825Sdfr    char *n, *f;
1987178825Sdfr    int nargs = 0;
1988178825Sdfr
1989178825Sdfr    name = find(as, "name");
1990178825Sdfr    n = strdup(name->u.value);
1991178825Sdfr    gen_name(n);
1992178825Sdfr    arg = find(as, "argument");
1993178825Sdfr    opt1 = find(as, "option");
1994178825Sdfr    function = find(as, "function");
1995178825Sdfr    if(function)
1996178825Sdfr	f = function->u.value;
1997178825Sdfr    else
1998178825Sdfr	f = n;
1999178825Sdfr
2000178825Sdfr
2001178825Sdfr    if(opt1 != NULL) {
2002178825Sdfr	gen_options(opt1, n);
2003178825Sdfr	hprint(0, "int %s(struct %s_options*, int, char **);\n", f, n);
2004178825Sdfr    } else {
2005178825Sdfr	hprint(0, "int %s(void*, int, char **);\n", f);
2006178825Sdfr    }
2007178825Sdfr
2008178825Sdfr    fprintf(cfile, "static int\n");
2009178825Sdfr    fprintf(cfile, "%s_wrap(int argc, char **argv)\n", n);
2010178825Sdfr    fprintf(cfile, "{\n");
2011178825Sdfr    if(opt1 != NULL)
2012178825Sdfr	cprint(1, "struct %s_options opt;\n", n);
2013178825Sdfr    cprint(1, "int ret;\n");
2014178825Sdfr    cprint(1, "int optidx = 0;\n");
2015178825Sdfr    cprint(1, "struct getargs args[] = {\n");
2016178825Sdfr    for(tmp = find(as, "option");
2017178825Sdfr	tmp != NULL;
2018178825Sdfr	tmp = find_next(tmp, "option")) {
2019178825Sdfr	struct assignment *type = find(tmp->u.assignment, "type");
2020178825Sdfr	struct assignment *lopt = find(tmp->u.assignment, "long");
2021178825Sdfr	struct assignment *sopt = find(tmp->u.assignment, "short");
2022178825Sdfr	struct assignment *aarg = find(tmp->u.assignment, "argument");
2023178825Sdfr	struct assignment *help = find(tmp->u.assignment, "help");
2024178825Sdfr
2025178825Sdfr	struct type_handler *th;
2026178825Sdfr
2027178825Sdfr	cprint(2, "{ ");
2028178825Sdfr	if(lopt)
2029178825Sdfr	    fprintf(cfile, "\"%s\", ", lopt->u.value);
2030178825Sdfr	else
2031178825Sdfr	    fprintf(cfile, "NULL, ");
2032178825Sdfr	if(sopt)
2033178825Sdfr	    fprintf(cfile, "'%c', ", *sopt->u.value);
2034178825Sdfr	else
2035178825Sdfr	    fprintf(cfile, "0, ");
2036178825Sdfr	th = find_handler(type);
2037178825Sdfr	fprintf(cfile, "%s, ", th->getarg_type);
2038178825Sdfr	fprintf(cfile, "NULL, ");
2039178825Sdfr	if(help)
2040178825Sdfr	    fprintf(cfile, "\"%s\", ", help->u.value);
2041178825Sdfr	else
2042178825Sdfr	    fprintf(cfile, "NULL, ");
2043178825Sdfr	if(aarg)
2044178825Sdfr	    fprintf(cfile, "\"%s\"", aarg->u.value);
2045178825Sdfr	else
2046178825Sdfr	    fprintf(cfile, "NULL");
2047178825Sdfr	fprintf(cfile, " },\n");
2048178825Sdfr    }
2049178825Sdfr    cprint(2, "{ \"help\", 'h', arg_flag, NULL, NULL, NULL }\n");
2050178825Sdfr    cprint(1, "};\n");
2051178825Sdfr    cprint(1, "int help_flag = 0;\n");
2052178825Sdfr
2053178825Sdfr    for(tmp = find(as, "option");
2054178825Sdfr	tmp != NULL;
2055178825Sdfr	tmp = find_next(tmp, "option")) {
2056178825Sdfr	char *s;
2057178825Sdfr	struct assignment *type = find(tmp->u.assignment, "type");
2058178825Sdfr
2059178825Sdfr	struct assignment *defval = find(tmp->u.assignment, "default");
2060178825Sdfr
2061178825Sdfr	struct type_handler *th;
2062178825Sdfr
2063178825Sdfr	s = make_name(tmp->u.assignment);
2064178825Sdfr	th = find_handler(type);
2065178825Sdfr	(*th->defval)(s, defval);
2066178825Sdfr	free(s);
2067178825Sdfr    }
2068178825Sdfr
2069178825Sdfr    for(tmp = find(as, "option");
2070178825Sdfr	tmp != NULL;
2071178825Sdfr	tmp = find_next(tmp, "option")) {
2072178825Sdfr	char *s;
2073178825Sdfr	s = make_name(tmp->u.assignment);
2074178825Sdfr	cprint(1, "args[%d].value = &opt.%s;\n", nargs++, s);
2075178825Sdfr	free(s);
2076178825Sdfr    }
2077178825Sdfr    cprint(1, "args[%d].value = &help_flag;\n", nargs++);
2078178825Sdfr    cprint(1, "if(getarg(args, %d, argc, argv, &optidx))\n", nargs);
2079178825Sdfr    cprint(2, "goto usage;\n");
2080178825Sdfr
2081178825Sdfr    {
2082178825Sdfr	int min_args = -1;
2083178825Sdfr	int max_args = -1;
2084178825Sdfr	char *end;
2085178825Sdfr	if(arg == NULL) {
2086178825Sdfr	    max_args = 0;
2087178825Sdfr	} else {
2088178825Sdfr	    if((tmp = find(as, "min_args")) != NULL) {
2089178825Sdfr		min_args = strtol(tmp->u.value, &end, 0);
2090178825Sdfr		if(*end != '\0') {
2091178825Sdfr		    ex(tmp, "min_args is not numeric");
2092178825Sdfr		    exit(1);
2093178825Sdfr		}
2094178825Sdfr		if(min_args < 0) {
2095178825Sdfr		    ex(tmp, "min_args must be non-negative");
2096178825Sdfr		    exit(1);
2097178825Sdfr		}
2098178825Sdfr	    }
2099178825Sdfr	    if((tmp = find(as, "max_args")) != NULL) {
2100178825Sdfr		max_args = strtol(tmp->u.value, &end, 0);
2101178825Sdfr		if(*end != '\0') {
2102178825Sdfr		    ex(tmp, "max_args is not numeric");
2103178825Sdfr		    exit(1);
2104178825Sdfr		}
2105178825Sdfr		if(max_args < 0) {
2106178825Sdfr		    ex(tmp, "max_args must be non-negative");
2107178825Sdfr		    exit(1);
2108178825Sdfr		}
2109178825Sdfr	    }
2110178825Sdfr	}
2111178825Sdfr	if(min_args != -1 || max_args != -1) {
2112178825Sdfr	    if(min_args == max_args) {
2113178825Sdfr		cprint(1, "if(argc - optidx != %d) {\n",
2114178825Sdfr		       min_args);
2115178825Sdfr		cprint(2, "fprintf(stderr, \"Need exactly %u parameters (%%u given).\\n\\n\", argc - optidx);\n", min_args);
2116178825Sdfr		cprint(2, "goto usage;\n");
2117178825Sdfr		cprint(1, "}\n");
2118178825Sdfr	    } else {
2119178825Sdfr		if(max_args != -1) {
2120178825Sdfr		    cprint(1, "if(argc - optidx > %d) {\n", max_args);
2121178825Sdfr		    cprint(2, "fprintf(stderr, \"Arguments given (%%u) are more than expected (%u).\\n\\n\", argc - optidx);\n", max_args);
2122178825Sdfr		    cprint(2, "goto usage;\n");
2123178825Sdfr		    cprint(1, "}\n");
2124178825Sdfr		}
2125178825Sdfr		if(min_args != -1) {
2126178825Sdfr		    cprint(1, "if(argc - optidx < %d) {\n", min_args);
2127178825Sdfr		    cprint(2, "fprintf(stderr, \"Arguments given (%%u) are less than expected (%u).\\n\\n\", argc - optidx);\n", min_args);
2128178825Sdfr		    cprint(2, "goto usage;\n");
2129178825Sdfr		    cprint(1, "}\n");
2130178825Sdfr		}
2131178825Sdfr	    }
2132178825Sdfr	}
2133178825Sdfr    }
2134178825Sdfr
2135178825Sdfr    cprint(1, "if(help_flag)\n");
2136178825Sdfr    cprint(2, "goto usage;\n");
2137178825Sdfr
2138178825Sdfr    cprint(1, "ret = %s(%s, argc - optidx, argv + optidx);\n",
2139178825Sdfr	   f, opt1 ? "&opt": "NULL");
2140178825Sdfr
2141178825Sdfr    /* free allocated data */
2142178825Sdfr    for(tmp = find(as, "option");
2143178825Sdfr	tmp != NULL;
2144178825Sdfr	tmp = find_next(tmp, "option")) {
2145178825Sdfr	char *s;
2146178825Sdfr	struct assignment *type = find(tmp->u.assignment, "type");
2147178825Sdfr	struct type_handler *th;
2148178825Sdfr	th = find_handler(type);
2149178825Sdfr	if(th->free == NULL)
2150178825Sdfr	    continue;
2151178825Sdfr	s = make_name(tmp->u.assignment);
2152178825Sdfr	(*th->free)(s);
2153178825Sdfr	free(s);
2154178825Sdfr    }
2155178825Sdfr    cprint(1, "return ret;\n");
2156178825Sdfr
2157178825Sdfr    cprint(0, "usage:\n");
2158178825Sdfr    cprint(1, "arg_printusage (args, %d, \"%s\", \"%s\");\n", nargs,
2159178825Sdfr	   name->u.value, arg ? arg->u.value : "");
2160178825Sdfr    /* free allocated data */
2161178825Sdfr    for(tmp = find(as, "option");
2162178825Sdfr	tmp != NULL;
2163178825Sdfr	tmp = find_next(tmp, "option")) {
2164178825Sdfr	char *s;
2165178825Sdfr	struct assignment *type = find(tmp->u.assignment, "type");
2166178825Sdfr	struct type_handler *th;
2167178825Sdfr	th = find_handler(type);
2168178825Sdfr	if(th->free == NULL)
2169178825Sdfr	    continue;
2170178825Sdfr	s = make_name(tmp->u.assignment);
2171178825Sdfr	(*th->free)(s);
2172178825Sdfr	free(s);
2173178825Sdfr    }
2174178825Sdfr    cprint(1, "return 0;\n");
2175178825Sdfr    cprint(0, "}\n");
2176178825Sdfr    cprint(0, "\n");
2177178825Sdfr}
2178178825Sdfr
2179178825Sdfrchar cname[PATH_MAX];
2180178825Sdfrchar hname[PATH_MAX];
2181178825Sdfr
2182178825Sdfrstatic void
2183178825Sdfrgen(struct assignment *as)
2184178825Sdfr{
2185178825Sdfr    struct assignment *a;
2186178825Sdfr    cprint(0, "#include <stdio.h>\n");
2187178825Sdfr    cprint(0, "#include <getarg.h>\n");
2188178825Sdfr    cprint(0, "#include <sl.h>\n");
2189178825Sdfr    cprint(0, "#include \"%s\"\n\n", hname);
2190178825Sdfr
2191178825Sdfr    hprint(0, "#include <stdio.h>\n");
2192178825Sdfr    hprint(0, "#include <sl.h>\n");
2193178825Sdfr    hprint(0, "\n");
2194178825Sdfr
2195178825Sdfr
2196178825Sdfr    for(a = as; a != NULL; a = a->next)
2197178825Sdfr	gen_wrapper(a->u.assignment);
2198178825Sdfr
2199178825Sdfr    cprint(0, "SL_cmd commands[] = {\n");
2200178825Sdfr    for(a = as; a != NULL; a = a->next)
2201178825Sdfr	gen_command(a->u.assignment);
2202178825Sdfr    cprint(1, "{ NULL }\n");
2203178825Sdfr    cprint(0, "};\n");
2204178825Sdfr
2205178825Sdfr    hprint(0, "extern SL_cmd commands[];\n");
2206178825Sdfr}
2207178825Sdfr
2208178825Sdfrint version_flag;
2209178825Sdfrint help_flag;
2210178825Sdfrstruct getargs args[] = {
2211178825Sdfr    { "version", 0, arg_flag, &version_flag },
2212178825Sdfr    { "help", 0, arg_flag, &help_flag }
2213178825Sdfr};
2214178825Sdfrint num_args = sizeof(args) / sizeof(args[0]);
2215178825Sdfr
2216178825Sdfrstatic void
2217178825Sdfrusage(int code)
2218178825Sdfr{
2219178825Sdfr    arg_printusage(args, num_args, NULL, "command-table");
2220178825Sdfr    exit(code);
2221178825Sdfr}
2222178825Sdfr
2223178825Sdfrint
2224178825Sdfrmain(int argc, char **argv)
2225178825Sdfr{
2226178825Sdfr    char *p;
2227178825Sdfr
2228178825Sdfr    int optidx = 0;
2229178825Sdfr
2230178825Sdfr    setprogname(argv[0]);
2231178825Sdfr    if(getarg(args, num_args, argc, argv, &optidx))
2232178825Sdfr	usage(1);
2233178825Sdfr    if(help_flag)
2234178825Sdfr	usage(0);
2235178825Sdfr    if(version_flag) {
2236178825Sdfr	print_version(NULL);
2237178825Sdfr	exit(0);
2238178825Sdfr    }
2239178825Sdfr
2240178825Sdfr    if(argc == optidx)
2241178825Sdfr	usage(1);
2242178825Sdfr
2243178825Sdfr    filename = argv[optidx];
2244178825Sdfr    yyin = fopen(filename, "r");
2245178825Sdfr    if(yyin == NULL)
2246178825Sdfr	err(1, "%s", filename);
2247178825Sdfr    p = strrchr(filename, '/');
2248178825Sdfr    if(p)
2249178825Sdfr	strlcpy(cname, p + 1, sizeof(cname));
2250178825Sdfr    else
2251178825Sdfr	strlcpy(cname, filename, sizeof(cname));
2252178825Sdfr    p = strrchr(cname, '.');
2253178825Sdfr    if(p)
2254178825Sdfr	*p = '\0';
2255178825Sdfr    strlcpy(hname, cname, sizeof(hname));
2256178825Sdfr    strlcat(cname, ".c", sizeof(cname));
2257178825Sdfr    strlcat(hname, ".h", sizeof(hname));
2258178825Sdfr    yyparse();
2259178825Sdfr    if(error_flag)
2260178825Sdfr	exit(1);
2261178825Sdfr    if(check(assignment) == 0) {
2262178825Sdfr	cfile = fopen(cname, "w");
2263178825Sdfr	if(cfile == NULL)
2264178825Sdfr	  err(1, "%s", cname);
2265178825Sdfr	hfile = fopen(hname, "w");
2266178825Sdfr	if(hfile == NULL)
2267178825Sdfr	  err(1, "%s", hname);
2268178825Sdfr	gen(assignment);
2269178825Sdfr	fclose(cfile);
2270178825Sdfr	fclose(hfile);
2271178825Sdfr    }
2272178825Sdfr    fclose(yyin);
2273178825Sdfr    return 0;
2274178825Sdfr}
2275178825Sdfr
2276