362d3b00b759efa8ac66800e3b9715aa84b5c03a
[openafs.git] / src / comerr / error_table_nt.c
1
2 /*  A Bison parser, made from error_table.y with Bison version GNU Bison version 1.24
3   */
4
5 #define YYBISON 1  /* Identify Bison output.  */
6
7 #define ERROR_TABLE     258
8 #define ERROR_CODE_ENTRY        259
9 #define END     260
10 #define STRING  261
11 #define QUOTED_STRING   262
12
13 #line 1 "error_table.y"
14
15 #include <afsconfig.h>
16 #include <afs/param.h>
17
18 RCSID("$Header$");
19
20
21 /*
22  * If __STDC__ is defined, function prototypes in the SunOS 5.5.1 lex
23  * and yacc templates are visible.  We turn this on explicitly on
24  * NT because the prototypes help supress certain warning from the
25  * Microsoft C compiler.
26  */
27
28 #ifdef AFS_NT40_ENV
29 #include <malloc.h>
30 # ifndef __STDC__
31 #  define __STDC__ 1
32 # endif
33 #endif
34
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <string.h>
38
39 #include "internal.h"
40
41 char *current_token = (char *)NULL;
42 extern char *table_name;
43
44 char *ds(const char *string);
45 char *quote(const char *string);
46 void set_table_1num(char *string);
47 int char_to_1num(char c);
48 void add_ec(const char *name, const char *description);
49 void add_ec_val(const char *name, const char *val, const char *description);
50 void put_ecs(void);
51 void set_table_num(char *string);
52 void set_table_fun(char *astring);
53
54
55 #line 38 "error_table.y"
56 typedef union {
57         char *dynstr;
58 } YYSTYPE;
59 #line 45 "error_table.y"
60
61
62 #ifndef YYLTYPE
63 typedef
64   struct yyltype
65     {
66       int timestamp;
67       int first_line;
68       int first_column;
69       int last_line;
70       int last_column;
71       char *text;
72    }
73   yyltype;
74
75 #define YYLTYPE yyltype
76 #endif
77
78 #include <stdio.h>
79
80 #ifndef __cplusplus
81 #ifndef __STDC__
82 #define const
83 #endif
84 #endif
85
86
87
88 #define YYFINAL         24
89 #define YYFLAG          -32768
90 #define YYNTBASE        10
91
92 #define YYTRANSLATE(x) ((unsigned)(x) <= 262 ? yytranslate[x] : 18)
93
94 static const char yytranslate[] = {     0,
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,     8,     2,     2,     2,     2,     2,     2,
100      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
101      9,     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,     2,     2,     2,     2,     2,
116      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
117      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
118      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
119      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
120      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
121      6,     7
122 };
123
124 #if YYDEBUG != 0
125 static const short yyprhs[] = {     0,
126      0,     5,     8,    10,    12,    14,    17,    19,    24,    31,
127     33
128 };
129
130 static const short yyrhs[] = {     3,
131     11,    14,     5,     0,    12,    13,     0,    13,     0,     6,
132      0,     6,     0,    14,    15,     0,    15,     0,     4,    16,
133      8,    17,     0,     4,    16,     9,     6,     8,    17,     0,
134      6,     0,     7,     0
135 };
136
137 #endif
138
139 #if YYDEBUG != 0
140 static const short yyrline[] = { 0,
141     50,    56,    59,    66,    73,    79,    80,    83,    87,    95,
142    100
143 };
144
145 static const char * const yytname[] = {   "$","error","$undefined.","ERROR_TABLE",
146 "ERROR_CODE_ENTRY","END","STRING","QUOTED_STRING","','","'='","error_table",
147 "header","table_fun","table_id","error_codes","ec_entry","ec_name","description",
148 ""
149 };
150 #endif
151
152 static const short yyr1[] = {     0,
153     10,    11,    11,    12,    13,    14,    14,    15,    15,    16,
154     17
155 };
156
157 static const short yyr2[] = {     0,
158      4,     2,     1,     1,     1,     2,     1,     4,     6,     1,
159      1
160 };
161
162 static const short yydefact[] = {     0,
163      0,     4,     0,     0,     3,     0,     0,     7,     5,     2,
164     10,     0,     1,     6,     0,     0,    11,     8,     0,     0,
165      9,     0,     0,     0
166 };
167
168 static const short yydefgoto[] = {    22,
169      3,     4,     5,     7,     8,    12,    18
170 };
171
172 static const short yypact[] = {     1,
173     -1,     2,     3,     4,-32768,     5,    -4,-32768,-32768,-32768,
174 -32768,    -6,-32768,-32768,     6,     8,-32768,-32768,     0,     6,
175 -32768,     9,    12,-32768
176 };
177
178 static const short yypgoto[] = {-32768,
179 -32768,-32768,    11,-32768,    10,-32768,    -2
180 };
181
182
183 #define YYLAST          18
184
185
186 static const short yytable[] = {     6,
187     13,    15,    16,     1,     2,    -5,     6,    20,    23,     9,
188     11,    24,    17,    19,    10,     0,    14,    21
189 };
190
191 static const short yycheck[] = {     4,
192      5,     8,     9,     3,     6,     4,     4,     8,     0,     6,
193      6,     0,     7,     6,     4,    -1,     7,    20
194 };
195 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
196 #line 3 "bison.simple"
197
198 /* Skeleton output parser for bison,
199    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
200
201    This program is free software; you can redistribute it and/or modify
202    it under the terms of the GNU General Public License as published by
203    the Free Software Foundation; either version 2, or (at your option)
204    any later version.
205
206    This program is distributed in the hope that it will be useful,
207    but WITHOUT ANY WARRANTY; without even the implied warranty of
208    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
209    GNU General Public License for more details.
210
211    You should have received a copy of the GNU General Public License
212    along with this program; if not, write to the Free Software
213    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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 #ifndef alloca
221 #ifdef __GNUC__
222 #define alloca __builtin_alloca
223 #else /* not GNU C.  */
224 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
225 #include <alloca.h>
226 #else /* not sparc */
227 #if defined (MSDOS) && !defined (__TURBOC__)
228 #include <malloc.h>
229 #else /* not MSDOS, or __TURBOC__ */
230 #if defined(_AIX)
231 #include <malloc.h>
232  #pragma alloca
233 #else /* not MSDOS, __TURBOC__, or _AIX */
234 #ifdef __hpux
235 #ifdef __cplusplus
236 extern "C" {
237 void *alloca (unsigned int);
238 };
239 #else /* not __cplusplus */
240 void *alloca ();
241 #endif /* not __cplusplus */
242 #endif /* __hpux */
243 #endif /* not _AIX */
244 #endif /* not MSDOS, or __TURBOC__ */
245 #endif /* not sparc.  */
246 #endif /* not GNU C.  */
247 #endif /* alloca not defined.  */
248
249 /* This is the parser code that is written into each bison parser
250   when the %semantic_parser declaration is not specified in the grammar.
251   It was written by Richard Stallman by simplifying the hairy parser
252   used when %semantic_parser is specified.  */
253
254 /* Note: there must be only one dollar sign in this file.
255    It is replaced by the list of actions, each action
256    as one case of the switch.  */
257
258 #define yyerrok         (yyerrstatus = 0)
259 #define yyclearin       (yychar = YYEMPTY)
260 #define YYEMPTY         -2
261 #define YYEOF           0
262 #define YYACCEPT        return(0)
263 #define YYABORT         return(1)
264 #define YYERROR         goto yyerrlab1
265 /* Like YYERROR except do call yyerror.
266    This remains here temporarily to ease the
267    transition to the new meaning of YYERROR, for GCC.
268    Once GCC version 2 has supplanted version 1, this can go.  */
269 #define YYFAIL          goto yyerrlab
270 #define YYRECOVERING()  (!!yyerrstatus)
271 #define YYBACKUP(token, value) \
272 do                                                              \
273   if (yychar == YYEMPTY && yylen == 1)                          \
274     { yychar = (token), yylval = (value);                       \
275       yychar1 = YYTRANSLATE (yychar);                           \
276       YYPOPSTACK;                                               \
277       goto yybackup;                                            \
278     }                                                           \
279   else                                                          \
280     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
281 while (0)
282
283 #define YYTERROR        1
284 #define YYERRCODE       256
285
286 #ifndef YYPURE
287 #define YYLEX           yylex()
288 #endif
289
290 #ifdef YYPURE
291 #ifdef YYLSP_NEEDED
292 #ifdef YYLEX_PARAM
293 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
294 #else
295 #define YYLEX           yylex(&yylval, &yylloc)
296 #endif
297 #else /* not YYLSP_NEEDED */
298 #ifdef YYLEX_PARAM
299 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
300 #else
301 #define YYLEX           yylex(&yylval)
302 #endif
303 #endif /* not YYLSP_NEEDED */
304 #endif
305
306 /* If nonreentrant, generate the variables here */
307
308 #ifndef YYPURE
309
310 int     yychar;                 /*  the lookahead symbol                */
311 YYSTYPE yylval;                 /*  the semantic value of the           */
312                                 /*  lookahead symbol                    */
313
314 #ifdef YYLSP_NEEDED
315 YYLTYPE yylloc;                 /*  location data for the lookahead     */
316                                 /*  symbol                              */
317 #endif
318
319 int yynerrs;                    /*  number of parse errors so far       */
320 #endif  /* not YYPURE */
321
322 #if YYDEBUG != 0
323 int yydebug;                    /*  nonzero means print parse trace     */
324 /* Since this is uninitialized, it does not stop multiple parsers
325    from coexisting.  */
326 #endif
327
328 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
329
330 #ifndef YYINITDEPTH
331 #define YYINITDEPTH 200
332 #endif
333
334 /*  YYMAXDEPTH is the maximum size the stacks can grow to
335     (effective only if the built-in stack extension method is used).  */
336
337 #if YYMAXDEPTH == 0
338 #undef YYMAXDEPTH
339 #endif
340
341 #ifndef YYMAXDEPTH
342 #define YYMAXDEPTH 10000
343 #endif
344
345 /* Prevent warning if -Wstrict-prototypes.  */
346 #ifdef __GNUC__
347 int yyparse (void);
348 #endif
349 \f
350 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
351 #define __yy_memcpy(FROM,TO,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
352 #else                           /* not GNU C or C++ */
353 #ifndef __cplusplus
354
355 /* This is the most reliable way to avoid incompatibilities
356    in available built-in functions on various systems.  */
357 static void
358 __yy_memcpy (from, to, count)
359      char *from;
360      char *to;
361      int count;
362 {
363   register char *f = from;
364   register char *t = to;
365   register int i = count;
366
367   while (i-- > 0)
368     *t++ = *f++;
369 }
370
371 #else /* __cplusplus */
372
373 /* This is the most reliable way to avoid incompatibilities
374    in available built-in functions on various systems.  */
375 static void
376 __yy_memcpy (char *from, char *to, int count)
377 {
378   register char *f = from;
379   register char *t = to;
380   register int i = count;
381
382   while (i-- > 0)
383     *t++ = *f++;
384 }
385
386 #endif
387 #endif
388 \f
389 #line 192 "bison.simple"
390
391 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
392    into yyparse.  The argument should have type void *.
393    It should actually point to an object.
394    Grammar actions can access the variable by casting it
395    to the proper pointer type.  */
396
397 #ifdef YYPARSE_PARAM
398 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
399 #else
400 #define YYPARSE_PARAM
401 #define YYPARSE_PARAM_DECL
402 #endif
403
404 int
405 yyparse(YYPARSE_PARAM)
406      YYPARSE_PARAM_DECL
407 {
408   register int yystate;
409   register int yyn;
410   register short *yyssp;
411   register YYSTYPE *yyvsp;
412   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
413   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
414
415   short yyssa[YYINITDEPTH];     /*  the state stack                     */
416   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
417
418   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
419   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
420
421 #ifdef YYLSP_NEEDED
422   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
423   YYLTYPE *yyls = yylsa;
424   YYLTYPE *yylsp;
425
426 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
427 #else
428 #define YYPOPSTACK   (yyvsp--, yyssp--)
429 #endif
430
431   int yystacksize = YYINITDEPTH;
432
433 #ifdef YYPURE
434   int yychar;
435   YYSTYPE yylval;
436   int yynerrs;
437 #ifdef YYLSP_NEEDED
438   YYLTYPE yylloc;
439 #endif
440 #endif
441
442   YYSTYPE yyval;                /*  the variable used to return         */
443                                 /*  semantic values from the action     */
444                                 /*  routines                            */
445
446   int yylen;
447
448 #if YYDEBUG != 0
449   if (yydebug)
450     fprintf(stderr, "Starting parse\n");
451 #endif
452
453   yystate = 0;
454   yyerrstatus = 0;
455   yynerrs = 0;
456   yychar = YYEMPTY;             /* Cause a token to be read.  */
457
458   /* Initialize stack pointers.
459      Waste one element of value and location stack
460      so that they stay on the same level as the state stack.
461      The wasted elements are never initialized.  */
462
463   yyssp = yyss - 1;
464   yyvsp = yyvs;
465 #ifdef YYLSP_NEEDED
466   yylsp = yyls;
467 #endif
468
469 /* Push a new state, which is found in  yystate  .  */
470 /* In all cases, when you get here, the value and location stacks
471    have just been pushed. so pushing a state here evens the stacks.  */
472 yynewstate:
473
474   *++yyssp = yystate;
475
476   if (yyssp >= yyss + yystacksize - 1)
477     {
478       /* Give user a chance to reallocate the stack */
479       /* Use copies of these so that the &'s don't force the real ones into memory. */
480       YYSTYPE *yyvs1 = yyvs;
481       short *yyss1 = yyss;
482 #ifdef YYLSP_NEEDED
483       YYLTYPE *yyls1 = yyls;
484 #endif
485
486       /* Get the current used size of the three stacks, in elements.  */
487       int size = yyssp - yyss + 1;
488
489 #ifdef yyoverflow
490       /* Each stack pointer address is followed by the size of
491          the data in use in that stack, in bytes.  */
492 #ifdef YYLSP_NEEDED
493       /* This used to be a conditional around just the two extra args,
494          but that might be undefined if yyoverflow is a macro.  */
495       yyoverflow("parser stack overflow",
496                  &yyss1, size * sizeof (*yyssp),
497                  &yyvs1, size * sizeof (*yyvsp),
498                  &yyls1, size * sizeof (*yylsp),
499                  &yystacksize);
500 #else
501       yyoverflow("parser stack overflow",
502                  &yyss1, size * sizeof (*yyssp),
503                  &yyvs1, size * sizeof (*yyvsp),
504                  &yystacksize);
505 #endif
506
507       yyss = yyss1; yyvs = yyvs1;
508 #ifdef YYLSP_NEEDED
509       yyls = yyls1;
510 #endif
511 #else /* no yyoverflow */
512       /* Extend the stack our own way.  */
513       if (yystacksize >= YYMAXDEPTH)
514         {
515           yyerror("parser stack overflow");
516           return 2;
517         }
518       yystacksize *= 2;
519       if (yystacksize > YYMAXDEPTH)
520         yystacksize = YYMAXDEPTH;
521       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
522       __yy_memcpy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
523       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
524       __yy_memcpy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
525 #ifdef YYLSP_NEEDED
526       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
527       __yy_memcpy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
528 #endif
529 #endif /* no yyoverflow */
530
531       yyssp = yyss + size - 1;
532       yyvsp = yyvs + size - 1;
533 #ifdef YYLSP_NEEDED
534       yylsp = yyls + size - 1;
535 #endif
536
537 #if YYDEBUG != 0
538       if (yydebug)
539         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
540 #endif
541
542       if (yyssp >= yyss + yystacksize - 1)
543         YYABORT;
544     }
545
546 #if YYDEBUG != 0
547   if (yydebug)
548     fprintf(stderr, "Entering state %d\n", yystate);
549 #endif
550
551   goto yybackup;
552  yybackup:
553
554 /* Do appropriate processing given the current state.  */
555 /* Read a lookahead token if we need one and don't already have one.  */
556 /* yyresume: */
557
558   /* First try to decide what to do without reference to lookahead token.  */
559
560   yyn = yypact[yystate];
561   if (yyn == YYFLAG)
562     goto yydefault;
563
564   /* Not known => get a lookahead token if don't already have one.  */
565
566   /* yychar is either YYEMPTY or YYEOF
567      or a valid token in external form.  */
568
569   if (yychar == YYEMPTY)
570     {
571 #if YYDEBUG != 0
572       if (yydebug)
573         fprintf(stderr, "Reading a token: ");
574 #endif
575       yychar = YYLEX;
576     }
577
578   /* Convert token to internal form (in yychar1) for indexing tables with */
579
580   if (yychar <= 0)              /* This means end of input. */
581     {
582       yychar1 = 0;
583       yychar = YYEOF;           /* Don't call YYLEX any more */
584
585 #if YYDEBUG != 0
586       if (yydebug)
587         fprintf(stderr, "Now at end of input.\n");
588 #endif
589     }
590   else
591     {
592       yychar1 = YYTRANSLATE(yychar);
593
594 #if YYDEBUG != 0
595       if (yydebug)
596         {
597           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
598           /* Give the individual parser a way to print the precise meaning
599              of a token, for further debugging info.  */
600 #ifdef YYPRINT
601           YYPRINT (stderr, yychar, yylval);
602 #endif
603           fprintf (stderr, ")\n");
604         }
605 #endif
606     }
607
608   yyn += yychar1;
609   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
610     goto yydefault;
611
612   yyn = yytable[yyn];
613
614   /* yyn is what to do for this token type in this state.
615      Negative => reduce, -yyn is rule number.
616      Positive => shift, yyn is new state.
617        New state is final state => don't bother to shift,
618        just return success.
619      0, or most negative number => error.  */
620
621   if (yyn < 0)
622     {
623       if (yyn == YYFLAG)
624         goto yyerrlab;
625       yyn = -yyn;
626       goto yyreduce;
627     }
628   else if (yyn == 0)
629     goto yyerrlab;
630
631   if (yyn == YYFINAL)
632     YYACCEPT;
633
634   /* Shift the lookahead token.  */
635
636 #if YYDEBUG != 0
637   if (yydebug)
638     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
639 #endif
640
641   /* Discard the token being shifted unless it is eof.  */
642   if (yychar != YYEOF)
643     yychar = YYEMPTY;
644
645   *++yyvsp = yylval;
646 #ifdef YYLSP_NEEDED
647   *++yylsp = yylloc;
648 #endif
649
650   /* count tokens shifted since error; after three, turn off error status.  */
651   if (yyerrstatus) yyerrstatus--;
652
653   yystate = yyn;
654   goto yynewstate;
655
656 /* Do the default action for the current state.  */
657 yydefault:
658
659   yyn = yydefact[yystate];
660   if (yyn == 0)
661     goto yyerrlab;
662
663 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
664 yyreduce:
665   yylen = yyr2[yyn];
666   if (yylen > 0)
667     yyval = yyvsp[1-yylen]; /* implement default value of the action */
668
669 #if YYDEBUG != 0
670   if (yydebug)
671     {
672       int i;
673
674       fprintf (stderr, "Reducing via rule %d (line %d), ",
675                yyn, yyrline[yyn]);
676
677       /* Print the symbols being reduced, and their result.  */
678       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
679         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
680       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
681     }
682 #endif
683
684
685   switch (yyn) {
686
687 case 1:
688 #line 51 "error_table.y"
689 { table_name = ds(yyvsp[-2].dynstr);
690                           current_token = table_name;
691                           put_ecs(); ;
692     break;}
693 case 2:
694 #line 57 "error_table.y"
695 { current_token = yyvsp[-1].dynstr;
696                           yyval.dynstr = yyvsp[0].dynstr; ;
697     break;}
698 case 3:
699 #line 60 "error_table.y"
700 { current_token = yyvsp[0].dynstr;
701                           set_table_fun(ds("1"));
702                           yyval.dynstr = yyvsp[0].dynstr;
703                         ;
704     break;}
705 case 4:
706 #line 67 "error_table.y"
707 { current_token = yyvsp[0].dynstr;
708                           set_table_fun(yyvsp[0].dynstr);
709                           yyval.dynstr = yyvsp[0].dynstr; ;
710     break;}
711 case 5:
712 #line 74 "error_table.y"
713 { current_token = yyvsp[0].dynstr;
714                           set_table_num(yyvsp[0].dynstr);
715                           yyval.dynstr = yyvsp[0].dynstr; ;
716     break;}
717 case 8:
718 #line 84 "error_table.y"
719 { add_ec(yyvsp[-2].dynstr, yyvsp[0].dynstr);
720                           free(yyvsp[-2].dynstr);
721                           free(yyvsp[0].dynstr); ;
722     break;}
723 case 9:
724 #line 88 "error_table.y"
725 { add_ec_val(yyvsp[-4].dynstr, yyvsp[-2].dynstr, yyvsp[0].dynstr);
726                           free(yyvsp[-4].dynstr);
727                           free(yyvsp[-2].dynstr);
728                           free(yyvsp[0].dynstr);
729                         ;
730     break;}
731 case 10:
732 #line 96 "error_table.y"
733 { yyval.dynstr = ds(yyvsp[0].dynstr);
734                           current_token = yyval.dynstr; ;
735     break;}
736 case 11:
737 #line 101 "error_table.y"
738 { yyval.dynstr = ds(yyvsp[0].dynstr);
739                           current_token = yyval.dynstr; ;
740     break;}
741 }
742    /* the action file gets copied in in place of this dollarsign */
743 #line 487 "bison.simple"
744 \f
745   yyvsp -= yylen;
746   yyssp -= yylen;
747 #ifdef YYLSP_NEEDED
748   yylsp -= yylen;
749 #endif
750
751 #if YYDEBUG != 0
752   if (yydebug)
753     {
754       short *ssp1 = yyss - 1;
755       fprintf (stderr, "state stack now");
756       while (ssp1 != yyssp)
757         fprintf (stderr, " %d", *++ssp1);
758       fprintf (stderr, "\n");
759     }
760 #endif
761
762   *++yyvsp = yyval;
763
764 #ifdef YYLSP_NEEDED
765   yylsp++;
766   if (yylen == 0)
767     {
768       yylsp->first_line = yylloc.first_line;
769       yylsp->first_column = yylloc.first_column;
770       yylsp->last_line = (yylsp-1)->last_line;
771       yylsp->last_column = (yylsp-1)->last_column;
772       yylsp->text = 0;
773     }
774   else
775     {
776       yylsp->last_line = (yylsp+yylen-1)->last_line;
777       yylsp->last_column = (yylsp+yylen-1)->last_column;
778     }
779 #endif
780
781   /* Now "shift" the result of the reduction.
782      Determine what state that goes to,
783      based on the state we popped back to
784      and the rule number reduced by.  */
785
786   yyn = yyr1[yyn];
787
788   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
789   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
790     yystate = yytable[yystate];
791   else
792     yystate = yydefgoto[yyn - YYNTBASE];
793
794   goto yynewstate;
795
796 yyerrlab:   /* here on detecting error */
797
798   if (! yyerrstatus)
799     /* If not already recovering from an error, report this error.  */
800     {
801       ++yynerrs;
802
803 #ifdef YYERROR_VERBOSE
804       yyn = yypact[yystate];
805
806       if (yyn > YYFLAG && yyn < YYLAST)
807         {
808           int size = 0;
809           char *msg;
810           int x, count;
811
812           count = 0;
813           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
814           for (x = (yyn < 0 ? -yyn : 0);
815                x < (sizeof(yytname) / sizeof(char *)); x++)
816             if (yycheck[x + yyn] == x)
817               size += strlen(yytname[x]) + 15, count++;
818           msg = (char *) malloc(size + 15);
819           if (msg != 0)
820             {
821               strcpy(msg, "parse error");
822
823               if (count < 5)
824                 {
825                   count = 0;
826                   for (x = (yyn < 0 ? -yyn : 0);
827                        x < (sizeof(yytname) / sizeof(char *)); x++)
828                     if (yycheck[x + yyn] == x)
829                       {
830                         strcat(msg, count == 0 ? ", expecting `" : " or `");
831                         strcat(msg, yytname[x]);
832                         strcat(msg, "'");
833                         count++;
834                       }
835                 }
836               yyerror(msg);
837               free(msg);
838             }
839           else
840             yyerror ("parse error; also virtual memory exceeded");
841         }
842       else
843 #endif /* YYERROR_VERBOSE */
844         yyerror("parse error");
845     }
846
847   goto yyerrlab1;
848 yyerrlab1:   /* here on error raised explicitly by an action */
849
850   if (yyerrstatus == 3)
851     {
852       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
853
854       /* return failure if at end of input */
855       if (yychar == YYEOF)
856         YYABORT;
857
858 #if YYDEBUG != 0
859       if (yydebug)
860         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
861 #endif
862
863       yychar = YYEMPTY;
864     }
865
866   /* Else will try to reuse lookahead token
867      after shifting the error token.  */
868
869   yyerrstatus = 3;              /* Each real token shifted decrements this */
870
871   goto yyerrhandle;
872
873 yyerrdefault:  /* current state does not do anything special for the error token. */
874
875 #if 0
876   /* This is wrong; only states that explicitly want error tokens
877      should shift them.  */
878   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
879   if (yyn) goto yydefault;
880 #endif
881
882 yyerrpop:   /* pop the current state because it cannot handle the error token */
883
884   if (yyssp == yyss) YYABORT;
885   yyvsp--;
886   yystate = *--yyssp;
887 #ifdef YYLSP_NEEDED
888   yylsp--;
889 #endif
890
891 #if YYDEBUG != 0
892   if (yydebug)
893     {
894       short *ssp1 = yyss - 1;
895       fprintf (stderr, "Error: state stack now");
896       while (ssp1 != yyssp)
897         fprintf (stderr, " %d", *++ssp1);
898       fprintf (stderr, "\n");
899     }
900 #endif
901
902 yyerrhandle:
903
904   yyn = yypact[yystate];
905   if (yyn == YYFLAG)
906     goto yyerrdefault;
907
908   yyn += YYTERROR;
909   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
910     goto yyerrdefault;
911
912   yyn = yytable[yyn];
913   if (yyn < 0)
914     {
915       if (yyn == YYFLAG)
916         goto yyerrpop;
917       yyn = -yyn;
918       goto yyreduce;
919     }
920   else if (yyn == 0)
921     goto yyerrpop;
922
923   if (yyn == YYFINAL)
924     YYACCEPT;
925
926 #if YYDEBUG != 0
927   if (yydebug)
928     fprintf(stderr, "Shifting error token, ");
929 #endif
930
931   *++yyvsp = yylval;
932 #ifdef YYLSP_NEEDED
933   *++yylsp = yylloc;
934 #endif
935
936   yystate = yyn;
937   goto yynewstate;
938 }
939 #line 105 "error_table.y"
940
941 /*
942  *
943  * Copyright 1986, 1987 by the MIT Student Information Processing Board
944  *
945  * For copyright info, see mit-sipb-cr.h.
946  */
947 #ifndef AFS_NT40_ENV
948 #include <unistd.h>
949 #endif
950 #include <afs/param.h>
951 #include <string.h>
952 #include <assert.h>
953 #include <ctype.h>
954 #ifdef AFS_NT40_ENV
955 #include <sys/types.h>
956 #include <afs/afsutil.h>
957 #else
958 #include <sys/time.h>
959 #endif
960 #include <sys/timeb.h>
961 #include "error_table.h"
962 #include "mit-sipb-cr.h"
963 #include <stdio.h>
964
965 /* Copyright (C)  1998  Transarc Corporation.  All rights reserved.
966  *
967  */
968
969 extern FILE *hfile, *cfile, *msfile;
970 extern int use_msf;
971
972 static afs_int32 gensym_n = 0;
973
974 char *gensym(const char *x)
975 {
976         char *symbol;
977         if (!gensym_n) {
978                 struct timeval tv;
979                 gettimeofday(&tv, (void *)0);
980                 gensym_n = (tv.tv_sec%10000)*100 + tv.tv_usec/10000;
981         }
982         symbol = (char *)malloc(32 * sizeof(char));
983         gensym_n++;
984         sprintf(symbol, "et%ld", gensym_n);
985         return(symbol);
986 }
987
988 char *
989 ds(const char *string)
990 {
991         char *rv;
992         rv = (char *)malloc(strlen(string)+1);
993         strcpy(rv, string);
994         return(rv);
995 }
996
997 char *
998 quote(const char *string)
999 {
1000         char *rv;
1001         rv = (char *)malloc(strlen(string)+3);
1002         strcpy(rv, "\"");
1003         strcat(rv, string);
1004         strcat(rv, "\"");
1005         return(rv);
1006 }
1007
1008 afs_int32 table_number = 0;
1009 int current = 0;
1010 char **error_codes = (char **)NULL;
1011
1012 void add_ec(const char *name, const char *description)
1013 {
1014         if (msfile) {
1015             if (current > 0)
1016 #ifndef sun
1017                 fprintf(msfile, "%d\t%s\n", current, description);
1018 #else
1019                 fprintf(msfile, "%d %s\n", current, description);
1020 #endif /* !sun */
1021         } else {
1022             fprintf(cfile, "\t\"%s\",\n", description);
1023         }
1024         if (error_codes == (char **)NULL) {
1025                 error_codes = (char **)malloc(sizeof(char *));
1026                 *error_codes = (char *)NULL;
1027         }
1028         error_codes = (char **)realloc((char *)error_codes,
1029                                        (current + 2)*sizeof(char *));
1030         error_codes[current++] = ds(name);
1031         error_codes[current] = (char *)NULL;
1032 }
1033
1034 void add_ec_val(const char *name, const char *val, const char *description)
1035 {
1036         const int ncurrent = atoi(val);
1037         if (ncurrent < current) {
1038                 printf("Error code %s (%d) out of order", name,
1039                        current);
1040                 return;
1041         }
1042       
1043         while (ncurrent > current) {
1044              if (!msfile)
1045                  fputs("\t(char *)NULL,\n", cfile);
1046              current++;
1047          }
1048         if (msfile) {
1049             if (current > 0)
1050 #ifndef sun
1051                 fprintf(msfile, "%d\t%s\n", current, description);
1052 #else
1053                 fprintf(msfile, "%d %s\n", current, description);
1054 #endif /* ! sun */
1055         } else {        
1056             fprintf(cfile, "\t\"%s\",\n", description);
1057         }
1058         if (error_codes == (char **)NULL) {
1059                 error_codes = (char **)malloc(sizeof(char *));
1060                 *error_codes = (char *)NULL;
1061         }
1062         error_codes = (char **)realloc((char *)error_codes,
1063                                        (current + 2)*sizeof(char *));
1064         error_codes[current++] = ds(name);
1065         error_codes[current] = (char *)NULL;
1066
1067
1068 void put_ecs(void)
1069 {
1070         int i;
1071         for (i = 0; i < current; i++) {
1072              if (error_codes[i] != (char *)NULL)
1073                   fprintf(hfile, "#define %-40s (%ldL)\n",
1074                           error_codes[i], table_number + i);
1075         }
1076 }
1077
1078 /*
1079  * char_to_num -- maps letters and numbers into a small numbering space
1080  *      uppercase ->  1-26
1081  *      lowercase -> 27-52
1082  *      digits    -> 53-62
1083  *      underscore-> 63
1084  */
1085
1086 static const char char_set[] =
1087         "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
1088
1089 int char_to_num(char c)
1090 {
1091         const char *where;
1092         int diff;
1093
1094         where = strchr (char_set, c);
1095         if (where) {
1096                 diff = where - char_set + 1;
1097                 assert (diff < (1 << ERRCODE_RANGE));
1098                 return diff;
1099         }
1100         else if (isprint (c))
1101                 fprintf (stderr,
1102                          "Illegal character `%c' in error table name\n",
1103                          c);
1104         else
1105                 fprintf (stderr,
1106                          "Illegal character %03o in error table name\n",
1107                          c);
1108         exit (1);
1109 }
1110
1111 void set_table_num(char *string)
1112 {
1113         if (msfile) {
1114             set_table_1num(string);
1115             return;
1116         }
1117         if (strlen(string) > 4) {
1118                 fprintf(stderr, "Table name %s too long, truncated ",
1119                         string);
1120                 string[4] = '\0';
1121                 fprintf(stderr, "to %s\n", string);
1122         }
1123         if (char_to_num (string[0]) > char_to_num ('z')) {
1124                 fprintf (stderr, "%s%s%s%s",
1125                          "First character of error table name must be ",
1126                          "a letter; name ``",
1127                          string, "'' rejected\n");
1128                 exit (1);
1129         }
1130         while (*string != '\0') {
1131                 table_number = (table_number << BITS_PER_CHAR)
1132                         + char_to_num(*string);
1133                 string++;
1134         }
1135         table_number = table_number << ERRCODE_RANGE;
1136 }
1137
1138 void set_table_fun(char *astring)
1139 {
1140     register char *tp;
1141     unsigned int tc;
1142
1143     for(tp=astring; (tc = *tp) != 0; tp++) {
1144         if (!isdigit(tc)) {
1145             fprintf(stderr, "Table function '%s' must be a decimal integer.\n",
1146                     astring);
1147             exit(1);
1148         }
1149     }
1150     if (msfile) 
1151         table_number += (atoi(astring)) << 28;
1152 }
1153
1154 /* for compatibility with old comerr's, we truncate package name to 4
1155  * characters, but only store first 3 in the error code.  Note that this
1156  * function, as a side effect, truncates the table name down to 4 chars.
1157  */
1158 void set_table_1num(char *string)
1159 {
1160         afs_int32 temp;
1161         int ctr;
1162
1163         if ((temp = strlen(string)) > 4) {
1164                 fprintf(stderr, "Table name %s too long, truncated ",
1165                         string);
1166                 string[4] = '\0';
1167                 fprintf(stderr, "to %s\n", string);
1168         }
1169         if (temp == 4) {
1170             fprintf(stderr, "Table name %s too long, only 3 characters fit in error code.\n",
1171                     string);
1172         }
1173         if (char_to_1num (string[0]) > char_to_1num ('z')) {
1174                 fprintf (stderr, "%s%s%s%s",
1175                          "First character of error table name must be ",
1176                          "a letter; name ``",
1177                          string, "'' rejected\n");
1178                 exit (1);
1179         }
1180         temp = 0;
1181         for(ctr=0; ctr < 3; ctr++) {            /* copy at most 3 chars to integer */
1182             if (*string == '\0') break;         /* and watch for early end */
1183             temp = (temp * 050)                 /* "radix fifty" is base 050 = 40 */
1184                 + char_to_1num(*string);
1185             string++;
1186         }
1187         table_number += temp << 12;
1188 }
1189
1190 /*
1191  * char_to_num -- maps letters and numbers into very small space
1192  *      0-9        -> 0-9
1193  *      mixed case -> 10-35
1194  *      _          -> 36
1195  *      others are reserved
1196  */
1197
1198 static const char char_1set[] =
1199         "abcdefghijklmnopqrstuvwxyz_0123456789";
1200
1201 int char_to_1num(char c)
1202 {
1203         const char *where;
1204         int diff;
1205
1206         if (isupper(c)) c = tolower(c);
1207
1208         where = strchr (char_1set, c);
1209         if (where) {
1210                 /* start at 1 so we can decode */
1211                 diff = where - char_1set;
1212                 assert (diff < 050);    /* it is radix 50, after all */
1213                 return diff;
1214         }
1215         else if (isprint (c))
1216                 fprintf (stderr,
1217                          "Illegal character `%c' in error table name\n",
1218                          c);
1219         else
1220                 fprintf (stderr,
1221                          "Illegal character %03o in error table name\n",
1222                          c);
1223         exit (1);
1224 }
1225
1226 #ifdef AFS_NT40_ENV
1227 #include "et_lex.lex_nt.c"
1228 #else
1229 #include "et_lex.lex.c"
1230 #endif