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
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.
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]
23 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 ** Skeleton parser driver for yacc output
37 ** yacc user known macros and defines
39 #define YYERROR goto yyerrlab
40 #define YYACCEPT return(0)
41 #define YYABORT return(1)
42 #define YYBACKUP( newtoken, newvalue )\
44 if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
46 yyerror( "syntax error - cannot backup" );\
54 #define YYRECOVERING() (!!yyerrflag)
55 #define YYNEW(type) malloc(sizeof(type) * yynewmax)
56 #define YYCOPY(to, from, type) \
57 (type *) memcpy(to, (char *) from, yymaxdepth * sizeof (type))
58 #define YYENLARGE( from, type) \
59 (type *) realloc((char *) from, yynewmax * sizeof(type))
61 # define YYDEBUG 1 /* make debugging available */
67 int yydebug; /* set to 1 to get debugging */
70 ** driver internal defines
72 #define YYFLAG (-10000000)
75 ** global variables used by the parser
77 YYSTYPE *yypv; /* top of value stack */
78 int *yyps; /* top of state stack */
80 int yystate; /* current state */
81 int yytmp; /* extra var (lasts between blocks) */
83 int yynerrs; /* number of errors */
84 int yyerrflag; /* error recovery flag */
85 int yychar; /* current input token number */
90 #define YYLEX() yycvtok(yylex())
92 ** yycvtok - return a token if i is a wchar_t value that exceeds 255.
93 ** If i<255, i itself is the token. If i>255 but the neither
94 ** of the 30th or 31st bit is on, i is already a token.
96 #if defined(__STDC__) || defined(__cplusplus)
103 int last = YYNMBCHARS - 1;
107 if(i&0x60000000){/*Must convert to a token. */
108 if( yymbchars[last].character < i ){
109 return i;/*Giving up*/
111 while ((last>=first)&&(first>=0)) {/*Binary search loop*/
112 mid = (first+last)/2;
113 j = yymbchars[mid].character;
115 return yymbchars[mid].tvalue;
122 /*No entry in the table.*/
123 return i;/* Giving up.*/
124 }else{/* i is already a token. */
129 #define YYLEX() yylex()
130 #endif/*!YYNMBCHARS*/
133 ** yyparse - return 0 if worked, 1 if syntax error not recovered from
135 #if defined(__STDC__) || defined(__cplusplus)
141 register YYSTYPE *yypvt = 0; /* top of value stack for $vars */
143 #if defined(__cplusplus) || defined(lint)
145 hacks to please C++ and lint - goto's inside
146 switch should never be executed
148 static int __yaccpar_lint_hack__ = 0;
149 switch (__yaccpar_lint_hack__)
151 case 1: goto yyerrlab;
152 case 2: goto yynewstate;
157 ** Initialize externals - yyparse may be called more than once
170 if ((yymaxdepth = YYEXPAND(0)) <= 0)
172 yyerror("yacc initialization error");
179 register YYSTYPE *yy_pv; /* top of value stack */
180 register int *yy_ps; /* top of state stack */
181 register int yy_state; /* current state */
182 register int yy_n; /* internal state number info */
183 goto yystack; /* moved from 6 lines above to here to please C++ */
186 ** get globals into registers.
187 ** branch to here only if YYBACKUP was called.
196 ** get globals into registers.
197 ** either we just started, or we just finished a reduction
205 ** top of for (;;) loop while no reductions done
209 ** put a state and value onto the stacks
213 ** if debugging, look up token value in list of value vs.
214 ** name pairs. 0 and negative (-1) are special values.
215 ** Note: linear search is used since time is not a real
216 ** consideration while debugging.
222 printf( "State %d, token ", yy_state );
224 printf( "end-of-file\n" );
225 else if ( yychar < 0 )
226 printf( "-none-\n" );
229 for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
232 if ( yytoks[yy_i].t_val == yychar )
235 printf( "%s\n", yytoks[yy_i].t_name );
239 if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */
242 ** reallocate and recover. Note that pointers
243 ** have to be reset, or bad things will happen
245 long yyps_index = (yy_ps - yys);
246 long yypv_index = (yy_pv - yyv);
247 long yypvt_index = (yypvt - yyv);
250 yynewmax = YYEXPAND(yymaxdepth);
252 yynewmax = 2 * yymaxdepth; /* double table size */
253 if (yymaxdepth == YYMAXDEPTH) /* first time growth */
255 char *newyys = (char *)YYNEW(int);
256 char *newyyv = (char *)YYNEW(YYSTYPE);
257 if (newyys != 0 && newyyv != 0)
259 yys = YYCOPY(newyys, yys, int);
260 yyv = YYCOPY(newyyv, yyv, YYSTYPE);
263 yynewmax = 0; /* failed */
265 else /* not first time */
267 yys = YYENLARGE(yys, int);
268 yyv = YYENLARGE(yyv, YYSTYPE);
269 if (yys == 0 || yyv == 0)
270 yynewmax = 0; /* failed */
273 if (yynewmax <= yymaxdepth) /* tables not expanded */
275 yyerror( "yacc stack overflow" );
278 yymaxdepth = yynewmax;
280 yy_ps = yys + yyps_index;
281 yy_pv = yyv + yypv_index;
282 yypvt = yyv + yypvt_index;
288 ** we have a new state - find out what to do
291 if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )
292 goto yydefault; /* simple state */
295 ** if debugging, need to mark whether new token grabbed
299 if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) )
300 yychar = 0; /* reached EOF */
302 if ( yydebug && yytmp )
306 printf( "Received token " );
308 printf( "end-of-file\n" );
309 else if ( yychar < 0 )
310 printf( "-none-\n" );
313 for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
316 if ( yytoks[yy_i].t_val == yychar )
319 printf( "%s\n", yytoks[yy_i].t_name );
323 if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )
325 if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/
336 if ( ( yy_n = yydef[ yy_state ] ) == -2 )
341 if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) )
342 yychar = 0; /* reached EOF */
344 if ( yydebug && yytmp )
348 printf( "Received token " );
350 printf( "end-of-file\n" );
351 else if ( yychar < 0 )
352 printf( "-none-\n" );
356 yytoks[yy_i].t_val >= 0;
359 if ( yytoks[yy_i].t_val
365 printf( "%s\n", yytoks[yy_i].t_name );
370 ** look through exception table
373 register YYCONST int *yyxi = yyexca;
375 while ( ( *yyxi != -1 ) ||
376 ( yyxi[1] != yy_state ) )
380 while ( ( *(yyxi += 2) >= 0 ) &&
381 ( *yyxi != yychar ) )
383 if ( ( yy_n = yyxi[1] ) < 0 )
389 ** check for syntax error
391 if ( yy_n == 0 ) /* have an error */
393 /* no worry about speed here! */
396 case 0: /* new error */
397 yyerror( "syntax error" );
401 ** get globals into registers.
402 ** we have a user generated syntax type error
411 case 2: /* incompletely recovered error */
415 ** find state where "error" is a legal
418 while ( yy_ps >= yys )
420 yy_n = yypact[ *yy_ps ] + YYERRCODE;
421 if ( yy_n >= 0 && yy_n < YYLAST &&
422 yychk[yyact[yy_n]] == YYERRCODE) {
424 ** simulate shift of "error"
426 yy_state = yyact[ yy_n ];
430 ** current state has no shift on
431 ** "error", pop stack
434 # define _POP_ "Error recovery pops state %d, uncovers state %d\n"
436 printf( _POP_, *yy_ps,
444 ** there is no state on stack with "error" as
445 ** a valid shift. give up.
448 case 3: /* no shift yet; eat a token */
451 ** if debugging, look up token in list of
452 ** pairs. 0 and negative shouldn't occur,
453 ** but since timing doesn't matter when
454 ** debugging, it doesn't hurt to leave the
461 printf( "Error recovery discards " );
463 printf( "token end-of-file\n" );
464 else if ( yychar < 0 )
465 printf( "token -none-\n" );
469 yytoks[yy_i].t_val >= 0;
472 if ( yytoks[yy_i].t_val
478 printf( "token %s\n",
479 yytoks[yy_i].t_name );
483 if ( yychar == 0 ) /* reached EOF. quit */
488 }/* end if ( yy_n == 0 ) */
490 ** reduction by production yy_n
491 ** put stack tops, etc. so things right after switch
495 ** if debugging, print the string that is the user's
496 ** specification of the reduction which is just about
500 printf( "Reduce by (%d) \"%s\"\n",
501 yy_n, yyreds[ yy_n ] );
503 yytmp = yy_n; /* value to switch over */
504 yypvt = yy_pv; /* $vars top of value stack */
506 ** Look in goto table for next state
507 ** Sorry about using yy_state here as temporary
508 ** register variable, but why not, if it works...
509 ** If yyr2[ yy_n ] doesn't have the low order bit
510 ** set, then there is no action to be done for
511 ** this reduction. So, no saving & unsaving of
512 ** registers done. The only difference between the
513 ** code just after the if and the body of the if is
514 ** the goto yy_stack in the body. This way the test
515 ** can be made before the choice of what to do is needed.
518 /* length of production doubled with extra bit */
519 register int yy_len = yyr2[ yy_n ];
521 if ( !( yy_len & 01 ) )
524 yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */
525 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
526 *( yy_ps -= yy_len ) + 1;
527 if ( yy_state >= YYLAST ||
529 yyact[ yy_state ] ] != -yy_n )
531 yy_state = yyact[ yypgo[ yy_n ] ];
536 yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */
537 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
538 *( yy_ps -= yy_len ) + 1;
539 if ( yy_state >= YYLAST ||
540 yychk[ yy_state = yyact[ yy_state ] ] != -yy_n )
542 yy_state = yyact[ yypgo[ yy_n ] ];
545 /* save until reenter driver code */
551 ** code supplied by user is placed in this switch
557 goto yystack; /* reset registers in driver code */