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