Update generated configure scripts.
[binutils.git] / binutils / sysinfo.c
blob68c258ce1864293f6f228d3e6899308eae634294
2 /* A Bison parser, made from sysinfo.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
7 #define COND 257
8 #define REPEAT 258
9 #define TYPE 259
10 #define NAME 260
11 #define NUMBER 261
12 #define UNIT 262
14 #line 1 "sysinfo.y"
16 #include <stdio.h>
17 #include <stdlib.h>
19 extern char *word;
20 extern char writecode;
21 extern int number;
22 extern int unit;
23 char nice_name[1000];
24 char *it;
25 int sofar;
26 int width;
27 int code;
28 char * repeat;
29 char *oldrepeat;
30 char *name;
31 int rdepth;
32 char *loop [] = {"","n","m","/*BAD*/"};
33 char *names[] = {" ","[n]","[n][m]"};
34 char *pnames[]= {"","*","**"};
36 #line 24 "sysinfo.y"
37 typedef union {
38 int i;
39 char *s;
40 } YYSTYPE;
41 #include <stdio.h>
43 #ifndef __cplusplus
44 #ifndef __STDC__
45 #define const
46 #endif
47 #endif
51 #define YYFINAL 55
52 #define YYFLAG -32768
53 #define YYNTBASE 11
55 #define YYTRANSLATE(x) ((unsigned)(x) <= 262 ? yytranslate[x] : 29)
57 static const char yytranslate[] = { 0,
58 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
59 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
60 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
61 2, 2, 2, 2, 2, 2, 2, 2, 2, 5,
62 6, 2, 2, 2, 2, 2, 2, 2, 2, 2,
63 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
64 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
65 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
66 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
67 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
68 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
69 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
70 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
71 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
72 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
73 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
74 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
75 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
76 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
77 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
78 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
79 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
80 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
81 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
82 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
83 2, 2, 2, 2, 2, 1, 3, 4, 7, 8,
84 9, 10
87 #if YYDEBUG != 0
88 static const short yyprhs[] = { 0,
89 0, 1, 4, 7, 8, 9, 16, 19, 22, 25,
90 26, 27, 34, 35, 42, 43, 54, 56, 57, 61,
91 64, 68, 69, 70, 74, 75
94 static const short yyrhs[] = { -1,
95 12, 13, 0, 14, 13, 0, 0, 0, 5, 8,
96 9, 15, 16, 6, 0, 21, 16, 0, 19, 16,
97 0, 17, 16, 0, 0, 0, 5, 4, 8, 18,
98 16, 6, 0, 0, 5, 3, 8, 20, 16, 6,
99 0, 0, 5, 24, 5, 23, 25, 6, 26, 22,
100 27, 6, 0, 7, 0, 0, 5, 8, 6, 0,
101 9, 10, 0, 5, 8, 6, 0, 0, 0, 5,
102 28, 6, 0, 0, 28, 5, 8, 8, 6, 0
105 #endif
107 #if YYDEBUG != 0
108 static const short yyrline[] = { 0,
109 38, 59, 75, 76, 79, 130, 150, 152, 153, 154,
110 157, 186, 204, 217, 230, 233, 338, 340, 343, 348,
111 354, 356, 359, 360, 362, 363
113 #endif
116 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
118 static const char * const yytname[] = { "$","error","$undefined.","COND","REPEAT",
119 "'('","')'","TYPE","NAME","NUMBER","UNIT","top","@1","it_list","it","@2","it_field_list",
120 "repeat_it_field","@3","cond_it_field","@4","it_field","@5","attr_type","attr_desc",
121 "attr_size","attr_id","enums","enum_list", NULL
123 #endif
125 static const short yyr1[] = { 0,
126 12, 11, 13, 13, 15, 14, 16, 16, 16, 16,
127 18, 17, 20, 19, 22, 21, 23, 23, 24, 25,
128 26, 26, 27, 27, 28, 28
131 static const short yyr2[] = { 0,
132 0, 2, 2, 0, 0, 6, 2, 2, 2, 0,
133 0, 6, 0, 6, 0, 10, 1, 0, 3, 2,
134 3, 0, 0, 3, 0, 5
137 static const short yydefact[] = { 1,
138 4, 0, 2, 4, 0, 3, 5, 10, 0, 0,
139 10, 10, 10, 0, 0, 0, 0, 6, 9, 8,
140 7, 13, 11, 0, 18, 10, 10, 19, 17, 0,
141 0, 0, 0, 0, 14, 12, 20, 22, 0, 15,
142 0, 23, 21, 25, 0, 0, 16, 0, 24, 0,
143 0, 26, 0, 0, 0
146 static const short yydefgoto[] = { 53,
147 1, 3, 4, 8, 10, 11, 27, 12, 26, 13,
148 42, 30, 17, 34, 40, 45, 46
151 static const short yypact[] = {-32768,
152 3, 2,-32768, 3, 4,-32768,-32768, 6, 0, 8,
153 6, 6, 6, 9, 10, 11, 7,-32768,-32768,-32768,
154 -32768,-32768,-32768, 14, 15, 6, 6,-32768,-32768, 12,
155 17, 18, -1, 19,-32768,-32768,-32768, 21, 20,-32768,
156 23, 22,-32768,-32768, 24, 1,-32768, 25,-32768, 26,
157 29,-32768, 31, 32,-32768
160 static const short yypgoto[] = {-32768,
161 -32768, 33,-32768,-32768, -11,-32768,-32768,-32768,-32768,-32768,
162 -32768,-32768,-32768,-32768,-32768,-32768,-32768
166 #define YYLAST 37
169 static const short yytable[] = { 19,
170 20, 21, 14, 15, 16, 48, 49, 2, 37, 5,
171 9, 25, 7, 18, 31, 32, 22, 23, 24, 28,
172 33, 29, 35, 36, 38, 39, 44, 41, 43, 47,
173 54, 55, 50, 51, 52, 0, 6
176 static const short yycheck[] = { 11,
177 12, 13, 3, 4, 5, 5, 6, 5, 10, 8,
178 5, 5, 9, 6, 26, 27, 8, 8, 8, 6,
179 9, 7, 6, 6, 6, 5, 5, 8, 6, 6,
180 0, 0, 8, 8, 6, -1, 4
182 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
183 #line 3 "/usr/share/misc/bison.simple"
184 /* This file comes from bison-1.28. */
186 /* Skeleton output parser for bison,
187 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
189 This program is free software; you can redistribute it and/or modify
190 it under the terms of the GNU General Public License as published by
191 the Free Software Foundation; either version 2, or (at your option)
192 any later version.
194 This program is distributed in the hope that it will be useful,
195 but WITHOUT ANY WARRANTY; without even the implied warranty of
196 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
197 GNU General Public License for more details.
199 You should have received a copy of the GNU General Public License
200 along with this program; if not, write to the Free Software
201 Foundation, Inc., 59 Temple Place - Suite 330,
202 Boston, MA 02111-1307, USA. */
204 /* As a special exception, when this file is copied by Bison into a
205 Bison output file, you may use that output file without restriction.
206 This special exception was added by the Free Software Foundation
207 in version 1.24 of Bison. */
209 /* This is the parser code that is written into each bison parser
210 when the %semantic_parser declaration is not specified in the grammar.
211 It was written by Richard Stallman by simplifying the hairy parser
212 used when %semantic_parser is specified. */
214 #ifndef YYSTACK_USE_ALLOCA
215 #ifdef alloca
216 #define YYSTACK_USE_ALLOCA
217 #else /* alloca not defined */
218 #ifdef __GNUC__
219 #define YYSTACK_USE_ALLOCA
220 #define alloca __builtin_alloca
221 #else /* not GNU C. */
222 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
223 #define YYSTACK_USE_ALLOCA
224 #include <alloca.h>
225 #else /* not sparc */
226 /* We think this test detects Watcom and Microsoft C. */
227 /* This used to test MSDOS, but that is a bad idea
228 since that symbol is in the user namespace. */
229 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
230 #if 0 /* No need for malloc.h, which pollutes the namespace;
231 instead, just don't use alloca. */
232 #include <malloc.h>
233 #endif
234 #else /* not MSDOS, or __TURBOC__ */
235 #if defined(_AIX)
236 /* I don't know what this was needed for, but it pollutes the namespace.
237 So I turned it off. rms, 2 May 1997. */
238 /* #include <malloc.h> */
239 #pragma alloca
240 #define YYSTACK_USE_ALLOCA
241 #else /* not MSDOS, or __TURBOC__, or _AIX */
242 #if 0
243 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
244 and on HPUX 10. Eventually we can turn this on. */
245 #define YYSTACK_USE_ALLOCA
246 #define alloca __builtin_alloca
247 #endif /* __hpux */
248 #endif
249 #endif /* not _AIX */
250 #endif /* not MSDOS, or __TURBOC__ */
251 #endif /* not sparc */
252 #endif /* not GNU C */
253 #endif /* alloca not defined */
254 #endif /* YYSTACK_USE_ALLOCA not defined */
256 #ifdef YYSTACK_USE_ALLOCA
257 #define YYSTACK_ALLOC alloca
258 #else
259 #define YYSTACK_ALLOC malloc
260 #endif
262 /* Note: there must be only one dollar sign in this file.
263 It is replaced by the list of actions, each action
264 as one case of the switch. */
266 #define yyerrok (yyerrstatus = 0)
267 #define yyclearin (yychar = YYEMPTY)
268 #define YYEMPTY -2
269 #define YYEOF 0
270 #define YYACCEPT goto yyacceptlab
271 #define YYABORT goto yyabortlab
272 #define YYERROR goto yyerrlab1
273 /* Like YYERROR except do call yyerror.
274 This remains here temporarily to ease the
275 transition to the new meaning of YYERROR, for GCC.
276 Once GCC version 2 has supplanted version 1, this can go. */
277 #define YYFAIL goto yyerrlab
278 #define YYRECOVERING() (!!yyerrstatus)
279 #define YYBACKUP(token, value) \
280 do \
281 if (yychar == YYEMPTY && yylen == 1) \
282 { yychar = (token), yylval = (value); \
283 yychar1 = YYTRANSLATE (yychar); \
284 YYPOPSTACK; \
285 goto yybackup; \
287 else \
288 { yyerror ("syntax error: cannot back up"); YYERROR; } \
289 while (0)
291 #define YYTERROR 1
292 #define YYERRCODE 256
294 #ifndef YYPURE
295 #define YYLEX yylex()
296 #endif
298 #ifdef YYPURE
299 #ifdef YYLSP_NEEDED
300 #ifdef YYLEX_PARAM
301 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
302 #else
303 #define YYLEX yylex(&yylval, &yylloc)
304 #endif
305 #else /* not YYLSP_NEEDED */
306 #ifdef YYLEX_PARAM
307 #define YYLEX yylex(&yylval, YYLEX_PARAM)
308 #else
309 #define YYLEX yylex(&yylval)
310 #endif
311 #endif /* not YYLSP_NEEDED */
312 #endif
314 /* If nonreentrant, generate the variables here */
316 #ifndef YYPURE
318 int yychar; /* the lookahead symbol */
319 YYSTYPE yylval; /* the semantic value of the */
320 /* lookahead symbol */
322 #ifdef YYLSP_NEEDED
323 YYLTYPE yylloc; /* location data for the lookahead */
324 /* symbol */
325 #endif
327 int yynerrs; /* number of parse errors so far */
328 #endif /* not YYPURE */
330 #if YYDEBUG != 0
331 int yydebug; /* nonzero means print parse trace */
332 /* Since this is uninitialized, it does not stop multiple parsers
333 from coexisting. */
334 #endif
336 /* YYINITDEPTH indicates the initial size of the parser's stacks */
338 #ifndef YYINITDEPTH
339 #define YYINITDEPTH 200
340 #endif
342 /* YYMAXDEPTH is the maximum size the stacks can grow to
343 (effective only if the built-in stack extension method is used). */
345 #if YYMAXDEPTH == 0
346 #undef YYMAXDEPTH
347 #endif
349 #ifndef YYMAXDEPTH
350 #define YYMAXDEPTH 10000
351 #endif
353 /* Define __yy_memcpy. Note that the size argument
354 should be passed with type unsigned int, because that is what the non-GCC
355 definitions require. With GCC, __builtin_memcpy takes an arg
356 of type size_t, but it can handle unsigned int. */
358 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
359 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
360 #else /* not GNU C or C++ */
361 #ifndef __cplusplus
363 /* This is the most reliable way to avoid incompatibilities
364 in available built-in functions on various systems. */
365 static void
366 __yy_memcpy (to, from, count)
367 char *to;
368 char *from;
369 unsigned int count;
371 register char *f = from;
372 register char *t = to;
373 register int i = count;
375 while (i-- > 0)
376 *t++ = *f++;
379 #else /* __cplusplus */
381 /* This is the most reliable way to avoid incompatibilities
382 in available built-in functions on various systems. */
383 static void
384 __yy_memcpy (char *to, char *from, unsigned int count)
386 register char *t = to;
387 register char *f = from;
388 register int i = count;
390 while (i-- > 0)
391 *t++ = *f++;
394 #endif
395 #endif
397 #line 217 "/usr/share/misc/bison.simple"
399 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
400 into yyparse. The argument should have type void *.
401 It should actually point to an object.
402 Grammar actions can access the variable by casting it
403 to the proper pointer type. */
405 #ifdef YYPARSE_PARAM
406 #ifdef __cplusplus
407 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
408 #define YYPARSE_PARAM_DECL
409 #else /* not __cplusplus */
410 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
411 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
412 #endif /* not __cplusplus */
413 #else /* not YYPARSE_PARAM */
414 #define YYPARSE_PARAM_ARG
415 #define YYPARSE_PARAM_DECL
416 #endif /* not YYPARSE_PARAM */
418 /* Prevent warning if -Wstrict-prototypes. */
419 #ifdef __GNUC__
420 #ifdef YYPARSE_PARAM
421 int yyparse (void *);
422 #else
423 int yyparse (void);
424 #endif
425 #endif
428 yyparse(YYPARSE_PARAM_ARG)
429 YYPARSE_PARAM_DECL
431 register int yystate;
432 register int yyn;
433 register short *yyssp;
434 register YYSTYPE *yyvsp;
435 int yyerrstatus; /* number of tokens to shift before error messages enabled */
436 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
438 short yyssa[YYINITDEPTH]; /* the state stack */
439 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
441 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
442 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
444 #ifdef YYLSP_NEEDED
445 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
446 YYLTYPE *yyls = yylsa;
447 YYLTYPE *yylsp;
449 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
450 #else
451 #define YYPOPSTACK (yyvsp--, yyssp--)
452 #endif
454 int yystacksize = YYINITDEPTH;
455 int yyfree_stacks = 0;
457 #ifdef YYPURE
458 int yychar;
459 YYSTYPE yylval;
460 int yynerrs;
461 #ifdef YYLSP_NEEDED
462 YYLTYPE yylloc;
463 #endif
464 #endif
466 YYSTYPE yyval; /* the variable used to return */
467 /* semantic values from the action */
468 /* routines */
470 int yylen;
472 #if YYDEBUG != 0
473 if (yydebug)
474 fprintf(stderr, "Starting parse\n");
475 #endif
477 yystate = 0;
478 yyerrstatus = 0;
479 yynerrs = 0;
480 yychar = YYEMPTY; /* Cause a token to be read. */
482 /* Initialize stack pointers.
483 Waste one element of value and location stack
484 so that they stay on the same level as the state stack.
485 The wasted elements are never initialized. */
487 yyssp = yyss - 1;
488 yyvsp = yyvs;
489 #ifdef YYLSP_NEEDED
490 yylsp = yyls;
491 #endif
493 /* Push a new state, which is found in yystate . */
494 /* In all cases, when you get here, the value and location stacks
495 have just been pushed. so pushing a state here evens the stacks. */
496 yynewstate:
498 *++yyssp = yystate;
500 if (yyssp >= yyss + yystacksize - 1)
502 /* Give user a chance to reallocate the stack */
503 /* Use copies of these so that the &'s don't force the real ones into memory. */
504 YYSTYPE *yyvs1 = yyvs;
505 short *yyss1 = yyss;
506 #ifdef YYLSP_NEEDED
507 YYLTYPE *yyls1 = yyls;
508 #endif
510 /* Get the current used size of the three stacks, in elements. */
511 int size = yyssp - yyss + 1;
513 #ifdef yyoverflow
514 /* Each stack pointer address is followed by the size of
515 the data in use in that stack, in bytes. */
516 #ifdef YYLSP_NEEDED
517 /* This used to be a conditional around just the two extra args,
518 but that might be undefined if yyoverflow is a macro. */
519 yyoverflow("parser stack overflow",
520 &yyss1, size * sizeof (*yyssp),
521 &yyvs1, size * sizeof (*yyvsp),
522 &yyls1, size * sizeof (*yylsp),
523 &yystacksize);
524 #else
525 yyoverflow("parser stack overflow",
526 &yyss1, size * sizeof (*yyssp),
527 &yyvs1, size * sizeof (*yyvsp),
528 &yystacksize);
529 #endif
531 yyss = yyss1; yyvs = yyvs1;
532 #ifdef YYLSP_NEEDED
533 yyls = yyls1;
534 #endif
535 #else /* no yyoverflow */
536 /* Extend the stack our own way. */
537 if (yystacksize >= YYMAXDEPTH)
539 yyerror("parser stack overflow");
540 if (yyfree_stacks)
542 free (yyss);
543 free (yyvs);
544 #ifdef YYLSP_NEEDED
545 free (yyls);
546 #endif
548 return 2;
550 yystacksize *= 2;
551 if (yystacksize > YYMAXDEPTH)
552 yystacksize = YYMAXDEPTH;
553 #ifndef YYSTACK_USE_ALLOCA
554 yyfree_stacks = 1;
555 #endif
556 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
557 __yy_memcpy ((char *)yyss, (char *)yyss1,
558 size * (unsigned int) sizeof (*yyssp));
559 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
560 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
561 size * (unsigned int) sizeof (*yyvsp));
562 #ifdef YYLSP_NEEDED
563 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
564 __yy_memcpy ((char *)yyls, (char *)yyls1,
565 size * (unsigned int) sizeof (*yylsp));
566 #endif
567 #endif /* no yyoverflow */
569 yyssp = yyss + size - 1;
570 yyvsp = yyvs + size - 1;
571 #ifdef YYLSP_NEEDED
572 yylsp = yyls + size - 1;
573 #endif
575 #if YYDEBUG != 0
576 if (yydebug)
577 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
578 #endif
580 if (yyssp >= yyss + yystacksize - 1)
581 YYABORT;
584 #if YYDEBUG != 0
585 if (yydebug)
586 fprintf(stderr, "Entering state %d\n", yystate);
587 #endif
589 goto yybackup;
590 yybackup:
592 /* Do appropriate processing given the current state. */
593 /* Read a lookahead token if we need one and don't already have one. */
594 /* yyresume: */
596 /* First try to decide what to do without reference to lookahead token. */
598 yyn = yypact[yystate];
599 if (yyn == YYFLAG)
600 goto yydefault;
602 /* Not known => get a lookahead token if don't already have one. */
604 /* yychar is either YYEMPTY or YYEOF
605 or a valid token in external form. */
607 if (yychar == YYEMPTY)
609 #if YYDEBUG != 0
610 if (yydebug)
611 fprintf(stderr, "Reading a token: ");
612 #endif
613 yychar = YYLEX;
616 /* Convert token to internal form (in yychar1) for indexing tables with */
618 if (yychar <= 0) /* This means end of input. */
620 yychar1 = 0;
621 yychar = YYEOF; /* Don't call YYLEX any more */
623 #if YYDEBUG != 0
624 if (yydebug)
625 fprintf(stderr, "Now at end of input.\n");
626 #endif
628 else
630 yychar1 = YYTRANSLATE(yychar);
632 #if YYDEBUG != 0
633 if (yydebug)
635 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
636 /* Give the individual parser a way to print the precise meaning
637 of a token, for further debugging info. */
638 #ifdef YYPRINT
639 YYPRINT (stderr, yychar, yylval);
640 #endif
641 fprintf (stderr, ")\n");
643 #endif
646 yyn += yychar1;
647 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
648 goto yydefault;
650 yyn = yytable[yyn];
652 /* yyn is what to do for this token type in this state.
653 Negative => reduce, -yyn is rule number.
654 Positive => shift, yyn is new state.
655 New state is final state => don't bother to shift,
656 just return success.
657 0, or most negative number => error. */
659 if (yyn < 0)
661 if (yyn == YYFLAG)
662 goto yyerrlab;
663 yyn = -yyn;
664 goto yyreduce;
666 else if (yyn == 0)
667 goto yyerrlab;
669 if (yyn == YYFINAL)
670 YYACCEPT;
672 /* Shift the lookahead token. */
674 #if YYDEBUG != 0
675 if (yydebug)
676 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
677 #endif
679 /* Discard the token being shifted unless it is eof. */
680 if (yychar != YYEOF)
681 yychar = YYEMPTY;
683 *++yyvsp = yylval;
684 #ifdef YYLSP_NEEDED
685 *++yylsp = yylloc;
686 #endif
688 /* count tokens shifted since error; after three, turn off error status. */
689 if (yyerrstatus) yyerrstatus--;
691 yystate = yyn;
692 goto yynewstate;
694 /* Do the default action for the current state. */
695 yydefault:
697 yyn = yydefact[yystate];
698 if (yyn == 0)
699 goto yyerrlab;
701 /* Do a reduction. yyn is the number of a rule to reduce with. */
702 yyreduce:
703 yylen = yyr2[yyn];
704 if (yylen > 0)
705 yyval = yyvsp[1-yylen]; /* implement default value of the action */
707 #if YYDEBUG != 0
708 if (yydebug)
710 int i;
712 fprintf (stderr, "Reducing via rule %d (line %d), ",
713 yyn, yyrline[yyn]);
715 /* Print the symbols being reduced, and their result. */
716 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
717 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
718 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
720 #endif
723 switch (yyn) {
725 case 1:
726 #line 38 "sysinfo.y"
728 switch (writecode)
730 case 'i':
731 printf("#ifdef SYSROFF_SWAP_IN\n");
732 break;
733 case 'p':
734 printf("#ifdef SYSROFF_p\n");
735 break;
736 case 'd':
737 break;
738 case 'g':
739 printf("#ifdef SYSROFF_SWAP_OUT\n");
740 break;
741 case 'c':
742 printf("#ifdef SYSROFF_PRINT\n");
743 printf("#include <stdio.h>\n");
744 printf("#include <stdlib.h>\n");
745 break;
748 break;}
749 case 2:
750 #line 59 "sysinfo.y"
752 switch (writecode) {
753 case 'i':
754 case 'p':
755 case 'g':
756 case 'c':
757 printf("#endif\n");
758 break;
759 case 'd':
760 break;
763 break;}
764 case 5:
765 #line 81 "sysinfo.y"
767 it = yyvsp[-1].s; code = yyvsp[0].i;
768 switch (writecode)
770 case 'd':
771 printf("\n\n\n#define IT_%s_CODE 0x%x\n", it,code);
772 printf("struct IT_%s { \n", it);
773 break;
774 case 'i':
775 printf("void sysroff_swap_%s_in(ptr)\n",yyvsp[-1].s);
776 printf("struct IT_%s *ptr;\n", it);
777 printf("{\n");
778 printf("char raw[255];\n");
779 printf("\tint idx = 0 ;\n");
780 printf("\tint size;\n");
781 printf("memset(raw,0,255);\n");
782 printf("memset(ptr,0,sizeof(*ptr));\n");
783 printf("size = fillup(raw);\n");
784 break;
785 case 'g':
786 printf("void sysroff_swap_%s_out(file,ptr)\n",yyvsp[-1].s);
787 printf("FILE * file;\n");
788 printf("struct IT_%s *ptr;\n", it);
789 printf("{\n");
790 printf("\tchar raw[255];\n");
791 printf("\tint idx = 16 ;\n");
792 printf("\tmemset (raw, 0, 255);\n");
793 printf("\tcode = IT_%s_CODE;\n", it);
794 break;
795 case 'o':
796 printf("void sysroff_swap_%s_out(abfd,ptr)\n",yyvsp[-1].s);
797 printf("bfd * abfd;\n");
798 printf("struct IT_%s *ptr;\n",it);
799 printf("{\n");
800 printf("int idx = 0 ;\n");
801 break;
802 case 'c':
803 printf("void sysroff_print_%s_out(ptr)\n",yyvsp[-1].s);
804 printf("struct IT_%s *ptr;\n", it);
805 printf("{\n");
806 printf("itheader(\"%s\", IT_%s_CODE);\n",yyvsp[-1].s,yyvsp[-1].s);
807 break;
809 case 't':
810 break;
814 break;}
815 case 6:
816 #line 131 "sysinfo.y"
818 switch (writecode) {
819 case 'd':
820 printf("};\n");
821 break;
822 case 'g':
823 printf("\tchecksum(file,raw, idx, IT_%s_CODE);\n", it);
825 case 'i':
827 case 'o':
828 case 'c':
829 printf("}\n");
832 break;}
833 case 11:
834 #line 158 "sysinfo.y"
836 rdepth++;
837 switch (writecode)
839 case 'c':
840 if (rdepth==1)
841 printf("\tprintf(\"repeat %%d\\n\", %s);\n",yyvsp[0].s);
842 if (rdepth==2)
843 printf("\tprintf(\"repeat %%d\\n\", %s[n]);\n",yyvsp[0].s);
844 case 'i':
845 case 'g':
846 case 'o':
848 if (rdepth==1)
850 printf("\t{ int n; for (n = 0; n < %s; n++) {\n", yyvsp[0].s);
852 if (rdepth == 2) {
853 printf("\t{ int m; for (m = 0; m < %s[n]; m++) {\n", yyvsp[0].s);
856 break;
859 oldrepeat = repeat;
860 repeat = yyvsp[0].s;
862 break;}
863 case 12:
864 #line 188 "sysinfo.y"
866 repeat = oldrepeat;
867 oldrepeat =0;
868 rdepth--;
869 switch (writecode)
871 case 'i':
872 case 'g':
873 case 'o':
874 case 'c':
875 printf("\t}}\n");
878 break;}
879 case 13:
880 #line 205 "sysinfo.y"
882 switch (writecode)
884 case 'i':
885 case 'g':
886 case 'o':
887 case 'c':
888 printf("\tif (%s) {\n", yyvsp[0].s);
889 break;
892 break;}
893 case 14:
894 #line 218 "sysinfo.y"
896 switch (writecode)
898 case 'i':
899 case 'g':
900 case 'o':
901 case 'c':
902 printf("\t}\n");
905 break;}
906 case 15:
907 #line 232 "sysinfo.y"
908 {name = yyvsp[0].s; ;
909 break;}
910 case 16:
911 #line 234 "sysinfo.y"
913 char *desc = yyvsp[-8].s;
914 char *type = yyvsp[-6].s;
915 int size = yyvsp[-5].i;
916 char *id = yyvsp[-3].s;
917 char *p = names[rdepth];
918 char *ptr = pnames[rdepth];
919 switch (writecode)
921 case 'g':
922 if (size % 8)
925 printf("\twriteBITS(ptr->%s%s,raw,&idx,%d);\n",
927 names[rdepth], size);
930 else {
931 printf("\twrite%s(ptr->%s%s,raw,&idx,%d,file);\n",
932 type,
934 names[rdepth],size/8);
936 break;
937 case 'i':
940 if (rdepth >= 1)
943 printf("if (!ptr->%s) ptr->%s = (%s*)xcalloc(%s, sizeof(ptr->%s[0]));\n",
944 id,
946 type,
947 repeat,
948 id);
951 if (rdepth == 2)
953 printf("if (!ptr->%s[n]) ptr->%s[n] = (%s**)xcalloc(%s[n], sizeof(ptr->%s[n][0]));\n",
954 id,
956 type,
957 repeat,
958 id);
963 if (size % 8)
965 printf("\tptr->%s%s = getBITS(raw,&idx, %d,size);\n",
967 names[rdepth],
968 size);
970 else {
971 printf("\tptr->%s%s = get%s(raw,&idx, %d,size);\n",
973 names[rdepth],
974 type,
975 size/8);
977 break;
978 case 'o':
979 printf("\tput%s(raw,%d,%d,&idx,ptr->%s%s);\n", type,size/8,size%8,id,names[rdepth]);
980 break;
981 case 'd':
982 if (repeat)
983 printf("\t/* repeat %s */\n", repeat);
985 if (type[0] == 'I') {
986 printf("\tint %s%s; \t/* %s */\n",ptr,id, desc);
988 else if (type[0] =='C') {
989 printf("\tchar %s*%s;\t /* %s */\n",ptr,id, desc);
991 else {
992 printf("\tbarray %s%s;\t /* %s */\n",ptr,id, desc);
994 break;
995 case 'c':
996 printf("tabout();\n");
997 printf("\tprintf(\"/*%-30s*/ ptr->%s = \");\n", desc, id);
999 if (type[0] == 'I')
1000 printf("\tprintf(\"%%d\\n\",ptr->%s%s);\n", id,p);
1001 else if (type[0] == 'C')
1002 printf("\tprintf(\"%%s\\n\",ptr->%s%s);\n", id,p);
1004 else if (type[0] == 'B')
1006 printf("\tpbarray(&ptr->%s%s);\n", id,p);
1008 else abort();
1009 break;
1012 break;}
1013 case 17:
1014 #line 339 "sysinfo.y"
1015 { yyval.s = yyvsp[0].s; ;
1016 break;}
1017 case 18:
1018 #line 340 "sysinfo.y"
1019 { yyval.s = "INT";;
1020 break;}
1021 case 19:
1022 #line 345 "sysinfo.y"
1023 { yyval.s = yyvsp[-1].s; ;
1024 break;}
1025 case 20:
1026 #line 350 "sysinfo.y"
1027 { yyval.i = yyvsp[-1].i * yyvsp[0].i; ;
1028 break;}
1029 case 21:
1030 #line 355 "sysinfo.y"
1031 { yyval.s = yyvsp[-1].s; ;
1032 break;}
1033 case 22:
1034 #line 356 "sysinfo.y"
1035 { yyval.s = "dummy";;
1036 break;}
1037 case 26:
1038 #line 364 "sysinfo.y"
1040 switch (writecode)
1042 case 'd':
1043 printf("#define %s %s\n", yyvsp[-2].s,yyvsp[-1].s);
1044 break;
1045 case 'c':
1046 printf("if (ptr->%s%s == %s) { tabout(); printf(\"%s\\n\");}\n", name, names[rdepth],yyvsp[-1].s,yyvsp[-2].s);
1049 break;}
1051 /* the action file gets copied in in place of this dollarsign */
1052 #line 543 "/usr/share/misc/bison.simple"
1054 yyvsp -= yylen;
1055 yyssp -= yylen;
1056 #ifdef YYLSP_NEEDED
1057 yylsp -= yylen;
1058 #endif
1060 #if YYDEBUG != 0
1061 if (yydebug)
1063 short *ssp1 = yyss - 1;
1064 fprintf (stderr, "state stack now");
1065 while (ssp1 != yyssp)
1066 fprintf (stderr, " %d", *++ssp1);
1067 fprintf (stderr, "\n");
1069 #endif
1071 *++yyvsp = yyval;
1073 #ifdef YYLSP_NEEDED
1074 yylsp++;
1075 if (yylen == 0)
1077 yylsp->first_line = yylloc.first_line;
1078 yylsp->first_column = yylloc.first_column;
1079 yylsp->last_line = (yylsp-1)->last_line;
1080 yylsp->last_column = (yylsp-1)->last_column;
1081 yylsp->text = 0;
1083 else
1085 yylsp->last_line = (yylsp+yylen-1)->last_line;
1086 yylsp->last_column = (yylsp+yylen-1)->last_column;
1088 #endif
1090 /* Now "shift" the result of the reduction.
1091 Determine what state that goes to,
1092 based on the state we popped back to
1093 and the rule number reduced by. */
1095 yyn = yyr1[yyn];
1097 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1098 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1099 yystate = yytable[yystate];
1100 else
1101 yystate = yydefgoto[yyn - YYNTBASE];
1103 goto yynewstate;
1105 yyerrlab: /* here on detecting error */
1107 if (! yyerrstatus)
1108 /* If not already recovering from an error, report this error. */
1110 ++yynerrs;
1112 #ifdef YYERROR_VERBOSE
1113 yyn = yypact[yystate];
1115 if (yyn > YYFLAG && yyn < YYLAST)
1117 int size = 0;
1118 char *msg;
1119 int x, count;
1121 count = 0;
1122 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1123 for (x = (yyn < 0 ? -yyn : 0);
1124 x < (sizeof(yytname) / sizeof(char *)); x++)
1125 if (yycheck[x + yyn] == x)
1126 size += strlen(yytname[x]) + 15, count++;
1127 msg = (char *) malloc(size + 15);
1128 if (msg != 0)
1130 strcpy(msg, "parse error");
1132 if (count < 5)
1134 count = 0;
1135 for (x = (yyn < 0 ? -yyn : 0);
1136 x < (sizeof(yytname) / sizeof(char *)); x++)
1137 if (yycheck[x + yyn] == x)
1139 strcat(msg, count == 0 ? ", expecting `" : " or `");
1140 strcat(msg, yytname[x]);
1141 strcat(msg, "'");
1142 count++;
1145 yyerror(msg);
1146 free(msg);
1148 else
1149 yyerror ("parse error; also virtual memory exceeded");
1151 else
1152 #endif /* YYERROR_VERBOSE */
1153 yyerror("parse error");
1156 goto yyerrlab1;
1157 yyerrlab1: /* here on error raised explicitly by an action */
1159 if (yyerrstatus == 3)
1161 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1163 /* return failure if at end of input */
1164 if (yychar == YYEOF)
1165 YYABORT;
1167 #if YYDEBUG != 0
1168 if (yydebug)
1169 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1170 #endif
1172 yychar = YYEMPTY;
1175 /* Else will try to reuse lookahead token
1176 after shifting the error token. */
1178 yyerrstatus = 3; /* Each real token shifted decrements this */
1180 goto yyerrhandle;
1182 yyerrdefault: /* current state does not do anything special for the error token. */
1184 #if 0
1185 /* This is wrong; only states that explicitly want error tokens
1186 should shift them. */
1187 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1188 if (yyn) goto yydefault;
1189 #endif
1191 yyerrpop: /* pop the current state because it cannot handle the error token */
1193 if (yyssp == yyss) YYABORT;
1194 yyvsp--;
1195 yystate = *--yyssp;
1196 #ifdef YYLSP_NEEDED
1197 yylsp--;
1198 #endif
1200 #if YYDEBUG != 0
1201 if (yydebug)
1203 short *ssp1 = yyss - 1;
1204 fprintf (stderr, "Error: state stack now");
1205 while (ssp1 != yyssp)
1206 fprintf (stderr, " %d", *++ssp1);
1207 fprintf (stderr, "\n");
1209 #endif
1211 yyerrhandle:
1213 yyn = yypact[yystate];
1214 if (yyn == YYFLAG)
1215 goto yyerrdefault;
1217 yyn += YYTERROR;
1218 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1219 goto yyerrdefault;
1221 yyn = yytable[yyn];
1222 if (yyn < 0)
1224 if (yyn == YYFLAG)
1225 goto yyerrpop;
1226 yyn = -yyn;
1227 goto yyreduce;
1229 else if (yyn == 0)
1230 goto yyerrpop;
1232 if (yyn == YYFINAL)
1233 YYACCEPT;
1235 #if YYDEBUG != 0
1236 if (yydebug)
1237 fprintf(stderr, "Shifting error token, ");
1238 #endif
1240 *++yyvsp = yylval;
1241 #ifdef YYLSP_NEEDED
1242 *++yylsp = yylloc;
1243 #endif
1245 yystate = yyn;
1246 goto yynewstate;
1248 yyacceptlab:
1249 /* YYACCEPT comes here. */
1250 if (yyfree_stacks)
1252 free (yyss);
1253 free (yyvs);
1254 #ifdef YYLSP_NEEDED
1255 free (yyls);
1256 #endif
1258 return 0;
1260 yyabortlab:
1261 /* YYABORT comes here. */
1262 if (yyfree_stacks)
1264 free (yyss);
1265 free (yyvs);
1266 #ifdef YYLSP_NEEDED
1267 free (yyls);
1268 #endif
1270 return 1;
1272 #line 379 "sysinfo.y"
1274 /* four modes
1276 -d write structure defintions for sysroff in host format
1277 -i write functions to swap into sysroff format in
1278 -o write functions to swap into sysroff format out
1279 -c write code to print info in human form */
1281 int yydebug;
1282 char writecode;
1284 int
1285 main(ac,av)
1286 int ac;
1287 char **av;
1289 yydebug=0;
1290 if (ac > 1)
1291 writecode = av[1][1];
1292 if (writecode == 'd')
1294 printf("typedef struct { unsigned char *data; int len; } barray; \n");
1295 printf("typedef int INT;\n");
1296 printf("typedef char * CHARS;\n");
1299 yyparse();
1300 return 0;
1304 yyerror(s)
1305 char *s;
1307 fprintf(stderr, "%s\n" , s);
1308 return 0;