1 2 # line 2 "../common/m4y_xpg4.y" 3 /* 4 * CDDL HEADER START 5 * 6 * The contents of this file are subject to the terms of the 7 * Common Development and Distribution License, Version 1.0 only 8 * (the "License"). You may not use this file except in compliance 9 * with the License. 10 * 11 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 12 * or http://www.opensolaris.org/os/licensing. 13 * See the License for the specific language governing permissions 14 * and limitations under the License. 15 * 16 * When distributing Covered Code, include this CDDL HEADER in each 17 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 18 * If applicable, add the following below this CDDL HEADER, with the 19 * fields enclosed by brackets "[]" replaced with your own identifying 20 * information: Portions Copyright [yyyy] [name of copyright owner] 21 * 22 * CDDL HEADER END 23 */ 24 25 # line 34 "../common/m4y_xpg4.y" 26 #pragma ident "%Z%%M% %I% %E% SMI" 27 extern long evalval; 28 #define YYSTYPE long 29 # define DIGITS 257 30 # define OROR 258 31 # define ANDAND 259 32 # define EQ 260 33 # define NE 261 34 # define LE 262 35 # define GE 263 36 # define LT 264 37 # define GT 265 38 # define LSHIFT 266 39 # define RSHIFT 267 40 # define POWER 268 41 # define UMINUS 269 42 43 #include <inttypes.h> 44 45 #ifdef __STDC__ 46 #include <stdlib.h> 47 #include <string.h> 48 #define YYCONST const 49 #else 50 #include <malloc.h> 51 #include <memory.h> 52 #define YYCONST 53 #endif 54 55 #include <values.h> 56 57 #if defined(__cplusplus) || defined(__STDC__) 58 59 #if defined(__cplusplus) && defined(__EXTERN_C__) 60 extern "C" { 61 #endif 62 #ifndef yyerror 63 #if defined(__cplusplus) 64 void yyerror(YYCONST char *); 65 #endif 66 #endif 67 #ifndef yylex 68 int yylex(void); 69 #endif 70 int yyparse(void); 71 #if defined(__cplusplus) && defined(__EXTERN_C__) 72 } 73 #endif 74 75 #endif 76 77 #define yyclearin yychar = -1 78 #define yyerrok yyerrflag = 0 79 extern int yychar; 80 extern int yyerrflag; 81 #ifndef YYSTYPE 82 #define YYSTYPE int 83 #endif 84 YYSTYPE yylval; 85 YYSTYPE yyval; 86 typedef int yytabelem; 87 #ifndef YYMAXDEPTH 88 #define YYMAXDEPTH 150 89 #endif 90 #if YYMAXDEPTH > 0 91 int yy_yys[YYMAXDEPTH], *yys = yy_yys; 92 YYSTYPE yy_yyv[YYMAXDEPTH], *yyv = yy_yyv; 93 #else /* user does initial allocation */ 94 int *yys; 95 YYSTYPE *yyv; 96 #endif 97 static int yymaxdepth = YYMAXDEPTH; 98 # define YYERRCODE 256 99 100 # line 85 "../common/m4y_xpg4.y" 101 102 103 #include "m4.h" 104 extern wchar_t *pe; 105 106 static int peek(char c, int r1, int r2); 107 static int peek3(char c1, int rc1, char c2, int rc2, int rc3); 108 109 int 110 yylex(void) 111 { 112 while (*pe == ' ' || *pe == '\t' || *pe == '\n') 113 pe++; 114 switch (*pe) { 115 case '\0': 116 case '+': 117 case '-': 118 case '/': 119 case '%': 120 case '^': 121 case '~': 122 case '(': 123 case ')': 124 return (*pe++); 125 case '*': 126 return (peek('*', POWER, '*')); 127 case '>': 128 return (peek3('=', GE, '>', RSHIFT, GT)); 129 case '<': 130 return (peek3('=', LE, '<', LSHIFT, LT)); 131 case '=': 132 return (peek('=', EQ, EQ)); 133 case '|': 134 return (peek('|', OROR, '|')); 135 case '&': 136 return (peek('&', ANDAND, '&')); 137 case '!': 138 return (peek('=', NE, '!')); 139 default: { 140 int base; 141 142 evalval = 0; 143 144 if (*pe == '0') { 145 if (*++pe == 'x' || *pe == 'X') { 146 base = 16; 147 ++pe; 148 } else 149 base = 8; 150 } else 151 base = 10; 152 153 for (;;) { 154 int c, dig; 155 156 c = *pe; 157 158 if (is_digit(c)) 159 dig = c - '0'; 160 else if (c >= 'a' && c <= 'f') 161 dig = c - 'a' + 10; 162 else if (c >= 'A' && c <= 'F') 163 dig = c - 'A' + 10; 164 else 165 break; 166 167 evalval = evalval*base + dig; 168 ++pe; 169 } 170 return (DIGITS); 171 } 172 } 173 } 174 175 static int 176 peek(char c, int r1, int r2) 177 { 178 if (*++pe != c) 179 return (r2); 180 ++pe; 181 return (r1); 182 } 183 184 static int 185 peek3(char c1, int rc1, char c2, int rc2, int rc3) 186 { 187 ++pe; 188 if (*pe == c1) { 189 ++pe; 190 return (rc1); 191 } 192 if (*pe == c2) { 193 ++pe; 194 return (rc2); 195 } 196 return (rc3); 197 } 198 199 /*ARGSUSED*/ 200 static void 201 yyerror(YYCONST char *msg) 202 { 203 } 204 static YYCONST yytabelem yyexca[] ={ 205 -1, 1, 206 0, -1, 207 -2, 0, 208 -1, 35, 209 260, 0, 210 261, 0, 211 -2, 7, 212 -1, 36, 213 260, 0, 214 261, 0, 215 -2, 8, 216 -1, 37, 217 262, 0, 218 263, 0, 219 264, 0, 220 265, 0, 221 -2, 9, 222 -1, 38, 223 262, 0, 224 263, 0, 225 264, 0, 226 265, 0, 227 -2, 10, 228 -1, 39, 229 262, 0, 230 263, 0, 231 264, 0, 232 265, 0, 233 -2, 11, 234 -1, 40, 235 262, 0, 236 263, 0, 237 264, 0, 238 265, 0, 239 -2, 12, 240 }; 241 # define YYNPROD 28 242 # define YYLAST 331 243 static YYCONST yytabelem yyact[]={ 244 245 26, 20, 27, 1, 52, 24, 22, 0, 23, 0, 246 25, 26, 20, 0, 0, 0, 24, 22, 0, 23, 247 0, 25, 26, 20, 0, 0, 0, 24, 22, 0, 248 23, 0, 25, 26, 20, 0, 0, 0, 24, 22, 249 0, 23, 0, 25, 26, 20, 0, 0, 0, 24, 250 22, 0, 23, 0, 25, 26, 20, 21, 0, 0, 251 24, 22, 0, 23, 26, 25, 26, 0, 21, 24, 252 22, 24, 23, 0, 25, 26, 25, 0, 0, 21, 253 24, 22, 0, 23, 0, 25, 26, 19, 0, 0, 254 21, 24, 22, 0, 23, 0, 25, 26, 19, 0, 255 0, 21, 24, 22, 0, 23, 3, 25, 0, 19, 256 0, 0, 0, 5, 0, 0, 7, 2, 6, 0, 257 19, 28, 29, 30, 31, 32, 0, 33, 34, 35, 258 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 259 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 260 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 261 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 262 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 263 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 264 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 265 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 267 0, 9, 10, 11, 12, 16, 14, 15, 13, 17, 268 18, 27, 9, 10, 11, 12, 16, 14, 15, 13, 269 17, 18, 27, 0, 10, 11, 12, 16, 14, 15, 270 13, 17, 18, 27, 0, 0, 11, 12, 16, 14, 271 15, 13, 17, 18, 27, 0, 0, 11, 12, 16, 272 14, 15, 13, 17, 18, 27, 0, 0, 11, 12, 273 16, 14, 15, 13, 17, 18, 27, 11, 12, 16, 274 14, 15, 13, 17, 18, 27, 0, 27, 0, 0, 275 16, 14, 15, 13, 17, 18, 27, 0, 0, 0, 276 0, 0, 0, 0, 0, 17, 18, 27, 0, 0, 277 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 278 8 }; 279 static YYCONST yytabelem yypact[]={ 280 281 73,-10000000, -26, 73, 73, 73, 73, 73,-10000000, 73, 282 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 283 73, 73, 73, 73, 73, 73, 73, 73,-10000000,-10000000, 284 -37,-10000000,-10000000, -15, -4, 38, 38, 49, 49, 49, 285 49, 60, 60, 7, 27, 18, 29, 29, -266, -266, 286 -266, -266,-10000000 }; 287 static YYCONST yytabelem yypgo[]={ 288 289 0, 3, 117 }; 290 static YYCONST yytabelem yyr1[]={ 291 292 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 293 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 294 2, 2, 2, 2, 2, 2, 2, 2 }; 295 static YYCONST yytabelem yyr2[]={ 296 297 0, 3, 1, 7, 7, 5, 5, 7, 7, 7, 298 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 299 7, 7, 7, 7, 7, 5, 5, 3 }; 300 static YYCONST yytabelem yychk[]={ 301 302 -10000000, -1, -2, 33, 126, 40, 45, 43, 257, 258, 303 259, 260, 261, 265, 263, 264, 262, 266, 267, 124, 304 38, 94, 43, 45, 42, 47, 37, 268, -2, -2, 305 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, 306 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, 307 -2, -2, 41 }; 308 static YYCONST yytabelem yydef[]={ 309 310 2, -2, 1, 0, 0, 0, 0, 0, 27, 0, 311 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 312 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 313 0, 25, 26, 3, 4, -2, -2, -2, -2, -2, 314 -2, 13, 14, 15, 16, 17, 18, 19, 20, 21, 315 22, 24, 23 }; 316 typedef struct 317 #ifdef __cplusplus 318 yytoktype 319 #endif 320 { 321 #ifdef __cplusplus 322 const 323 #endif 324 char *t_name; int t_val; } yytoktype; 325 #ifndef YYDEBUG 326 # define YYDEBUG 0 /* don't allow debugging */ 327 #endif 328 329 #if YYDEBUG 330 331 yytoktype yytoks[] = 332 { 333 "DIGITS", 257, 334 "OROR", 258, 335 "ANDAND", 259, 336 "|", 124, 337 "^", 94, 338 "&", 38, 339 "EQ", 260, 340 "NE", 261, 341 "LE", 262, 342 "GE", 263, 343 "LT", 264, 344 "GT", 265, 345 "LSHIFT", 266, 346 "RSHIFT", 267, 347 "+", 43, 348 "-", 45, 349 "*", 42, 350 "/", 47, 351 "%", 37, 352 "POWER", 268, 353 "!", 33, 354 "~", 126, 355 "UMINUS", 269, 356 "-unknown-", -1 /* ends search */ 357 }; 358 359 #ifdef __cplusplus 360 const 361 #endif 362 char * yyreds[] = 363 { 364 "-no such reduction-", 365 "s : e", 366 "s : /* empty */", 367 "e : e OROR e", 368 "e : e ANDAND e", 369 "e : '!' e", 370 "e : '~' e", 371 "e : e EQ e", 372 "e : e NE e", 373 "e : e GT e", 374 "e : e GE e", 375 "e : e LT e", 376 "e : e LE e", 377 "e : e LSHIFT e", 378 "e : e RSHIFT e", 379 "e : e '|' e", 380 "e : e '&' e", 381 "e : e '^' e", 382 "e : e '+' e", 383 "e : e '-' e", 384 "e : e '*' e", 385 "e : e '/' e", 386 "e : e '%' e", 387 "e : '(' e ')'", 388 "e : e POWER e", 389 "e : '-' e", 390 "e : '+' e", 391 "e : DIGITS", 392 }; 393 #endif /* YYDEBUG */ 394 # line 1 "/usr/share/lib/ccs/yaccpar" 395 /* 396 * CDDL HEADER START 397 * 398 * The contents of this file are subject to the terms of the 399 * Common Development and Distribution License, Version 1.0 only 400 * (the "License"). You may not use this file except in compliance 401 * with the License. 402 * 403 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 404 * or http://www.opensolaris.org/os/licensing. 405 * See the License for the specific language governing permissions 406 * and limitations under the License. 407 * 408 * When distributing Covered Code, include this CDDL HEADER in each 409 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 410 * If applicable, add the following below this CDDL HEADER, with the 411 * fields enclosed by brackets "[]" replaced with your own identifying 412 * information: Portions Copyright [yyyy] [name of copyright owner] 413 * 414 * CDDL HEADER END 415 */ 416 /* 417 * Copyright 1993 Sun Microsystems, Inc. All rights reserved. 418 * Use is subject to license terms. 419 */ 420 421 /* Copyright (c) 1988 AT&T */ 422 /* All Rights Reserved */ 423 424 #pragma ident "%Z%%M% %I% %E% SMI" 425 426 /* 427 ** Skeleton parser driver for yacc output 428 */ 429 430 /* 431 ** yacc user known macros and defines 432 */ 433 #define YYERROR goto yyerrlab 434 #define YYACCEPT return(0) 435 #define YYABORT return(1) 436 #define YYBACKUP( newtoken, newvalue )\ 437 {\ 438 if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\ 439 {\ 440 yyerror( "syntax error - cannot backup" );\ 441 goto yyerrlab;\ 442 }\ 443 yychar = newtoken;\ 444 yystate = *yyps;\ 445 yylval = newvalue;\ 446 goto yynewstate;\ 447 } 448 #define YYRECOVERING() (!!yyerrflag) 449 #define YYNEW(type) malloc(sizeof(type) * yynewmax) 450 #define YYCOPY(to, from, type) \ 451 (type *) memcpy(to, (char *) from, yymaxdepth * sizeof (type)) 452 #define YYENLARGE( from, type) \ 453 (type *) realloc((char *) from, yynewmax * sizeof(type)) 454 #ifndef YYDEBUG 455 # define YYDEBUG 1 /* make debugging available */ 456 #endif 457 458 /* 459 ** user known globals 460 */ 461 int yydebug; /* set to 1 to get debugging */ 462 463 /* 464 ** driver internal defines 465 */ 466 #define YYFLAG (-10000000) 467 468 /* 469 ** global variables used by the parser 470 */ 471 YYSTYPE *yypv; /* top of value stack */ 472 int *yyps; /* top of state stack */ 473 474 int yystate; /* current state */ 475 int yytmp; /* extra var (lasts between blocks) */ 476 477 int yynerrs; /* number of errors */ 478 int yyerrflag; /* error recovery flag */ 479 int yychar; /* current input token number */ 480 481 482 483 #ifdef YYNMBCHARS 484 #define YYLEX() yycvtok(yylex()) 485 /* 486 ** yycvtok - return a token if i is a wchar_t value that exceeds 255. 487 ** If i<255, i itself is the token. If i>255 but the neither 488 ** of the 30th or 31st bit is on, i is already a token. 489 */ 490 #if defined(__STDC__) || defined(__cplusplus) 491 int yycvtok(int i) 492 #else 493 int yycvtok(i) int i; 494 #endif 495 { 496 int first = 0; 497 int last = YYNMBCHARS - 1; 498 int mid; 499 wchar_t j; 500 501 if(i&0x60000000){/*Must convert to a token. */ 502 if( yymbchars[last].character < i ){ 503 return i;/*Giving up*/ 504 } 505 while ((last>=first)&&(first>=0)) {/*Binary search loop*/ 506 mid = (first+last)/2; 507 j = yymbchars[mid].character; 508 if( j==i ){/*Found*/ 509 return yymbchars[mid].tvalue; 510 }else if( j<i ){ 511 first = mid + 1; 512 }else{ 513 last = mid -1; 514 } 515 } 516 /*No entry in the table.*/ 517 return i;/* Giving up.*/ 518 }else{/* i is already a token. */ 519 return i; 520 } 521 } 522 #else/*!YYNMBCHARS*/ 523 #define YYLEX() yylex() 524 #endif/*!YYNMBCHARS*/ 525 526 /* 527 ** yyparse - return 0 if worked, 1 if syntax error not recovered from 528 */ 529 #if defined(__STDC__) || defined(__cplusplus) 530 int yyparse(void) 531 #else 532 int yyparse() 533 #endif 534 { 535 register YYSTYPE *yypvt = 0; /* top of value stack for $vars */ 536 537 #if defined(__cplusplus) || defined(lint) 538 /* 539 hacks to please C++ and lint - goto's inside 540 switch should never be executed 541 */ 542 static int __yaccpar_lint_hack__ = 0; 543 switch (__yaccpar_lint_hack__) 544 { 545 case 1: goto yyerrlab; 546 case 2: goto yynewstate; 547 } 548 #endif 549 550 /* 551 ** Initialize externals - yyparse may be called more than once 552 */ 553 yypv = &yyv[-1]; 554 yyps = &yys[-1]; 555 yystate = 0; 556 yytmp = 0; 557 yynerrs = 0; 558 yyerrflag = 0; 559 yychar = -1; 560 561 #if YYMAXDEPTH <= 0 562 if (yymaxdepth <= 0) 563 { 564 if ((yymaxdepth = YYEXPAND(0)) <= 0) 565 { 566 yyerror("yacc initialization error"); 567 YYABORT; 568 } 569 } 570 #endif 571 572 { 573 register YYSTYPE *yy_pv; /* top of value stack */ 574 register int *yy_ps; /* top of state stack */ 575 register int yy_state; /* current state */ 576 register int yy_n; /* internal state number info */ 577 goto yystack; /* moved from 6 lines above to here to please C++ */ 578 579 /* 580 ** get globals into registers. 581 ** branch to here only if YYBACKUP was called. 582 */ 583 yynewstate: 584 yy_pv = yypv; 585 yy_ps = yyps; 586 yy_state = yystate; 587 goto yy_newstate; 588 589 /* 590 ** get globals into registers. 591 ** either we just started, or we just finished a reduction 592 */ 593 yystack: 594 yy_pv = yypv; 595 yy_ps = yyps; 596 yy_state = yystate; 597 598 /* 599 ** top of for (;;) loop while no reductions done 600 */ 601 yy_stack: 602 /* 603 ** put a state and value onto the stacks 604 */ 605 #if YYDEBUG 606 /* 607 ** if debugging, look up token value in list of value vs. 608 ** name pairs. 0 and negative (-1) are special values. 609 ** Note: linear search is used since time is not a real 610 ** consideration while debugging. 611 */ 612 if ( yydebug ) 613 { 614 register int yy_i; 615 616 printf( "State %d, token ", yy_state ); 617 if ( yychar == 0 ) 618 printf( "end-of-file\n" ); 619 else if ( yychar < 0 ) 620 printf( "-none-\n" ); 621 else 622 { 623 for ( yy_i = 0; yytoks[yy_i].t_val >= 0; 624 yy_i++ ) 625 { 626 if ( yytoks[yy_i].t_val == yychar ) 627 break; 628 } 629 printf( "%s\n", yytoks[yy_i].t_name ); 630 } 631 } 632 #endif /* YYDEBUG */ 633 if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */ 634 { 635 /* 636 ** reallocate and recover. Note that pointers 637 ** have to be reset, or bad things will happen 638 */ 639 long yyps_index = (yy_ps - yys); 640 long yypv_index = (yy_pv - yyv); 641 long yypvt_index = (yypvt - yyv); 642 int yynewmax; 643 #ifdef YYEXPAND 644 yynewmax = YYEXPAND(yymaxdepth); 645 #else 646 yynewmax = 2 * yymaxdepth; /* double table size */ 647 if (yymaxdepth == YYMAXDEPTH) /* first time growth */ 648 { 649 char *newyys = (char *)YYNEW(int); 650 char *newyyv = (char *)YYNEW(YYSTYPE); 651 if (newyys != 0 && newyyv != 0) 652 { 653 yys = YYCOPY(newyys, yys, int); 654 yyv = YYCOPY(newyyv, yyv, YYSTYPE); 655 } 656 else 657 yynewmax = 0; /* failed */ 658 } 659 else /* not first time */ 660 { 661 yys = YYENLARGE(yys, int); 662 yyv = YYENLARGE(yyv, YYSTYPE); 663 if (yys == 0 || yyv == 0) 664 yynewmax = 0; /* failed */ 665 } 666 #endif 667 if (yynewmax <= yymaxdepth) /* tables not expanded */ 668 { 669 yyerror( "yacc stack overflow" ); 670 YYABORT; 671 } 672 yymaxdepth = yynewmax; 673 674 yy_ps = yys + yyps_index; 675 yy_pv = yyv + yypv_index; 676 yypvt = yyv + yypvt_index; 677 } 678 *yy_ps = yy_state; 679 *++yy_pv = yyval; 680 681 /* 682 ** we have a new state - find out what to do 683 */ 684 yy_newstate: 685 if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG ) 686 goto yydefault; /* simple state */ 687 #if YYDEBUG 688 /* 689 ** if debugging, need to mark whether new token grabbed 690 */ 691 yytmp = yychar < 0; 692 #endif 693 if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) ) 694 yychar = 0; /* reached EOF */ 695 #if YYDEBUG 696 if ( yydebug && yytmp ) 697 { 698 register int yy_i; 699 700 printf( "Received token " ); 701 if ( yychar == 0 ) 702 printf( "end-of-file\n" ); 703 else if ( yychar < 0 ) 704 printf( "-none-\n" ); 705 else 706 { 707 for ( yy_i = 0; yytoks[yy_i].t_val >= 0; 708 yy_i++ ) 709 { 710 if ( yytoks[yy_i].t_val == yychar ) 711 break; 712 } 713 printf( "%s\n", yytoks[yy_i].t_name ); 714 } 715 } 716 #endif /* YYDEBUG */ 717 if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) ) 718 goto yydefault; 719 if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/ 720 { 721 yychar = -1; 722 yyval = yylval; 723 yy_state = yy_n; 724 if ( yyerrflag > 0 ) 725 yyerrflag--; 726 goto yy_stack; 727 } 728 729 yydefault: 730 if ( ( yy_n = yydef[ yy_state ] ) == -2 ) 731 { 732 #if YYDEBUG 733 yytmp = yychar < 0; 734 #endif 735 if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) ) 736 yychar = 0; /* reached EOF */ 737 #if YYDEBUG 738 if ( yydebug && yytmp ) 739 { 740 register int yy_i; 741 742 printf( "Received token " ); 743 if ( yychar == 0 ) 744 printf( "end-of-file\n" ); 745 else if ( yychar < 0 ) 746 printf( "-none-\n" ); 747 else 748 { 749 for ( yy_i = 0; 750 yytoks[yy_i].t_val >= 0; 751 yy_i++ ) 752 { 753 if ( yytoks[yy_i].t_val 754 == yychar ) 755 { 756 break; 757 } 758 } 759 printf( "%s\n", yytoks[yy_i].t_name ); 760 } 761 } 762 #endif /* YYDEBUG */ 763 /* 764 ** look through exception table 765 */ 766 { 767 register YYCONST int *yyxi = yyexca; 768 769 while ( ( *yyxi != -1 ) || 770 ( yyxi[1] != yy_state ) ) 771 { 772 yyxi += 2; 773 } 774 while ( ( *(yyxi += 2) >= 0 ) && 775 ( *yyxi != yychar ) ) 776 ; 777 if ( ( yy_n = yyxi[1] ) < 0 ) 778 YYACCEPT; 779 } 780 } 781 782 /* 783 ** check for syntax error 784 */ 785 if ( yy_n == 0 ) /* have an error */ 786 { 787 /* no worry about speed here! */ 788 switch ( yyerrflag ) 789 { 790 case 0: /* new error */ 791 yyerror( "syntax error" ); 792 goto skip_init; 793 yyerrlab: 794 /* 795 ** get globals into registers. 796 ** we have a user generated syntax type error 797 */ 798 yy_pv = yypv; 799 yy_ps = yyps; 800 yy_state = yystate; 801 skip_init: 802 yynerrs++; 803 /* FALLTHRU */ 804 case 1: 805 case 2: /* incompletely recovered error */ 806 /* try again... */ 807 yyerrflag = 3; 808 /* 809 ** find state where "error" is a legal 810 ** shift action 811 */ 812 while ( yy_ps >= yys ) 813 { 814 yy_n = yypact[ *yy_ps ] + YYERRCODE; 815 if ( yy_n >= 0 && yy_n < YYLAST && 816 yychk[yyact[yy_n]] == YYERRCODE) { 817 /* 818 ** simulate shift of "error" 819 */ 820 yy_state = yyact[ yy_n ]; 821 goto yy_stack; 822 } 823 /* 824 ** current state has no shift on 825 ** "error", pop stack 826 */ 827 #if YYDEBUG 828 # define _POP_ "Error recovery pops state %d, uncovers state %d\n" 829 if ( yydebug ) 830 printf( _POP_, *yy_ps, 831 yy_ps[-1] ); 832 # undef _POP_ 833 #endif 834 yy_ps--; 835 yy_pv--; 836 } 837 /* 838 ** there is no state on stack with "error" as 839 ** a valid shift. give up. 840 */ 841 YYABORT; 842 case 3: /* no shift yet; eat a token */ 843 #if YYDEBUG 844 /* 845 ** if debugging, look up token in list of 846 ** pairs. 0 and negative shouldn't occur, 847 ** but since timing doesn't matter when 848 ** debugging, it doesn't hurt to leave the 849 ** tests here. 850 */ 851 if ( yydebug ) 852 { 853 register int yy_i; 854 855 printf( "Error recovery discards " ); 856 if ( yychar == 0 ) 857 printf( "token end-of-file\n" ); 858 else if ( yychar < 0 ) 859 printf( "token -none-\n" ); 860 else 861 { 862 for ( yy_i = 0; 863 yytoks[yy_i].t_val >= 0; 864 yy_i++ ) 865 { 866 if ( yytoks[yy_i].t_val 867 == yychar ) 868 { 869 break; 870 } 871 } 872 printf( "token %s\n", 873 yytoks[yy_i].t_name ); 874 } 875 } 876 #endif /* YYDEBUG */ 877 if ( yychar == 0 ) /* reached EOF. quit */ 878 YYABORT; 879 yychar = -1; 880 goto yy_newstate; 881 } 882 }/* end if ( yy_n == 0 ) */ 883 /* 884 ** reduction by production yy_n 885 ** put stack tops, etc. so things right after switch 886 */ 887 #if YYDEBUG 888 /* 889 ** if debugging, print the string that is the user's 890 ** specification of the reduction which is just about 891 ** to be done. 892 */ 893 if ( yydebug ) 894 printf( "Reduce by (%d) \"%s\"\n", 895 yy_n, yyreds[ yy_n ] ); 896 #endif 897 yytmp = yy_n; /* value to switch over */ 898 yypvt = yy_pv; /* $vars top of value stack */ 899 /* 900 ** Look in goto table for next state 901 ** Sorry about using yy_state here as temporary 902 ** register variable, but why not, if it works... 903 ** If yyr2[ yy_n ] doesn't have the low order bit 904 ** set, then there is no action to be done for 905 ** this reduction. So, no saving & unsaving of 906 ** registers done. The only difference between the 907 ** code just after the if and the body of the if is 908 ** the goto yy_stack in the body. This way the test 909 ** can be made before the choice of what to do is needed. 910 */ 911 { 912 /* length of production doubled with extra bit */ 913 register int yy_len = yyr2[ yy_n ]; 914 915 if ( !( yy_len & 01 ) ) 916 { 917 yy_len >>= 1; 918 yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ 919 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + 920 *( yy_ps -= yy_len ) + 1; 921 if ( yy_state >= YYLAST || 922 yychk[ yy_state = 923 yyact[ yy_state ] ] != -yy_n ) 924 { 925 yy_state = yyact[ yypgo[ yy_n ] ]; 926 } 927 goto yy_stack; 928 } 929 yy_len >>= 1; 930 yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ 931 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + 932 *( yy_ps -= yy_len ) + 1; 933 if ( yy_state >= YYLAST || 934 yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) 935 { 936 yy_state = yyact[ yypgo[ yy_n ] ]; 937 } 938 } 939 /* save until reenter driver code */ 940 yystate = yy_state; 941 yyps = yy_ps; 942 yypv = yy_pv; 943 } 944 /* 945 ** code supplied by user is placed in this switch 946 */ 947 switch( yytmp ) 948 { 949 950 case 1: 951 # line 54 "../common/m4y_xpg4.y" 952 { evalval = yypvt[-0]; } break; 953 case 2: 954 # line 55 "../common/m4y_xpg4.y" 955 { evalval = 0; } break; 956 case 3: 957 # line 58 "../common/m4y_xpg4.y" 958 { yyval = (yypvt[-2] != 0 || yypvt[-0] != 0) ? 1 : 0; } break; 959 case 4: 960 # line 59 "../common/m4y_xpg4.y" 961 { yyval = (yypvt[-2] != 0 && yypvt[-0] != 0) ? 1 : 0; } break; 962 case 5: 963 # line 60 "../common/m4y_xpg4.y" 964 { yyval = yypvt[-0] == 0; } break; 965 case 6: 966 # line 61 "../common/m4y_xpg4.y" 967 { yyval = ~yypvt[-0]; } break; 968 case 7: 969 # line 62 "../common/m4y_xpg4.y" 970 { yyval = yypvt[-2] == yypvt[-0]; } break; 971 case 8: 972 # line 63 "../common/m4y_xpg4.y" 973 { yyval = yypvt[-2] != yypvt[-0]; } break; 974 case 9: 975 # line 64 "../common/m4y_xpg4.y" 976 { yyval = yypvt[-2] > yypvt[-0]; } break; 977 case 10: 978 # line 65 "../common/m4y_xpg4.y" 979 { yyval = yypvt[-2] >= yypvt[-0]; } break; 980 case 11: 981 # line 66 "../common/m4y_xpg4.y" 982 { yyval = yypvt[-2] < yypvt[-0]; } break; 983 case 12: 984 # line 67 "../common/m4y_xpg4.y" 985 { yyval = yypvt[-2] <= yypvt[-0]; } break; 986 case 13: 987 # line 68 "../common/m4y_xpg4.y" 988 { yyval = yypvt[-2] << yypvt[-0]; } break; 989 case 14: 990 # line 69 "../common/m4y_xpg4.y" 991 { yyval = yypvt[-2] >> yypvt[-0]; } break; 992 case 15: 993 # line 70 "../common/m4y_xpg4.y" 994 { yyval = (yypvt[-2] | yypvt[-0]); } break; 995 case 16: 996 # line 71 "../common/m4y_xpg4.y" 997 { yyval = (yypvt[-2] & yypvt[-0]); } break; 998 case 17: 999 # line 72 "../common/m4y_xpg4.y" 1000 { yyval = (yypvt[-2] ^ yypvt[-0]); } break; 1001 case 18: 1002 # line 73 "../common/m4y_xpg4.y" 1003 { yyval = (yypvt[-2] + yypvt[-0]); } break; 1004 case 19: 1005 # line 74 "../common/m4y_xpg4.y" 1006 { yyval = (yypvt[-2] - yypvt[-0]); } break; 1007 case 20: 1008 # line 75 "../common/m4y_xpg4.y" 1009 { yyval = (yypvt[-2] * yypvt[-0]); } break; 1010 case 21: 1011 # line 76 "../common/m4y_xpg4.y" 1012 { yyval = (yypvt[-2] / yypvt[-0]); } break; 1013 case 22: 1014 # line 77 "../common/m4y_xpg4.y" 1015 { yyval = (yypvt[-2] % yypvt[-0]); } break; 1016 case 23: 1017 # line 78 "../common/m4y_xpg4.y" 1018 { yyval = (yypvt[-1]); } break; 1019 case 24: 1020 # line 79 "../common/m4y_xpg4.y" 1021 { for (yyval = 1; yypvt[-0]-- > 0; yyval *= yypvt[-2]); } break; 1022 case 25: 1023 # line 80 "../common/m4y_xpg4.y" 1024 { yyval = yypvt[-0]-1; yyval = -yypvt[-0]; } break; 1025 case 26: 1026 # line 81 "../common/m4y_xpg4.y" 1027 { yyval = yypvt[-0]-1; yyval = yypvt[-0]; } break; 1028 case 27: 1029 # line 82 "../common/m4y_xpg4.y" 1030 { yyval = evalval; } break; 1031 # line 556 "/usr/share/lib/ccs/yaccpar" 1032 } 1033 goto yystack; /* reset registers in driver code */ 1034 } 1035 1036