a7160a4d42fe5a4ec6c6504866c7e973fcf2aba4
[samba.git] / source4 / heimdal / lib / com_err / parse.c
1
2 /*  A Bison parser, made from ../../../lib/com_err/parse.y
3     by GNU Bison version 1.28  */
4
5 #define YYBISON 1  /* Identify Bison output.  */
6
7 #define ET      257
8 #define INDEX   258
9 #define PREFIX  259
10 #define EC      260
11 #define ID      261
12 #define END     262
13 #define STRING  263
14 #define NUMBER  264
15
16 #line 1 "../../../lib/com_err/parse.y"
17
18 /*
19  * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan
20  * (Royal Institute of Technology, Stockholm, Sweden). 
21  * All rights reserved. 
22  *
23  * Redistribution and use in source and binary forms, with or without 
24  * modification, are permitted provided that the following conditions 
25  * are met: 
26  *
27  * 1. Redistributions of source code must retain the above copyright 
28  *    notice, this list of conditions and the following disclaimer. 
29  *
30  * 2. Redistributions in binary form must reproduce the above copyright 
31  *    notice, this list of conditions and the following disclaimer in the 
32  *    documentation and/or other materials provided with the distribution. 
33  *
34  * 3. Neither the name of the Institute nor the names of its contributors 
35  *    may be used to endorse or promote products derived from this software 
36  *    without specific prior written permission. 
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
39  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
40  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
41  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
42  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
43  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
44  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
45  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
46  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
47  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
48  * SUCH DAMAGE. 
49  */
50
51 #include "compile_et.h"
52 #include "lex.h"
53
54 RCSID("$Id: parse.y,v 1.15 2005/06/16 19:21:42 lha Exp $");
55
56 void yyerror (char *s);
57 static long name2number(const char *str);
58
59 extern char *yytext;
60
61 /* This is for bison */
62
63 #if !defined(alloca) && !defined(HAVE_ALLOCA)
64 #define alloca(x) malloc(x)
65 #endif
66
67
68 #line 53 "../../../lib/com_err/parse.y"
69 typedef union {
70   char *string;
71   int number;
72 } YYSTYPE;
73 #include <stdio.h>
74
75 #ifndef __cplusplus
76 #ifndef __STDC__
77 #define const
78 #endif
79 #endif
80
81
82
83 #define YYFINAL         24
84 #define YYFLAG          -32768
85 #define YYNTBASE        12
86
87 #define YYTRANSLATE(x) ((unsigned)(x) <= 264 ? yytranslate[x] : 18)
88
89 static const char yytranslate[] = {     0,
90      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
91      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
92      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
93      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
94      2,     2,     2,    11,     2,     2,     2,     2,     2,     2,
95      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
96      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
97      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
98      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
99      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
100      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
101      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
102      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
103      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
104      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
105      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
106      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
107      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
108      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
109      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
110      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
111      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
112      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
113      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
114      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
115      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
116      7,     8,     9,    10
117 };
118
119 #if YYDEBUG != 0
120 static const short yyprhs[] = {     0,
121      0,     1,     4,     7,     9,    12,    15,    19,    21,    24,
122     27,    30,    32,    37
123 };
124
125 static const short yyrhs[] = {    -1,
126     13,    16,     0,    14,    15,     0,    15,     0,     7,     9,
127      0,     3,     9,     0,     3,     9,     9,     0,    17,     0,
128     16,    17,     0,     4,    10,     0,     5,     9,     0,     5,
129      0,     6,     9,    11,     9,     0,     8,     0
130 };
131
132 #endif
133
134 #if YYDEBUG != 0
135 static const short yyrline[] = { 0,
136     64,    65,    68,    69,    72,    78,    84,    93,    94,    97,
137    101,   109,   116,   136
138 };
139 #endif
140
141
142 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
143
144 static const char * const yytname[] = {   "$","error","$undefined.","ET","INDEX",
145 "PREFIX","EC","ID","END","STRING","NUMBER","','","file","header","id","et","statements",
146 "statement", NULL
147 };
148 #endif
149
150 static const short yyr1[] = {     0,
151     12,    12,    13,    13,    14,    15,    15,    16,    16,    17,
152     17,    17,    17,    17
153 };
154
155 static const short yyr2[] = {     0,
156      0,     2,     2,     1,     2,     2,     3,     1,     2,     2,
157      2,     1,     4,     1
158 };
159
160 static const short yydefact[] = {     1,
161      0,     0,     0,     0,     4,     6,     5,     0,    12,     0,
162     14,     2,     8,     3,     7,    10,    11,     0,     9,     0,
163     13,     0,     0,     0
164 };
165
166 static const short yydefgoto[] = {    22,
167      3,     4,     5,    12,    13
168 };
169
170 static const short yypact[] = {     0,
171     -3,    -1,    -4,     2,-32768,     1,-32768,     3,     5,     6,
172 -32768,    -4,-32768,-32768,-32768,-32768,-32768,    -2,-32768,     7,
173 -32768,    11,    12,-32768
174 };
175
176 static const short yypgoto[] = {-32768,
177 -32768,-32768,    13,-32768,     8
178 };
179
180
181 #define YYLAST          20
182
183
184 static const short yytable[] = {     8,
185      9,    10,     1,    11,     1,     6,     2,     7,    20,    15,
186     23,    24,    16,    17,    18,    21,    14,     0,     0,    19
187 };
188
189 static const short yycheck[] = {     4,
190      5,     6,     3,     8,     3,     9,     7,     9,    11,     9,
191      0,     0,    10,     9,     9,     9,     4,    -1,    -1,    12
192 };
193 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
194 #line 3 "/usr/share/bison.simple"
195 /* This file comes from bison-1.28.  */
196
197 /* Skeleton output parser for bison,
198    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
199
200    This program is free software; you can redistribute it and/or modify
201    it under the terms of the GNU General Public License as published by
202    the Free Software Foundation; either version 2, or (at your option)
203    any later version.
204
205    This program is distributed in the hope that it will be useful,
206    but WITHOUT ANY WARRANTY; without even the implied warranty of
207    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
208    GNU General Public License for more details.
209
210    You should have received a copy of the GNU General Public License
211    along with this program; if not, write to the Free Software
212    Foundation, Inc., 59 Temple Place - Suite 330,
213    Boston, MA 02111-1307, USA.  */
214
215 /* As a special exception, when this file is copied by Bison into a
216    Bison output file, you may use that output file without restriction.
217    This special exception was added by the Free Software Foundation
218    in version 1.24 of Bison.  */
219
220 /* This is the parser code that is written into each bison parser
221   when the %semantic_parser declaration is not specified in the grammar.
222   It was written by Richard Stallman by simplifying the hairy parser
223   used when %semantic_parser is specified.  */
224
225 #ifndef YYSTACK_USE_ALLOCA
226 #ifdef alloca
227 #define YYSTACK_USE_ALLOCA
228 #else /* alloca not defined */
229 #ifdef __GNUC__
230 #define YYSTACK_USE_ALLOCA
231 #define alloca __builtin_alloca
232 #else /* not GNU C.  */
233 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
234 #define YYSTACK_USE_ALLOCA
235 #include <alloca.h>
236 #else /* not sparc */
237 /* We think this test detects Watcom and Microsoft C.  */
238 /* This used to test MSDOS, but that is a bad idea
239    since that symbol is in the user namespace.  */
240 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
241 #if 0 /* No need for malloc.h, which pollutes the namespace;
242          instead, just don't use alloca.  */
243 #include <malloc.h>
244 #endif
245 #else /* not MSDOS, or __TURBOC__ */
246 #if defined(_AIX)
247 /* I don't know what this was needed for, but it pollutes the namespace.
248    So I turned it off.   rms, 2 May 1997.  */
249 /* #include <malloc.h>  */
250  #pragma alloca
251 #define YYSTACK_USE_ALLOCA
252 #else /* not MSDOS, or __TURBOC__, or _AIX */
253 #if 0
254 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
255                  and on HPUX 10.  Eventually we can turn this on.  */
256 #define YYSTACK_USE_ALLOCA
257 #define alloca __builtin_alloca
258 #endif /* __hpux */
259 #endif
260 #endif /* not _AIX */
261 #endif /* not MSDOS, or __TURBOC__ */
262 #endif /* not sparc */
263 #endif /* not GNU C */
264 #endif /* alloca not defined */
265 #endif /* YYSTACK_USE_ALLOCA not defined */
266
267 #ifdef YYSTACK_USE_ALLOCA
268 #define YYSTACK_ALLOC alloca
269 #else
270 #define YYSTACK_ALLOC malloc
271 #endif
272
273 /* Note: there must be only one dollar sign in this file.
274    It is replaced by the list of actions, each action
275    as one case of the switch.  */
276
277 #define yyerrok         (yyerrstatus = 0)
278 #define yyclearin       (yychar = YYEMPTY)
279 #define YYEMPTY         -2
280 #define YYEOF           0
281 #define YYACCEPT        goto yyacceptlab
282 #define YYABORT         goto yyabortlab
283 #define YYERROR         goto yyerrlab1
284 /* Like YYERROR except do call yyerror.
285    This remains here temporarily to ease the
286    transition to the new meaning of YYERROR, for GCC.
287    Once GCC version 2 has supplanted version 1, this can go.  */
288 #define YYFAIL          goto yyerrlab
289 #define YYRECOVERING()  (!!yyerrstatus)
290 #define YYBACKUP(token, value) \
291 do                                                              \
292   if (yychar == YYEMPTY && yylen == 1)                          \
293     { yychar = (token), yylval = (value);                       \
294       yychar1 = YYTRANSLATE (yychar);                           \
295       YYPOPSTACK;                                               \
296       goto yybackup;                                            \
297     }                                                           \
298   else                                                          \
299     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
300 while (0)
301
302 #define YYTERROR        1
303 #define YYERRCODE       256
304
305 #ifndef YYPURE
306 #define YYLEX           yylex()
307 #endif
308
309 #ifdef YYPURE
310 #ifdef YYLSP_NEEDED
311 #ifdef YYLEX_PARAM
312 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
313 #else
314 #define YYLEX           yylex(&yylval, &yylloc)
315 #endif
316 #else /* not YYLSP_NEEDED */
317 #ifdef YYLEX_PARAM
318 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
319 #else
320 #define YYLEX           yylex(&yylval)
321 #endif
322 #endif /* not YYLSP_NEEDED */
323 #endif
324
325 /* If nonreentrant, generate the variables here */
326
327 #ifndef YYPURE
328
329 int     yychar;                 /*  the lookahead symbol                */
330 YYSTYPE yylval;                 /*  the semantic value of the           */
331                                 /*  lookahead symbol                    */
332
333 #ifdef YYLSP_NEEDED
334 YYLTYPE yylloc;                 /*  location data for the lookahead     */
335                                 /*  symbol                              */
336 #endif
337
338 int yynerrs;                    /*  number of parse errors so far       */
339 #endif  /* not YYPURE */
340
341 #if YYDEBUG != 0
342 int yydebug;                    /*  nonzero means print parse trace     */
343 /* Since this is uninitialized, it does not stop multiple parsers
344    from coexisting.  */
345 #endif
346
347 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
348
349 #ifndef YYINITDEPTH
350 #define YYINITDEPTH 200
351 #endif
352
353 /*  YYMAXDEPTH is the maximum size the stacks can grow to
354     (effective only if the built-in stack extension method is used).  */
355
356 #if YYMAXDEPTH == 0
357 #undef YYMAXDEPTH
358 #endif
359
360 #ifndef YYMAXDEPTH
361 #define YYMAXDEPTH 10000
362 #endif
363 \f
364 /* Define __yy_memcpy.  Note that the size argument
365    should be passed with type unsigned int, because that is what the non-GCC
366    definitions require.  With GCC, __builtin_memcpy takes an arg
367    of type size_t, but it can handle unsigned int.  */
368
369 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
370 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
371 #else                           /* not GNU C or C++ */
372 #ifndef __cplusplus
373
374 /* This is the most reliable way to avoid incompatibilities
375    in available built-in functions on various systems.  */
376 static void
377 __yy_memcpy (to, from, count)
378      char *to;
379      char *from;
380      unsigned int count;
381 {
382   register char *f = from;
383   register char *t = to;
384   register int i = count;
385
386   while (i-- > 0)
387     *t++ = *f++;
388 }
389
390 #else /* __cplusplus */
391
392 /* This is the most reliable way to avoid incompatibilities
393    in available built-in functions on various systems.  */
394 static void
395 __yy_memcpy (char *to, char *from, unsigned int count)
396 {
397   register char *t = to;
398   register char *f = from;
399   register int i = count;
400
401   while (i-- > 0)
402     *t++ = *f++;
403 }
404
405 #endif
406 #endif
407 \f
408 #line 217 "/usr/share/bison.simple"
409
410 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
411    into yyparse.  The argument should have type void *.
412    It should actually point to an object.
413    Grammar actions can access the variable by casting it
414    to the proper pointer type.  */
415
416 #ifdef YYPARSE_PARAM
417 #ifdef __cplusplus
418 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
419 #define YYPARSE_PARAM_DECL
420 #else /* not __cplusplus */
421 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
422 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
423 #endif /* not __cplusplus */
424 #else /* not YYPARSE_PARAM */
425 #define YYPARSE_PARAM_ARG
426 #define YYPARSE_PARAM_DECL
427 #endif /* not YYPARSE_PARAM */
428
429 /* Prevent warning if -Wstrict-prototypes.  */
430 #ifdef __GNUC__
431 #ifdef YYPARSE_PARAM
432 int yyparse (void *);
433 #else
434 int yyparse (void);
435 #endif
436 #endif
437
438 int
439 yyparse(YYPARSE_PARAM_ARG)
440      YYPARSE_PARAM_DECL
441 {
442   register int yystate;
443   register int yyn;
444   register short *yyssp;
445   register YYSTYPE *yyvsp;
446   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
447   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
448
449   short yyssa[YYINITDEPTH];     /*  the state stack                     */
450   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
451
452   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
453   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
454
455 #ifdef YYLSP_NEEDED
456   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
457   YYLTYPE *yyls = yylsa;
458   YYLTYPE *yylsp;
459
460 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
461 #else
462 #define YYPOPSTACK   (yyvsp--, yyssp--)
463 #endif
464
465   int yystacksize = YYINITDEPTH;
466   int yyfree_stacks = 0;
467
468 #ifdef YYPURE
469   int yychar;
470   YYSTYPE yylval;
471   int yynerrs;
472 #ifdef YYLSP_NEEDED
473   YYLTYPE yylloc;
474 #endif
475 #endif
476
477   YYSTYPE yyval;                /*  the variable used to return         */
478                                 /*  semantic values from the action     */
479                                 /*  routines                            */
480
481   int yylen;
482
483 #if YYDEBUG != 0
484   if (yydebug)
485     fprintf(stderr, "Starting parse\n");
486 #endif
487
488   yystate = 0;
489   yyerrstatus = 0;
490   yynerrs = 0;
491   yychar = YYEMPTY;             /* Cause a token to be read.  */
492
493   /* Initialize stack pointers.
494      Waste one element of value and location stack
495      so that they stay on the same level as the state stack.
496      The wasted elements are never initialized.  */
497
498   yyssp = yyss - 1;
499   yyvsp = yyvs;
500 #ifdef YYLSP_NEEDED
501   yylsp = yyls;
502 #endif
503
504 /* Push a new state, which is found in  yystate  .  */
505 /* In all cases, when you get here, the value and location stacks
506    have just been pushed. so pushing a state here evens the stacks.  */
507 yynewstate:
508
509   *++yyssp = yystate;
510
511   if (yyssp >= yyss + yystacksize - 1)
512     {
513       /* Give user a chance to reallocate the stack */
514       /* Use copies of these so that the &'s don't force the real ones into memory. */
515       YYSTYPE *yyvs1 = yyvs;
516       short *yyss1 = yyss;
517 #ifdef YYLSP_NEEDED
518       YYLTYPE *yyls1 = yyls;
519 #endif
520
521       /* Get the current used size of the three stacks, in elements.  */
522       int size = yyssp - yyss + 1;
523
524 #ifdef yyoverflow
525       /* Each stack pointer address is followed by the size of
526          the data in use in that stack, in bytes.  */
527 #ifdef YYLSP_NEEDED
528       /* This used to be a conditional around just the two extra args,
529          but that might be undefined if yyoverflow is a macro.  */
530       yyoverflow("parser stack overflow",
531                  &yyss1, size * sizeof (*yyssp),
532                  &yyvs1, size * sizeof (*yyvsp),
533                  &yyls1, size * sizeof (*yylsp),
534                  &yystacksize);
535 #else
536       yyoverflow("parser stack overflow",
537                  &yyss1, size * sizeof (*yyssp),
538                  &yyvs1, size * sizeof (*yyvsp),
539                  &yystacksize);
540 #endif
541
542       yyss = yyss1; yyvs = yyvs1;
543 #ifdef YYLSP_NEEDED
544       yyls = yyls1;
545 #endif
546 #else /* no yyoverflow */
547       /* Extend the stack our own way.  */
548       if (yystacksize >= YYMAXDEPTH)
549         {
550           yyerror("parser stack overflow");
551           if (yyfree_stacks)
552             {
553               free (yyss);
554               free (yyvs);
555 #ifdef YYLSP_NEEDED
556               free (yyls);
557 #endif
558             }
559           return 2;
560         }
561       yystacksize *= 2;
562       if (yystacksize > YYMAXDEPTH)
563         yystacksize = YYMAXDEPTH;
564 #ifndef YYSTACK_USE_ALLOCA
565       yyfree_stacks = 1;
566 #endif
567       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
568       __yy_memcpy ((char *)yyss, (char *)yyss1,
569                    size * (unsigned int) sizeof (*yyssp));
570       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
571       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
572                    size * (unsigned int) sizeof (*yyvsp));
573 #ifdef YYLSP_NEEDED
574       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
575       __yy_memcpy ((char *)yyls, (char *)yyls1,
576                    size * (unsigned int) sizeof (*yylsp));
577 #endif
578 #endif /* no yyoverflow */
579
580       yyssp = yyss + size - 1;
581       yyvsp = yyvs + size - 1;
582 #ifdef YYLSP_NEEDED
583       yylsp = yyls + size - 1;
584 #endif
585
586 #if YYDEBUG != 0
587       if (yydebug)
588         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
589 #endif
590
591       if (yyssp >= yyss + yystacksize - 1)
592         YYABORT;
593     }
594
595 #if YYDEBUG != 0
596   if (yydebug)
597     fprintf(stderr, "Entering state %d\n", yystate);
598 #endif
599
600   goto yybackup;
601  yybackup:
602
603 /* Do appropriate processing given the current state.  */
604 /* Read a lookahead token if we need one and don't already have one.  */
605 /* yyresume: */
606
607   /* First try to decide what to do without reference to lookahead token.  */
608
609   yyn = yypact[yystate];
610   if (yyn == YYFLAG)
611     goto yydefault;
612
613   /* Not known => get a lookahead token if don't already have one.  */
614
615   /* yychar is either YYEMPTY or YYEOF
616      or a valid token in external form.  */
617
618   if (yychar == YYEMPTY)
619     {
620 #if YYDEBUG != 0
621       if (yydebug)
622         fprintf(stderr, "Reading a token: ");
623 #endif
624       yychar = YYLEX;
625     }
626
627   /* Convert token to internal form (in yychar1) for indexing tables with */
628
629   if (yychar <= 0)              /* This means end of input. */
630     {
631       yychar1 = 0;
632       yychar = YYEOF;           /* Don't call YYLEX any more */
633
634 #if YYDEBUG != 0
635       if (yydebug)
636         fprintf(stderr, "Now at end of input.\n");
637 #endif
638     }
639   else
640     {
641       yychar1 = YYTRANSLATE(yychar);
642
643 #if YYDEBUG != 0
644       if (yydebug)
645         {
646           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
647           /* Give the individual parser a way to print the precise meaning
648              of a token, for further debugging info.  */
649 #ifdef YYPRINT
650           YYPRINT (stderr, yychar, yylval);
651 #endif
652           fprintf (stderr, ")\n");
653         }
654 #endif
655     }
656
657   yyn += yychar1;
658   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
659     goto yydefault;
660
661   yyn = yytable[yyn];
662
663   /* yyn is what to do for this token type in this state.
664      Negative => reduce, -yyn is rule number.
665      Positive => shift, yyn is new state.
666        New state is final state => don't bother to shift,
667        just return success.
668      0, or most negative number => error.  */
669
670   if (yyn < 0)
671     {
672       if (yyn == YYFLAG)
673         goto yyerrlab;
674       yyn = -yyn;
675       goto yyreduce;
676     }
677   else if (yyn == 0)
678     goto yyerrlab;
679
680   if (yyn == YYFINAL)
681     YYACCEPT;
682
683   /* Shift the lookahead token.  */
684
685 #if YYDEBUG != 0
686   if (yydebug)
687     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
688 #endif
689
690   /* Discard the token being shifted unless it is eof.  */
691   if (yychar != YYEOF)
692     yychar = YYEMPTY;
693
694   *++yyvsp = yylval;
695 #ifdef YYLSP_NEEDED
696   *++yylsp = yylloc;
697 #endif
698
699   /* count tokens shifted since error; after three, turn off error status.  */
700   if (yyerrstatus) yyerrstatus--;
701
702   yystate = yyn;
703   goto yynewstate;
704
705 /* Do the default action for the current state.  */
706 yydefault:
707
708   yyn = yydefact[yystate];
709   if (yyn == 0)
710     goto yyerrlab;
711
712 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
713 yyreduce:
714   yylen = yyr2[yyn];
715   if (yylen > 0)
716     yyval = yyvsp[1-yylen]; /* implement default value of the action */
717
718 #if YYDEBUG != 0
719   if (yydebug)
720     {
721       int i;
722
723       fprintf (stderr, "Reducing via rule %d (line %d), ",
724                yyn, yyrline[yyn]);
725
726       /* Print the symbols being reduced, and their result.  */
727       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
728         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
729       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
730     }
731 #endif
732
733
734   switch (yyn) {
735
736 case 5:
737 #line 73 "../../../lib/com_err/parse.y"
738 {
739                     id_str = yyvsp[0].string;
740                 ;
741     break;}
742 case 6:
743 #line 79 "../../../lib/com_err/parse.y"
744 {
745                     base_id = name2number(yyvsp[0].string);
746                     strlcpy(name, yyvsp[0].string, sizeof(name));
747                     free(yyvsp[0].string);
748                 ;
749     break;}
750 case 7:
751 #line 85 "../../../lib/com_err/parse.y"
752 {
753                     base_id = name2number(yyvsp[-1].string);
754                     strlcpy(name, yyvsp[0].string, sizeof(name));
755                     free(yyvsp[-1].string);
756                     free(yyvsp[0].string);
757                 ;
758     break;}
759 case 10:
760 #line 98 "../../../lib/com_err/parse.y"
761 {
762                         number = yyvsp[0].number;
763                 ;
764     break;}
765 case 11:
766 #line 102 "../../../lib/com_err/parse.y"
767 {
768                     free(prefix);
769                     asprintf (&prefix, "%s_", yyvsp[0].string);
770                     if (prefix == NULL)
771                         errx(1, "malloc");
772                     free(yyvsp[0].string);
773                 ;
774     break;}
775 case 12:
776 #line 110 "../../../lib/com_err/parse.y"
777 {
778                     prefix = realloc(prefix, 1);
779                     if (prefix == NULL)
780                         errx(1, "malloc");
781                     *prefix = '\0';
782                 ;
783     break;}
784 case 13:
785 #line 117 "../../../lib/com_err/parse.y"
786 {
787                     struct error_code *ec = malloc(sizeof(*ec));
788                     
789                     if (ec == NULL)
790                         errx(1, "malloc");
791
792                     ec->next = NULL;
793                     ec->number = number;
794                     if(prefix && *prefix != '\0') {
795                         asprintf (&ec->name, "%s%s", prefix, yyvsp[-2].string);
796                         if (ec->name == NULL)
797                             errx(1, "malloc");
798                         free(yyvsp[-2].string);
799                     } else
800                         ec->name = yyvsp[-2].string;
801                     ec->string = yyvsp[0].string;
802                     APPEND(codes, ec);
803                     number++;
804                 ;
805     break;}
806 case 14:
807 #line 137 "../../../lib/com_err/parse.y"
808 {
809                         YYACCEPT;
810                 ;
811     break;}
812 }
813    /* the action file gets copied in in place of this dollarsign */
814 #line 543 "/usr/share/bison.simple"
815 \f
816   yyvsp -= yylen;
817   yyssp -= yylen;
818 #ifdef YYLSP_NEEDED
819   yylsp -= yylen;
820 #endif
821
822 #if YYDEBUG != 0
823   if (yydebug)
824     {
825       short *ssp1 = yyss - 1;
826       fprintf (stderr, "state stack now");
827       while (ssp1 != yyssp)
828         fprintf (stderr, " %d", *++ssp1);
829       fprintf (stderr, "\n");
830     }
831 #endif
832
833   *++yyvsp = yyval;
834
835 #ifdef YYLSP_NEEDED
836   yylsp++;
837   if (yylen == 0)
838     {
839       yylsp->first_line = yylloc.first_line;
840       yylsp->first_column = yylloc.first_column;
841       yylsp->last_line = (yylsp-1)->last_line;
842       yylsp->last_column = (yylsp-1)->last_column;
843       yylsp->text = 0;
844     }
845   else
846     {
847       yylsp->last_line = (yylsp+yylen-1)->last_line;
848       yylsp->last_column = (yylsp+yylen-1)->last_column;
849     }
850 #endif
851
852   /* Now "shift" the result of the reduction.
853      Determine what state that goes to,
854      based on the state we popped back to
855      and the rule number reduced by.  */
856
857   yyn = yyr1[yyn];
858
859   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
860   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
861     yystate = yytable[yystate];
862   else
863     yystate = yydefgoto[yyn - YYNTBASE];
864
865   goto yynewstate;
866
867 yyerrlab:   /* here on detecting error */
868
869   if (! yyerrstatus)
870     /* If not already recovering from an error, report this error.  */
871     {
872       ++yynerrs;
873
874 #ifdef YYERROR_VERBOSE
875       yyn = yypact[yystate];
876
877       if (yyn > YYFLAG && yyn < YYLAST)
878         {
879           int size = 0;
880           char *msg;
881           int x, count;
882
883           count = 0;
884           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
885           for (x = (yyn < 0 ? -yyn : 0);
886                x < (sizeof(yytname) / sizeof(char *)); x++)
887             if (yycheck[x + yyn] == x)
888               size += strlen(yytname[x]) + 15, count++;
889           msg = (char *) malloc(size + 15);
890           if (msg != 0)
891             {
892               strcpy(msg, "parse error");
893
894               if (count < 5)
895                 {
896                   count = 0;
897                   for (x = (yyn < 0 ? -yyn : 0);
898                        x < (sizeof(yytname) / sizeof(char *)); x++)
899                     if (yycheck[x + yyn] == x)
900                       {
901                         strcat(msg, count == 0 ? ", expecting `" : " or `");
902                         strcat(msg, yytname[x]);
903                         strcat(msg, "'");
904                         count++;
905                       }
906                 }
907               yyerror(msg);
908               free(msg);
909             }
910           else
911             yyerror ("parse error; also virtual memory exceeded");
912         }
913       else
914 #endif /* YYERROR_VERBOSE */
915         yyerror("parse error");
916     }
917
918   goto yyerrlab1;
919 yyerrlab1:   /* here on error raised explicitly by an action */
920
921   if (yyerrstatus == 3)
922     {
923       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
924
925       /* return failure if at end of input */
926       if (yychar == YYEOF)
927         YYABORT;
928
929 #if YYDEBUG != 0
930       if (yydebug)
931         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
932 #endif
933
934       yychar = YYEMPTY;
935     }
936
937   /* Else will try to reuse lookahead token
938      after shifting the error token.  */
939
940   yyerrstatus = 3;              /* Each real token shifted decrements this */
941
942   goto yyerrhandle;
943
944 yyerrdefault:  /* current state does not do anything special for the error token. */
945
946 #if 0
947   /* This is wrong; only states that explicitly want error tokens
948      should shift them.  */
949   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
950   if (yyn) goto yydefault;
951 #endif
952
953 yyerrpop:   /* pop the current state because it cannot handle the error token */
954
955   if (yyssp == yyss) YYABORT;
956   yyvsp--;
957   yystate = *--yyssp;
958 #ifdef YYLSP_NEEDED
959   yylsp--;
960 #endif
961
962 #if YYDEBUG != 0
963   if (yydebug)
964     {
965       short *ssp1 = yyss - 1;
966       fprintf (stderr, "Error: state stack now");
967       while (ssp1 != yyssp)
968         fprintf (stderr, " %d", *++ssp1);
969       fprintf (stderr, "\n");
970     }
971 #endif
972
973 yyerrhandle:
974
975   yyn = yypact[yystate];
976   if (yyn == YYFLAG)
977     goto yyerrdefault;
978
979   yyn += YYTERROR;
980   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
981     goto yyerrdefault;
982
983   yyn = yytable[yyn];
984   if (yyn < 0)
985     {
986       if (yyn == YYFLAG)
987         goto yyerrpop;
988       yyn = -yyn;
989       goto yyreduce;
990     }
991   else if (yyn == 0)
992     goto yyerrpop;
993
994   if (yyn == YYFINAL)
995     YYACCEPT;
996
997 #if YYDEBUG != 0
998   if (yydebug)
999     fprintf(stderr, "Shifting error token, ");
1000 #endif
1001
1002   *++yyvsp = yylval;
1003 #ifdef YYLSP_NEEDED
1004   *++yylsp = yylloc;
1005 #endif
1006
1007   yystate = yyn;
1008   goto yynewstate;
1009
1010  yyacceptlab:
1011   /* YYACCEPT comes here.  */
1012   if (yyfree_stacks)
1013     {
1014       free (yyss);
1015       free (yyvs);
1016 #ifdef YYLSP_NEEDED
1017       free (yyls);
1018 #endif
1019     }
1020   return 0;
1021
1022  yyabortlab:
1023   /* YYABORT comes here.  */
1024   if (yyfree_stacks)
1025     {
1026       free (yyss);
1027       free (yyvs);
1028 #ifdef YYLSP_NEEDED
1029       free (yyls);
1030 #endif
1031     }
1032   return 1;
1033 }
1034 #line 142 "../../../lib/com_err/parse.y"
1035
1036
1037 static long
1038 name2number(const char *str)
1039 {
1040     const char *p;
1041     long num = 0;
1042     const char *x = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1043         "abcdefghijklmnopqrstuvwxyz0123456789_";
1044     if(strlen(str) > 4) {
1045         yyerror("table name too long");
1046         return 0;
1047     }
1048     for(p = str; *p; p++){
1049         char *q = strchr(x, *p);
1050         if(q == NULL) {
1051             yyerror("invalid character in table name");
1052             return 0;
1053         }
1054         num = (num << 6) + (q - x) + 1;
1055     }
1056     num <<= 8;
1057     if(num > 0x7fffffff)
1058         num = -(0xffffffff - num + 1);
1059     return num;
1060 }
1061
1062 void
1063 yyerror (char *s)
1064 {
1065      error_message ("%s\n", s);
1066 }