xref: /illumos-gate/usr/src/cmd/sgs/yacc/common/yaccpar (revision a97db1b7)
17c478bd9Sstevel@tonic-gate/*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate/*
237c478bd9Sstevel@tonic-gate * Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate/* Copyright (c) 1988 AT&T */
287c478bd9Sstevel@tonic-gate/* All Rights Reserved */
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate/*
317c478bd9Sstevel@tonic-gate** Skeleton parser driver for yacc output
327c478bd9Sstevel@tonic-gate*/
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gate/*
357c478bd9Sstevel@tonic-gate** yacc user known macros and defines
367c478bd9Sstevel@tonic-gate*/
377c478bd9Sstevel@tonic-gate#define YYERROR		goto yyerrlab
387c478bd9Sstevel@tonic-gate#define YYACCEPT	return(0)
397c478bd9Sstevel@tonic-gate#define YYABORT		return(1)
407c478bd9Sstevel@tonic-gate#define YYBACKUP( newtoken, newvalue )\
417c478bd9Sstevel@tonic-gate{\
427c478bd9Sstevel@tonic-gate	if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
437c478bd9Sstevel@tonic-gate	{\
447c478bd9Sstevel@tonic-gate		yyerror( "syntax error - cannot backup" );\
457c478bd9Sstevel@tonic-gate		goto yyerrlab;\
467c478bd9Sstevel@tonic-gate	}\
477c478bd9Sstevel@tonic-gate	yychar = newtoken;\
487c478bd9Sstevel@tonic-gate	yystate = *yyps;\
497c478bd9Sstevel@tonic-gate	yylval = newvalue;\
507c478bd9Sstevel@tonic-gate	goto yynewstate;\
517c478bd9Sstevel@tonic-gate}
527c478bd9Sstevel@tonic-gate#define YYRECOVERING()	(!!yyerrflag)
537c478bd9Sstevel@tonic-gate#define YYNEW(type)	malloc(sizeof(type) * yynewmax)
547c478bd9Sstevel@tonic-gate#define YYCOPY(to, from, type) \
557c478bd9Sstevel@tonic-gate	(type *) memcpy(to, (char *) from, yymaxdepth * sizeof (type))
567c478bd9Sstevel@tonic-gate#define YYENLARGE( from, type) \
577c478bd9Sstevel@tonic-gate	(type *) realloc((char *) from, yynewmax * sizeof(type))
587c478bd9Sstevel@tonic-gate#ifndef YYDEBUG
597c478bd9Sstevel@tonic-gate#	define YYDEBUG	1	/* make debugging available */
607c478bd9Sstevel@tonic-gate#endif
617c478bd9Sstevel@tonic-gate
627c478bd9Sstevel@tonic-gate/*
637c478bd9Sstevel@tonic-gate** user known globals
647c478bd9Sstevel@tonic-gate*/
657c478bd9Sstevel@tonic-gateint yydebug;			/* set to 1 to get debugging */
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate/*
687c478bd9Sstevel@tonic-gate** driver internal defines
697c478bd9Sstevel@tonic-gate*/
707c478bd9Sstevel@tonic-gate#define YYFLAG		(-10000000)
717c478bd9Sstevel@tonic-gate
727c478bd9Sstevel@tonic-gate/*
737c478bd9Sstevel@tonic-gate** global variables used by the parser
747c478bd9Sstevel@tonic-gate*/
757c478bd9Sstevel@tonic-gateYYSTYPE *yypv;			/* top of value stack */
767c478bd9Sstevel@tonic-gateint *yyps;			/* top of state stack */
777c478bd9Sstevel@tonic-gate
787c478bd9Sstevel@tonic-gateint yystate;			/* current state */
797c478bd9Sstevel@tonic-gateint yytmp;			/* extra var (lasts between blocks) */
807c478bd9Sstevel@tonic-gate
817c478bd9Sstevel@tonic-gateint yynerrs;			/* number of errors */
827c478bd9Sstevel@tonic-gateint yyerrflag;			/* error recovery flag */
837c478bd9Sstevel@tonic-gateint yychar;			/* current input token number */
847c478bd9Sstevel@tonic-gate
857c478bd9Sstevel@tonic-gate
867c478bd9Sstevel@tonic-gate
877c478bd9Sstevel@tonic-gate#ifdef YYNMBCHARS
887c478bd9Sstevel@tonic-gate#define YYLEX()		yycvtok(yylex())
897c478bd9Sstevel@tonic-gate/*
907c478bd9Sstevel@tonic-gate** yycvtok - return a token if i is a wchar_t value that exceeds 255.
91*a97db1b7SToomas Soome**	If i<255, i itself is the token.  If i>255 but the neither
927c478bd9Sstevel@tonic-gate**	of the 30th or 31st bit is on, i is already a token.
937c478bd9Sstevel@tonic-gate*/
947c478bd9Sstevel@tonic-gateint yycvtok(int i)
957c478bd9Sstevel@tonic-gate{
967c478bd9Sstevel@tonic-gate	int first = 0;
977c478bd9Sstevel@tonic-gate	int last = YYNMBCHARS - 1;
987c478bd9Sstevel@tonic-gate	int mid;
997c478bd9Sstevel@tonic-gate	wchar_t j;
1007c478bd9Sstevel@tonic-gate
1017c478bd9Sstevel@tonic-gate	if(i&0x60000000){/*Must convert to a token. */
1027c478bd9Sstevel@tonic-gate		if( yymbchars[last].character < i ){
1037c478bd9Sstevel@tonic-gate			return i;/*Giving up*/
1047c478bd9Sstevel@tonic-gate		}
1057c478bd9Sstevel@tonic-gate		while ((last>=first)&&(first>=0)) {/*Binary search loop*/
1067c478bd9Sstevel@tonic-gate			mid = (first+last)/2;
1077c478bd9Sstevel@tonic-gate			j = yymbchars[mid].character;
108*a97db1b7SToomas Soome			if( j==i ){/*Found*/
1097c478bd9Sstevel@tonic-gate				return yymbchars[mid].tvalue;
1107c478bd9Sstevel@tonic-gate			}else if( j<i ){
1117c478bd9Sstevel@tonic-gate				first = mid + 1;
1127c478bd9Sstevel@tonic-gate			}else{
1137c478bd9Sstevel@tonic-gate				last = mid -1;
1147c478bd9Sstevel@tonic-gate			}
1157c478bd9Sstevel@tonic-gate		}
1167c478bd9Sstevel@tonic-gate		/*No entry in the table.*/
1177c478bd9Sstevel@tonic-gate		return i;/* Giving up.*/
1187c478bd9Sstevel@tonic-gate	}else{/* i is already a token. */
1197c478bd9Sstevel@tonic-gate		return i;
1207c478bd9Sstevel@tonic-gate	}
1217c478bd9Sstevel@tonic-gate}
1227c478bd9Sstevel@tonic-gate#else/*!YYNMBCHARS*/
1237c478bd9Sstevel@tonic-gate#define YYLEX()		yylex()
1247c478bd9Sstevel@tonic-gate#endif/*!YYNMBCHARS*/
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gate/*
1277c478bd9Sstevel@tonic-gate** yyparse - return 0 if worked, 1 if syntax error not recovered from
1287c478bd9Sstevel@tonic-gate*/
1297c478bd9Sstevel@tonic-gateint yyparse(void)
1307c478bd9Sstevel@tonic-gate{
131*a97db1b7SToomas Soome	YYSTYPE *yypvt = 0;	/* top of value stack for $vars */
1327c478bd9Sstevel@tonic-gate
1337c478bd9Sstevel@tonic-gate#if defined(__cplusplus) || defined(lint)
1347c478bd9Sstevel@tonic-gate/*
1357c478bd9Sstevel@tonic-gate	hacks to please C++ and lint - goto's inside
1367c478bd9Sstevel@tonic-gate	switch should never be executed
1377c478bd9Sstevel@tonic-gate*/
1387c478bd9Sstevel@tonic-gate	static int __yaccpar_lint_hack__ = 0;
1397c478bd9Sstevel@tonic-gate	switch (__yaccpar_lint_hack__)
1407c478bd9Sstevel@tonic-gate	{
1417c478bd9Sstevel@tonic-gate		case 1: goto yyerrlab;
1427c478bd9Sstevel@tonic-gate		case 2: goto yynewstate;
1437c478bd9Sstevel@tonic-gate	}
1447c478bd9Sstevel@tonic-gate#endif
1457c478bd9Sstevel@tonic-gate
1467c478bd9Sstevel@tonic-gate	/*
1477c478bd9Sstevel@tonic-gate	** Initialize externals - yyparse may be called more than once
1487c478bd9Sstevel@tonic-gate	*/
1497c478bd9Sstevel@tonic-gate	yypv = &yyv[-1];
1507c478bd9Sstevel@tonic-gate	yyps = &yys[-1];
1517c478bd9Sstevel@tonic-gate	yystate = 0;
1527c478bd9Sstevel@tonic-gate	yytmp = 0;
1537c478bd9Sstevel@tonic-gate	yynerrs = 0;
1547c478bd9Sstevel@tonic-gate	yyerrflag = 0;
1557c478bd9Sstevel@tonic-gate	yychar = -1;
1567c478bd9Sstevel@tonic-gate
1577c478bd9Sstevel@tonic-gate#if YYMAXDEPTH <= 0
1587c478bd9Sstevel@tonic-gate	if (yymaxdepth <= 0)
1597c478bd9Sstevel@tonic-gate	{
1607c478bd9Sstevel@tonic-gate		if ((yymaxdepth = YYEXPAND(0)) <= 0)
1617c478bd9Sstevel@tonic-gate		{
1627c478bd9Sstevel@tonic-gate			yyerror("yacc initialization error");
1637c478bd9Sstevel@tonic-gate			YYABORT;
1647c478bd9Sstevel@tonic-gate		}
1657c478bd9Sstevel@tonic-gate	}
1667c478bd9Sstevel@tonic-gate#endif
1677c478bd9Sstevel@tonic-gate
1687c478bd9Sstevel@tonic-gate	{
169*a97db1b7SToomas Soome		YYSTYPE *yy_pv;	/* top of value stack */
170*a97db1b7SToomas Soome		int *yy_ps;		/* top of state stack */
171*a97db1b7SToomas Soome		int yy_state;		/* current state */
172*a97db1b7SToomas Soome		int  yy_n;		/* internal state number info */
1737c478bd9Sstevel@tonic-gate	goto yystack;	/* moved from 6 lines above to here to please C++ */
1747c478bd9Sstevel@tonic-gate
1757c478bd9Sstevel@tonic-gate		/*
1767c478bd9Sstevel@tonic-gate		** get globals into registers.
1777c478bd9Sstevel@tonic-gate		** branch to here only if YYBACKUP was called.
1787c478bd9Sstevel@tonic-gate		*/
1797c478bd9Sstevel@tonic-gate	yynewstate:
1807c478bd9Sstevel@tonic-gate		yy_pv = yypv;
1817c478bd9Sstevel@tonic-gate		yy_ps = yyps;
1827c478bd9Sstevel@tonic-gate		yy_state = yystate;
1837c478bd9Sstevel@tonic-gate		goto yy_newstate;
1847c478bd9Sstevel@tonic-gate
1857c478bd9Sstevel@tonic-gate		/*
1867c478bd9Sstevel@tonic-gate		** get globals into registers.
1877c478bd9Sstevel@tonic-gate		** either we just started, or we just finished a reduction
1887c478bd9Sstevel@tonic-gate		*/
1897c478bd9Sstevel@tonic-gate	yystack:
1907c478bd9Sstevel@tonic-gate		yy_pv = yypv;
1917c478bd9Sstevel@tonic-gate		yy_ps = yyps;
1927c478bd9Sstevel@tonic-gate		yy_state = yystate;
1937c478bd9Sstevel@tonic-gate
1947c478bd9Sstevel@tonic-gate		/*
1957c478bd9Sstevel@tonic-gate		** top of for (;;) loop while no reductions done
1967c478bd9Sstevel@tonic-gate		*/
1977c478bd9Sstevel@tonic-gate	yy_stack:
1987c478bd9Sstevel@tonic-gate		/*
1997c478bd9Sstevel@tonic-gate		** put a state and value onto the stacks
2007c478bd9Sstevel@tonic-gate		*/
2017c478bd9Sstevel@tonic-gate#if YYDEBUG
2027c478bd9Sstevel@tonic-gate		/*
2037c478bd9Sstevel@tonic-gate		** if debugging, look up token value in list of value vs.
2047c478bd9Sstevel@tonic-gate		** name pairs.  0 and negative (-1) are special values.
2057c478bd9Sstevel@tonic-gate		** Note: linear search is used since time is not a real
2067c478bd9Sstevel@tonic-gate		** consideration while debugging.
2077c478bd9Sstevel@tonic-gate		*/
2087c478bd9Sstevel@tonic-gate		if ( yydebug )
2097c478bd9Sstevel@tonic-gate		{
210*a97db1b7SToomas Soome			int yy_i;
2117c478bd9Sstevel@tonic-gate
2127c478bd9Sstevel@tonic-gate			printf( "State %d, token ", yy_state );
2137c478bd9Sstevel@tonic-gate			if ( yychar == 0 )
2147c478bd9Sstevel@tonic-gate				printf( "end-of-file\n" );
2157c478bd9Sstevel@tonic-gate			else if ( yychar < 0 )
2167c478bd9Sstevel@tonic-gate				printf( "-none-\n" );
2177c478bd9Sstevel@tonic-gate			else
2187c478bd9Sstevel@tonic-gate			{
2197c478bd9Sstevel@tonic-gate				for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
2207c478bd9Sstevel@tonic-gate					yy_i++ )
2217c478bd9Sstevel@tonic-gate				{
2227c478bd9Sstevel@tonic-gate					if ( yytoks[yy_i].t_val == yychar )
2237c478bd9Sstevel@tonic-gate						break;
2247c478bd9Sstevel@tonic-gate				}
2257c478bd9Sstevel@tonic-gate				printf( "%s\n", yytoks[yy_i].t_name );
2267c478bd9Sstevel@tonic-gate			}
2277c478bd9Sstevel@tonic-gate		}
2287c478bd9Sstevel@tonic-gate#endif /* YYDEBUG */
2297c478bd9Sstevel@tonic-gate		if ( ++yy_ps >= &yys[ yymaxdepth ] )	/* room on stack? */
2307c478bd9Sstevel@tonic-gate		{
2317c478bd9Sstevel@tonic-gate			/*
2327c478bd9Sstevel@tonic-gate			** reallocate and recover.  Note that pointers
2337c478bd9Sstevel@tonic-gate			** have to be reset, or bad things will happen
2347c478bd9Sstevel@tonic-gate			*/
2357c478bd9Sstevel@tonic-gate			long yyps_index = (yy_ps - yys);
2367c478bd9Sstevel@tonic-gate			long yypv_index = (yy_pv - yyv);
2377c478bd9Sstevel@tonic-gate			long yypvt_index = (yypvt - yyv);
2387c478bd9Sstevel@tonic-gate			int yynewmax;
2397c478bd9Sstevel@tonic-gate#ifdef YYEXPAND
2407c478bd9Sstevel@tonic-gate			yynewmax = YYEXPAND(yymaxdepth);
2417c478bd9Sstevel@tonic-gate#else
2427c478bd9Sstevel@tonic-gate			yynewmax = 2 * yymaxdepth;	/* double table size */
2437c478bd9Sstevel@tonic-gate			if (yymaxdepth == YYMAXDEPTH)	/* first time growth */
2447c478bd9Sstevel@tonic-gate			{
2457c478bd9Sstevel@tonic-gate				char *newyys = (char *)YYNEW(int);
2467c478bd9Sstevel@tonic-gate				char *newyyv = (char *)YYNEW(YYSTYPE);
2477c478bd9Sstevel@tonic-gate				if (newyys != 0 && newyyv != 0)
2487c478bd9Sstevel@tonic-gate				{
2497c478bd9Sstevel@tonic-gate					yys = YYCOPY(newyys, yys, int);
2507c478bd9Sstevel@tonic-gate					yyv = YYCOPY(newyyv, yyv, YYSTYPE);
2517c478bd9Sstevel@tonic-gate				}
2527c478bd9Sstevel@tonic-gate				else
2537c478bd9Sstevel@tonic-gate					yynewmax = 0;	/* failed */
2547c478bd9Sstevel@tonic-gate			}
2557c478bd9Sstevel@tonic-gate			else				/* not first time */
2567c478bd9Sstevel@tonic-gate			{
2577c478bd9Sstevel@tonic-gate				yys = YYENLARGE(yys, int);
2587c478bd9Sstevel@tonic-gate				yyv = YYENLARGE(yyv, YYSTYPE);
2597c478bd9Sstevel@tonic-gate				if (yys == 0 || yyv == 0)
2607c478bd9Sstevel@tonic-gate					yynewmax = 0;	/* failed */
2617c478bd9Sstevel@tonic-gate			}
2627c478bd9Sstevel@tonic-gate#endif
2637c478bd9Sstevel@tonic-gate			if (yynewmax <= yymaxdepth)	/* tables not expanded */
2647c478bd9Sstevel@tonic-gate			{
2657c478bd9Sstevel@tonic-gate				yyerror( "yacc stack overflow" );
2667c478bd9Sstevel@tonic-gate				YYABORT;
2677c478bd9Sstevel@tonic-gate			}
2687c478bd9Sstevel@tonic-gate			yymaxdepth = yynewmax;
2697c478bd9Sstevel@tonic-gate
2707c478bd9Sstevel@tonic-gate			yy_ps = yys + yyps_index;
2717c478bd9Sstevel@tonic-gate			yy_pv = yyv + yypv_index;
2727c478bd9Sstevel@tonic-gate			yypvt = yyv + yypvt_index;
2737c478bd9Sstevel@tonic-gate		}
2747c478bd9Sstevel@tonic-gate		*yy_ps = yy_state;
2757c478bd9Sstevel@tonic-gate		*++yy_pv = yyval;
2767c478bd9Sstevel@tonic-gate
2777c478bd9Sstevel@tonic-gate		/*
2787c478bd9Sstevel@tonic-gate		** we have a new state - find out what to do
2797c478bd9Sstevel@tonic-gate		*/
2807c478bd9Sstevel@tonic-gate	yy_newstate:
2817c478bd9Sstevel@tonic-gate		if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )
2827c478bd9Sstevel@tonic-gate			goto yydefault;		/* simple state */
2837c478bd9Sstevel@tonic-gate#if YYDEBUG
2847c478bd9Sstevel@tonic-gate		/*
2857c478bd9Sstevel@tonic-gate		** if debugging, need to mark whether new token grabbed
2867c478bd9Sstevel@tonic-gate		*/
2877c478bd9Sstevel@tonic-gate		yytmp = yychar < 0;
2887c478bd9Sstevel@tonic-gate#endif
2897c478bd9Sstevel@tonic-gate		if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) )
2907c478bd9Sstevel@tonic-gate			yychar = 0;		/* reached EOF */
2917c478bd9Sstevel@tonic-gate#if YYDEBUG
2927c478bd9Sstevel@tonic-gate		if ( yydebug && yytmp )
2937c478bd9Sstevel@tonic-gate		{
294*a97db1b7SToomas Soome			int yy_i;
2957c478bd9Sstevel@tonic-gate
2967c478bd9Sstevel@tonic-gate			printf( "Received token " );
2977c478bd9Sstevel@tonic-gate			if ( yychar == 0 )
2987c478bd9Sstevel@tonic-gate				printf( "end-of-file\n" );
2997c478bd9Sstevel@tonic-gate			else if ( yychar < 0 )
3007c478bd9Sstevel@tonic-gate				printf( "-none-\n" );
3017c478bd9Sstevel@tonic-gate			else
3027c478bd9Sstevel@tonic-gate			{
3037c478bd9Sstevel@tonic-gate				for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
3047c478bd9Sstevel@tonic-gate					yy_i++ )
3057c478bd9Sstevel@tonic-gate				{
3067c478bd9Sstevel@tonic-gate					if ( yytoks[yy_i].t_val == yychar )
3077c478bd9Sstevel@tonic-gate						break;
3087c478bd9Sstevel@tonic-gate				}
3097c478bd9Sstevel@tonic-gate				printf( "%s\n", yytoks[yy_i].t_name );
3107c478bd9Sstevel@tonic-gate			}
3117c478bd9Sstevel@tonic-gate		}
3127c478bd9Sstevel@tonic-gate#endif /* YYDEBUG */
3137c478bd9Sstevel@tonic-gate		if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )
3147c478bd9Sstevel@tonic-gate			goto yydefault;
3157c478bd9Sstevel@tonic-gate		if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar )	/*valid shift*/
3167c478bd9Sstevel@tonic-gate		{
3177c478bd9Sstevel@tonic-gate			yychar = -1;
3187c478bd9Sstevel@tonic-gate			yyval = yylval;
3197c478bd9Sstevel@tonic-gate			yy_state = yy_n;
3207c478bd9Sstevel@tonic-gate			if ( yyerrflag > 0 )
3217c478bd9Sstevel@tonic-gate				yyerrflag--;
3227c478bd9Sstevel@tonic-gate			goto yy_stack;
3237c478bd9Sstevel@tonic-gate		}
3247c478bd9Sstevel@tonic-gate
3257c478bd9Sstevel@tonic-gate	yydefault:
3267c478bd9Sstevel@tonic-gate		if ( ( yy_n = yydef[ yy_state ] ) == -2 )
3277c478bd9Sstevel@tonic-gate		{
3287c478bd9Sstevel@tonic-gate#if YYDEBUG
3297c478bd9Sstevel@tonic-gate			yytmp = yychar < 0;
3307c478bd9Sstevel@tonic-gate#endif
3317c478bd9Sstevel@tonic-gate			if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) )
3327c478bd9Sstevel@tonic-gate				yychar = 0;		/* reached EOF */
3337c478bd9Sstevel@tonic-gate#if YYDEBUG
3347c478bd9Sstevel@tonic-gate			if ( yydebug && yytmp )
3357c478bd9Sstevel@tonic-gate			{
336*a97db1b7SToomas Soome				int yy_i;
3377c478bd9Sstevel@tonic-gate
3387c478bd9Sstevel@tonic-gate				printf( "Received token " );
3397c478bd9Sstevel@tonic-gate				if ( yychar == 0 )
3407c478bd9Sstevel@tonic-gate					printf( "end-of-file\n" );
3417c478bd9Sstevel@tonic-gate				else if ( yychar < 0 )
3427c478bd9Sstevel@tonic-gate					printf( "-none-\n" );
3437c478bd9Sstevel@tonic-gate				else
3447c478bd9Sstevel@tonic-gate				{
3457c478bd9Sstevel@tonic-gate					for ( yy_i = 0;
3467c478bd9Sstevel@tonic-gate						yytoks[yy_i].t_val >= 0;
3477c478bd9Sstevel@tonic-gate						yy_i++ )
3487c478bd9Sstevel@tonic-gate					{
3497c478bd9Sstevel@tonic-gate						if ( yytoks[yy_i].t_val
3507c478bd9Sstevel@tonic-gate							== yychar )
3517c478bd9Sstevel@tonic-gate						{
3527c478bd9Sstevel@tonic-gate							break;
3537c478bd9Sstevel@tonic-gate						}
3547c478bd9Sstevel@tonic-gate					}
3557c478bd9Sstevel@tonic-gate					printf( "%s\n", yytoks[yy_i].t_name );
3567c478bd9Sstevel@tonic-gate				}
3577c478bd9Sstevel@tonic-gate			}
3587c478bd9Sstevel@tonic-gate#endif /* YYDEBUG */
3597c478bd9Sstevel@tonic-gate			/*
3607c478bd9Sstevel@tonic-gate			** look through exception table
3617c478bd9Sstevel@tonic-gate			*/
3627c478bd9Sstevel@tonic-gate			{
363*a97db1b7SToomas Soome				YYCONST int *yyxi = yyexca;
3647c478bd9Sstevel@tonic-gate
3657c478bd9Sstevel@tonic-gate				while ( ( *yyxi != -1 ) ||
3667c478bd9Sstevel@tonic-gate					( yyxi[1] != yy_state ) )
3677c478bd9Sstevel@tonic-gate				{
3687c478bd9Sstevel@tonic-gate					yyxi += 2;
3697c478bd9Sstevel@tonic-gate				}
3707c478bd9Sstevel@tonic-gate				while ( ( *(yyxi += 2) >= 0 ) &&
3717c478bd9Sstevel@tonic-gate					( *yyxi != yychar ) )
3727c478bd9Sstevel@tonic-gate					;
3737c478bd9Sstevel@tonic-gate				if ( ( yy_n = yyxi[1] ) < 0 )
3747c478bd9Sstevel@tonic-gate					YYACCEPT;
3757c478bd9Sstevel@tonic-gate			}
3767c478bd9Sstevel@tonic-gate		}
3777c478bd9Sstevel@tonic-gate
3787c478bd9Sstevel@tonic-gate		/*
3797c478bd9Sstevel@tonic-gate		** check for syntax error
3807c478bd9Sstevel@tonic-gate		*/
3817c478bd9Sstevel@tonic-gate		if ( yy_n == 0 )	/* have an error */
3827c478bd9Sstevel@tonic-gate		{
3837c478bd9Sstevel@tonic-gate			/* no worry about speed here! */
3847c478bd9Sstevel@tonic-gate			switch ( yyerrflag )
3857c478bd9Sstevel@tonic-gate			{
3867c478bd9Sstevel@tonic-gate			case 0:		/* new error */
3877c478bd9Sstevel@tonic-gate				yyerror( "syntax error" );
3887c478bd9Sstevel@tonic-gate				goto skip_init;
3897c478bd9Sstevel@tonic-gate			yyerrlab:
3907c478bd9Sstevel@tonic-gate				/*
3917c478bd9Sstevel@tonic-gate				** get globals into registers.
3927c478bd9Sstevel@tonic-gate				** we have a user generated syntax type error
3937c478bd9Sstevel@tonic-gate				*/
3947c478bd9Sstevel@tonic-gate				yy_pv = yypv;
3957c478bd9Sstevel@tonic-gate				yy_ps = yyps;
3967c478bd9Sstevel@tonic-gate				yy_state = yystate;
3977c478bd9Sstevel@tonic-gate			skip_init:
3987c478bd9Sstevel@tonic-gate				yynerrs++;
3997c478bd9Sstevel@tonic-gate				/* FALLTHRU */
4007c478bd9Sstevel@tonic-gate			case 1:
4017c478bd9Sstevel@tonic-gate			case 2:		/* incompletely recovered error */
4027c478bd9Sstevel@tonic-gate					/* try again... */
4037c478bd9Sstevel@tonic-gate				yyerrflag = 3;
4047c478bd9Sstevel@tonic-gate				/*
4057c478bd9Sstevel@tonic-gate				** find state where "error" is a legal
4067c478bd9Sstevel@tonic-gate				** shift action
4077c478bd9Sstevel@tonic-gate				*/
4087c478bd9Sstevel@tonic-gate				while ( yy_ps >= yys )
4097c478bd9Sstevel@tonic-gate				{
4107c478bd9Sstevel@tonic-gate					yy_n = yypact[ *yy_ps ] + YYERRCODE;
4117c478bd9Sstevel@tonic-gate					if ( yy_n >= 0 && yy_n < YYLAST &&
4127c478bd9Sstevel@tonic-gate						yychk[yyact[yy_n]] == YYERRCODE)					{
4137c478bd9Sstevel@tonic-gate						/*
4147c478bd9Sstevel@tonic-gate						** simulate shift of "error"
4157c478bd9Sstevel@tonic-gate						*/
4167c478bd9Sstevel@tonic-gate						yy_state = yyact[ yy_n ];
4177c478bd9Sstevel@tonic-gate						goto yy_stack;
4187c478bd9Sstevel@tonic-gate					}
4197c478bd9Sstevel@tonic-gate					/*
4207c478bd9Sstevel@tonic-gate					** current state has no shift on
4217c478bd9Sstevel@tonic-gate					** "error", pop stack
4227c478bd9Sstevel@tonic-gate					*/
4237c478bd9Sstevel@tonic-gate#if YYDEBUG
4247c478bd9Sstevel@tonic-gate#	define _POP_ "Error recovery pops state %d, uncovers state %d\n"
4257c478bd9Sstevel@tonic-gate					if ( yydebug )
4267c478bd9Sstevel@tonic-gate						printf( _POP_, *yy_ps,
4277c478bd9Sstevel@tonic-gate							yy_ps[-1] );
4287c478bd9Sstevel@tonic-gate#	undef _POP_
4297c478bd9Sstevel@tonic-gate#endif
4307c478bd9Sstevel@tonic-gate					yy_ps--;
4317c478bd9Sstevel@tonic-gate					yy_pv--;
4327c478bd9Sstevel@tonic-gate				}
4337c478bd9Sstevel@tonic-gate				/*
4347c478bd9Sstevel@tonic-gate				** there is no state on stack with "error" as
4357c478bd9Sstevel@tonic-gate				** a valid shift.  give up.
4367c478bd9Sstevel@tonic-gate				*/
4377c478bd9Sstevel@tonic-gate				YYABORT;
4387c478bd9Sstevel@tonic-gate			case 3:		/* no shift yet; eat a token */
4397c478bd9Sstevel@tonic-gate#if YYDEBUG
4407c478bd9Sstevel@tonic-gate				/*
4417c478bd9Sstevel@tonic-gate				** if debugging, look up token in list of
4427c478bd9Sstevel@tonic-gate				** pairs.  0 and negative shouldn't occur,
4437c478bd9Sstevel@tonic-gate				** but since timing doesn't matter when
4447c478bd9Sstevel@tonic-gate				** debugging, it doesn't hurt to leave the
4457c478bd9Sstevel@tonic-gate				** tests here.
4467c478bd9Sstevel@tonic-gate				*/
4477c478bd9Sstevel@tonic-gate				if ( yydebug )
4487c478bd9Sstevel@tonic-gate				{
449*a97db1b7SToomas Soome					int yy_i;
4507c478bd9Sstevel@tonic-gate
4517c478bd9Sstevel@tonic-gate					printf( "Error recovery discards " );
4527c478bd9Sstevel@tonic-gate					if ( yychar == 0 )
4537c478bd9Sstevel@tonic-gate						printf( "token end-of-file\n" );
4547c478bd9Sstevel@tonic-gate					else if ( yychar < 0 )
4557c478bd9Sstevel@tonic-gate						printf( "token -none-\n" );
4567c478bd9Sstevel@tonic-gate					else
4577c478bd9Sstevel@tonic-gate					{
4587c478bd9Sstevel@tonic-gate						for ( yy_i = 0;
4597c478bd9Sstevel@tonic-gate							yytoks[yy_i].t_val >= 0;
4607c478bd9Sstevel@tonic-gate							yy_i++ )
4617c478bd9Sstevel@tonic-gate						{
4627c478bd9Sstevel@tonic-gate							if ( yytoks[yy_i].t_val
4637c478bd9Sstevel@tonic-gate								== yychar )
4647c478bd9Sstevel@tonic-gate							{
4657c478bd9Sstevel@tonic-gate								break;
4667c478bd9Sstevel@tonic-gate							}
4677c478bd9Sstevel@tonic-gate						}
4687c478bd9Sstevel@tonic-gate						printf( "token %s\n",
4697c478bd9Sstevel@tonic-gate							yytoks[yy_i].t_name );
4707c478bd9Sstevel@tonic-gate					}
4717c478bd9Sstevel@tonic-gate				}
4727c478bd9Sstevel@tonic-gate#endif /* YYDEBUG */
4737c478bd9Sstevel@tonic-gate				if ( yychar == 0 )	/* reached EOF. quit */
4747c478bd9Sstevel@tonic-gate					YYABORT;
4757c478bd9Sstevel@tonic-gate				yychar = -1;
4767c478bd9Sstevel@tonic-gate				goto yy_newstate;
4777c478bd9Sstevel@tonic-gate			}
4787c478bd9Sstevel@tonic-gate		}/* end if ( yy_n == 0 ) */
4797c478bd9Sstevel@tonic-gate		/*
4807c478bd9Sstevel@tonic-gate		** reduction by production yy_n
4817c478bd9Sstevel@tonic-gate		** put stack tops, etc. so things right after switch
4827c478bd9Sstevel@tonic-gate		*/
4837c478bd9Sstevel@tonic-gate#if YYDEBUG
4847c478bd9Sstevel@tonic-gate		/*
4857c478bd9Sstevel@tonic-gate		** if debugging, print the string that is the user's
4867c478bd9Sstevel@tonic-gate		** specification of the reduction which is just about
4877c478bd9Sstevel@tonic-gate		** to be done.
4887c478bd9Sstevel@tonic-gate		*/
4897c478bd9Sstevel@tonic-gate		if ( yydebug )
4907c478bd9Sstevel@tonic-gate			printf( "Reduce by (%d) \"%s\"\n",
4917c478bd9Sstevel@tonic-gate				yy_n, yyreds[ yy_n ] );
4927c478bd9Sstevel@tonic-gate#endif
4937c478bd9Sstevel@tonic-gate		yytmp = yy_n;			/* value to switch over */
4947c478bd9Sstevel@tonic-gate		yypvt = yy_pv;			/* $vars top of value stack */
4957c478bd9Sstevel@tonic-gate		/*
4967c478bd9Sstevel@tonic-gate		** Look in goto table for next state
4977c478bd9Sstevel@tonic-gate		** Sorry about using yy_state here as temporary
4987c478bd9Sstevel@tonic-gate		** register variable, but why not, if it works...
4997c478bd9Sstevel@tonic-gate		** If yyr2[ yy_n ] doesn't have the low order bit
5007c478bd9Sstevel@tonic-gate		** set, then there is no action to be done for
5017c478bd9Sstevel@tonic-gate		** this reduction.  So, no saving & unsaving of
5027c478bd9Sstevel@tonic-gate		** registers done.  The only difference between the
5037c478bd9Sstevel@tonic-gate		** code just after the if and the body of the if is
5047c478bd9Sstevel@tonic-gate		** the goto yy_stack in the body.  This way the test
5057c478bd9Sstevel@tonic-gate		** can be made before the choice of what to do is needed.
5067c478bd9Sstevel@tonic-gate		*/
5077c478bd9Sstevel@tonic-gate		{
5087c478bd9Sstevel@tonic-gate			/* length of production doubled with extra bit */
509*a97db1b7SToomas Soome			int yy_len = yyr2[ yy_n ];
5107c478bd9Sstevel@tonic-gate
5117c478bd9Sstevel@tonic-gate			if ( !( yy_len & 01 ) )
5127c478bd9Sstevel@tonic-gate			{
5137c478bd9Sstevel@tonic-gate				yy_len >>= 1;
5147c478bd9Sstevel@tonic-gate				yyval = ( yy_pv -= yy_len )[1];	/* $$ = $1 */
5157c478bd9Sstevel@tonic-gate				yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
5167c478bd9Sstevel@tonic-gate					*( yy_ps -= yy_len ) + 1;
5177c478bd9Sstevel@tonic-gate				if ( yy_state >= YYLAST ||
5187c478bd9Sstevel@tonic-gate					yychk[ yy_state =
5197c478bd9Sstevel@tonic-gate					yyact[ yy_state ] ] != -yy_n )
5207c478bd9Sstevel@tonic-gate				{
5217c478bd9Sstevel@tonic-gate					yy_state = yyact[ yypgo[ yy_n ] ];
5227c478bd9Sstevel@tonic-gate				}
5237c478bd9Sstevel@tonic-gate				goto yy_stack;
5247c478bd9Sstevel@tonic-gate			}
5257c478bd9Sstevel@tonic-gate			yy_len >>= 1;
5267c478bd9Sstevel@tonic-gate			yyval = ( yy_pv -= yy_len )[1];	/* $$ = $1 */
5277c478bd9Sstevel@tonic-gate			yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
5287c478bd9Sstevel@tonic-gate				*( yy_ps -= yy_len ) + 1;
5297c478bd9Sstevel@tonic-gate			if ( yy_state >= YYLAST ||
5307c478bd9Sstevel@tonic-gate				yychk[ yy_state = yyact[ yy_state ] ] != -yy_n )
5317c478bd9Sstevel@tonic-gate			{
5327c478bd9Sstevel@tonic-gate				yy_state = yyact[ yypgo[ yy_n ] ];
5337c478bd9Sstevel@tonic-gate			}
5347c478bd9Sstevel@tonic-gate		}
5357c478bd9Sstevel@tonic-gate					/* save until reenter driver code */
5367c478bd9Sstevel@tonic-gate		yystate = yy_state;
5377c478bd9Sstevel@tonic-gate		yyps = yy_ps;
5387c478bd9Sstevel@tonic-gate		yypv = yy_pv;
5397c478bd9Sstevel@tonic-gate	}
5407c478bd9Sstevel@tonic-gate	/*
5417c478bd9Sstevel@tonic-gate	** code supplied by user is placed in this switch
5427c478bd9Sstevel@tonic-gate	*/
5437c478bd9Sstevel@tonic-gate	switch( yytmp )
5447c478bd9Sstevel@tonic-gate	{
5457c478bd9Sstevel@tonic-gate		$A
5467c478bd9Sstevel@tonic-gate	}
5477c478bd9Sstevel@tonic-gate	goto yystack;		/* reset registers in driver code */
5487c478bd9Sstevel@tonic-gate}
549