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