1 
2 # line 2 "../common/parser.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 (the "License").
8  * You may not use this file except in compliance with the License.
9  *
10  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11  * or http://www.opensolaris.org/os/licensing.
12  * See the License for the specific language governing permissions
13  * and limitations under the License.
14  *
15  * When distributing Covered Code, include this CDDL HEADER in each
16  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17  * If applicable, add the following below this CDDL HEADER, with the
18  * fields enclosed by brackets "[]" replaced with your own identifying
19  * information: Portions Copyright [yyyy] [name of copyright owner]
20  *
21  * CDDL HEADER END
22  */
23 
24 # line 33 "../common/parser.y"
25 #pragma ident	"%Z%%M%	%I%	%E% SMI"
26 
27 /*
28  * Lint is unable to properly handle formats with wide strings
29  * (e.g. %ws) and misdiagnoses them as being malformed.
30  * This macro is used to work around that, by substituting
31  * a pointer to a null string when compiled by lint. This
32  * trick works because lint is not able to evaluate the
33  * variable.
34  *
35  * When lint is able to handle %ws, it would be appropriate
36  * to come back through and remove the use of this macro.
37  */
38 #if defined(__lint)
39 static const char *lint_ws_fmt = "";
40 #define	WSFMT(_fmt) lint_ws_fmt
41 #else
42 #define	WSFMT(_fmt) _fmt
43 #endif
44 
45 void yyerror(char *);
46 
47 # define CHAR 257
48 # define CCL 258
49 # define NCCL 259
50 # define STR 260
51 # define DELIM 261
52 # define SCON 262
53 # define ITER 263
54 # define NEWE 264
55 # define NULLS 265
56 # define XSCON 266
57 # define ARRAY 267
58 # define POINTER 268
59 # define CAT 269
60 
61 # line 78 "../common/parser.y"
62 #include "ldefs.h"
63 
64 #define YYSTYPE union _yystype_
65 union _yystype_
66 {
67 	int	i;
68 	CHR	*cp;
69 };
70 int	peekon = 0; /* need this to check if "^" came in a definition section */
71 
72 
73 #include <inttypes.h>
74 
75 #ifdef __STDC__
76 #include <stdlib.h>
77 #include <string.h>
78 #define	YYCONST	const
79 #else
80 #include <malloc.h>
81 #include <memory.h>
82 #define	YYCONST
83 #endif
84 
85 #include <values.h>
86 
87 #if defined(__cplusplus) || defined(__STDC__)
88 
89 #if defined(__cplusplus) && defined(__EXTERN_C__)
90 extern "C" {
91 #endif
92 #ifndef yyerror
93 #if defined(__cplusplus)
94 	void yyerror(YYCONST char *);
95 #endif
96 #endif
97 #ifndef yylex
98 	int yylex(void);
99 #endif
100 	int yyparse(void);
101 #if defined(__cplusplus) && defined(__EXTERN_C__)
102 }
103 #endif
104 
105 #endif
106 
107 #define yyclearin yychar = -1
108 #define yyerrok yyerrflag = 0
109 extern int yychar;
110 extern int yyerrflag;
111 #ifndef YYSTYPE
112 #define YYSTYPE int
113 #endif
114 YYSTYPE yylval;
115 YYSTYPE yyval;
116 typedef int yytabelem;
117 #ifndef YYMAXDEPTH
118 #define YYMAXDEPTH 150
119 #endif
120 #if YYMAXDEPTH > 0
121 int yy_yys[YYMAXDEPTH], *yys = yy_yys;
122 YYSTYPE yy_yyv[YYMAXDEPTH], *yyv = yy_yyv;
123 #else	/* user does initial allocation */
124 int *yys;
125 YYSTYPE *yyv;
126 #endif
127 static int yymaxdepth = YYMAXDEPTH;
128 
129 # line 91 "../common/parser.y"
130 int i;
131 int j,k;
132 int g;
133 CHR *p;
134 static wchar_t  L_PctUpT[]= {'%', 'T', 0};
135 static wchar_t  L_PctLoT[]= {'%', 't', 0};
136 static wchar_t  L_PctCbr[]= {'%', '}', 0};
137 # define YYERRCODE 256
138 
139 # line 294 "../common/parser.y"
140 
141 int
142 yylex(void)
143 {
144 	CHR *p;
145 	int  i;
146 	CHR *xp;
147 	int lex_startcond_lookupval;
148 	CHR  *t, c;
149 	int n, j = 0, k, x;
150 	CHR ch;
151 	static int sectbegin;
152 	static CHR token[TOKENSIZE];
153 	static int iter;
154 	int ccs; /* Current CodeSet. */
155 	CHR *ccp;
156 	int exclusive_flag;	/* XCU4: exclusive start flag */
157 
158 # ifdef DEBUG
159 	yylval.i = 0;
160 # endif
161 
162 	if(sect == DEFSECTION) {		/* definitions section */
163 		while(!eof) {
164 			if(prev == '\n'){    /* next char is at beginning of line */
165 				(void)getl(p=buf);
166 				switch(*p){
167 				case '%':
168 					switch(c= *(p+1)){
169 					case '%':
170 						/*LINTED: E_BAD_PTR_CAST_ALIGN*/
171 						if(scomp(p, (CHR *)"%%")) {
172 							p++;
173 							while(*(++p))
174 								if(!space(*p)) {
175 									warning("invalid string following %%%% be ignored");
176 									break;
177 								}
178 						}
179 						lgate();
180 						if(!ratfor)(void) fprintf(fout,"# ");
181 						(void) fprintf(fout,"define YYNEWLINE %d\n",ctable['\n']);
182 						if(!ratfor)(void) fprintf(fout,"int yylex(){\nint nstr; extern int yyprevious;\n");
183 						sectbegin = TRUE;
184 						i = treesize*(sizeof(*name)+sizeof(*left)+
185 							sizeof(*right)+sizeof(*nullstr)+sizeof(*parent))+ALITTLEEXTRA;
186 						c = (int)myalloc(i,1);
187 						if(c == 0)
188 							error("Too little core for parse tree");
189 						p = (CHR *)c;
190 						free(p);
191 						/*LINTED: E_BAD_PTR_CAST_ALIGN*/
192 						name = (int *)myalloc(treesize,sizeof(*name));
193 						/*LINTED: E_BAD_PTR_CAST_ALIGN*/
194 						left = (int *)myalloc(treesize,sizeof(*left));
195 						/*LINTED: E_BAD_PTR_CAST_ALIGN*/
196 						right = (int *)myalloc(treesize,sizeof(*right));
197 						nullstr = myalloc(treesize,sizeof(*nullstr));
198 						/*LINTED: E_BAD_PTR_CAST_ALIGN*/
199 						parent = (int *)myalloc(treesize,sizeof(*parent));
200 						if(name == 0 || left == 0 || right == 0 || parent == 0 || nullstr == 0)
201 							error("Too little core for parse tree");
202 						return(freturn(DELIM));
203 					case 'p': case 'P':
204 					        /* %p or %pointer */
205 						if ((*(p+2) == 'o') ||
206 						    (*(p+2) == 'O')) {
207 						    if(lgatflg)
208 							error("Too late for %%pointer");
209 						    while(*p && !iswspace(*p))
210 							p++;
211 						    isArray = 0;
212 						    continue;
213 						}
214 						/* has overridden number of positions */
215 						p += 2;
216 						maxpos = siconv(p);
217 						if (maxpos<=0)error("illegal position number");
218 # ifdef DEBUG
219 						if (debug) (void) printf("positions (%%p) now %d\n",maxpos);
220 # endif
221 						if(report == 2)report = 1;
222 						continue;
223 					case 'n': case 'N':	/* has overridden number of states */
224 						p += 2;
225 						nstates = siconv(p);
226 						if(nstates<=0)error("illegal state number");
227 # ifdef DEBUG
228 						if(debug)(void) printf( " no. states (%%n) now %d\n",nstates);
229 # endif
230 						if(report == 2)report = 1;
231 						continue;
232 					case 'e': case 'E':		/* has overridden number of tree nodes */
233 						p += 2;
234 						treesize = siconv(p);
235 						if(treesize<=0)error("illegal number of parse tree nodes");
236 # ifdef DEBUG
237 						if (debug) (void) printf("treesize (%%e) now %d\n",treesize);
238 # endif
239 						if(report == 2)report = 1;
240 						continue;
241 					case 'o': case 'O':
242 						p += 2;
243 						outsize = siconv(p);
244 						if(outsize<=0)error("illegal size of output array");
245 						if (report ==2) report=1;
246 						continue;
247 					case 'a': case 'A':
248 					        /* %a or %array */
249 						if ((*(p+2) == 'r') ||
250 						    (*(p+2) == 'R')) {
251 						    if(lgatflg)
252 							error("Too late for %%array");
253 						    while(*p && !iswspace(*p))
254 							p++;
255 						    isArray = 1;
256 						    continue;
257 						}
258 						/* has overridden number of transitions */
259 						p += 2;
260 						ntrans = siconv(p);
261 						if(ntrans<=0)error("illegal translation number");
262 # ifdef DEBUG
263 						if (debug)(void) printf("N. trans (%%a) now %d\n",ntrans);
264 # endif
265 						if(report == 2)report = 1;
266 						continue;
267 					case 'k': case 'K': /* overriden packed char classes */
268 						p += 2;
269 						free(pchar);
270 						pchlen = siconv(p);
271 						if(pchlen<=0)error("illegal number of packed character class");
272 # ifdef DEBUG
273 						if (debug) (void) printf( "Size classes (%%k) now %d\n",pchlen);
274 # endif
275 						/*LINTED: E_BAD_PTR_CAST_ALIGN*/
276 						pchar=pcptr=(CHR *)myalloc(pchlen, sizeof(*pchar));
277 						if (report==2) report=1;
278 						continue;
279 					case 't': case 'T': 	/* character set specifier */
280 						if(handleeuc)
281 							error("\
282 Character table (%t) is supported only in ASCII compatibility mode.\n");
283 						ZCH = watoi(p+2);
284 						if (ZCH < NCH) ZCH = NCH;
285 						if (ZCH > 2*NCH) error("ch table needs redeclaration");
286 						chset = TRUE;
287 						for(i = 0; i<ZCH; i++)
288 							ctable[i] = 0;
289 						while(getl(p) && scomp(p,L_PctUpT) != 0 && scomp(p,L_PctLoT) != 0){
290 							if((n = siconv(p)) <= 0 || n > ZCH){
291 								error("Character value %d out of range",n);
292 								continue;
293 								}
294 							while(digit(*p)) p++;
295 							if(!iswspace(*p)) error("bad translation format");
296 							while(iswspace(*p)) p++;
297 							t = p;
298 							while(*t){
299 								c = ctrans(&t);
300 								if(ctable[(unsigned)c]){
301 									if (iswprint(c))
302 										warning("Character '%wc' used twice",c);
303 
304 									else
305 										error("Chararter %o used twice",c);
306 									}
307 								else ctable[(unsigned)c] = n;
308 								t++;
309 								}
310 							p = buf;
311 							}
312 						{
313 						char chused[2*NCH]; int kr;
314 						for(i=0; i<ZCH; i++)
315 							chused[i]=0;
316 						for(i=0; i<NCH; i++)
317 							chused[ctable[i]]=1;
318 						for(kr=i=1; i<NCH; i++)
319 							if (ctable[i]==0)
320 								{
321 								while (chused[kr] == 0)
322 									kr++;
323 								ctable[i]=kr;
324 								chused[kr]=1;
325 								}
326 						}
327 						lgate();
328 						continue;
329 					case 'r': case 'R':
330 						c = 'r';
331 						/* FALLTHRU */
332 					case 'c': case 'C':
333 						if(lgatflg)
334 							error("Too late for language specifier");
335 						ratfor = (c == 'r');
336 						continue;
337 					case '{':
338 						lgate();
339 						while(getl(p) && scomp(p, L_PctCbr) != 0)
340 							if(p[0]=='/' && p[1]=='*')
341 								cpycom(p);
342 							else
343 								(void) fprintf(fout,WSFMT("%ws\n"),p);
344 						if(p[0] == '%') continue;
345 						if (*p) error("EOF before %%%%");
346 						else error("EOF before %%}");
347 						break;
348 
349 					case 'x': case 'X':		/* XCU4: exclusive start conditions */
350 						exclusive_flag = 1;
351 						goto start;
352 
353 					case 's': case 'S':		/* start conditions */
354 						exclusive_flag = 0;
355 start:
356 						lgate();
357 
358 						while(*p && !iswspace(*p) && ((*p) != (wchar_t)',')) p++;
359 						n = TRUE;
360 						while(n){
361 							while(*p && (iswspace(*p) || ((*p) == (wchar_t)','))) p++;
362 							t = p;
363 							while(*p && !iswspace(*p) && ((*p) != (wchar_t)',')) {
364 							    if(!isascii(*p))
365 								error("None-ASCII characters in start condition.");
366 							    p++;
367 							}
368 							if(!*p) n = FALSE;
369 							*p++ = 0;
370 							if (*t == 0) continue;
371 							i = sptr*2;
372 							if(!ratfor)(void) fprintf(fout,"# ");
373 							(void) fprintf(fout,WSFMT("define %ws %d\n"),t,i);
374 							scopy(t,sp);
375 							sname[sptr] = sp;
376 							/* XCU4: save exclusive flag with start name */
377 							exclusive[sptr++] = exclusive_flag;
378 							sname[sptr] = 0;	/* required by lookup */
379 							if(sptr >= STARTSIZE)
380 								error("Too many start conditions");
381 							sp += slength(sp) + 1;
382 							if(sp >= schar+STARTCHAR)
383 								error("Start conditions too long");
384 							}
385 						continue;
386 					default:
387 						error("Invalid request %s",p);
388 						continue;
389 						}	/* end of switch after seeing '%' */
390 					break;
391 				case ' ': case '\t':		/* must be code */
392 					lgate();
393 					if( p[1]=='/' && p[2]=='*' ) cpycom(p);
394 					else (void) fprintf(fout, WSFMT("%ws\n"),p);
395 					continue;
396 				case '/':	/* look for comments */
397 					lgate();
398 					if((*(p+1))=='*') cpycom(p);
399 					/* FALLTHRU */
400 				default:		/* definition */
401 					while(*p && !iswspace(*p)) p++;
402 					if(*p == 0)
403 						continue;
404 					prev = *p;
405 					*p = 0;
406 					bptr = p+1;
407 					yylval.cp = (CHR *)buf;
408 					if(digit(buf[0]))
409 						warning("Substitution strings may not begin with digits");
410 					return(freturn(STR));
411 				}
412 			} else { /* still sect 1, but prev != '\n' */
413 				p = bptr;
414 				while(*p && iswspace(*p)) p++;
415 				if(*p == 0)
416 					warning("No translation given - null string assumed");
417 				scopy(p,token);
418 				yylval.cp = (CHR *)token;
419 				prev = '\n';
420 				return(freturn(STR));
421 				}
422 			}
423 		error("unexpected EOF before %%%%");
424 		/* end of section one processing */
425 	} else if(sect == RULESECTION){		/* rules and actions */
426 		lgate();
427 		while(!eof){
428 			static int first_test=TRUE, first_value;
429 			static int reverse=FALSE;
430 			switch(c=gch()){
431 			case '\0':
432 				if(n_error)error_tail();
433 				return(freturn(0));
434 			case '\n':
435 				if(prev == '\n') continue;
436 				x = NEWE;
437 				break;
438 			case ' ':
439 			case '\t':
440 				if(prev == '\n') copy_line = TRUE;
441 				if(sectbegin == TRUE){
442 					(void)cpyact();
443 					copy_line = FALSE;
444 					/*LINTED: E_EQUALITY_NOT_ASSIGNMENT*/
445 					while((c=gch()) && c != '\n');
446 					continue;
447 					}
448 				if(!funcflag)phead2();
449 				funcflag = TRUE;
450 				if(ratfor)(void) fprintf(fout,"%d\n",30000+casecount);
451 				else (void) fprintf(fout,"case %d:\n",casecount);
452 				if(cpyact()){
453 					if(ratfor)(void) fprintf(fout,"goto 30997\n");
454 					else (void) fprintf(fout,"break;\n");
455 					}
456 				/*LINTED: E_EQUALITY_NOT_ASSIGNMENT*/
457 				while((c=gch()) && c != '\n') {
458 					if (c=='/') {
459 						if((c=gch())=='*') {
460 							c=gch();
461 							while(c !=EOF) {
462 								while (c=='*')
463 									if ((c=gch()) == '/') goto w_loop;
464 								c = gch();
465 							}
466 							error("EOF inside comment");
467 						} else
468 							warning("undefined string");
469 					} else if (c=='}')
470 						error("illegal extra \"}\"");
471 				w_loop: ;
472 				}
473 				/* while ((c=gch())== ' ' || c == '\t') ; */
474 				/* if (!space(c)) error("undefined action string"); */
475 				if(peek == ' ' || peek == '\t' || sectbegin == TRUE){
476 					fatal = 0;
477 					n_error++;
478 					error("executable statements should occur right after %%%%");
479 					fatal = 1;
480 					continue;
481 					}
482 				x = NEWE;
483 				break;
484 			case '%':
485 				if(prev != '\n') goto character;
486 				if(peek == '{'){	/* included code */
487 					(void)getl(buf);
488 					while(!eof&& getl(buf) && scomp(L_PctCbr,buf)!=0)
489 						if(buf[0]=='/' && buf[1]=='*')
490 							cpycom(buf);
491 						else
492 							(void) fprintf(fout,WSFMT("%ws\n"),buf);
493 					continue;
494 					}
495 				if(peek == '%'){
496 					c = gch();
497 					c = gch();
498 					x = DELIM;
499 					break;
500 					}
501 				goto character;
502 			case '|':
503 				if(peek == ' ' || peek == '\t' || peek == '\n'){
504 					if(ratfor)(void) fprintf(fout,"%d\n",30000+casecount++);
505 					else (void) fprintf(fout,"case %d:\n",casecount++);
506 					continue;
507 					}
508 				x = '|';
509 				break;
510 			case '$':
511 				if(peek == '\n' || peek == ' ' || peek == '\t' || peek == '|' || peek == '/'){
512 					x = c;
513 					break;
514 					}
515 				goto character;
516 			case '^':
517                                 if(peekon && (prev == '}')){
518                                         x = c;
519                                         break;
520                                 }
521 				if(prev != '\n' && scon != TRUE) goto character;
522 				/* valid only at line begin */
523 				x = c;
524 				break;
525 			case '?':
526 			case '+':
527 			case '*':
528 				if(prev == '\n' ) {
529 					fatal = 0;
530 					n_error++;
531 					error("illegal operator -- %c",c);
532 					fatal = 1;
533 				}
534 				/* FALLTHRU */
535 			case '.':
536 			case '(':
537 			case ')':
538 			case ',':
539 			case '/':
540 				x = c;
541 				break;
542 			case '}':
543 				iter = FALSE;
544 				x = c;
545 				break;
546 			case '{':	/* either iteration or definition */
547 				if(digit(c=gch())){	/* iteration */
548 					iter = TRUE;
549 					if(prev=='{') first_test = TRUE;
550 				ieval:
551 					i = 0;
552 					while(digit(c)){
553 						token[i++] = c;
554 						c = gch();
555 						}
556 					token[i] = 0;
557 					yylval.i = siconv(token);
558 					if(first_test) {
559 						first_test = FALSE;
560 						first_value = yylval.i;
561 					} else
562 						if(first_value>yylval.i)warning("the values between braces are reversed");
563 					ch = c;
564 					munput('c',&ch);
565 					x = ITER;
566 					break;
567 					}
568 				else {		/* definition */
569 					i = 0;
570 					while(c && c!='}'){
571 						token[i++] = c;
572 						if(i >= TOKENSIZE)
573 							error("definition too long");
574 						c = gch();
575 						}
576 					token[i] = 0;
577 					i = lookup(token,def);
578 					if(i < 0)
579 						error("definition %ws not found",token);
580 					else
581 						munput('s',(CHR *)(subs[i]));
582             				if (peek == '^')
583                                                 peekon = 1;
584 					continue;
585 					}
586 			case '<':		/* start condition ? */
587 				if(prev != '\n')  /* not at line begin, not start */
588 					goto character;
589 				t = slptr;
590 				do {
591 					i = 0;
592 					if(!isascii(c = gch()))
593 					    error("Non-ASCII characters in start condition.");
594 					while(c != ',' && c && c != '>'){
595 						token[i++] = c;
596 						if(i >= TOKENSIZE)
597 							error("string name too long");
598 						if(!isascii(c = gch()))
599 						    error("None-ASCII characters in start condition.");
600 						}
601 					token[i] = 0;
602 					if(i == 0)
603 						goto character;
604 					i = lookup(token,sname);
605 					lex_startcond_lookupval = i;
606 					if(i < 0) {
607 						fatal = 0;
608 						n_error++;
609 						error("undefined start condition %ws",token);
610 						fatal = 1;
611 						continue;
612 						}
613 					*slptr++ = i+1;
614 					} while(c && c != '>');
615 				*slptr++ = 0;
616 				/* check if previous value re-usable */
617 				for (xp=slist; xp<t; )
618 					{
619 					if (scomp(xp, t)==0)
620 						break;
621 					while (*xp++);
622 					}
623 				if (xp<t)
624 					{
625 					/* re-use previous pointer to string */
626 					slptr=t;
627 					t=xp;
628 					}
629 				if(slptr > slist+STARTSIZE)	/* note not packed */
630 					error("Too many start conditions used");
631 				yylval.cp = (CHR *)t;
632 
633 				/* XCU4: add XSCON */
634 
635 				if (exclusive[lex_startcond_lookupval])
636 					x = XSCON;
637 				else
638 					x = SCON;
639 				break;
640 			case '"':
641 				i = 0;
642 				/*LINTED: E_EQUALITY_NOT_ASSIGNMENT*/
643 				while((c=gch()) && c != '"' && c != '\n'){
644 					if(c == '\\') c = usescape(c=gch());
645 					remch(c);
646 					token[i++] = c;
647 					if(i >= TOKENSIZE){
648 						warning("String too long");
649 						i = TOKENSIZE-1;
650 						break;
651 						}
652 					}
653 				if(c == '\n') {
654 					yyline--;
655 					warning("Non-terminated string");
656 					yyline++;
657 					}
658 				token[i] = 0;
659 				if(i == 0)x = NULLS;
660 				else if(i == 1){
661 					yylval.i = (unsigned)token[0];
662 					x = CHAR;
663 					}
664 				else {
665 					yylval.cp = (CHR *)token;
666 					x = STR;
667 					}
668 				break;
669 			case '[':
670 				reverse = FALSE;
671 				x = CCL;
672 				if((c = gch()) == '^'){
673 					x = NCCL;
674 					reverse = TRUE;
675 					c = gch();
676 					}
677 				i = 0;
678 				while(c != ']' && c){
679 					static int light=TRUE, ESCAPE=FALSE;
680 					if(c == '-' && prev == '^' && reverse){
681 						symbol[(unsigned)c] = 1;
682 						c = gch();
683 						continue;
684 					}
685 					if(c == '\\') {
686 						c = usescape(c=gch());
687 						ESCAPE = TRUE;
688 					}
689 					if(c=='-' && !ESCAPE && prev!='[' && peek!=']'){
690 					/* range specified */
691 						if (light) {
692 							c = gch();
693 							if(c == '\\')
694 								c=usescape(c=gch());
695 							remch(c);
696 							k = c;
697 							ccs=wcsetno(k);
698 							if(wcsetno(j)!=ccs)
699 							    error("\
700 Character range specified between different codesets.");
701 							if((unsigned)j > (unsigned)k) {
702 								n = j;
703 								j = k;
704 								k = n;
705 								}
706 							if(!handleeuc)
707 							if(!(('A'<=j && k<='Z') ||
708 						     	     ('a'<=j && k<='z') ||
709 						     	     ('0'<=j && k<='9')))
710 								warning("Non-portable Character Class");
711 							token[i++] = RANGE;
712 							token[i++] = j;
713 							token[i++] = k;
714 							light = FALSE;
715 						} else {
716 							error("unmatched hyphen");
717 							if(symbol[(unsigned)c])warning("\"%c\" redefined inside brackets",c);
718 							else symbol[(unsigned)c] = 1;
719 						}
720 						ESCAPE = FALSE;
721 					} else {
722 						j = c;
723 						remch(c);
724 						token[i++] = c; /* Remember whatever.*/
725 						light = TRUE;
726 						ESCAPE = FALSE;
727 					}
728 					c = gch();
729 				}
730 				/* try to pack ccl's */
731 
732 				token[i] = 0;
733 				ccp = ccl;
734 				while (ccp < ccptr && scomp(token, ccp) != 0) ccp++;
735 				if (ccp < ccptr) {  /* found in ccl */
736 				    yylval.cp = ccp;
737 				} else {            /* not in ccl, add it */
738 				    scopy(token,ccptr);
739 				    yylval.cp = ccptr;
740 				    ccptr += slength(token) + 1;
741 				    if(ccptr >= ccl+CCLSIZE)
742 				      error("Too many large character classes");
743 				}
744 				break;
745 			case '\\':
746 				c = usescape(c=gch());
747 			default:
748 			character:
749 				if(iter){	/* second part of an iteration */
750 					iter = FALSE;
751 					if('0' <= c && c <= '9')
752 						goto ieval;
753 					}
754 				remch(c);
755 				if(alpha(peek)){
756 					i = 0;
757 					yylval.cp = (CHR *)token;
758 					token[i++] = c;
759 					while(alpha(peek)) {
760 						remch(token[i++] = gch());
761 						if(i >= TOKENSIZE) {
762 							warning("string too long");
763 							i = TOKENSIZE - 1;
764 							break;
765 							}
766 						}
767 					if(peek == '?' || peek == '*' || peek == '+')
768 						munput('c',&token[--i]);
769 					token[i] = 0;
770 					if(i == 1){
771 						yylval.i = (unsigned)(token[0]);
772 						x = CHAR;
773 						}
774 					else x = STR;
775 					}
776 				else {
777 					yylval.i = (unsigned)c;
778 					x = CHAR;
779 					}
780 				}
781 			scon = FALSE;
782 			peekon = 0;
783 			if((x == SCON) || (x == XSCON))
784 				scon = TRUE;
785 			sectbegin = FALSE;
786 			return(freturn(x));
787 			/* NOTREACHED */
788 			}
789 		}
790 	/* section three */
791 	lgate();
792 	ptail();
793 # ifdef DEBUG
794 	if(debug)
795 		(void) fprintf(fout,"\n/*this comes from section three - debug */\n");
796 # endif
797 
798 	if(getl(buf) && !eof) {
799   		if (sargv[optind] == NULL)
800 			(void) fprintf(fout, "\n# line %d\n", yyline-1);
801 		else
802 			(void) fprintf(fout,
803 				"\n# line %d \"%s\"\n", yyline-1, sargv[optind]);
804 		(void) fprintf(fout,WSFMT("%ws\n"),buf);
805 		while(getl(buf) && !eof)
806 			(void) fprintf(fout,WSFMT("%ws\n"),buf);
807         }
808 
809 	return(freturn(0));
810 	}
811 /* end of yylex */
812 # ifdef DEBUG
813 freturn(i)
814   int i; {
815 	if(yydebug) {
816 		(void) printf("now return ");
817 		if((unsigned)i < NCH) allprint(i);
818 		else (void) printf("%d",i);
819 		(void) printf("   yylval = ");
820 		switch(i){
821 			case STR: case CCL: case NCCL:
822 				strpt(yylval.cp);
823 				break;
824 			case CHAR:
825 				allprint(yylval.i);
826 				break;
827 			default:
828 				(void) printf("%d",yylval.i);
829 				break;
830 			}
831 		(void) putchar('\n');
832 		}
833 	return(i);
834 	}
835 # endif
836 static YYCONST yytabelem yyexca[] ={
837 -1, 0,
838 	260, 8,
839 	261, 8,
840 	-2, 0,
841 -1, 1,
842 	0, -1,
843 	-2, 0,
844 -1, 5,
845 	0, 6,
846 	-2, 0,
847 -1, 8,
848 	0, 6,
849 	-2, 0,
850 	};
851 # define YYNPROD 36
852 # define YYLAST 313
853 static YYCONST yytabelem yyact[]={
854 
855     37,    49,    38,    26,    22,    47,    30,    31,     6,     7,
856     16,    35,    37,     4,    50,     8,    22,    45,    30,    31,
857      3,    10,    16,    35,    30,    31,     2,    32,    11,    22,
858     28,     9,     5,     1,     0,    16,     0,    37,     0,    32,
859     27,    22,     0,    30,    31,    32,     0,    16,    35,     0,
860     22,     0,     0,     0,     0,     0,    16,     0,    21,    37,
861      0,     0,     0,    22,    32,    30,    31,     0,     0,    16,
862     21,     0,     0,    22,     0,    30,    31,     0,     0,    16,
863      0,     0,     0,    21,     0,    34,    32,    22,    33,    30,
864     31,    12,     0,    16,    12,    21,    32,     0,    46,     0,
865     33,     0,     0,     0,    21,    39,    40,    41,    42,     0,
866     32,     0,     0,     0,     0,     0,     0,    21,     0,    43,
867      0,    44,     0,     0,     0,    33,     0,     0,     0,     0,
868      0,     0,     0,     0,     0,     0,     0,     0,     0,    48,
869      0,     0,     0,     0,     0,     0,     0,    33,     0,     0,
870      0,     0,     0,     0,     0,     0,     0,    33,     0,     0,
871      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
872      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
873      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
874      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
875      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
876      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
877      0,    14,    17,    18,    15,     0,    19,    36,     0,    23,
878     20,    24,    25,    14,    17,    18,    15,     0,    19,    36,
879     29,    23,    20,    24,    25,    13,    14,    17,    18,    15,
880      7,    19,     0,     0,    23,    20,    24,    25,    14,    17,
881     18,    15,     0,     0,    36,     0,    23,    14,    17,    18,
882     15,     0,    19,     0,     0,    23,    20,    24,    25,     0,
883     14,    17,    18,    15,     0,     0,    36,     0,    23,     0,
884     14,    17,    18,    15,     0,     0,    36,     0,    23,     0,
885      0,     0,     0,     0,    14,    17,    18,    15,     0,     0,
886     36,     0,    23 };
887 static YYCONST yytabelem yypact[]={
888 
889   -243,-10000000,-10000000,  -252,-10000000,   -11,  -257,-10000000,   -11,-10000000,
890 -10000000,-10000000,   -24,  -262,-10000000,-10000000,-10000000,-10000000,-10000000,    10,
891     10,    10,    10,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,-10000000,
892 -10000000,-10000000,-10000000,    10,   -18,    10,   -27,-10000000,-10000000,     1,
893      1,    33,   -36,    47,    23,  -124,-10000000,-10000000,  -111,-10000000,
894 -10000000 };
895 static YYCONST yytabelem yypgo[]={
896 
897      0,    33,    26,    20,    28,    15,    31,    21,    85 };
898 static YYCONST yytabelem yyr1[]={
899 
900      0,     1,     2,     2,     2,     6,     6,     3,     3,     4,
901      5,     5,     7,     7,     8,     8,     8,     8,     8,     8,
902      8,     8,     8,     8,     8,     8,     8,     8,     8,     8,
903      8,     8,     8,     8,     8,     8 };
904 static YYCONST yytabelem yyr2[]={
905 
906      0,     3,     8,     7,     3,     2,     0,     7,     0,     3,
907      5,     3,     5,     5,     3,     3,     3,     3,     3,     5,
908      5,     5,     7,     5,     7,    11,     7,     9,     5,     5,
909      5,     5,     7,     3,     3,     3 };
910 static YYCONST yytabelem yychk[]={
911 
912 -10000000,    -1,    -2,    -3,   256,    -4,   260,   261,    -5,    -6,
913     -7,    -4,    -8,   256,   257,   260,    46,   258,   259,   262,
914    266,    94,    40,   265,   267,   268,   260,    -6,    -7,   264,
915     42,    43,    63,   124,    -8,    47,   263,    36,   264,    -8,
916     -8,    -8,    -8,    -8,    -8,    44,   125,    41,   263,   125,
917    125 };
918 static YYCONST yytabelem yydef[]={
919 
920     -2,    -2,     1,     0,     4,    -2,     0,     9,    -2,     3,
921     11,     5,     0,     0,    14,    15,    16,    17,    18,     0,
922      0,     0,     0,    33,    34,    35,     7,     2,    10,    12,
923     19,    20,    21,     0,    23,     0,     0,    31,    13,    28,
924     29,    30,     0,    22,    24,     0,    26,    32,     0,    27,
925     25 };
926 typedef struct
927 #ifdef __cplusplus
928 	yytoktype
929 #endif
930 {
931 #ifdef __cplusplus
932 const
933 #endif
934 char *t_name; int t_val; } yytoktype;
935 #ifndef YYDEBUG
936 #	define YYDEBUG	0	/* don't allow debugging */
937 #endif
938 
939 #if YYDEBUG
940 
941 yytoktype yytoks[] =
942 {
943 	"CHAR",	257,
944 	"CCL",	258,
945 	"NCCL",	259,
946 	"STR",	260,
947 	"DELIM",	261,
948 	"SCON",	262,
949 	"ITER",	263,
950 	"NEWE",	264,
951 	"NULLS",	265,
952 	"XSCON",	266,
953 	"ARRAY",	267,
954 	"POINTER",	268,
955 	"/",	47,
956 	"$",	36,
957 	"^",	94,
958 	"|",	124,
959 	"(",	40,
960 	".",	46,
961 	"CAT",	269,
962 	"*",	42,
963 	"+",	43,
964 	"?",	63,
965 	"-unknown-",	-1	/* ends search */
966 };
967 
968 #ifdef __cplusplus
969 const
970 #endif
971 char * yyreds[] =
972 {
973 	"-no such reduction-",
974 	"acc : lexinput",
975 	"lexinput : defns delim prods end",
976 	"lexinput : defns delim end",
977 	"lexinput : error",
978 	"end : delim",
979 	"end : /* empty */",
980 	"defns : defns STR STR",
981 	"defns : /* empty */",
982 	"delim : DELIM",
983 	"prods : prods pr",
984 	"prods : pr",
985 	"pr : r NEWE",
986 	"pr : error NEWE",
987 	"r : CHAR",
988 	"r : STR",
989 	"r : '.'",
990 	"r : CCL",
991 	"r : NCCL",
992 	"r : r '*'",
993 	"r : r '+'",
994 	"r : r '?'",
995 	"r : r '|' r",
996 	"r : r r",
997 	"r : r '/' r",
998 	"r : r ITER ',' ITER '}'",
999 	"r : r ITER '}'",
1000 	"r : r ITER ',' '}'",
1001 	"r : SCON r",
1002 	"r : XSCON r",
1003 	"r : '^' r",
1004 	"r : r '$'",
1005 	"r : '(' r ')'",
1006 	"r : NULLS",
1007 	"r : ARRAY",
1008 	"r : POINTER",
1009 };
1010 #endif /* YYDEBUG */
1011 # line	1 "/usr/share/lib/ccs/yaccpar"
1012 /*
1013  * CDDL HEADER START
1014  *
1015  * The contents of this file are subject to the terms of the
1016  * Common Development and Distribution License, Version 1.0 only
1017  * (the "License").  You may not use this file except in compliance
1018  * with the License.
1019  *
1020  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1021  * or http://www.opensolaris.org/os/licensing.
1022  * See the License for the specific language governing permissions
1023  * and limitations under the License.
1024  *
1025  * When distributing Covered Code, include this CDDL HEADER in each
1026  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1027  * If applicable, add the following below this CDDL HEADER, with the
1028  * fields enclosed by brackets "[]" replaced with your own identifying
1029  * information: Portions Copyright [yyyy] [name of copyright owner]
1030  *
1031  * CDDL HEADER END
1032  */
1033 /*
1034  * Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
1035  * Use is subject to license terms.
1036  */
1037 
1038 /* Copyright (c) 1988 AT&T */
1039 /* All Rights Reserved */
1040 
1041 #pragma ident	"%Z%%M%	%I%	%E% SMI"
1042 
1043 /*
1044 ** Skeleton parser driver for yacc output
1045 */
1046 
1047 /*
1048 ** yacc user known macros and defines
1049 */
1050 #define YYERROR		goto yyerrlab
1051 #define YYACCEPT	return(0)
1052 #define YYABORT		return(1)
1053 #define YYBACKUP( newtoken, newvalue )\
1054 {\
1055 	if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
1056 	{\
1057 		yyerror( "syntax error - cannot backup" );\
1058 		goto yyerrlab;\
1059 	}\
1060 	yychar = newtoken;\
1061 	yystate = *yyps;\
1062 	yylval = newvalue;\
1063 	goto yynewstate;\
1064 }
1065 #define YYRECOVERING()	(!!yyerrflag)
1066 #define YYNEW(type)	malloc(sizeof(type) * yynewmax)
1067 #define YYCOPY(to, from, type) \
1068 	(type *) memcpy(to, (char *) from, yymaxdepth * sizeof (type))
1069 #define YYENLARGE( from, type) \
1070 	(type *) realloc((char *) from, yynewmax * sizeof(type))
1071 #ifndef YYDEBUG
1072 #	define YYDEBUG	1	/* make debugging available */
1073 #endif
1074 
1075 /*
1076 ** user known globals
1077 */
1078 int yydebug;			/* set to 1 to get debugging */
1079 
1080 /*
1081 ** driver internal defines
1082 */
1083 #define YYFLAG		(-10000000)
1084 
1085 /*
1086 ** global variables used by the parser
1087 */
1088 YYSTYPE *yypv;			/* top of value stack */
1089 int *yyps;			/* top of state stack */
1090 
1091 int yystate;			/* current state */
1092 int yytmp;			/* extra var (lasts between blocks) */
1093 
1094 int yynerrs;			/* number of errors */
1095 int yyerrflag;			/* error recovery flag */
1096 int yychar;			/* current input token number */
1097 
1098 
1099 
1100 #ifdef YYNMBCHARS
1101 #define YYLEX()		yycvtok(yylex())
1102 /*
1103 ** yycvtok - return a token if i is a wchar_t value that exceeds 255.
1104 **	If i<255, i itself is the token.  If i>255 but the neither
1105 **	of the 30th or 31st bit is on, i is already a token.
1106 */
1107 #if defined(__STDC__) || defined(__cplusplus)
1108 int yycvtok(int i)
1109 #else
1110 int yycvtok(i) int i;
1111 #endif
1112 {
1113 	int first = 0;
1114 	int last = YYNMBCHARS - 1;
1115 	int mid;
1116 	wchar_t j;
1117 
1118 	if(i&0x60000000){/*Must convert to a token. */
1119 		if( yymbchars[last].character < i ){
1120 			return i;/*Giving up*/
1121 		}
1122 		while ((last>=first)&&(first>=0)) {/*Binary search loop*/
1123 			mid = (first+last)/2;
1124 			j = yymbchars[mid].character;
1125 			if( j==i ){/*Found*/
1126 				return yymbchars[mid].tvalue;
1127 			}else if( j<i ){
1128 				first = mid + 1;
1129 			}else{
1130 				last = mid -1;
1131 			}
1132 		}
1133 		/*No entry in the table.*/
1134 		return i;/* Giving up.*/
1135 	}else{/* i is already a token. */
1136 		return i;
1137 	}
1138 }
1139 #else/*!YYNMBCHARS*/
1140 #define YYLEX()		yylex()
1141 #endif/*!YYNMBCHARS*/
1142 
1143 /*
1144 ** yyparse - return 0 if worked, 1 if syntax error not recovered from
1145 */
1146 #if defined(__STDC__) || defined(__cplusplus)
1147 int yyparse(void)
1148 #else
1149 int yyparse()
1150 #endif
1151 {
1152 	register YYSTYPE *yypvt = 0;	/* top of value stack for $vars */
1153 
1154 #if defined(__cplusplus) || defined(lint)
1155 /*
1156 	hacks to please C++ and lint - goto's inside
1157 	switch should never be executed
1158 */
1159 	static int __yaccpar_lint_hack__ = 0;
1160 	switch (__yaccpar_lint_hack__)
1161 	{
1162 		case 1: goto yyerrlab;
1163 		case 2: goto yynewstate;
1164 	}
1165 #endif
1166 
1167 	/*
1168 	** Initialize externals - yyparse may be called more than once
1169 	*/
1170 	yypv = &yyv[-1];
1171 	yyps = &yys[-1];
1172 	yystate = 0;
1173 	yytmp = 0;
1174 	yynerrs = 0;
1175 	yyerrflag = 0;
1176 	yychar = -1;
1177 
1178 #if YYMAXDEPTH <= 0
1179 	if (yymaxdepth <= 0)
1180 	{
1181 		if ((yymaxdepth = YYEXPAND(0)) <= 0)
1182 		{
1183 			yyerror("yacc initialization error");
1184 			YYABORT;
1185 		}
1186 	}
1187 #endif
1188 
1189 	{
1190 		register YYSTYPE *yy_pv;	/* top of value stack */
1191 		register int *yy_ps;		/* top of state stack */
1192 		register int yy_state;		/* current state */
1193 		register int  yy_n;		/* internal state number info */
1194 	goto yystack;	/* moved from 6 lines above to here to please C++ */
1195 
1196 		/*
1197 		** get globals into registers.
1198 		** branch to here only if YYBACKUP was called.
1199 		*/
1200 	yynewstate:
1201 		yy_pv = yypv;
1202 		yy_ps = yyps;
1203 		yy_state = yystate;
1204 		goto yy_newstate;
1205 
1206 		/*
1207 		** get globals into registers.
1208 		** either we just started, or we just finished a reduction
1209 		*/
1210 	yystack:
1211 		yy_pv = yypv;
1212 		yy_ps = yyps;
1213 		yy_state = yystate;
1214 
1215 		/*
1216 		** top of for (;;) loop while no reductions done
1217 		*/
1218 	yy_stack:
1219 		/*
1220 		** put a state and value onto the stacks
1221 		*/
1222 #if YYDEBUG
1223 		/*
1224 		** if debugging, look up token value in list of value vs.
1225 		** name pairs.  0 and negative (-1) are special values.
1226 		** Note: linear search is used since time is not a real
1227 		** consideration while debugging.
1228 		*/
1229 		if ( yydebug )
1230 		{
1231 			register int yy_i;
1232 
1233 			printf( "State %d, token ", yy_state );
1234 			if ( yychar == 0 )
1235 				printf( "end-of-file\n" );
1236 			else if ( yychar < 0 )
1237 				printf( "-none-\n" );
1238 			else
1239 			{
1240 				for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
1241 					yy_i++ )
1242 				{
1243 					if ( yytoks[yy_i].t_val == yychar )
1244 						break;
1245 				}
1246 				printf( "%s\n", yytoks[yy_i].t_name );
1247 			}
1248 		}
1249 #endif /* YYDEBUG */
1250 		if ( ++yy_ps >= &yys[ yymaxdepth ] )	/* room on stack? */
1251 		{
1252 			/*
1253 			** reallocate and recover.  Note that pointers
1254 			** have to be reset, or bad things will happen
1255 			*/
1256 			long yyps_index = (yy_ps - yys);
1257 			long yypv_index = (yy_pv - yyv);
1258 			long yypvt_index = (yypvt - yyv);
1259 			int yynewmax;
1260 #ifdef YYEXPAND
1261 			yynewmax = YYEXPAND(yymaxdepth);
1262 #else
1263 			yynewmax = 2 * yymaxdepth;	/* double table size */
1264 			if (yymaxdepth == YYMAXDEPTH)	/* first time growth */
1265 			{
1266 				char *newyys = (char *)YYNEW(int);
1267 				char *newyyv = (char *)YYNEW(YYSTYPE);
1268 				if (newyys != 0 && newyyv != 0)
1269 				{
1270 					yys = YYCOPY(newyys, yys, int);
1271 					yyv = YYCOPY(newyyv, yyv, YYSTYPE);
1272 				}
1273 				else
1274 					yynewmax = 0;	/* failed */
1275 			}
1276 			else				/* not first time */
1277 			{
1278 				yys = YYENLARGE(yys, int);
1279 				yyv = YYENLARGE(yyv, YYSTYPE);
1280 				if (yys == 0 || yyv == 0)
1281 					yynewmax = 0;	/* failed */
1282 			}
1283 #endif
1284 			if (yynewmax <= yymaxdepth)	/* tables not expanded */
1285 			{
1286 				yyerror( "yacc stack overflow" );
1287 				YYABORT;
1288 			}
1289 			yymaxdepth = yynewmax;
1290 
1291 			yy_ps = yys + yyps_index;
1292 			yy_pv = yyv + yypv_index;
1293 			yypvt = yyv + yypvt_index;
1294 		}
1295 		*yy_ps = yy_state;
1296 		*++yy_pv = yyval;
1297 
1298 		/*
1299 		** we have a new state - find out what to do
1300 		*/
1301 	yy_newstate:
1302 		if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )
1303 			goto yydefault;		/* simple state */
1304 #if YYDEBUG
1305 		/*
1306 		** if debugging, need to mark whether new token grabbed
1307 		*/
1308 		yytmp = yychar < 0;
1309 #endif
1310 		if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) )
1311 			yychar = 0;		/* reached EOF */
1312 #if YYDEBUG
1313 		if ( yydebug && yytmp )
1314 		{
1315 			register int yy_i;
1316 
1317 			printf( "Received token " );
1318 			if ( yychar == 0 )
1319 				printf( "end-of-file\n" );
1320 			else if ( yychar < 0 )
1321 				printf( "-none-\n" );
1322 			else
1323 			{
1324 				for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
1325 					yy_i++ )
1326 				{
1327 					if ( yytoks[yy_i].t_val == yychar )
1328 						break;
1329 				}
1330 				printf( "%s\n", yytoks[yy_i].t_name );
1331 			}
1332 		}
1333 #endif /* YYDEBUG */
1334 		if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )
1335 			goto yydefault;
1336 		if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar )	/*valid shift*/
1337 		{
1338 			yychar = -1;
1339 			yyval = yylval;
1340 			yy_state = yy_n;
1341 			if ( yyerrflag > 0 )
1342 				yyerrflag--;
1343 			goto yy_stack;
1344 		}
1345 
1346 	yydefault:
1347 		if ( ( yy_n = yydef[ yy_state ] ) == -2 )
1348 		{
1349 #if YYDEBUG
1350 			yytmp = yychar < 0;
1351 #endif
1352 			if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) )
1353 				yychar = 0;		/* reached EOF */
1354 #if YYDEBUG
1355 			if ( yydebug && yytmp )
1356 			{
1357 				register int yy_i;
1358 
1359 				printf( "Received token " );
1360 				if ( yychar == 0 )
1361 					printf( "end-of-file\n" );
1362 				else if ( yychar < 0 )
1363 					printf( "-none-\n" );
1364 				else
1365 				{
1366 					for ( yy_i = 0;
1367 						yytoks[yy_i].t_val >= 0;
1368 						yy_i++ )
1369 					{
1370 						if ( yytoks[yy_i].t_val
1371 							== yychar )
1372 						{
1373 							break;
1374 						}
1375 					}
1376 					printf( "%s\n", yytoks[yy_i].t_name );
1377 				}
1378 			}
1379 #endif /* YYDEBUG */
1380 			/*
1381 			** look through exception table
1382 			*/
1383 			{
1384 				register YYCONST int *yyxi = yyexca;
1385 
1386 				while ( ( *yyxi != -1 ) ||
1387 					( yyxi[1] != yy_state ) )
1388 				{
1389 					yyxi += 2;
1390 				}
1391 				while ( ( *(yyxi += 2) >= 0 ) &&
1392 					( *yyxi != yychar ) )
1393 					;
1394 				if ( ( yy_n = yyxi[1] ) < 0 )
1395 					YYACCEPT;
1396 			}
1397 		}
1398 
1399 		/*
1400 		** check for syntax error
1401 		*/
1402 		if ( yy_n == 0 )	/* have an error */
1403 		{
1404 			/* no worry about speed here! */
1405 			switch ( yyerrflag )
1406 			{
1407 			case 0:		/* new error */
1408 				yyerror( "syntax error" );
1409 				goto skip_init;
1410 			yyerrlab:
1411 				/*
1412 				** get globals into registers.
1413 				** we have a user generated syntax type error
1414 				*/
1415 				yy_pv = yypv;
1416 				yy_ps = yyps;
1417 				yy_state = yystate;
1418 			skip_init:
1419 				yynerrs++;
1420 				/* FALLTHRU */
1421 			case 1:
1422 			case 2:		/* incompletely recovered error */
1423 					/* try again... */
1424 				yyerrflag = 3;
1425 				/*
1426 				** find state where "error" is a legal
1427 				** shift action
1428 				*/
1429 				while ( yy_ps >= yys )
1430 				{
1431 					yy_n = yypact[ *yy_ps ] + YYERRCODE;
1432 					if ( yy_n >= 0 && yy_n < YYLAST &&
1433 						yychk[yyact[yy_n]] == YYERRCODE)					{
1434 						/*
1435 						** simulate shift of "error"
1436 						*/
1437 						yy_state = yyact[ yy_n ];
1438 						goto yy_stack;
1439 					}
1440 					/*
1441 					** current state has no shift on
1442 					** "error", pop stack
1443 					*/
1444 #if YYDEBUG
1445 #	define _POP_ "Error recovery pops state %d, uncovers state %d\n"
1446 					if ( yydebug )
1447 						printf( _POP_, *yy_ps,
1448 							yy_ps[-1] );
1449 #	undef _POP_
1450 #endif
1451 					yy_ps--;
1452 					yy_pv--;
1453 				}
1454 				/*
1455 				** there is no state on stack with "error" as
1456 				** a valid shift.  give up.
1457 				*/
1458 				YYABORT;
1459 			case 3:		/* no shift yet; eat a token */
1460 #if YYDEBUG
1461 				/*
1462 				** if debugging, look up token in list of
1463 				** pairs.  0 and negative shouldn't occur,
1464 				** but since timing doesn't matter when
1465 				** debugging, it doesn't hurt to leave the
1466 				** tests here.
1467 				*/
1468 				if ( yydebug )
1469 				{
1470 					register int yy_i;
1471 
1472 					printf( "Error recovery discards " );
1473 					if ( yychar == 0 )
1474 						printf( "token end-of-file\n" );
1475 					else if ( yychar < 0 )
1476 						printf( "token -none-\n" );
1477 					else
1478 					{
1479 						for ( yy_i = 0;
1480 							yytoks[yy_i].t_val >= 0;
1481 							yy_i++ )
1482 						{
1483 							if ( yytoks[yy_i].t_val
1484 								== yychar )
1485 							{
1486 								break;
1487 							}
1488 						}
1489 						printf( "token %s\n",
1490 							yytoks[yy_i].t_name );
1491 					}
1492 				}
1493 #endif /* YYDEBUG */
1494 				if ( yychar == 0 )	/* reached EOF. quit */
1495 					YYABORT;
1496 				yychar = -1;
1497 				goto yy_newstate;
1498 			}
1499 		}/* end if ( yy_n == 0 ) */
1500 		/*
1501 		** reduction by production yy_n
1502 		** put stack tops, etc. so things right after switch
1503 		*/
1504 #if YYDEBUG
1505 		/*
1506 		** if debugging, print the string that is the user's
1507 		** specification of the reduction which is just about
1508 		** to be done.
1509 		*/
1510 		if ( yydebug )
1511 			printf( "Reduce by (%d) \"%s\"\n",
1512 				yy_n, yyreds[ yy_n ] );
1513 #endif
1514 		yytmp = yy_n;			/* value to switch over */
1515 		yypvt = yy_pv;			/* $vars top of value stack */
1516 		/*
1517 		** Look in goto table for next state
1518 		** Sorry about using yy_state here as temporary
1519 		** register variable, but why not, if it works...
1520 		** If yyr2[ yy_n ] doesn't have the low order bit
1521 		** set, then there is no action to be done for
1522 		** this reduction.  So, no saving & unsaving of
1523 		** registers done.  The only difference between the
1524 		** code just after the if and the body of the if is
1525 		** the goto yy_stack in the body.  This way the test
1526 		** can be made before the choice of what to do is needed.
1527 		*/
1528 		{
1529 			/* length of production doubled with extra bit */
1530 			register int yy_len = yyr2[ yy_n ];
1531 
1532 			if ( !( yy_len & 01 ) )
1533 			{
1534 				yy_len >>= 1;
1535 				yyval = ( yy_pv -= yy_len )[1];	/* $$ = $1 */
1536 				yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
1537 					*( yy_ps -= yy_len ) + 1;
1538 				if ( yy_state >= YYLAST ||
1539 					yychk[ yy_state =
1540 					yyact[ yy_state ] ] != -yy_n )
1541 				{
1542 					yy_state = yyact[ yypgo[ yy_n ] ];
1543 				}
1544 				goto yy_stack;
1545 			}
1546 			yy_len >>= 1;
1547 			yyval = ( yy_pv -= yy_len )[1];	/* $$ = $1 */
1548 			yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
1549 				*( yy_ps -= yy_len ) + 1;
1550 			if ( yy_state >= YYLAST ||
1551 				yychk[ yy_state = yyact[ yy_state ] ] != -yy_n )
1552 			{
1553 				yy_state = yyact[ yypgo[ yy_n ] ];
1554 			}
1555 		}
1556 					/* save until reenter driver code */
1557 		yystate = yy_state;
1558 		yyps = yy_ps;
1559 		yypv = yy_pv;
1560 	}
1561 	/*
1562 	** code supplied by user is placed in this switch
1563 	*/
1564 	switch( yytmp )
1565 	{
1566 
1567 case 1:
1568 # line 100 "../common/parser.y"
1569 {
1570 # ifdef DEBUG
1571 		if(debug) sect2dump();
1572 # endif
1573 	} break;
1574 case 3:
1575 # line 108 "../common/parser.y"
1576 {
1577 		if(!funcflag)phead2();
1578 		funcflag = TRUE;
1579 	} break;
1580 case 4:
1581 # line 113 "../common/parser.y"
1582 {
1583 # ifdef DEBUG
1584 		if(debug) {
1585 			sect1dump();
1586 			sect2dump();
1587 			}
1588 # endif
1589 		fatal = 0;
1590 		n_error++;
1591 		error("Illegal definition");
1592 		fatal = 1;
1593 		} break;
1594 case 7:
1595 # line 128 "../common/parser.y"
1596 {	scopy(yypvt[-1].cp,dp);
1597 		def[dptr] = dp;
1598 		dp += slength(yypvt[-1].cp) + 1;
1599 		scopy(yypvt[-0].cp,dp);
1600 		subs[dptr++] = dp;
1601 		if(dptr >= DEFSIZE)
1602 			error("Too many definitions");
1603 		dp += slength(yypvt[-0].cp) + 1;
1604 		if(dp >= dchar+DEFCHAR)
1605 			error("Definitions too long");
1606 		subs[dptr]=def[dptr]=0;	/* for lookup - require ending null */
1607 	} break;
1608 case 9:
1609 # line 143 "../common/parser.y"
1610 {
1611 # ifdef DEBUG
1612 		if(sect == DEFSECTION && debug) sect1dump();
1613 # endif
1614 		sect++;
1615 		} break;
1616 case 10:
1617 # line 151 "../common/parser.y"
1618 {	yyval.i = mn2(RNEWE,yypvt[-1].i,yypvt[-0].i);
1619 		} break;
1620 case 11:
1621 # line 154 "../common/parser.y"
1622 {	yyval.i = yypvt[-0].i;} break;
1623 case 12:
1624 # line 157 "../common/parser.y"
1625 {
1626 		if(divflg == TRUE)
1627 			i = mn1(S1FINAL,casecount);
1628 		else i = mn1(FINAL,casecount);
1629 		yyval.i = mn2(RCAT,yypvt[-1].i,i);
1630 		divflg = FALSE;
1631 		if((++casecount)>NACTIONS)
1632 			error("Too many (>%d) pattern-action rules.", NACTIONS);
1633 		} break;
1634 case 13:
1635 # line 167 "../common/parser.y"
1636 {
1637 # ifdef DEBUG
1638 		if(debug) sect2dump();
1639 # endif
1640 		fatal = 0;
1641 		yyline--;
1642 		n_error++;
1643 		error("Illegal rule");
1644 		fatal = 1;
1645 		yyline++;
1646 		} break;
1647 case 14:
1648 # line 179 "../common/parser.y"
1649 {	yyval.i = mn0(yypvt[-0].i); } break;
1650 case 15:
1651 # line 181 "../common/parser.y"
1652 {
1653 		p = (CHR *)yypvt[-0].cp;
1654 		i = mn0((unsigned)(*p++));
1655 		while(*p)
1656 			i = mn2(RSTR,i,(unsigned)(*p++));
1657 		yyval.i = i;
1658 		} break;
1659 case 16:
1660 # line 189 "../common/parser.y"
1661 {
1662 		yyval.i = mn0(DOT);
1663 		} break;
1664 case 17:
1665 # line 193 "../common/parser.y"
1666 {	yyval.i = mn1(RCCL,yypvt[-0].i); } break;
1667 case 18:
1668 # line 195 "../common/parser.y"
1669 {	yyval.i = mn1(RNCCL,yypvt[-0].i); } break;
1670 case 19:
1671 # line 197 "../common/parser.y"
1672 {	yyval.i = mn1(STAR,yypvt[-1].i); } break;
1673 case 20:
1674 # line 199 "../common/parser.y"
1675 {	yyval.i = mn1(PLUS,yypvt[-1].i); } break;
1676 case 21:
1677 # line 201 "../common/parser.y"
1678 {	yyval.i = mn1(QUEST,yypvt[-1].i); } break;
1679 case 22:
1680 # line 203 "../common/parser.y"
1681 {	yyval.i = mn2(BAR,yypvt[-2].i,yypvt[-0].i); } break;
1682 case 23:
1683 # line 205 "../common/parser.y"
1684 {	yyval.i = mn2(RCAT,yypvt[-1].i,yypvt[-0].i); } break;
1685 case 24:
1686 # line 207 "../common/parser.y"
1687 {	if(!divflg){
1688 			j = mn1(S2FINAL,-casecount);
1689 			i = mn2(RCAT,yypvt[-2].i,j);
1690 			yyval.i = mn2(DIV,i,yypvt[-0].i);
1691 			}
1692 		else {
1693 			yyval.i = mn2(RCAT,yypvt[-2].i,yypvt[-0].i);
1694 			error("illegal extra slash");
1695 			}
1696 		divflg = TRUE;
1697 		} break;
1698 case 25:
1699 # line 219 "../common/parser.y"
1700 {	if(yypvt[-3].i > yypvt[-1].i){
1701 			i = yypvt[-3].i;
1702 			yypvt[-3].i = yypvt[-1].i;
1703 			yypvt[-1].i = i;
1704 			}
1705 		if(yypvt[-1].i <= 0)
1706 			error("iteration range must be positive");
1707 		else {
1708 			j = yypvt[-4].i;
1709 			for(k = 2; k<=yypvt[-3].i;k++)
1710 				j = mn2(RCAT,j,dupl(yypvt[-4].i));
1711 			for(i = yypvt[-3].i+1; i<=yypvt[-1].i; i++){
1712 				g = dupl(yypvt[-4].i);
1713 				for(k=2;k<=i;k++)
1714 					g = mn2(RCAT,g,dupl(yypvt[-4].i));
1715 				j = mn2(BAR,j,g);
1716 				}
1717 			yyval.i = j;
1718 			}
1719 	} break;
1720 case 26:
1721 # line 240 "../common/parser.y"
1722 {
1723 		if(yypvt[-1].i < 0)error("can't have negative iteration");
1724 		else if(yypvt[-1].i == 0) yyval.i = mn0(RNULLS);
1725 		else {
1726 			j = yypvt[-2].i;
1727 			for(k=2;k<=yypvt[-1].i;k++)
1728 				j = mn2(RCAT,j,dupl(yypvt[-2].i));
1729 			yyval.i = j;
1730 			}
1731 		} break;
1732 case 27:
1733 # line 251 "../common/parser.y"
1734 {
1735 				/* from n to infinity */
1736 		if(yypvt[-2].i < 0)error("can't have negative iteration");
1737 		else if(yypvt[-2].i == 0) yyval.i = mn1(STAR,yypvt[-3].i);
1738 		else if(yypvt[-2].i == 1)yyval.i = mn1(PLUS,yypvt[-3].i);
1739 		else {		/* >= 2 iterations minimum */
1740 			j = yypvt[-3].i;
1741 			for(k=2;k<yypvt[-2].i;k++)
1742 				j = mn2(RCAT,j,dupl(yypvt[-3].i));
1743 			k = mn1(PLUS,dupl(yypvt[-3].i));
1744 			yyval.i = mn2(RCAT,j,k);
1745 			}
1746 		} break;
1747 case 28:
1748 # line 265 "../common/parser.y"
1749 {	yyval.i = mn2(RSCON,yypvt[-0].i,(uintptr_t)yypvt[-1].cp); } break;
1750 case 29:
1751 # line 269 "../common/parser.y"
1752 {	yyval.i = mn2(RXSCON,yypvt[-0].i,(uintptr_t)yypvt[-1].cp); } break;
1753 case 30:
1754 # line 271 "../common/parser.y"
1755 {	yyval.i = mn1(CARAT,yypvt[-0].i); } break;
1756 case 31:
1757 # line 273 "../common/parser.y"
1758 {	i = mn0('\n');
1759 		if(!divflg){
1760 			j = mn1(S2FINAL,-casecount);
1761 			k = mn2(RCAT,yypvt[-1].i,j);
1762 			yyval.i = mn2(DIV,k,i);
1763 			}
1764 		else yyval.i = mn2(RCAT,yypvt[-1].i,i);
1765 		divflg = TRUE;
1766 		} break;
1767 case 32:
1768 # line 283 "../common/parser.y"
1769 {	yyval.i = yypvt[-1].i; } break;
1770 case 33:
1771 # line 285 "../common/parser.y"
1772 {	yyval.i = mn0(RNULLS); } break;
1773 case 34:
1774 # line 289 "../common/parser.y"
1775 { isArray = 1; } break;
1776 case 35:
1777 # line 291 "../common/parser.y"
1778 { isArray = 0; } break;
1779 # line	556 "/usr/share/lib/ccs/yaccpar"
1780 	}
1781 	goto yystack;		/* reset registers in driver code */
1782 }
1783 
1784