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