1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* 23 * Copyright 1993 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27/* Copyright (c) 1988 AT&T */ 28/* All Rights Reserved */ 29 30/* 31** Skeleton parser driver for yacc output 32*/ 33 34/* 35** yacc user known macros and defines 36*/ 37#define YYERROR goto yyerrlab 38#define YYACCEPT return(0) 39#define YYABORT return(1) 40#define YYBACKUP( newtoken, newvalue )\ 41{\ 42 if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\ 43 {\ 44 (void) yyerror( "syntax error - cannot backup" );\ 45 goto yyerrlab;\ 46 }\ 47 yychar = newtoken;\ 48 yystate = *yyps;\ 49 yylval = newvalue;\ 50 goto yynewstate;\ 51} 52#define YYRECOVERING() (!!yyerrflag) 53#define YYNEW(type) malloc(sizeof(type) * yynewmax) 54#define YYCOPY(to, from, type) \ 55 (type *) memcpy(to, (char *) from, yymaxdepth * sizeof (type)) 56#define YYENLARGE( from, type) \ 57 (type *) realloc((char *) from, yynewmax * sizeof(type)) 58#ifndef YYDEBUG 59# define YYDEBUG 1 /* make debugging available */ 60#endif 61 62/* 63** user known globals 64*/ 65int yydebug; /* set to 1 to get debugging */ 66 67/* 68** driver internal defines 69*/ 70#define YYFLAG (-10000000) 71 72/* 73** global variables used by the parser 74*/ 75YYSTYPE *yypv; /* top of value stack */ 76int *yyps; /* top of state stack */ 77 78int yystate; /* current state */ 79int yytmp; /* extra var (lasts between blocks) */ 80 81int yynerrs; /* number of errors */ 82int yyerrflag; /* error recovery flag */ 83int yychar; /* current input token number */ 84 85 86 87#ifdef YYNMBCHARS 88#define YYLEX() yycvtok(yylex()) 89/* 90** yycvtok - return a token if i is a wchar_t value that exceeds 255. 91** If i<255, i itself is the token. If i>255 but the neither 92** of the 30th or 31st bit is on, i is already a token. 93*/ 94int 95yycvtok(int i) 96{ 97 int first = 0; 98 int last = YYNMBCHARS - 1; 99 int mid; 100 wchar_t j; 101 102 if(i&0x60000000){/*Must convert to a token. */ 103 if( yymbchars[last].character < i ){ 104 return i;/*Giving up*/ 105 } 106 while ((last>=first)&&(first>=0)) {/*Binary search loop*/ 107 mid = (first+last)/2; 108 j = yymbchars[mid].character; 109 if( j==i ){/*Found*/ 110 return yymbchars[mid].tvalue; 111 }else if( j<i ){ 112 first = mid + 1; 113 }else{ 114 last = mid -1; 115 } 116 } 117 /*No entry in the table.*/ 118 return i;/* Giving up.*/ 119 }else{/* i is already a token. */ 120 return i; 121 } 122} 123#else/*!YYNMBCHARS*/ 124#define YYLEX() yylex() 125#endif/*!YYNMBCHARS*/ 126 127/* 128** yyparse - return 0 if worked, 1 if syntax error not recovered from 129*/ 130int 131yyparse(void) 132{ 133 YYSTYPE *yypvt = 0; /* top of value stack for $vars */ 134 135#if defined(__cplusplus) || defined(lint) 136/* 137 hacks to please C++ and lint - goto's inside 138 switch should never be executed 139*/ 140 static int __yaccpar_lint_hack__ = 0; 141 switch (__yaccpar_lint_hack__) 142 { 143 case 1: goto yyerrlab; 144 case 2: goto yynewstate; 145 } 146#endif 147 148 /* 149 ** Initialize externals - yyparse may be called more than once 150 */ 151 yypv = &yyv[-1]; 152 yyps = &yys[-1]; 153 yystate = 0; 154 yytmp = 0; 155 yynerrs = 0; 156 yyerrflag = 0; 157 yychar = -1; 158 159#if YYMAXDEPTH <= 0 160 if (yymaxdepth <= 0) 161 { 162 if ((yymaxdepth = YYEXPAND(0)) <= 0) 163 { 164 (void) yyerror("yacc initialization error"); 165 YYABORT; 166 } 167 } 168#endif 169 170 { 171 YYSTYPE *yy_pv; /* top of value stack */ 172 int *yy_ps; /* top of state stack */ 173 int yy_state; /* current state */ 174 int yy_n; /* internal state number info */ 175 goto yystack; /* moved from 6 lines above to here to please C++ */ 176 177 /* 178 ** get globals into registers. 179 ** branch to here only if YYBACKUP was called. 180 */ 181 yynewstate: 182 yy_pv = yypv; 183 yy_ps = yyps; 184 yy_state = yystate; 185 goto yy_newstate; 186 187 /* 188 ** get globals into registers. 189 ** either we just started, or we just finished a reduction 190 */ 191 yystack: 192 yy_pv = yypv; 193 yy_ps = yyps; 194 yy_state = yystate; 195 196 /* 197 ** top of for (;;) loop while no reductions done 198 */ 199 yy_stack: 200 /* 201 ** put a state and value onto the stacks 202 */ 203#if YYDEBUG 204 /* 205 ** if debugging, look up token value in list of value vs. 206 ** name pairs. 0 and negative (-1) are special values. 207 ** Note: linear search is used since time is not a real 208 ** consideration while debugging. 209 */ 210 if ( yydebug ) 211 { 212 int yy_i; 213 214 printf( "State %d, token ", yy_state ); 215 if ( yychar == 0 ) 216 printf( "end-of-file\n" ); 217 else if ( yychar < 0 ) 218 printf( "-none-\n" ); 219 else 220 { 221 for ( yy_i = 0; yytoks[yy_i].t_val >= 0; 222 yy_i++ ) 223 { 224 if ( yytoks[yy_i].t_val == yychar ) 225 break; 226 } 227 printf( "%s\n", yytoks[yy_i].t_name ); 228 } 229 } 230#endif /* YYDEBUG */ 231 if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */ 232 { 233 /* 234 ** reallocate and recover. Note that pointers 235 ** have to be reset, or bad things will happen 236 */ 237 long yyps_index = (yy_ps - yys); 238 long yypv_index = (yy_pv - yyv); 239 long yypvt_index = (yypvt - yyv); 240 int yynewmax; 241#ifdef YYEXPAND 242 yynewmax = YYEXPAND(yymaxdepth); 243#else 244 yynewmax = 2 * yymaxdepth; /* double table size */ 245 if (yymaxdepth == YYMAXDEPTH) /* first time growth */ 246 { 247 char *newyys = (char *)YYNEW(int); 248 char *newyyv = (char *)YYNEW(YYSTYPE); 249 if (newyys != 0 && newyyv != 0) 250 { 251 yys = YYCOPY(newyys, yys, int); 252 yyv = YYCOPY(newyyv, yyv, YYSTYPE); 253 } 254 else 255 yynewmax = 0; /* failed */ 256 } 257 else /* not first time */ 258 { 259 yys = YYENLARGE(yys, int); 260 yyv = YYENLARGE(yyv, YYSTYPE); 261 if (yys == 0 || yyv == 0) 262 yynewmax = 0; /* failed */ 263 } 264#endif 265 if (yynewmax <= yymaxdepth) /* tables not expanded */ 266 { 267 (void) yyerror( "yacc stack overflow" ); 268 YYABORT; 269 } 270 yymaxdepth = yynewmax; 271 272 yy_ps = yys + yyps_index; 273 yy_pv = yyv + yypv_index; 274 yypvt = yyv + yypvt_index; 275 } 276 *yy_ps = yy_state; 277 *++yy_pv = yyval; 278 279 /* 280 ** we have a new state - find out what to do 281 */ 282 yy_newstate: 283 if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG ) 284 goto yydefault; /* simple state */ 285#if YYDEBUG 286 /* 287 ** if debugging, need to mark whether new token grabbed 288 */ 289 yytmp = yychar < 0; 290#endif 291 if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) ) 292 yychar = 0; /* reached EOF */ 293#if YYDEBUG 294 if ( yydebug && yytmp ) 295 { 296 int yy_i; 297 298 printf( "Received token " ); 299 if ( yychar == 0 ) 300 printf( "end-of-file\n" ); 301 else if ( yychar < 0 ) 302 printf( "-none-\n" ); 303 else 304 { 305 for ( yy_i = 0; yytoks[yy_i].t_val >= 0; 306 yy_i++ ) 307 { 308 if ( yytoks[yy_i].t_val == yychar ) 309 break; 310 } 311 printf( "%s\n", yytoks[yy_i].t_name ); 312 } 313 } 314#endif /* YYDEBUG */ 315 if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) ) 316 goto yydefault; 317 if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/ 318 { 319 yychar = -1; 320 yyval = yylval; 321 yy_state = yy_n; 322 if ( yyerrflag > 0 ) 323 yyerrflag--; 324 goto yy_stack; 325 } 326 327 yydefault: 328 if ( ( yy_n = yydef[ yy_state ] ) == -2 ) 329 { 330#if YYDEBUG 331 yytmp = yychar < 0; 332#endif 333 if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) ) 334 yychar = 0; /* reached EOF */ 335#if YYDEBUG 336 if ( yydebug && yytmp ) 337 { 338 int yy_i; 339 340 printf( "Received token " ); 341 if ( yychar == 0 ) 342 printf( "end-of-file\n" ); 343 else if ( yychar < 0 ) 344 printf( "-none-\n" ); 345 else 346 { 347 for ( yy_i = 0; 348 yytoks[yy_i].t_val >= 0; 349 yy_i++ ) 350 { 351 if ( yytoks[yy_i].t_val 352 == yychar ) 353 { 354 break; 355 } 356 } 357 printf( "%s\n", yytoks[yy_i].t_name ); 358 } 359 } 360#endif /* YYDEBUG */ 361 /* 362 ** look through exception table 363 */ 364 { 365 const int *yyxi = yyexca; 366 367 while ( ( *yyxi != -1 ) || 368 ( yyxi[1] != yy_state ) ) 369 { 370 yyxi += 2; 371 } 372 while ( ( *(yyxi += 2) >= 0 ) && 373 ( *yyxi != yychar ) ) 374 ; 375 if ( ( yy_n = yyxi[1] ) < 0 ) 376 YYACCEPT; 377 } 378 } 379 380 /* 381 ** check for syntax error 382 */ 383 if ( yy_n == 0 ) /* have an error */ 384 { 385 /* no worry about speed here! */ 386 switch ( yyerrflag ) 387 { 388 case 0: /* new error */ 389 (void) yyerror( "syntax error" ); 390 goto skip_init; 391 yyerrlab: 392 /* 393 ** get globals into registers. 394 ** we have a user generated syntax type error 395 */ 396 yy_pv = yypv; 397 yy_ps = yyps; 398 yy_state = yystate; 399 skip_init: 400 yynerrs++; 401 /* FALLTHRU */ 402 case 1: 403 case 2: /* incompletely recovered error */ 404 /* try again... */ 405 yyerrflag = 3; 406 /* 407 ** find state where "error" is a legal 408 ** shift action 409 */ 410 while ( yy_ps >= yys ) 411 { 412 yy_n = yypact[ *yy_ps ] + YYERRCODE; 413 if ( yy_n >= 0 && yy_n < YYLAST && 414 yychk[yyact[yy_n]] == YYERRCODE) { 415 /* 416 ** simulate shift of "error" 417 */ 418 yy_state = yyact[ yy_n ]; 419 goto yy_stack; 420 } 421 /* 422 ** current state has no shift on 423 ** "error", pop stack 424 */ 425#if YYDEBUG 426# define _POP_ "Error recovery pops state %d, uncovers state %d\n" 427 if ( yydebug ) 428 printf( _POP_, *yy_ps, 429 yy_ps[-1] ); 430# undef _POP_ 431#endif 432 yy_ps--; 433 yy_pv--; 434 } 435 /* 436 ** there is no state on stack with "error" as 437 ** a valid shift. give up. 438 */ 439 YYABORT; 440 case 3: /* no shift yet; eat a token */ 441#if YYDEBUG 442 /* 443 ** if debugging, look up token in list of 444 ** pairs. 0 and negative shouldn't occur, 445 ** but since timing doesn't matter when 446 ** debugging, it doesn't hurt to leave the 447 ** tests here. 448 */ 449 if ( yydebug ) 450 { 451 int yy_i; 452 453 printf( "Error recovery discards " ); 454 if ( yychar == 0 ) 455 printf( "token end-of-file\n" ); 456 else if ( yychar < 0 ) 457 printf( "token -none-\n" ); 458 else 459 { 460 for ( yy_i = 0; 461 yytoks[yy_i].t_val >= 0; 462 yy_i++ ) 463 { 464 if ( yytoks[yy_i].t_val 465 == yychar ) 466 { 467 break; 468 } 469 } 470 printf( "token %s\n", 471 yytoks[yy_i].t_name ); 472 } 473 } 474#endif /* YYDEBUG */ 475 if ( yychar == 0 ) /* reached EOF. quit */ 476 YYABORT; 477 yychar = -1; 478 goto yy_newstate; 479 } 480 }/* end if ( yy_n == 0 ) */ 481 /* 482 ** reduction by production yy_n 483 ** put stack tops, etc. so things right after switch 484 */ 485#if YYDEBUG 486 /* 487 ** if debugging, print the string that is the user's 488 ** specification of the reduction which is just about 489 ** to be done. 490 */ 491 if ( yydebug ) 492 printf( "Reduce by (%d) \"%s\"\n", 493 yy_n, yyreds[ yy_n ] ); 494#endif 495 yytmp = yy_n; /* value to switch over */ 496 yypvt = yy_pv; /* $vars top of value stack */ 497 /* 498 ** Look in goto table for next state 499 ** Sorry about using yy_state here as temporary 500 ** register variable, but why not, if it works... 501 ** If yyr2[ yy_n ] doesn't have the low order bit 502 ** set, then there is no action to be done for 503 ** this reduction. So, no saving & unsaving of 504 ** registers done. The only difference between the 505 ** code just after the if and the body of the if is 506 ** the goto yy_stack in the body. This way the test 507 ** can be made before the choice of what to do is needed. 508 */ 509 { 510 /* length of production doubled with extra bit */ 511 int yy_len = yyr2[ yy_n ]; 512 513 if ( !( yy_len & 01 ) ) 514 { 515 yy_len >>= 1; 516 yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ 517 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + 518 *( yy_ps -= yy_len ) + 1; 519 if ( yy_state >= YYLAST || 520 yychk[ yy_state = 521 yyact[ yy_state ] ] != -yy_n ) 522 { 523 yy_state = yyact[ yypgo[ yy_n ] ]; 524 } 525 goto yy_stack; 526 } 527 yy_len >>= 1; 528 yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ 529 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] + 530 *( yy_ps -= yy_len ) + 1; 531 if ( yy_state >= YYLAST || 532 yychk[ yy_state = yyact[ yy_state ] ] != -yy_n ) 533 { 534 yy_state = yyact[ yypgo[ yy_n ] ]; 535 } 536 } 537 /* save until reenter driver code */ 538 yystate = yy_state; 539 yyps = yy_ps; 540 yypv = yy_pv; 541 } 542 /* 543 ** code supplied by user is placed in this switch 544 */ 545 switch( yytmp ) 546 { 547 $A 548 } 549 goto yystack; /* reset registers in driver code */ 550} 551