|
|
1.1 ! root 1: ! 2: /* A Bison parser, made from bi-parser.y */ ! 3: ! 4: #define YYBISON 1 /* Identify Bison output. */ ! 5: ! 6: #define DEFOP 258 ! 7: #define STRING 259 ! 8: ! 9: #line 21 "bi-parser.y" ! 10: ! 11: ! 12: #include <stdio.h> ! 13: #include "hconfig.h" ! 14: #include "bi-defs.h" ! 15: ! 16: extern char yytext[]; ! 17: extern int yyleng; ! 18: ! 19: ! 20: /* Chain of all defs built by the parser. */ ! 21: struct def *defs; ! 22: int ndefs; ! 23: ! 24: static struct node *makenode (); ! 25: static struct variation *makevar (); ! 26: static struct def *makedef (); ! 27: ! 28: void yyerror (); ! 29: ! 30: ! 31: #line 43 "bi-parser.y" ! 32: typedef union ! 33: { ! 34: char *string; ! 35: struct def *def; ! 36: struct variation *variation; ! 37: struct node *node; ! 38: } YYSTYPE; ! 39: ! 40: #ifndef YYLTYPE ! 41: typedef ! 42: struct yyltype ! 43: { ! 44: int timestamp; ! 45: int first_line; ! 46: int first_column; ! 47: int last_line; ! 48: int last_column; ! 49: char *text; ! 50: } ! 51: yyltype; ! 52: ! 53: #define YYLTYPE yyltype ! 54: #endif ! 55: ! 56: #include <stdio.h> ! 57: ! 58: #ifndef __STDC__ ! 59: #define const ! 60: #endif ! 61: ! 62: ! 63: ! 64: #define YYFINAL 39 ! 65: #define YYFLAG -32768 ! 66: #define YYNTBASE 8 ! 67: ! 68: #define YYTRANSLATE(x) ((unsigned)(x) <= 259 ? yytranslate[x] : 17) ! 69: ! 70: static const char yytranslate[] = { 0, ! 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, 5, ! 75: 7, 2, 2, 6, 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, 2, 2, 2, 2, 2, ! 84: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ! 85: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ! 86: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ! 87: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ! 88: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ! 89: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ! 90: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ! 91: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ! 92: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ! 93: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ! 94: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ! 95: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ! 96: 2, 2, 2, 2, 2, 1, 2, 3, 4 ! 97: }; ! 98: ! 99: static const short yyprhs[] = { 0, ! 100: 0, 2, 4, 7, 18, 20, 24, 28, 34, 42, ! 101: 52, 53, 55, 59, 60, 62, 66 ! 102: }; ! 103: ! 104: static const short yyrhs[] = { 9, ! 105: 0, 10, 0, 9, 10, 0, 3, 5, 4, 6, ! 106: 13, 6, 5, 11, 7, 7, 0, 12, 0, 11, ! 107: 6, 12, 0, 5, 13, 7, 0, 5, 13, 6, ! 108: 14, 7, 0, 5, 13, 6, 14, 6, 14, 7, ! 109: 0, 5, 13, 6, 14, 6, 14, 6, 14, 7, ! 110: 0, 0, 4, 0, 5, 15, 7, 0, 0, 16, ! 111: 0, 16, 6, 15, 0, 4, 0 ! 112: }; ! 113: ! 114: #if YYDEBUG != 0 ! 115: static const short yyrline[] = { 0, ! 116: 59, 64, 66, 70, 75, 77, 81, 84, 86, 88, ! 117: 92, 94, 97, 100, 104, 107, 111 ! 118: }; ! 119: ! 120: static const char * const yytname[] = { "$","error","$illegal.","DEFOP","STRING", ! 121: "'('","','","')'","top","defs","def","variations","variation","opt_string","list", ! 122: "items","item","" ! 123: }; ! 124: #endif ! 125: ! 126: static const short yyr1[] = { 0, ! 127: 8, 9, 9, 10, 11, 11, 12, 12, 12, 12, ! 128: 13, 13, 14, 14, 15, 15, 16 ! 129: }; ! 130: ! 131: static const short yyr2[] = { 0, ! 132: 1, 1, 2, 10, 1, 3, 3, 5, 7, 9, ! 133: 0, 1, 3, 0, 1, 3, 1 ! 134: }; ! 135: ! 136: static const short yydefact[] = { 0, ! 137: 0, 1, 2, 0, 3, 0, 11, 12, 0, 0, ! 138: 0, 11, 0, 5, 0, 0, 0, 14, 7, 6, ! 139: 4, 0, 0, 17, 0, 15, 14, 8, 13, 0, ! 140: 0, 16, 14, 9, 0, 10, 0, 0, 0 ! 141: }; ! 142: ! 143: static const short yydefgoto[] = { 37, ! 144: 2, 3, 13, 14, 9, 23, 25, 26 ! 145: }; ! 146: ! 147: static const short yypact[] = { 2, ! 148: 6, 2,-32768, 8,-32768, 7, 10,-32768, 9, 11, ! 149: 12, 10, -5,-32768, -3, 12, 13, 14,-32768,-32768, ! 150: -32768, 17, 1,-32768, 15, 18, 14,-32768,-32768, 17, ! 151: 3,-32768, 14,-32768, 16,-32768, 25, 26,-32768 ! 152: }; ! 153: ! 154: static const short yypgoto[] = {-32768, ! 155: -32768, 27,-32768, 19, 20, -27, -12,-32768 ! 156: }; ! 157: ! 158: ! 159: #define YYLAST 35 ! 160: ! 161: ! 162: static const short yytable[] = { 31, ! 163: 16, 17, 18, 19, 1, 35, 27, 28, 33, 34, ! 164: 4, 6, 7, 8, 10, 11, 12, 32, 22, 21, ! 165: 24, 29, 36, 30, 38, 39, 0, 0, 5, 0, ! 166: 0, 15, 0, 0, 20 ! 167: }; ! 168: ! 169: static const short yycheck[] = { 27, ! 170: 6, 7, 6, 7, 3, 33, 6, 7, 6, 7, ! 171: 5, 4, 6, 4, 6, 5, 5, 30, 5, 7, ! 172: 4, 7, 7, 6, 0, 0, -1, -1, 2, -1, ! 173: -1, 12, -1, -1, 16 ! 174: }; ! 175: /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ ! 176: #line 3 "bison.simple" ! 177: ! 178: /* Skeleton output parser for bison, ! 179: Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman ! 180: ! 181: This program is free software; you can redistribute it and/or modify ! 182: it under the terms of the GNU General Public License as published by ! 183: the Free Software Foundation; either version 1, or (at your option) ! 184: any later version. ! 185: ! 186: This program is distributed in the hope that it will be useful, ! 187: but WITHOUT ANY WARRANTY; without even the implied warranty of ! 188: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! 189: GNU General Public License for more details. ! 190: ! 191: You should have received a copy of the GNU General Public License ! 192: along with this program; if not, write to the Free Software ! 193: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ ! 194: ! 195: ! 196: #ifndef alloca ! 197: #ifdef __GNUC__ ! 198: #define alloca __builtin_alloca ! 199: #else /* not GNU C. */ ! 200: #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) ! 201: #include <alloca.h> ! 202: #else /* not sparc */ ! 203: #if defined (MSDOS) && !defined (__TURBOC__) ! 204: #include <malloc.h> ! 205: #else /* not MSDOS, or __TURBOC__ */ ! 206: #if defined(_AIX) ! 207: #include <malloc.h> ! 208: #pragma alloca ! 209: #else /* not MSDOS, __TURBOC__, or _AIX */ ! 210: #ifdef __hpux ! 211: #ifdef __cplusplus ! 212: extern "C" { ! 213: void *alloca (unsigned int); ! 214: }; ! 215: #else /* not __cplusplus */ ! 216: void *alloca (); ! 217: #endif /* not __cplusplus */ ! 218: #endif /* __hpux */ ! 219: #endif /* not _AIX */ ! 220: #endif /* not MSDOS, or __TURBOC__ */ ! 221: #endif /* not sparc. */ ! 222: #endif /* not GNU C. */ ! 223: #endif /* alloca not defined. */ ! 224: ! 225: /* This is the parser code that is written into each bison parser ! 226: when the %semantic_parser declaration is not specified in the grammar. ! 227: It was written by Richard Stallman by simplifying the hairy parser ! 228: used when %semantic_parser is specified. */ ! 229: ! 230: /* Note: there must be only one dollar sign in this file. ! 231: It is replaced by the list of actions, each action ! 232: as one case of the switch. */ ! 233: ! 234: #define yyerrok (yyerrstatus = 0) ! 235: #define yyclearin (yychar = YYEMPTY) ! 236: #define YYEMPTY -2 ! 237: #define YYEOF 0 ! 238: #define YYACCEPT return(0) ! 239: #define YYABORT return(1) ! 240: #define YYERROR goto yyerrlab1 ! 241: /* Like YYERROR except do call yyerror. ! 242: This remains here temporarily to ease the ! 243: transition to the new meaning of YYERROR, for GCC. ! 244: Once GCC version 2 has supplanted version 1, this can go. */ ! 245: #define YYFAIL goto yyerrlab ! 246: #define YYRECOVERING() (!!yyerrstatus) ! 247: #define YYBACKUP(token, value) \ ! 248: do \ ! 249: if (yychar == YYEMPTY && yylen == 1) \ ! 250: { yychar = (token), yylval = (value); \ ! 251: yychar1 = YYTRANSLATE (yychar); \ ! 252: YYPOPSTACK; \ ! 253: goto yybackup; \ ! 254: } \ ! 255: else \ ! 256: { yyerror ("syntax error: cannot back up"); YYERROR; } \ ! 257: while (0) ! 258: ! 259: #define YYTERROR 1 ! 260: #define YYERRCODE 256 ! 261: ! 262: #ifndef YYPURE ! 263: #define YYLEX yylex() ! 264: #endif ! 265: ! 266: #ifdef YYPURE ! 267: #ifdef YYLSP_NEEDED ! 268: #define YYLEX yylex(&yylval, &yylloc) ! 269: #else ! 270: #define YYLEX yylex(&yylval) ! 271: #endif ! 272: #endif ! 273: ! 274: /* If nonreentrant, generate the variables here */ ! 275: ! 276: #ifndef YYPURE ! 277: ! 278: int yychar; /* the lookahead symbol */ ! 279: YYSTYPE yylval; /* the semantic value of the */ ! 280: /* lookahead symbol */ ! 281: ! 282: #ifdef YYLSP_NEEDED ! 283: YYLTYPE yylloc; /* location data for the lookahead */ ! 284: /* symbol */ ! 285: #endif ! 286: ! 287: int yynerrs; /* number of parse errors so far */ ! 288: #endif /* not YYPURE */ ! 289: ! 290: #if YYDEBUG != 0 ! 291: int yydebug; /* nonzero means print parse trace */ ! 292: /* Since this is uninitialized, it does not stop multiple parsers ! 293: from coexisting. */ ! 294: #endif ! 295: ! 296: /* YYINITDEPTH indicates the initial size of the parser's stacks */ ! 297: ! 298: #ifndef YYINITDEPTH ! 299: #define YYINITDEPTH 200 ! 300: #endif ! 301: ! 302: /* YYMAXDEPTH is the maximum size the stacks can grow to ! 303: (effective only if the built-in stack extension method is used). */ ! 304: ! 305: #if YYMAXDEPTH == 0 ! 306: #undef YYMAXDEPTH ! 307: #endif ! 308: ! 309: #ifndef YYMAXDEPTH ! 310: #define YYMAXDEPTH 10000 ! 311: #endif ! 312: ! 313: /* Prevent warning if -Wstrict-prototypes. */ ! 314: #ifdef __GNUC__ ! 315: int yyparse (void); ! 316: #endif ! 317: ! 318: #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ ! 319: #define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT) ! 320: #else /* not GNU C or C++ */ ! 321: #ifndef __cplusplus ! 322: ! 323: /* This is the most reliable way to avoid incompatibilities ! 324: in available built-in functions on various systems. */ ! 325: static void ! 326: __yy_bcopy (from, to, count) ! 327: char *from; ! 328: char *to; ! 329: int count; ! 330: { ! 331: register char *f = from; ! 332: register char *t = to; ! 333: register int i = count; ! 334: ! 335: while (i-- > 0) ! 336: *t++ = *f++; ! 337: } ! 338: ! 339: #else /* __cplusplus */ ! 340: ! 341: /* This is the most reliable way to avoid incompatibilities ! 342: in available built-in functions on various systems. */ ! 343: static void ! 344: __yy_bcopy (char *from, char *to, int count) ! 345: { ! 346: register char *f = from; ! 347: register char *t = to; ! 348: register int i = count; ! 349: ! 350: while (i-- > 0) ! 351: *t++ = *f++; ! 352: } ! 353: ! 354: #endif ! 355: #endif ! 356: ! 357: #line 184 "bison.simple" ! 358: ! 359: /* The user can define YYPARSE_PARAM as the name of an argument to be passed ! 360: into yyparse. The argument should have type void *. ! 361: It should actually point to an object. ! 362: Grammar actions can access the variable by casting it ! 363: to the proper pointer type. */ ! 364: ! 365: #ifdef YYPARSE_PARAM ! 366: #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; ! 367: #else ! 368: #define YYPARSE_PARAM ! 369: #define YYPARSE_PARAM_DECL ! 370: #endif ! 371: ! 372: int ! 373: yyparse(YYPARSE_PARAM) ! 374: YYPARSE_PARAM_DECL ! 375: { ! 376: register int yystate; ! 377: register int yyn; ! 378: register short *yyssp; ! 379: register YYSTYPE *yyvsp; ! 380: int yyerrstatus; /* number of tokens to shift before error messages enabled */ ! 381: int yychar1 = 0; /* lookahead token as an internal (translated) token number */ ! 382: ! 383: short yyssa[YYINITDEPTH]; /* the state stack */ ! 384: YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ ! 385: ! 386: short *yyss = yyssa; /* refer to the stacks thru separate pointers */ ! 387: YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ ! 388: ! 389: #ifdef YYLSP_NEEDED ! 390: YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ ! 391: YYLTYPE *yyls = yylsa; ! 392: YYLTYPE *yylsp; ! 393: ! 394: #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) ! 395: #else ! 396: #define YYPOPSTACK (yyvsp--, yyssp--) ! 397: #endif ! 398: ! 399: int yystacksize = YYINITDEPTH; ! 400: ! 401: #ifdef YYPURE ! 402: int yychar; ! 403: YYSTYPE yylval; ! 404: int yynerrs; ! 405: #ifdef YYLSP_NEEDED ! 406: YYLTYPE yylloc; ! 407: #endif ! 408: #endif ! 409: ! 410: YYSTYPE yyval; /* the variable used to return */ ! 411: /* semantic values from the action */ ! 412: /* routines */ ! 413: ! 414: int yylen; ! 415: ! 416: #if YYDEBUG != 0 ! 417: if (yydebug) ! 418: fprintf(stderr, "Starting parse\n"); ! 419: #endif ! 420: ! 421: yystate = 0; ! 422: yyerrstatus = 0; ! 423: yynerrs = 0; ! 424: yychar = YYEMPTY; /* Cause a token to be read. */ ! 425: ! 426: /* Initialize stack pointers. ! 427: Waste one element of value and location stack ! 428: so that they stay on the same level as the state stack. ! 429: The wasted elements are never initialized. */ ! 430: ! 431: yyssp = yyss - 1; ! 432: yyvsp = yyvs; ! 433: #ifdef YYLSP_NEEDED ! 434: yylsp = yyls; ! 435: #endif ! 436: ! 437: /* Push a new state, which is found in yystate . */ ! 438: /* In all cases, when you get here, the value and location stacks ! 439: have just been pushed. so pushing a state here evens the stacks. */ ! 440: yynewstate: ! 441: ! 442: *++yyssp = yystate; ! 443: ! 444: if (yyssp >= yyss + yystacksize - 1) ! 445: { ! 446: /* Give user a chance to reallocate the stack */ ! 447: /* Use copies of these so that the &'s don't force the real ones into memory. */ ! 448: YYSTYPE *yyvs1 = yyvs; ! 449: short *yyss1 = yyss; ! 450: #ifdef YYLSP_NEEDED ! 451: YYLTYPE *yyls1 = yyls; ! 452: #endif ! 453: ! 454: /* Get the current used size of the three stacks, in elements. */ ! 455: int size = yyssp - yyss + 1; ! 456: ! 457: #ifdef yyoverflow ! 458: /* Each stack pointer address is followed by the size of ! 459: the data in use in that stack, in bytes. */ ! 460: #ifdef YYLSP_NEEDED ! 461: /* This used to be a conditional around just the two extra args, ! 462: but that might be undefined if yyoverflow is a macro. */ ! 463: yyoverflow("parser stack overflow", ! 464: &yyss1, size * sizeof (*yyssp), ! 465: &yyvs1, size * sizeof (*yyvsp), ! 466: &yyls1, size * sizeof (*yylsp), ! 467: &yystacksize); ! 468: #else ! 469: yyoverflow("parser stack overflow", ! 470: &yyss1, size * sizeof (*yyssp), ! 471: &yyvs1, size * sizeof (*yyvsp), ! 472: &yystacksize); ! 473: #endif ! 474: ! 475: yyss = yyss1; yyvs = yyvs1; ! 476: #ifdef YYLSP_NEEDED ! 477: yyls = yyls1; ! 478: #endif ! 479: #else /* no yyoverflow */ ! 480: /* Extend the stack our own way. */ ! 481: if (yystacksize >= YYMAXDEPTH) ! 482: { ! 483: yyerror("parser stack overflow"); ! 484: return 2; ! 485: } ! 486: yystacksize *= 2; ! 487: if (yystacksize > YYMAXDEPTH) ! 488: yystacksize = YYMAXDEPTH; ! 489: yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); ! 490: __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp)); ! 491: yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); ! 492: __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp)); ! 493: #ifdef YYLSP_NEEDED ! 494: yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); ! 495: __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp)); ! 496: #endif ! 497: #endif /* no yyoverflow */ ! 498: ! 499: yyssp = yyss + size - 1; ! 500: yyvsp = yyvs + size - 1; ! 501: #ifdef YYLSP_NEEDED ! 502: yylsp = yyls + size - 1; ! 503: #endif ! 504: ! 505: #if YYDEBUG != 0 ! 506: if (yydebug) ! 507: fprintf(stderr, "Stack size increased to %d\n", yystacksize); ! 508: #endif ! 509: ! 510: if (yyssp >= yyss + yystacksize - 1) ! 511: YYABORT; ! 512: } ! 513: ! 514: #if YYDEBUG != 0 ! 515: if (yydebug) ! 516: fprintf(stderr, "Entering state %d\n", yystate); ! 517: #endif ! 518: ! 519: goto yybackup; ! 520: yybackup: ! 521: ! 522: /* Do appropriate processing given the current state. */ ! 523: /* Read a lookahead token if we need one and don't already have one. */ ! 524: /* yyresume: */ ! 525: ! 526: /* First try to decide what to do without reference to lookahead token. */ ! 527: ! 528: yyn = yypact[yystate]; ! 529: if (yyn == YYFLAG) ! 530: goto yydefault; ! 531: ! 532: /* Not known => get a lookahead token if don't already have one. */ ! 533: ! 534: /* yychar is either YYEMPTY or YYEOF ! 535: or a valid token in external form. */ ! 536: ! 537: if (yychar == YYEMPTY) ! 538: { ! 539: #if YYDEBUG != 0 ! 540: if (yydebug) ! 541: fprintf(stderr, "Reading a token: "); ! 542: #endif ! 543: yychar = YYLEX; ! 544: } ! 545: ! 546: /* Convert token to internal form (in yychar1) for indexing tables with */ ! 547: ! 548: if (yychar <= 0) /* This means end of input. */ ! 549: { ! 550: yychar1 = 0; ! 551: yychar = YYEOF; /* Don't call YYLEX any more */ ! 552: ! 553: #if YYDEBUG != 0 ! 554: if (yydebug) ! 555: fprintf(stderr, "Now at end of input.\n"); ! 556: #endif ! 557: } ! 558: else ! 559: { ! 560: yychar1 = YYTRANSLATE(yychar); ! 561: ! 562: #if YYDEBUG != 0 ! 563: if (yydebug) ! 564: { ! 565: fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); ! 566: /* Give the individual parser a way to print the precise meaning ! 567: of a token, for further debugging info. */ ! 568: #ifdef YYPRINT ! 569: YYPRINT (stderr, yychar, yylval); ! 570: #endif ! 571: fprintf (stderr, ")\n"); ! 572: } ! 573: #endif ! 574: } ! 575: ! 576: yyn += yychar1; ! 577: if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) ! 578: goto yydefault; ! 579: ! 580: yyn = yytable[yyn]; ! 581: ! 582: /* yyn is what to do for this token type in this state. ! 583: Negative => reduce, -yyn is rule number. ! 584: Positive => shift, yyn is new state. ! 585: New state is final state => don't bother to shift, ! 586: just return success. ! 587: 0, or most negative number => error. */ ! 588: ! 589: if (yyn < 0) ! 590: { ! 591: if (yyn == YYFLAG) ! 592: goto yyerrlab; ! 593: yyn = -yyn; ! 594: goto yyreduce; ! 595: } ! 596: else if (yyn == 0) ! 597: goto yyerrlab; ! 598: ! 599: if (yyn == YYFINAL) ! 600: YYACCEPT; ! 601: ! 602: /* Shift the lookahead token. */ ! 603: ! 604: #if YYDEBUG != 0 ! 605: if (yydebug) ! 606: fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); ! 607: #endif ! 608: ! 609: /* Discard the token being shifted unless it is eof. */ ! 610: if (yychar != YYEOF) ! 611: yychar = YYEMPTY; ! 612: ! 613: *++yyvsp = yylval; ! 614: #ifdef YYLSP_NEEDED ! 615: *++yylsp = yylloc; ! 616: #endif ! 617: ! 618: /* count tokens shifted since error; after three, turn off error status. */ ! 619: if (yyerrstatus) yyerrstatus--; ! 620: ! 621: yystate = yyn; ! 622: goto yynewstate; ! 623: ! 624: /* Do the default action for the current state. */ ! 625: yydefault: ! 626: ! 627: yyn = yydefact[yystate]; ! 628: if (yyn == 0) ! 629: goto yyerrlab; ! 630: ! 631: /* Do a reduction. yyn is the number of a rule to reduce with. */ ! 632: yyreduce: ! 633: yylen = yyr2[yyn]; ! 634: if (yylen > 0) ! 635: yyval = yyvsp[1-yylen]; /* implement default value of the action */ ! 636: ! 637: #if YYDEBUG != 0 ! 638: if (yydebug) ! 639: { ! 640: int i; ! 641: ! 642: fprintf (stderr, "Reducing via rule %d (line %d), ", ! 643: yyn, yyrline[yyn]); ! 644: ! 645: /* Print the symbols being reduced, and their result. */ ! 646: for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) ! 647: fprintf (stderr, "%s ", yytname[yyrhs[i]]); ! 648: fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); ! 649: } ! 650: #endif ! 651: ! 652: ! 653: switch (yyn) { ! 654: ! 655: case 1: ! 656: #line 61 "bi-parser.y" ! 657: { defs = yyvsp[0].def; ; ! 658: break;} ! 659: case 3: ! 660: #line 67 "bi-parser.y" ! 661: { yyvsp[0].def->next = yyvsp[-1].def; yyval.def = yyvsp[0].def; ; ! 662: break;} ! 663: case 4: ! 664: #line 72 "bi-parser.y" ! 665: { yyval.def = makedef (yyvsp[-7].string, yyvsp[-5].string, yyvsp[-2].variation); ; ! 666: break;} ! 667: case 6: ! 668: #line 78 "bi-parser.y" ! 669: { yyvsp[0].variation->next = yyvsp[-2].variation; yyval.variation = yyvsp[0].variation; ; ! 670: break;} ! 671: case 7: ! 672: #line 83 "bi-parser.y" ! 673: { yyval.variation = makevar (yyvsp[-1].string, (struct node *) NULL, (struct node *) NULL, (struct node *) NULL); ; ! 674: break;} ! 675: case 8: ! 676: #line 85 "bi-parser.y" ! 677: { yyval.variation = makevar (yyvsp[-3].string, yyvsp[-1].node, (struct node *) NULL, (struct node *) NULL); ; ! 678: break;} ! 679: case 9: ! 680: #line 87 "bi-parser.y" ! 681: { yyval.variation = makevar (yyvsp[-5].string, yyvsp[-3].node, yyvsp[-1].node, (struct node *) NULL); ; ! 682: break;} ! 683: case 10: ! 684: #line 89 "bi-parser.y" ! 685: { yyval.variation = makevar (yyvsp[-7].string, yyvsp[-5].node, yyvsp[-3].node, yyvsp[-1].node); ; ! 686: break;} ! 687: case 11: ! 688: #line 93 "bi-parser.y" ! 689: { yyval.string = ""; ; ! 690: break;} ! 691: case 12: ! 692: #line 94 "bi-parser.y" ! 693: { yyval.string = yyvsp[0].string; ; ! 694: break;} ! 695: case 13: ! 696: #line 99 "bi-parser.y" ! 697: { yyval.node = yyvsp[-1].node; ; ! 698: break;} ! 699: case 14: ! 700: #line 101 "bi-parser.y" ! 701: { yyval.node = NULL; ; ! 702: break;} ! 703: case 16: ! 704: #line 108 "bi-parser.y" ! 705: { yyvsp[-2].node->next = yyvsp[0].node; yyval.node = yyvsp[-2].node; ; ! 706: break;} ! 707: case 17: ! 708: #line 113 "bi-parser.y" ! 709: { yyval.node = makenode (yyvsp[0].string); ; ! 710: break;} ! 711: } ! 712: /* the action file gets copied in in place of this dollarsign */ ! 713: #line 480 "bison.simple" ! 714: ! 715: yyvsp -= yylen; ! 716: yyssp -= yylen; ! 717: #ifdef YYLSP_NEEDED ! 718: yylsp -= yylen; ! 719: #endif ! 720: ! 721: #if YYDEBUG != 0 ! 722: if (yydebug) ! 723: { ! 724: short *ssp1 = yyss - 1; ! 725: fprintf (stderr, "state stack now"); ! 726: while (ssp1 != yyssp) ! 727: fprintf (stderr, " %d", *++ssp1); ! 728: fprintf (stderr, "\n"); ! 729: } ! 730: #endif ! 731: ! 732: *++yyvsp = yyval; ! 733: ! 734: #ifdef YYLSP_NEEDED ! 735: yylsp++; ! 736: if (yylen == 0) ! 737: { ! 738: yylsp->first_line = yylloc.first_line; ! 739: yylsp->first_column = yylloc.first_column; ! 740: yylsp->last_line = (yylsp-1)->last_line; ! 741: yylsp->last_column = (yylsp-1)->last_column; ! 742: yylsp->text = 0; ! 743: } ! 744: else ! 745: { ! 746: yylsp->last_line = (yylsp+yylen-1)->last_line; ! 747: yylsp->last_column = (yylsp+yylen-1)->last_column; ! 748: } ! 749: #endif ! 750: ! 751: /* Now "shift" the result of the reduction. ! 752: Determine what state that goes to, ! 753: based on the state we popped back to ! 754: and the rule number reduced by. */ ! 755: ! 756: yyn = yyr1[yyn]; ! 757: ! 758: yystate = yypgoto[yyn - YYNTBASE] + *yyssp; ! 759: if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) ! 760: yystate = yytable[yystate]; ! 761: else ! 762: yystate = yydefgoto[yyn - YYNTBASE]; ! 763: ! 764: goto yynewstate; ! 765: ! 766: yyerrlab: /* here on detecting error */ ! 767: ! 768: if (! yyerrstatus) ! 769: /* If not already recovering from an error, report this error. */ ! 770: { ! 771: ++yynerrs; ! 772: ! 773: #ifdef YYERROR_VERBOSE ! 774: yyn = yypact[yystate]; ! 775: ! 776: if (yyn > YYFLAG && yyn < YYLAST) ! 777: { ! 778: int size = 0; ! 779: char *msg; ! 780: int x, count; ! 781: ! 782: count = 0; ! 783: /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ ! 784: for (x = (yyn < 0 ? -yyn : 0); ! 785: x < (sizeof(yytname) / sizeof(char *)); x++) ! 786: if (yycheck[x + yyn] == x) ! 787: size += strlen(yytname[x]) + 15, count++; ! 788: msg = (char *) malloc(size + 15); ! 789: if (msg != 0) ! 790: { ! 791: strcpy(msg, "parse error"); ! 792: ! 793: if (count < 5) ! 794: { ! 795: count = 0; ! 796: for (x = (yyn < 0 ? -yyn : 0); ! 797: x < (sizeof(yytname) / sizeof(char *)); x++) ! 798: if (yycheck[x + yyn] == x) ! 799: { ! 800: strcat(msg, count == 0 ? ", expecting `" : " or `"); ! 801: strcat(msg, yytname[x]); ! 802: strcat(msg, "'"); ! 803: count++; ! 804: } ! 805: } ! 806: yyerror(msg); ! 807: free(msg); ! 808: } ! 809: else ! 810: yyerror ("parse error; also virtual memory exceeded"); ! 811: } ! 812: else ! 813: #endif /* YYERROR_VERBOSE */ ! 814: yyerror("parse error"); ! 815: } ! 816: ! 817: goto yyerrlab1; ! 818: yyerrlab1: /* here on error raised explicitly by an action */ ! 819: ! 820: if (yyerrstatus == 3) ! 821: { ! 822: /* if just tried and failed to reuse lookahead token after an error, discard it. */ ! 823: ! 824: /* return failure if at end of input */ ! 825: if (yychar == YYEOF) ! 826: YYABORT; ! 827: ! 828: #if YYDEBUG != 0 ! 829: if (yydebug) ! 830: fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); ! 831: #endif ! 832: ! 833: yychar = YYEMPTY; ! 834: } ! 835: ! 836: /* Else will try to reuse lookahead token ! 837: after shifting the error token. */ ! 838: ! 839: yyerrstatus = 3; /* Each real token shifted decrements this */ ! 840: ! 841: goto yyerrhandle; ! 842: ! 843: yyerrdefault: /* current state does not do anything special for the error token. */ ! 844: ! 845: #if 0 ! 846: /* This is wrong; only states that explicitly want error tokens ! 847: should shift them. */ ! 848: yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ ! 849: if (yyn) goto yydefault; ! 850: #endif ! 851: ! 852: yyerrpop: /* pop the current state because it cannot handle the error token */ ! 853: ! 854: if (yyssp == yyss) YYABORT; ! 855: yyvsp--; ! 856: yystate = *--yyssp; ! 857: #ifdef YYLSP_NEEDED ! 858: yylsp--; ! 859: #endif ! 860: ! 861: #if YYDEBUG != 0 ! 862: if (yydebug) ! 863: { ! 864: short *ssp1 = yyss - 1; ! 865: fprintf (stderr, "Error: state stack now"); ! 866: while (ssp1 != yyssp) ! 867: fprintf (stderr, " %d", *++ssp1); ! 868: fprintf (stderr, "\n"); ! 869: } ! 870: #endif ! 871: ! 872: yyerrhandle: ! 873: ! 874: yyn = yypact[yystate]; ! 875: if (yyn == YYFLAG) ! 876: goto yyerrdefault; ! 877: ! 878: yyn += YYTERROR; ! 879: if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) ! 880: goto yyerrdefault; ! 881: ! 882: yyn = yytable[yyn]; ! 883: if (yyn < 0) ! 884: { ! 885: if (yyn == YYFLAG) ! 886: goto yyerrpop; ! 887: yyn = -yyn; ! 888: goto yyreduce; ! 889: } ! 890: else if (yyn == 0) ! 891: goto yyerrpop; ! 892: ! 893: if (yyn == YYFINAL) ! 894: YYACCEPT; ! 895: ! 896: #if YYDEBUG != 0 ! 897: if (yydebug) ! 898: fprintf(stderr, "Shifting error token, "); ! 899: #endif ! 900: ! 901: *++yyvsp = yylval; ! 902: #ifdef YYLSP_NEEDED ! 903: *++yylsp = yylloc; ! 904: #endif ! 905: ! 906: yystate = yyn; ! 907: goto yynewstate; ! 908: } ! 909: #line 116 "bi-parser.y" ! 910: ! 911: ! 912: static struct node * ! 913: makenode (s) ! 914: char *s; ! 915: { ! 916: struct node *n; ! 917: ! 918: n = (struct node *) malloc (sizeof (struct node)); ! 919: n->text = s; ! 920: n->next = NULL; ! 921: return n; ! 922: } ! 923: ! 924: static struct variation * ! 925: makevar (name, inputs, outputs, literals) ! 926: char *name; ! 927: struct node *inputs, *outputs, *literals; ! 928: { ! 929: struct variation *v; ! 930: ! 931: v = (struct variation *) malloc (sizeof (struct variation)); ! 932: v->name = name; ! 933: v->code = ndefs++; ! 934: v->inputs = inputs; ! 935: v->outputs = outputs; ! 936: v->literals = literals; ! 937: v->next = NULL; ! 938: return v; ! 939: } ! 940: ! 941: static struct def * ! 942: makedef (name, template, vars) ! 943: char *name, *template; ! 944: struct variation *vars; ! 945: { ! 946: struct def *d; ! 947: ! 948: d = (struct def *) malloc (sizeof (struct def)); ! 949: d->basename = name; ! 950: d->template = template; ! 951: d->variations = vars; ! 952: d->next = NULL; ! 953: return d; ! 954: } ! 955: ! 956: void ! 957: yyerror (s) ! 958: char *s; ! 959: { ! 960: fprintf (stderr, "syntax error in input\n"); ! 961: exit (FATAL_EXIT_CODE); ! 962: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.