s4-torture: dns torture test depends on AD DC build
[Samba/vl.git] / source4 / heimdal / lib / com_err / parse.c
blobcbb30765cb54b74a153ad89a2a927f8020922926
1 #ifndef lint
2 static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
3 #endif
5 #define YYBYACC 1
6 #define YYMAJOR 1
7 #define YYMINOR 9
8 #define YYPATCH 20101229
10 #define YYEMPTY (-1)
11 #define yyclearin (yychar = YYEMPTY)
12 #define yyerrok (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
15 #define YYPREFIX "yy"
17 #define YYPURE 0
20 * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan
21 * (Royal Institute of Technology, Stockholm, Sweden).
22 * All rights reserved.
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
26 * are met:
28 * 1. Redistributions of source code must retain the above copyright
29 * notice, this list of conditions and the following disclaimer.
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in the
33 * documentation and/or other materials provided with the distribution.
35 * 3. Neither the name of the Institute nor the names of its contributors
36 * may be used to endorse or promote products derived from this software
37 * without specific prior written permission.
39 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
40 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
42 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
43 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
44 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
45 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
48 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49 * SUCH DAMAGE.
52 #include "compile_et.h"
53 #include "lex.h"
55 void yyerror (char *s);
56 static long name2number(const char *str);
58 extern char *yytext;
60 /* This is for bison */
62 #if !defined(alloca) && !defined(HAVE_ALLOCA)
63 #define alloca(x) malloc(x)
64 #endif
66 #define YYMALLOC malloc
67 #define YYFREE free
69 #ifdef YYSTYPE
70 #undef YYSTYPE_IS_DECLARED
71 #define YYSTYPE_IS_DECLARED 1
72 #endif
73 #ifndef YYSTYPE_IS_DECLARED
74 #define YYSTYPE_IS_DECLARED 1
75 typedef union {
76 char *string;
77 int number;
78 } YYSTYPE;
79 #endif /* !YYSTYPE_IS_DECLARED */
80 /* compatibility with bison */
81 #ifdef YYPARSE_PARAM
82 /* compatibility with FreeBSD */
83 # ifdef YYPARSE_PARAM_TYPE
84 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
85 # else
86 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
87 # endif
88 #else
89 # define YYPARSE_DECL() yyparse(void)
90 #endif
92 /* Parameters sent to lex. */
93 #ifdef YYLEX_PARAM
94 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
95 # define YYLEX yylex(YYLEX_PARAM)
96 #else
97 # define YYLEX_DECL() yylex(void)
98 # define YYLEX yylex()
99 #endif
101 /* Parameters sent to yyerror. */
102 #define YYERROR_DECL() yyerror(const char *s)
103 #define YYERROR_CALL(msg) yyerror(msg)
105 extern int YYPARSE_DECL();
107 #define ET 257
108 #define INDEX 258
109 #define PREFIX 259
110 #define EC 260
111 #define ID 261
112 #define END 262
113 #define STRING 263
114 #define NUMBER 264
115 #define YYERRCODE 256
116 static const short yylhs[] = { -1,
117 0, 0, 1, 1, 3, 4, 4, 2, 2, 5,
118 5, 5, 5, 5,
120 static const short yylen[] = { 2,
121 0, 2, 2, 1, 2, 2, 3, 1, 2, 2,
122 2, 1, 4, 1,
124 static const short yydefred[] = { 0,
125 0, 0, 0, 0, 0, 4, 0, 5, 0, 0,
126 0, 14, 0, 8, 3, 7, 10, 11, 0, 9,
127 0, 13,
129 static const short yydgoto[] = { 3,
130 4, 13, 5, 6, 14,
132 static const short yysindex[] = { -247,
133 -263, -258, 0, -256, -245, 0, -250, 0, -249, -246,
134 -244, 0, -256, 0, 0, 0, 0, 0, -28, 0,
135 -243, 0,
137 static const short yyrindex[] = { 18,
138 0, 0, 0, 0, 0, 0, -251, 0, 0, 1,
139 0, 0, 21, 0, 0, 0, 0, 0, 0, 0,
140 0, 0,
142 static const short yygindex[] = { 0,
143 0, 0, 0, 17, 10,
145 #define YYTABLESIZE 263
146 static const short yytable[] = { 7,
147 12, 9, 10, 11, 8, 12, 6, 6, 6, 1,
148 6, 1, 16, 2, 17, 21, 18, 1, 19, 22,
149 2, 15, 20, 0, 0, 0, 0, 0, 0, 0,
150 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
151 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
152 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
153 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
154 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
158 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
159 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
160 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
161 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
162 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
163 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
164 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
165 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
166 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
167 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
168 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
169 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
170 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
171 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
172 0, 0, 0, 0, 0, 0, 0, 0, 12, 12,
173 12, 0, 12,
175 static const short yycheck[] = { 263,
176 0, 258, 259, 260, 263, 262, 258, 259, 260, 257,
177 262, 257, 263, 261, 264, 44, 263, 0, 263, 263,
178 0, 5, 13, -1, -1, -1, -1, -1, -1, -1,
179 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
180 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
181 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
182 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
183 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
184 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
185 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
186 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
187 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
188 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
189 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
190 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
191 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
192 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
193 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
194 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
195 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
196 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
197 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
198 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
199 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
200 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
201 -1, -1, -1, -1, -1, -1, -1, -1, 258, 259,
202 260, -1, 262,
204 #define YYFINAL 3
205 #ifndef YYDEBUG
206 #define YYDEBUG 0
207 #endif
208 #define YYMAXTOKEN 264
209 #if YYDEBUG
210 static const char *yyname[] = {
212 "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
213 0,0,0,0,0,0,0,0,0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
214 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
215 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
216 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
217 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
218 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"ET","INDEX","PREFIX","EC",
219 "ID","END","STRING","NUMBER",
221 static const char *yyrule[] = {
222 "$accept : file",
223 "file :",
224 "file : header statements",
225 "header : id et",
226 "header : et",
227 "id : ID STRING",
228 "et : ET STRING",
229 "et : ET STRING STRING",
230 "statements : statement",
231 "statements : statements statement",
232 "statement : INDEX NUMBER",
233 "statement : PREFIX STRING",
234 "statement : PREFIX",
235 "statement : EC STRING ',' STRING",
236 "statement : END",
239 #endif
240 /* define the initial stack-sizes */
241 #ifdef YYSTACKSIZE
242 #undef YYMAXDEPTH
243 #define YYMAXDEPTH YYSTACKSIZE
244 #else
245 #ifdef YYMAXDEPTH
246 #define YYSTACKSIZE YYMAXDEPTH
247 #else
248 #define YYSTACKSIZE 500
249 #define YYMAXDEPTH 500
250 #endif
251 #endif
253 #define YYINITSTACKSIZE 500
255 int yydebug;
256 int yynerrs;
258 typedef struct {
259 unsigned stacksize;
260 short *s_base;
261 short *s_mark;
262 short *s_last;
263 YYSTYPE *l_base;
264 YYSTYPE *l_mark;
265 } YYSTACKDATA;
266 int yyerrflag;
267 int yychar;
268 YYSTYPE yyval;
269 YYSTYPE yylval;
271 /* variables for the parser stack */
272 static YYSTACKDATA yystack;
274 static long
275 name2number(const char *str)
277 const char *p;
278 long num = 0;
279 const char *x = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
280 "abcdefghijklmnopqrstuvwxyz0123456789_";
281 if(strlen(str) > 4) {
282 yyerror("table name too long");
283 return 0;
285 for(p = str; *p; p++){
286 char *q = strchr(x, *p);
287 if(q == NULL) {
288 yyerror("invalid character in table name");
289 return 0;
291 num = (num << 6) + (q - x) + 1;
293 num <<= 8;
294 if(num > 0x7fffffff)
295 num = -(0xffffffff - num + 1);
296 return num;
299 void
300 yyerror (char *s)
302 _lex_error_message ("%s\n", s);
305 #if YYDEBUG
306 #include <stdio.h> /* needed for printf */
307 #endif
309 #include <stdlib.h> /* needed for malloc, etc */
310 #include <string.h> /* needed for memset */
312 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
313 static int yygrowstack(YYSTACKDATA *data)
315 int i;
316 unsigned newsize;
317 short *newss;
318 YYSTYPE *newvs;
320 if ((newsize = data->stacksize) == 0)
321 newsize = YYINITSTACKSIZE;
322 else if (newsize >= YYMAXDEPTH)
323 return -1;
324 else if ((newsize *= 2) > YYMAXDEPTH)
325 newsize = YYMAXDEPTH;
327 i = data->s_mark - data->s_base;
328 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
329 if (newss == 0)
330 return -1;
332 data->s_base = newss;
333 data->s_mark = newss + i;
335 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
336 if (newvs == 0)
337 return -1;
339 data->l_base = newvs;
340 data->l_mark = newvs + i;
342 data->stacksize = newsize;
343 data->s_last = data->s_base + newsize - 1;
344 return 0;
347 #if YYPURE || defined(YY_NO_LEAKS)
348 static void yyfreestack(YYSTACKDATA *data)
350 free(data->s_base);
351 free(data->l_base);
352 memset(data, 0, sizeof(*data));
354 #else
355 #define yyfreestack(data) /* nothing */
356 #endif
358 #define YYABORT goto yyabort
359 #define YYREJECT goto yyabort
360 #define YYACCEPT goto yyaccept
361 #define YYERROR goto yyerrlab
364 YYPARSE_DECL()
366 int yym, yyn, yystate;
367 #if YYDEBUG
368 const char *yys;
370 if ((yys = getenv("YYDEBUG")) != 0)
372 yyn = *yys;
373 if (yyn >= '0' && yyn <= '9')
374 yydebug = yyn - '0';
376 #endif
378 yynerrs = 0;
379 yyerrflag = 0;
380 yychar = YYEMPTY;
381 yystate = 0;
383 #if YYPURE
384 memset(&yystack, 0, sizeof(yystack));
385 #endif
387 if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
388 yystack.s_mark = yystack.s_base;
389 yystack.l_mark = yystack.l_base;
390 yystate = 0;
391 *yystack.s_mark = 0;
393 yyloop:
394 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
395 if (yychar < 0)
397 if ((yychar = YYLEX) < 0) yychar = 0;
398 #if YYDEBUG
399 if (yydebug)
401 yys = 0;
402 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
403 if (!yys) yys = "illegal-symbol";
404 printf("%sdebug: state %d, reading %d (%s)\n",
405 YYPREFIX, yystate, yychar, yys);
407 #endif
409 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
410 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
412 #if YYDEBUG
413 if (yydebug)
414 printf("%sdebug: state %d, shifting to state %d\n",
415 YYPREFIX, yystate, yytable[yyn]);
416 #endif
417 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
419 goto yyoverflow;
421 yystate = yytable[yyn];
422 *++yystack.s_mark = yytable[yyn];
423 *++yystack.l_mark = yylval;
424 yychar = YYEMPTY;
425 if (yyerrflag > 0) --yyerrflag;
426 goto yyloop;
428 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
429 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
431 yyn = yytable[yyn];
432 goto yyreduce;
434 if (yyerrflag) goto yyinrecovery;
436 yyerror("syntax error");
438 goto yyerrlab;
440 yyerrlab:
441 ++yynerrs;
443 yyinrecovery:
444 if (yyerrflag < 3)
446 yyerrflag = 3;
447 for (;;)
449 if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
450 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
452 #if YYDEBUG
453 if (yydebug)
454 printf("%sdebug: state %d, error recovery shifting\
455 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
456 #endif
457 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
459 goto yyoverflow;
461 yystate = yytable[yyn];
462 *++yystack.s_mark = yytable[yyn];
463 *++yystack.l_mark = yylval;
464 goto yyloop;
466 else
468 #if YYDEBUG
469 if (yydebug)
470 printf("%sdebug: error recovery discarding state %d\n",
471 YYPREFIX, *yystack.s_mark);
472 #endif
473 if (yystack.s_mark <= yystack.s_base) goto yyabort;
474 --yystack.s_mark;
475 --yystack.l_mark;
479 else
481 if (yychar == 0) goto yyabort;
482 #if YYDEBUG
483 if (yydebug)
485 yys = 0;
486 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
487 if (!yys) yys = "illegal-symbol";
488 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
489 YYPREFIX, yystate, yychar, yys);
491 #endif
492 yychar = YYEMPTY;
493 goto yyloop;
496 yyreduce:
497 #if YYDEBUG
498 if (yydebug)
499 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
500 YYPREFIX, yystate, yyn, yyrule[yyn]);
501 #endif
502 yym = yylen[yyn];
503 if (yym)
504 yyval = yystack.l_mark[1-yym];
505 else
506 memset(&yyval, 0, sizeof yyval);
507 switch (yyn)
509 case 5:
511 id_str = yystack.l_mark[0].string;
513 break;
514 case 6:
516 base_id = name2number(yystack.l_mark[0].string);
517 strlcpy(name, yystack.l_mark[0].string, sizeof(name));
518 free(yystack.l_mark[0].string);
520 break;
521 case 7:
523 base_id = name2number(yystack.l_mark[-1].string);
524 strlcpy(name, yystack.l_mark[0].string, sizeof(name));
525 free(yystack.l_mark[-1].string);
526 free(yystack.l_mark[0].string);
528 break;
529 case 10:
531 number = yystack.l_mark[0].number;
533 break;
534 case 11:
536 free(prefix);
537 asprintf (&prefix, "%s_", yystack.l_mark[0].string);
538 if (prefix == NULL)
539 errx(1, "malloc");
540 free(yystack.l_mark[0].string);
542 break;
543 case 12:
545 prefix = realloc(prefix, 1);
546 if (prefix == NULL)
547 errx(1, "malloc");
548 *prefix = '\0';
550 break;
551 case 13:
553 struct error_code *ec = malloc(sizeof(*ec));
555 if (ec == NULL)
556 errx(1, "malloc");
558 ec->next = NULL;
559 ec->number = number;
560 if(prefix && *prefix != '\0') {
561 asprintf (&ec->name, "%s%s", prefix, yystack.l_mark[-2].string);
562 if (ec->name == NULL)
563 errx(1, "malloc");
564 free(yystack.l_mark[-2].string);
565 } else
566 ec->name = yystack.l_mark[-2].string;
567 ec->string = yystack.l_mark[0].string;
568 APPEND(codes, ec);
569 number++;
571 break;
572 case 14:
574 YYACCEPT;
576 break;
578 yystack.s_mark -= yym;
579 yystate = *yystack.s_mark;
580 yystack.l_mark -= yym;
581 yym = yylhs[yyn];
582 if (yystate == 0 && yym == 0)
584 #if YYDEBUG
585 if (yydebug)
586 printf("%sdebug: after reduction, shifting from state 0 to\
587 state %d\n", YYPREFIX, YYFINAL);
588 #endif
589 yystate = YYFINAL;
590 *++yystack.s_mark = YYFINAL;
591 *++yystack.l_mark = yyval;
592 if (yychar < 0)
594 if ((yychar = YYLEX) < 0) yychar = 0;
595 #if YYDEBUG
596 if (yydebug)
598 yys = 0;
599 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
600 if (!yys) yys = "illegal-symbol";
601 printf("%sdebug: state %d, reading %d (%s)\n",
602 YYPREFIX, YYFINAL, yychar, yys);
604 #endif
606 if (yychar == 0) goto yyaccept;
607 goto yyloop;
609 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
610 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
611 yystate = yytable[yyn];
612 else
613 yystate = yydgoto[yym];
614 #if YYDEBUG
615 if (yydebug)
616 printf("%sdebug: after reduction, shifting from state %d \
617 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
618 #endif
619 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
621 goto yyoverflow;
623 *++yystack.s_mark = (short) yystate;
624 *++yystack.l_mark = yyval;
625 goto yyloop;
627 yyoverflow:
628 yyerror("yacc stack overflow");
630 yyabort:
631 yyfreestack(&yystack);
632 return (1);
634 yyaccept:
635 yyfreestack(&yystack);
636 return (0);