xref: /illumos-gate/usr/src/cmd/sgs/lex/common/parser.y (revision 1e819975)
17c478bd9Sstevel@tonic-gate %{
27c478bd9Sstevel@tonic-gate /*
37c478bd9Sstevel@tonic-gate  * CDDL HEADER START
47c478bd9Sstevel@tonic-gate  *
57c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
667298654Sdamico  * Common Development and Distribution License (the "License").
767298654Sdamico  * You may not use this file except in compliance 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 /*
241dd08564Sab  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
297c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate %{
337c478bd9Sstevel@tonic-gate 
341dd08564Sab /*
351dd08564Sab  * Lint is unable to properly handle formats with wide strings
361dd08564Sab  * (e.g. %ws) and misdiagnoses them as being malformed.
371dd08564Sab  * This macro is used to work around that, by substituting
381dd08564Sab  * a pointer to a null string when compiled by lint. This
391dd08564Sab  * trick works because lint is not able to evaluate the
401dd08564Sab  * variable.
411dd08564Sab  *
421dd08564Sab  * When lint is able to handle %ws, it would be appropriate
431dd08564Sab  * to come back through and remove the use of this macro.
441dd08564Sab  */
451dd08564Sab #if defined(__lint)
461dd08564Sab static const char *lint_ws_fmt = "";
471dd08564Sab #define	WSFMT(_fmt) lint_ws_fmt
481dd08564Sab #else
491dd08564Sab #define	WSFMT(_fmt) _fmt
501dd08564Sab #endif
511dd08564Sab 
527c478bd9Sstevel@tonic-gate void yyerror(char *);
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate %}
557c478bd9Sstevel@tonic-gate /* parser.y */
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /* XCU4: add XSCON: %x exclusive start token */
587c478bd9Sstevel@tonic-gate /* XCU4: add ARRAY: %a yytext is char array */
597c478bd9Sstevel@tonic-gate /* XCU4: add POINTER: %p yytext is a pointer to char */
607c478bd9Sstevel@tonic-gate %token CHAR CCL NCCL STR DELIM SCON ITER NEWE NULLS XSCON ARRAY POINTER
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate %nonassoc ARRAY POINTER
637c478bd9Sstevel@tonic-gate %left XSCON SCON NEWE
647c478bd9Sstevel@tonic-gate %left '/'
657c478bd9Sstevel@tonic-gate /*
667c478bd9Sstevel@tonic-gate  * XCU4: lower the precedence of $ and ^ to less than the or operator
677c478bd9Sstevel@tonic-gate  * per Spec. 1170
687c478bd9Sstevel@tonic-gate  */
697c478bd9Sstevel@tonic-gate %left '$' '^'
707c478bd9Sstevel@tonic-gate %left '|'
717c478bd9Sstevel@tonic-gate %left CHAR CCL NCCL '(' '.' STR NULLS
727c478bd9Sstevel@tonic-gate %left ITER
737c478bd9Sstevel@tonic-gate %left CAT
747c478bd9Sstevel@tonic-gate %left '*' '+' '?'
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate %{
7767298654Sdamico #include "ldefs.h"
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate #define YYSTYPE union _yystype_
807c478bd9Sstevel@tonic-gate union _yystype_
817c478bd9Sstevel@tonic-gate {
827c478bd9Sstevel@tonic-gate 	int	i;
837c478bd9Sstevel@tonic-gate 	CHR	*cp;
847c478bd9Sstevel@tonic-gate };
857c478bd9Sstevel@tonic-gate int	peekon = 0; /* need this to check if "^" came in a definition section */
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate %}
887c478bd9Sstevel@tonic-gate %%
897c478bd9Sstevel@tonic-gate %{
907c478bd9Sstevel@tonic-gate int i;
917c478bd9Sstevel@tonic-gate int j,k;
927c478bd9Sstevel@tonic-gate int g;
937c478bd9Sstevel@tonic-gate CHR *p;
947c478bd9Sstevel@tonic-gate static wchar_t  L_PctUpT[]= {'%', 'T', 0};
957c478bd9Sstevel@tonic-gate static wchar_t  L_PctLoT[]= {'%', 't', 0};
967c478bd9Sstevel@tonic-gate static wchar_t  L_PctCbr[]= {'%', '}', 0};
977c478bd9Sstevel@tonic-gate %}
987c478bd9Sstevel@tonic-gate acc	:	lexinput
997c478bd9Sstevel@tonic-gate 	={
1007c478bd9Sstevel@tonic-gate # ifdef DEBUG
1017c478bd9Sstevel@tonic-gate 		if(debug) sect2dump();
1027c478bd9Sstevel@tonic-gate # endif
1037c478bd9Sstevel@tonic-gate 	}
1047c478bd9Sstevel@tonic-gate 	;
1057c478bd9Sstevel@tonic-gate lexinput:	defns delim prods end
1067c478bd9Sstevel@tonic-gate 	|	defns delim end
1077c478bd9Sstevel@tonic-gate 	={
1087c478bd9Sstevel@tonic-gate 		if(!funcflag)phead2();
1097c478bd9Sstevel@tonic-gate 		funcflag = TRUE;
1107c478bd9Sstevel@tonic-gate 	}
1117c478bd9Sstevel@tonic-gate 	| error
1127c478bd9Sstevel@tonic-gate 	={
1137c478bd9Sstevel@tonic-gate # ifdef DEBUG
1147c478bd9Sstevel@tonic-gate 		if(debug) {
1157c478bd9Sstevel@tonic-gate 			sect1dump();
1167c478bd9Sstevel@tonic-gate 			sect2dump();
1177c478bd9Sstevel@tonic-gate 			}
1187c478bd9Sstevel@tonic-gate # endif
1197c478bd9Sstevel@tonic-gate 		fatal = 0;
1207c478bd9Sstevel@tonic-gate 		n_error++;
1217c478bd9Sstevel@tonic-gate 		error("Illegal definition");
1227c478bd9Sstevel@tonic-gate 		fatal = 1;
1237c478bd9Sstevel@tonic-gate 		}
1247c478bd9Sstevel@tonic-gate 	;
1257c478bd9Sstevel@tonic-gate end:		delim | ;
1267c478bd9Sstevel@tonic-gate defns:	defns STR STR
1277c478bd9Sstevel@tonic-gate 	={	scopy($2.cp,dp);
1287c478bd9Sstevel@tonic-gate 		def[dptr] = dp;
1297c478bd9Sstevel@tonic-gate 		dp += slength($2.cp) + 1;
1307c478bd9Sstevel@tonic-gate 		scopy($3.cp,dp);
1317c478bd9Sstevel@tonic-gate 		subs[dptr++] = dp;
1327c478bd9Sstevel@tonic-gate 		if(dptr >= DEFSIZE)
1337c478bd9Sstevel@tonic-gate 			error("Too many definitions");
1347c478bd9Sstevel@tonic-gate 		dp += slength($3.cp) + 1;
1357c478bd9Sstevel@tonic-gate 		if(dp >= dchar+DEFCHAR)
1367c478bd9Sstevel@tonic-gate 			error("Definitions too long");
1377c478bd9Sstevel@tonic-gate 		subs[dptr]=def[dptr]=0;	/* for lookup - require ending null */
1387c478bd9Sstevel@tonic-gate 	}
1397c478bd9Sstevel@tonic-gate 	|
1407c478bd9Sstevel@tonic-gate 	;
1417c478bd9Sstevel@tonic-gate delim:	DELIM
1427c478bd9Sstevel@tonic-gate 	={
1437c478bd9Sstevel@tonic-gate # ifdef DEBUG
1447c478bd9Sstevel@tonic-gate 		if(sect == DEFSECTION && debug) sect1dump();
1457c478bd9Sstevel@tonic-gate # endif
1467c478bd9Sstevel@tonic-gate 		sect++;
1477c478bd9Sstevel@tonic-gate 		}
1487c478bd9Sstevel@tonic-gate 	;
1497c478bd9Sstevel@tonic-gate prods:	prods pr
1507c478bd9Sstevel@tonic-gate 	={	$$.i = mn2(RNEWE,$1.i,$2.i);
1517c478bd9Sstevel@tonic-gate 		}
1527c478bd9Sstevel@tonic-gate 	|	pr
1537c478bd9Sstevel@tonic-gate 	={	$$.i = $1.i;}
1547c478bd9Sstevel@tonic-gate 	;
1557c478bd9Sstevel@tonic-gate pr:	r NEWE
1567c478bd9Sstevel@tonic-gate 	={
1577c478bd9Sstevel@tonic-gate 		if(divflg == TRUE)
1587c478bd9Sstevel@tonic-gate 			i = mn1(S1FINAL,casecount);
1597c478bd9Sstevel@tonic-gate 		else i = mn1(FINAL,casecount);
1607c478bd9Sstevel@tonic-gate 		$$.i = mn2(RCAT,$1.i,i);
1617c478bd9Sstevel@tonic-gate 		divflg = FALSE;
1627c478bd9Sstevel@tonic-gate 		if((++casecount)>NACTIONS)
1637c478bd9Sstevel@tonic-gate 			error("Too many (>%d) pattern-action rules.", NACTIONS);
1647c478bd9Sstevel@tonic-gate 		}
1657c478bd9Sstevel@tonic-gate 	| error NEWE
1667c478bd9Sstevel@tonic-gate 	={
1677c478bd9Sstevel@tonic-gate # ifdef DEBUG
1687c478bd9Sstevel@tonic-gate 		if(debug) sect2dump();
1697c478bd9Sstevel@tonic-gate # endif
1707c478bd9Sstevel@tonic-gate 		fatal = 0;
1717c478bd9Sstevel@tonic-gate 		yyline--;
1727c478bd9Sstevel@tonic-gate 		n_error++;
1737c478bd9Sstevel@tonic-gate 		error("Illegal rule");
1747c478bd9Sstevel@tonic-gate 		fatal = 1;
1757c478bd9Sstevel@tonic-gate 		yyline++;
1767c478bd9Sstevel@tonic-gate 		}
1777c478bd9Sstevel@tonic-gate r:	CHAR
1787c478bd9Sstevel@tonic-gate 	={	$$.i = mn0($1.i); }
1797c478bd9Sstevel@tonic-gate 	| STR
1807c478bd9Sstevel@tonic-gate 	={
1817c478bd9Sstevel@tonic-gate 		p = (CHR *)$1.cp;
1827c478bd9Sstevel@tonic-gate 		i = mn0((unsigned)(*p++));
1837c478bd9Sstevel@tonic-gate 		while(*p)
1847c478bd9Sstevel@tonic-gate 			i = mn2(RSTR,i,(unsigned)(*p++));
1857c478bd9Sstevel@tonic-gate 		$$.i = i;
1867c478bd9Sstevel@tonic-gate 		}
1877c478bd9Sstevel@tonic-gate 	| '.'
1887c478bd9Sstevel@tonic-gate 	={
1897c478bd9Sstevel@tonic-gate 		$$.i = mn0(DOT);
1907c478bd9Sstevel@tonic-gate 		}
1917c478bd9Sstevel@tonic-gate 	| CCL
1927c478bd9Sstevel@tonic-gate 	={	$$.i = mn1(RCCL,$1.i); }
1937c478bd9Sstevel@tonic-gate 	| NCCL
1947c478bd9Sstevel@tonic-gate 	={	$$.i = mn1(RNCCL,$1.i); }
1957c478bd9Sstevel@tonic-gate 	| r '*'
1967c478bd9Sstevel@tonic-gate 	={	$$.i = mn1(STAR,$1.i); }
1977c478bd9Sstevel@tonic-gate 	| r '+'
1987c478bd9Sstevel@tonic-gate 	={	$$.i = mn1(PLUS,$1.i); }
1997c478bd9Sstevel@tonic-gate 	| r '?'
2007c478bd9Sstevel@tonic-gate 	={	$$.i = mn1(QUEST,$1.i); }
2017c478bd9Sstevel@tonic-gate 	| r '|' r
2027c478bd9Sstevel@tonic-gate 	={	$$.i = mn2(BAR,$1.i,$3.i); }
2037c478bd9Sstevel@tonic-gate 	| r r %prec CAT
2047c478bd9Sstevel@tonic-gate 	={	$$.i = mn2(RCAT,$1.i,$2.i); }
2057c478bd9Sstevel@tonic-gate 	| r '/' r
2067c478bd9Sstevel@tonic-gate 	={	if(!divflg){
2077c478bd9Sstevel@tonic-gate 			j = mn1(S2FINAL,-casecount);
2087c478bd9Sstevel@tonic-gate 			i = mn2(RCAT,$1.i,j);
2097c478bd9Sstevel@tonic-gate 			$$.i = mn2(DIV,i,$3.i);
2107c478bd9Sstevel@tonic-gate 			}
2117c478bd9Sstevel@tonic-gate 		else {
2127c478bd9Sstevel@tonic-gate 			$$.i = mn2(RCAT,$1.i,$3.i);
2137c478bd9Sstevel@tonic-gate 			error("illegal extra slash");
2147c478bd9Sstevel@tonic-gate 			}
2157c478bd9Sstevel@tonic-gate 		divflg = TRUE;
2167c478bd9Sstevel@tonic-gate 		}
2177c478bd9Sstevel@tonic-gate 	| r ITER ',' ITER '}'
2187c478bd9Sstevel@tonic-gate 	={	if($2.i > $4.i){
2197c478bd9Sstevel@tonic-gate 			i = $2.i;
2207c478bd9Sstevel@tonic-gate 			$2.i = $4.i;
2217c478bd9Sstevel@tonic-gate 			$4.i = i;
2227c478bd9Sstevel@tonic-gate 			}
2237c478bd9Sstevel@tonic-gate 		if($4.i <= 0)
2247c478bd9Sstevel@tonic-gate 			error("iteration range must be positive");
2257c478bd9Sstevel@tonic-gate 		else {
2267c478bd9Sstevel@tonic-gate 			j = $1.i;
2277c478bd9Sstevel@tonic-gate 			for(k = 2; k<=$2.i;k++)
2287c478bd9Sstevel@tonic-gate 				j = mn2(RCAT,j,dupl($1.i));
2297c478bd9Sstevel@tonic-gate 			for(i = $2.i+1; i<=$4.i; i++){
2307c478bd9Sstevel@tonic-gate 				g = dupl($1.i);
2317c478bd9Sstevel@tonic-gate 				for(k=2;k<=i;k++)
2327c478bd9Sstevel@tonic-gate 					g = mn2(RCAT,g,dupl($1.i));
2337c478bd9Sstevel@tonic-gate 				j = mn2(BAR,j,g);
2347c478bd9Sstevel@tonic-gate 				}
2357c478bd9Sstevel@tonic-gate 			$$.i = j;
2367c478bd9Sstevel@tonic-gate 			}
2377c478bd9Sstevel@tonic-gate 	}
2387c478bd9Sstevel@tonic-gate 	| r ITER '}'
2397c478bd9Sstevel@tonic-gate 	={
2407c478bd9Sstevel@tonic-gate 		if($2.i < 0)error("can't have negative iteration");
2417c478bd9Sstevel@tonic-gate 		else if($2.i == 0) $$.i = mn0(RNULLS);
2427c478bd9Sstevel@tonic-gate 		else {
2437c478bd9Sstevel@tonic-gate 			j = $1.i;
2447c478bd9Sstevel@tonic-gate 			for(k=2;k<=$2.i;k++)
2457c478bd9Sstevel@tonic-gate 				j = mn2(RCAT,j,dupl($1.i));
2467c478bd9Sstevel@tonic-gate 			$$.i = j;
2477c478bd9Sstevel@tonic-gate 			}
2487c478bd9Sstevel@tonic-gate 		}
2497c478bd9Sstevel@tonic-gate 	| r ITER ',' '}'
2507c478bd9Sstevel@tonic-gate 	={
2517c478bd9Sstevel@tonic-gate 				/* from n to infinity */
2527c478bd9Sstevel@tonic-gate 		if($2.i < 0)error("can't have negative iteration");
2537c478bd9Sstevel@tonic-gate 		else if($2.i == 0) $$.i = mn1(STAR,$1.i);
2547c478bd9Sstevel@tonic-gate 		else if($2.i == 1)$$.i = mn1(PLUS,$1.i);
2557c478bd9Sstevel@tonic-gate 		else {		/* >= 2 iterations minimum */
2567c478bd9Sstevel@tonic-gate 			j = $1.i;
2577c478bd9Sstevel@tonic-gate 			for(k=2;k<$2.i;k++)
2587c478bd9Sstevel@tonic-gate 				j = mn2(RCAT,j,dupl($1.i));
2597c478bd9Sstevel@tonic-gate 			k = mn1(PLUS,dupl($1.i));
2607c478bd9Sstevel@tonic-gate 			$$.i = mn2(RCAT,j,k);
2617c478bd9Sstevel@tonic-gate 			}
2627c478bd9Sstevel@tonic-gate 		}
2637c478bd9Sstevel@tonic-gate 	| SCON r
2647c478bd9Sstevel@tonic-gate 	={	$$.i = mn2(RSCON,$2.i,(uintptr_t)$1.cp); }
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate 	/* XCU4: add XSCON */
2677c478bd9Sstevel@tonic-gate 	| XSCON r
2687c478bd9Sstevel@tonic-gate 	={	$$.i = mn2(RXSCON,$2.i,(uintptr_t)$1.cp); }
2697c478bd9Sstevel@tonic-gate 	| '^' r
2707c478bd9Sstevel@tonic-gate 	={	$$.i = mn1(CARAT,$2.i); }
2717c478bd9Sstevel@tonic-gate 	| r '$'
2727c478bd9Sstevel@tonic-gate 	={	i = mn0('\n');
2737c478bd9Sstevel@tonic-gate 		if(!divflg){
2747c478bd9Sstevel@tonic-gate 			j = mn1(S2FINAL,-casecount);
2757c478bd9Sstevel@tonic-gate 			k = mn2(RCAT,$1.i,j);
2767c478bd9Sstevel@tonic-gate 			$$.i = mn2(DIV,k,i);
2777c478bd9Sstevel@tonic-gate 			}
2787c478bd9Sstevel@tonic-gate 		else $$.i = mn2(RCAT,$1.i,i);
2797c478bd9Sstevel@tonic-gate 		divflg = TRUE;
2807c478bd9Sstevel@tonic-gate 		}
2817c478bd9Sstevel@tonic-gate 	| '(' r ')'
2827c478bd9Sstevel@tonic-gate 	={	$$.i = $2.i; }
2837c478bd9Sstevel@tonic-gate 	|	NULLS
2847c478bd9Sstevel@tonic-gate 	={	$$.i = mn0(RNULLS); }
2857c478bd9Sstevel@tonic-gate 
2867c478bd9Sstevel@tonic-gate 	/* XCU4: add ARRAY and POINTER */
2877c478bd9Sstevel@tonic-gate 	| ARRAY
2887c478bd9Sstevel@tonic-gate 	={ isArray = 1; };
2897c478bd9Sstevel@tonic-gate 	|     POINTER
2907c478bd9Sstevel@tonic-gate 	={ isArray = 0; };
2917c478bd9Sstevel@tonic-gate 	;
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate %%
2947c478bd9Sstevel@tonic-gate int
2957c478bd9Sstevel@tonic-gate yylex(void)
2967c478bd9Sstevel@tonic-gate {
2977c478bd9Sstevel@tonic-gate 	CHR *p;
2987c478bd9Sstevel@tonic-gate 	int  i;
2997c478bd9Sstevel@tonic-gate 	CHR *xp;
3007c478bd9Sstevel@tonic-gate 	int lex_startcond_lookupval;
3017c478bd9Sstevel@tonic-gate 	CHR  *t, c;
3027c478bd9Sstevel@tonic-gate 	int n, j = 0, k, x;
3037c478bd9Sstevel@tonic-gate 	CHR ch;
3047c478bd9Sstevel@tonic-gate 	static int sectbegin;
3057c478bd9Sstevel@tonic-gate 	static CHR token[TOKENSIZE];
3067c478bd9Sstevel@tonic-gate 	static int iter;
3077c478bd9Sstevel@tonic-gate 	int ccs; /* Current CodeSet. */
3087c478bd9Sstevel@tonic-gate 	CHR *ccp;
3097c478bd9Sstevel@tonic-gate 	int exclusive_flag;	/* XCU4: exclusive start flag */
3107c478bd9Sstevel@tonic-gate 
3117c478bd9Sstevel@tonic-gate # ifdef DEBUG
3127c478bd9Sstevel@tonic-gate 	yylval.i = 0;
3137c478bd9Sstevel@tonic-gate # endif
3147c478bd9Sstevel@tonic-gate 
3157c478bd9Sstevel@tonic-gate 	if(sect == DEFSECTION) {		/* definitions section */
3167c478bd9Sstevel@tonic-gate 		while(!eof) {
3177c478bd9Sstevel@tonic-gate 			if(prev == '\n'){    /* next char is at beginning of line */
3187c478bd9Sstevel@tonic-gate 				(void)getl(p=buf);
3197c478bd9Sstevel@tonic-gate 				switch(*p){
3207c478bd9Sstevel@tonic-gate 				case '%':
3217c478bd9Sstevel@tonic-gate 					switch(c= *(p+1)){
3227c478bd9Sstevel@tonic-gate 					case '%':
3231dd08564Sab 						/*LINTED: E_BAD_PTR_CAST_ALIGN*/
3247c478bd9Sstevel@tonic-gate 						if(scomp(p, (CHR *)"%%")) {
3257c478bd9Sstevel@tonic-gate 							p++;
3267c478bd9Sstevel@tonic-gate 							while(*(++p))
3277c478bd9Sstevel@tonic-gate 								if(!space(*p)) {
3287c478bd9Sstevel@tonic-gate 									warning("invalid string following %%%% be ignored");
3297c478bd9Sstevel@tonic-gate 									break;
3307c478bd9Sstevel@tonic-gate 								}
3317c478bd9Sstevel@tonic-gate 						}
3327c478bd9Sstevel@tonic-gate 						lgate();
3337c478bd9Sstevel@tonic-gate 						if(!ratfor)(void) fprintf(fout,"# ");
3347c478bd9Sstevel@tonic-gate 						(void) fprintf(fout,"define YYNEWLINE %d\n",ctable['\n']);
3357c478bd9Sstevel@tonic-gate 						if(!ratfor)(void) fprintf(fout,"int yylex(){\nint nstr; extern int yyprevious;\n");
3367c478bd9Sstevel@tonic-gate 						sectbegin = TRUE;
3377c478bd9Sstevel@tonic-gate 						i = treesize*(sizeof(*name)+sizeof(*left)+
3387c478bd9Sstevel@tonic-gate 							sizeof(*right)+sizeof(*nullstr)+sizeof(*parent))+ALITTLEEXTRA;
3397c478bd9Sstevel@tonic-gate 						c = (int)myalloc(i,1);
3407c478bd9Sstevel@tonic-gate 						if(c == 0)
3417c478bd9Sstevel@tonic-gate 							error("Too little core for parse tree");
3427c478bd9Sstevel@tonic-gate 						p = (CHR *)c;
3437c478bd9Sstevel@tonic-gate 						free(p);
3441dd08564Sab 						/*LINTED: E_BAD_PTR_CAST_ALIGN*/
3457c478bd9Sstevel@tonic-gate 						name = (int *)myalloc(treesize,sizeof(*name));
3461dd08564Sab 						/*LINTED: E_BAD_PTR_CAST_ALIGN*/
3477c478bd9Sstevel@tonic-gate 						left = (int *)myalloc(treesize,sizeof(*left));
3481dd08564Sab 						/*LINTED: E_BAD_PTR_CAST_ALIGN*/
3497c478bd9Sstevel@tonic-gate 						right = (int *)myalloc(treesize,sizeof(*right));
3507c478bd9Sstevel@tonic-gate 						nullstr = myalloc(treesize,sizeof(*nullstr));
3511dd08564Sab 						/*LINTED: E_BAD_PTR_CAST_ALIGN*/
3527c478bd9Sstevel@tonic-gate 						parent = (int *)myalloc(treesize,sizeof(*parent));
3537c478bd9Sstevel@tonic-gate 						if(name == 0 || left == 0 || right == 0 || parent == 0 || nullstr == 0)
3547c478bd9Sstevel@tonic-gate 							error("Too little core for parse tree");
3557c478bd9Sstevel@tonic-gate 						return(freturn(DELIM));
3567c478bd9Sstevel@tonic-gate 					case 'p': case 'P':
3577c478bd9Sstevel@tonic-gate 					        /* %p or %pointer */
3587c478bd9Sstevel@tonic-gate 						if ((*(p+2) == 'o') ||
3597c478bd9Sstevel@tonic-gate 						    (*(p+2) == 'O')) {
3607c478bd9Sstevel@tonic-gate 						    if(lgatflg)
3617c478bd9Sstevel@tonic-gate 							error("Too late for %%pointer");
3627c478bd9Sstevel@tonic-gate 						    while(*p && !iswspace(*p))
3637c478bd9Sstevel@tonic-gate 							p++;
3647c478bd9Sstevel@tonic-gate 						    isArray = 0;
3657c478bd9Sstevel@tonic-gate 						    continue;
3667c478bd9Sstevel@tonic-gate 						}
3677c478bd9Sstevel@tonic-gate 						/* has overridden number of positions */
3687c478bd9Sstevel@tonic-gate 						p += 2;
3697c478bd9Sstevel@tonic-gate 						maxpos = siconv(p);
3707c478bd9Sstevel@tonic-gate 						if (maxpos<=0)error("illegal position number");
3717c478bd9Sstevel@tonic-gate # ifdef DEBUG
3727c478bd9Sstevel@tonic-gate 						if (debug) (void) printf("positions (%%p) now %d\n",maxpos);
3737c478bd9Sstevel@tonic-gate # endif
3747c478bd9Sstevel@tonic-gate 						if(report == 2)report = 1;
3757c478bd9Sstevel@tonic-gate 						continue;
3767c478bd9Sstevel@tonic-gate 					case 'n': case 'N':	/* has overridden number of states */
3777c478bd9Sstevel@tonic-gate 						p += 2;
3787c478bd9Sstevel@tonic-gate 						nstates = siconv(p);
3797c478bd9Sstevel@tonic-gate 						if(nstates<=0)error("illegal state number");
3807c478bd9Sstevel@tonic-gate # ifdef DEBUG
3817c478bd9Sstevel@tonic-gate 						if(debug)(void) printf( " no. states (%%n) now %d\n",nstates);
3827c478bd9Sstevel@tonic-gate # endif
3837c478bd9Sstevel@tonic-gate 						if(report == 2)report = 1;
3847c478bd9Sstevel@tonic-gate 						continue;
3857c478bd9Sstevel@tonic-gate 					case 'e': case 'E':		/* has overridden number of tree nodes */
3867c478bd9Sstevel@tonic-gate 						p += 2;
3877c478bd9Sstevel@tonic-gate 						treesize = siconv(p);
3887c478bd9Sstevel@tonic-gate 						if(treesize<=0)error("illegal number of parse tree nodes");
3897c478bd9Sstevel@tonic-gate # ifdef DEBUG
3907c478bd9Sstevel@tonic-gate 						if (debug) (void) printf("treesize (%%e) now %d\n",treesize);
3917c478bd9Sstevel@tonic-gate # endif
3927c478bd9Sstevel@tonic-gate 						if(report == 2)report = 1;
3937c478bd9Sstevel@tonic-gate 						continue;
3947c478bd9Sstevel@tonic-gate 					case 'o': case 'O':
3957c478bd9Sstevel@tonic-gate 						p += 2;
3967c478bd9Sstevel@tonic-gate 						outsize = siconv(p);
3977c478bd9Sstevel@tonic-gate 						if(outsize<=0)error("illegal size of output array");
3987c478bd9Sstevel@tonic-gate 						if (report ==2) report=1;
3997c478bd9Sstevel@tonic-gate 						continue;
4007c478bd9Sstevel@tonic-gate 					case 'a': case 'A':
4017c478bd9Sstevel@tonic-gate 					        /* %a or %array */
4027c478bd9Sstevel@tonic-gate 						if ((*(p+2) == 'r') ||
4037c478bd9Sstevel@tonic-gate 						    (*(p+2) == 'R')) {
4047c478bd9Sstevel@tonic-gate 						    if(lgatflg)
4057c478bd9Sstevel@tonic-gate 							error("Too late for %%array");
4067c478bd9Sstevel@tonic-gate 						    while(*p && !iswspace(*p))
4077c478bd9Sstevel@tonic-gate 							p++;
4087c478bd9Sstevel@tonic-gate 						    isArray = 1;
4097c478bd9Sstevel@tonic-gate 						    continue;
4107c478bd9Sstevel@tonic-gate 						}
4117c478bd9Sstevel@tonic-gate 						/* has overridden number of transitions */
4127c478bd9Sstevel@tonic-gate 						p += 2;
4137c478bd9Sstevel@tonic-gate 						ntrans = siconv(p);
4147c478bd9Sstevel@tonic-gate 						if(ntrans<=0)error("illegal translation number");
4157c478bd9Sstevel@tonic-gate # ifdef DEBUG
4167c478bd9Sstevel@tonic-gate 						if (debug)(void) printf("N. trans (%%a) now %d\n",ntrans);
4177c478bd9Sstevel@tonic-gate # endif
4187c478bd9Sstevel@tonic-gate 						if(report == 2)report = 1;
4197c478bd9Sstevel@tonic-gate 						continue;
4207c478bd9Sstevel@tonic-gate 					case 'k': case 'K': /* overriden packed char classes */
4217c478bd9Sstevel@tonic-gate 						p += 2;
4227c478bd9Sstevel@tonic-gate 						free(pchar);
4237c478bd9Sstevel@tonic-gate 						pchlen = siconv(p);
4247c478bd9Sstevel@tonic-gate 						if(pchlen<=0)error("illegal number of packed character class");
4257c478bd9Sstevel@tonic-gate # ifdef DEBUG
4267c478bd9Sstevel@tonic-gate 						if (debug) (void) printf( "Size classes (%%k) now %d\n",pchlen);
4277c478bd9Sstevel@tonic-gate # endif
4281dd08564Sab 						/*LINTED: E_BAD_PTR_CAST_ALIGN*/
4297c478bd9Sstevel@tonic-gate 						pchar=pcptr=(CHR *)myalloc(pchlen, sizeof(*pchar));
4307c478bd9Sstevel@tonic-gate 						if (report==2) report=1;
4317c478bd9Sstevel@tonic-gate 						continue;
4327c478bd9Sstevel@tonic-gate 					case 't': case 'T': 	/* character set specifier */
4337c478bd9Sstevel@tonic-gate 						if(handleeuc)
4347c478bd9Sstevel@tonic-gate 							error("\
4357c478bd9Sstevel@tonic-gate Character table (%t) is supported only in ASCII compatibility mode.\n");
4367c478bd9Sstevel@tonic-gate 						ZCH = watoi(p+2);
4377c478bd9Sstevel@tonic-gate 						if (ZCH < NCH) ZCH = NCH;
4387c478bd9Sstevel@tonic-gate 						if (ZCH > 2*NCH) error("ch table needs redeclaration");
4397c478bd9Sstevel@tonic-gate 						chset = TRUE;
4407c478bd9Sstevel@tonic-gate 						for(i = 0; i<ZCH; i++)
4417c478bd9Sstevel@tonic-gate 							ctable[i] = 0;
4427c478bd9Sstevel@tonic-gate 						while(getl(p) && scomp(p,L_PctUpT) != 0 && scomp(p,L_PctLoT) != 0){
4437c478bd9Sstevel@tonic-gate 							if((n = siconv(p)) <= 0 || n > ZCH){
4447c478bd9Sstevel@tonic-gate 								error("Character value %d out of range",n);
4457c478bd9Sstevel@tonic-gate 								continue;
4467c478bd9Sstevel@tonic-gate 								}
4477c478bd9Sstevel@tonic-gate 							while(digit(*p)) p++;
4487c478bd9Sstevel@tonic-gate 							if(!iswspace(*p)) error("bad translation format");
4497c478bd9Sstevel@tonic-gate 							while(iswspace(*p)) p++;
4507c478bd9Sstevel@tonic-gate 							t = p;
4517c478bd9Sstevel@tonic-gate 							while(*t){
4527c478bd9Sstevel@tonic-gate 								c = ctrans(&t);
4537c478bd9Sstevel@tonic-gate 								if(ctable[(unsigned)c]){
4547c478bd9Sstevel@tonic-gate 									if (iswprint(c))
4557c478bd9Sstevel@tonic-gate 										warning("Character '%wc' used twice",c);
4567c478bd9Sstevel@tonic-gate 
4577c478bd9Sstevel@tonic-gate 									else
4587c478bd9Sstevel@tonic-gate 										error("Chararter %o used twice",c);
4597c478bd9Sstevel@tonic-gate 									}
4607c478bd9Sstevel@tonic-gate 								else ctable[(unsigned)c] = n;
4617c478bd9Sstevel@tonic-gate 								t++;
4627c478bd9Sstevel@tonic-gate 								}
4637c478bd9Sstevel@tonic-gate 							p = buf;
4647c478bd9Sstevel@tonic-gate 							}
4657c478bd9Sstevel@tonic-gate 						{
4667c478bd9Sstevel@tonic-gate 						char chused[2*NCH]; int kr;
4677c478bd9Sstevel@tonic-gate 						for(i=0; i<ZCH; i++)
4687c478bd9Sstevel@tonic-gate 							chused[i]=0;
4697c478bd9Sstevel@tonic-gate 						for(i=0; i<NCH; i++)
4707c478bd9Sstevel@tonic-gate 							chused[ctable[i]]=1;
4717c478bd9Sstevel@tonic-gate 						for(kr=i=1; i<NCH; i++)
4727c478bd9Sstevel@tonic-gate 							if (ctable[i]==0)
4737c478bd9Sstevel@tonic-gate 								{
4747c478bd9Sstevel@tonic-gate 								while (chused[kr] == 0)
4757c478bd9Sstevel@tonic-gate 									kr++;
4767c478bd9Sstevel@tonic-gate 								ctable[i]=kr;
4777c478bd9Sstevel@tonic-gate 								chused[kr]=1;
4787c478bd9Sstevel@tonic-gate 								}
4797c478bd9Sstevel@tonic-gate 						}
4807c478bd9Sstevel@tonic-gate 						lgate();
4817c478bd9Sstevel@tonic-gate 						continue;
4827c478bd9Sstevel@tonic-gate 					case 'r': case 'R':
4837c478bd9Sstevel@tonic-gate 						c = 'r';
4847c478bd9Sstevel@tonic-gate 						/* FALLTHRU */
4857c478bd9Sstevel@tonic-gate 					case 'c': case 'C':
4867c478bd9Sstevel@tonic-gate 						if(lgatflg)
4877c478bd9Sstevel@tonic-gate 							error("Too late for language specifier");
4887c478bd9Sstevel@tonic-gate 						ratfor = (c == 'r');
4897c478bd9Sstevel@tonic-gate 						continue;
4907c478bd9Sstevel@tonic-gate 					case '{':
4917c478bd9Sstevel@tonic-gate 						lgate();
4927c478bd9Sstevel@tonic-gate 						while(getl(p) && scomp(p, L_PctCbr) != 0)
4937c478bd9Sstevel@tonic-gate 							if(p[0]=='/' && p[1]=='*')
4947c478bd9Sstevel@tonic-gate 								cpycom(p);
4957c478bd9Sstevel@tonic-gate 							else
4961dd08564Sab 								(void) fprintf(fout,WSFMT("%ws\n"),p);
4977c478bd9Sstevel@tonic-gate 						if(p[0] == '%') continue;
4987c478bd9Sstevel@tonic-gate 						if (*p) error("EOF before %%%%");
4997c478bd9Sstevel@tonic-gate 						else error("EOF before %%}");
5007c478bd9Sstevel@tonic-gate 						break;
5017c478bd9Sstevel@tonic-gate 
5027c478bd9Sstevel@tonic-gate 					case 'x': case 'X':		/* XCU4: exclusive start conditions */
5037c478bd9Sstevel@tonic-gate 						exclusive_flag = 1;
5047c478bd9Sstevel@tonic-gate 						goto start;
5057c478bd9Sstevel@tonic-gate 
5067c478bd9Sstevel@tonic-gate 					case 's': case 'S':		/* start conditions */
5077c478bd9Sstevel@tonic-gate 						exclusive_flag = 0;
5087c478bd9Sstevel@tonic-gate start:
5097c478bd9Sstevel@tonic-gate 						lgate();
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate 						while(*p && !iswspace(*p) && ((*p) != (wchar_t)',')) p++;
5127c478bd9Sstevel@tonic-gate 						n = TRUE;
5137c478bd9Sstevel@tonic-gate 						while(n){
5147c478bd9Sstevel@tonic-gate 							while(*p && (iswspace(*p) || ((*p) == (wchar_t)','))) p++;
5157c478bd9Sstevel@tonic-gate 							t = p;
5167c478bd9Sstevel@tonic-gate 							while(*p && !iswspace(*p) && ((*p) != (wchar_t)',')) {
5177c478bd9Sstevel@tonic-gate 							    if(!isascii(*p))
5187c478bd9Sstevel@tonic-gate 								error("None-ASCII characters in start condition.");
5197c478bd9Sstevel@tonic-gate 							    p++;
5207c478bd9Sstevel@tonic-gate 							}
5217c478bd9Sstevel@tonic-gate 							if(!*p) n = FALSE;
5227c478bd9Sstevel@tonic-gate 							*p++ = 0;
5237c478bd9Sstevel@tonic-gate 							if (*t == 0) continue;
5247c478bd9Sstevel@tonic-gate 							i = sptr*2;
5257c478bd9Sstevel@tonic-gate 							if(!ratfor)(void) fprintf(fout,"# ");
5261dd08564Sab 							(void) fprintf(fout,WSFMT("define %ws %d\n"),t,i);
5277c478bd9Sstevel@tonic-gate 							scopy(t,sp);
5287c478bd9Sstevel@tonic-gate 							sname[sptr] = sp;
5297c478bd9Sstevel@tonic-gate 							/* XCU4: save exclusive flag with start name */
5307c478bd9Sstevel@tonic-gate 							exclusive[sptr++] = exclusive_flag;
5317c478bd9Sstevel@tonic-gate 							sname[sptr] = 0;	/* required by lookup */
5327c478bd9Sstevel@tonic-gate 							if(sptr >= STARTSIZE)
5337c478bd9Sstevel@tonic-gate 								error("Too many start conditions");
5347c478bd9Sstevel@tonic-gate 							sp += slength(sp) + 1;
5357c478bd9Sstevel@tonic-gate 							if(sp >= schar+STARTCHAR)
5367c478bd9Sstevel@tonic-gate 								error("Start conditions too long");
5377c478bd9Sstevel@tonic-gate 							}
5387c478bd9Sstevel@tonic-gate 						continue;
5397c478bd9Sstevel@tonic-gate 					default:
5407c478bd9Sstevel@tonic-gate 						error("Invalid request %s",p);
5417c478bd9Sstevel@tonic-gate 						continue;
5427c478bd9Sstevel@tonic-gate 						}	/* end of switch after seeing '%' */
5437c478bd9Sstevel@tonic-gate 					break;
5447c478bd9Sstevel@tonic-gate 				case ' ': case '\t':		/* must be code */
5457c478bd9Sstevel@tonic-gate 					lgate();
5467c478bd9Sstevel@tonic-gate 					if( p[1]=='/' && p[2]=='*' ) cpycom(p);
5471dd08564Sab 					else (void) fprintf(fout, WSFMT("%ws\n"),p);
5487c478bd9Sstevel@tonic-gate 					continue;
5497c478bd9Sstevel@tonic-gate 				case '/':	/* look for comments */
5507c478bd9Sstevel@tonic-gate 					lgate();
5517c478bd9Sstevel@tonic-gate 					if((*(p+1))=='*') cpycom(p);
5527c478bd9Sstevel@tonic-gate 					/* FALLTHRU */
5537c478bd9Sstevel@tonic-gate 				default:		/* definition */
5547c478bd9Sstevel@tonic-gate 					while(*p && !iswspace(*p)) p++;
5557c478bd9Sstevel@tonic-gate 					if(*p == 0)
5567c478bd9Sstevel@tonic-gate 						continue;
5577c478bd9Sstevel@tonic-gate 					prev = *p;
5587c478bd9Sstevel@tonic-gate 					*p = 0;
5597c478bd9Sstevel@tonic-gate 					bptr = p+1;
5607c478bd9Sstevel@tonic-gate 					yylval.cp = (CHR *)buf;
5617c478bd9Sstevel@tonic-gate 					if(digit(buf[0]))
5627c478bd9Sstevel@tonic-gate 						warning("Substitution strings may not begin with digits");
5637c478bd9Sstevel@tonic-gate 					return(freturn(STR));
5647c478bd9Sstevel@tonic-gate 				}
5657c478bd9Sstevel@tonic-gate 			} else { /* still sect 1, but prev != '\n' */
5667c478bd9Sstevel@tonic-gate 				p = bptr;
5677c478bd9Sstevel@tonic-gate 				while(*p && iswspace(*p)) p++;
5687c478bd9Sstevel@tonic-gate 				if(*p == 0)
5697c478bd9Sstevel@tonic-gate 					warning("No translation given - null string assumed");
5707c478bd9Sstevel@tonic-gate 				scopy(p,token);
5717c478bd9Sstevel@tonic-gate 				yylval.cp = (CHR *)token;
5727c478bd9Sstevel@tonic-gate 				prev = '\n';
5737c478bd9Sstevel@tonic-gate 				return(freturn(STR));
5747c478bd9Sstevel@tonic-gate 				}
5757c478bd9Sstevel@tonic-gate 			}
5767c478bd9Sstevel@tonic-gate 		error("unexpected EOF before %%%%");
5777c478bd9Sstevel@tonic-gate 		/* end of section one processing */
5787c478bd9Sstevel@tonic-gate 	} else if(sect == RULESECTION){		/* rules and actions */
5797c478bd9Sstevel@tonic-gate 		lgate();
5807c478bd9Sstevel@tonic-gate 		while(!eof){
5817c478bd9Sstevel@tonic-gate 			static int first_test=TRUE, first_value;
5827c478bd9Sstevel@tonic-gate 			static int reverse=FALSE;
5837c478bd9Sstevel@tonic-gate 			switch(c=gch()){
5847c478bd9Sstevel@tonic-gate 			case '\0':
5857c478bd9Sstevel@tonic-gate 				if(n_error)error_tail();
5867c478bd9Sstevel@tonic-gate 				return(freturn(0));
5877c478bd9Sstevel@tonic-gate 			case '\n':
5887c478bd9Sstevel@tonic-gate 				if(prev == '\n') continue;
5897c478bd9Sstevel@tonic-gate 				x = NEWE;
5907c478bd9Sstevel@tonic-gate 				break;
5917c478bd9Sstevel@tonic-gate 			case ' ':
5927c478bd9Sstevel@tonic-gate 			case '\t':
5937c478bd9Sstevel@tonic-gate 				if(prev == '\n') copy_line = TRUE;
5947c478bd9Sstevel@tonic-gate 				if(sectbegin == TRUE){
5957c478bd9Sstevel@tonic-gate 					(void)cpyact();
5967c478bd9Sstevel@tonic-gate 					copy_line = FALSE;
5971dd08564Sab 					/*LINTED: E_EQUALITY_NOT_ASSIGNMENT*/
5987c478bd9Sstevel@tonic-gate 					while((c=gch()) && c != '\n');
5997c478bd9Sstevel@tonic-gate 					continue;
6007c478bd9Sstevel@tonic-gate 					}
6017c478bd9Sstevel@tonic-gate 				if(!funcflag)phead2();
6027c478bd9Sstevel@tonic-gate 				funcflag = TRUE;
6037c478bd9Sstevel@tonic-gate 				if(ratfor)(void) fprintf(fout,"%d\n",30000+casecount);
6047c478bd9Sstevel@tonic-gate 				else (void) fprintf(fout,"case %d:\n",casecount);
6057c478bd9Sstevel@tonic-gate 				if(cpyact()){
6067c478bd9Sstevel@tonic-gate 					if(ratfor)(void) fprintf(fout,"goto 30997\n");
6077c478bd9Sstevel@tonic-gate 					else (void) fprintf(fout,"break;\n");
6087c478bd9Sstevel@tonic-gate 					}
6091dd08564Sab 				/*LINTED: E_EQUALITY_NOT_ASSIGNMENT*/
6107c478bd9Sstevel@tonic-gate 				while((c=gch()) && c != '\n') {
6117c478bd9Sstevel@tonic-gate 					if (c=='/') {
6127c478bd9Sstevel@tonic-gate 						if((c=gch())=='*') {
6137c478bd9Sstevel@tonic-gate 							c=gch();
6147c478bd9Sstevel@tonic-gate 							while(c !=EOF) {
6157c478bd9Sstevel@tonic-gate 								while (c=='*')
6167c478bd9Sstevel@tonic-gate 									if ((c=gch()) == '/') goto w_loop;
6177c478bd9Sstevel@tonic-gate 								c = gch();
6187c478bd9Sstevel@tonic-gate 							}
6197c478bd9Sstevel@tonic-gate 							error("EOF inside comment");
6207c478bd9Sstevel@tonic-gate 						} else
6217c478bd9Sstevel@tonic-gate 							warning("undefined string");
6227c478bd9Sstevel@tonic-gate 					} else if (c=='}')
6237c478bd9Sstevel@tonic-gate 						error("illegal extra \"}\"");
6247c478bd9Sstevel@tonic-gate 				w_loop: ;
6257c478bd9Sstevel@tonic-gate 				}
6267c478bd9Sstevel@tonic-gate 				/* while ((c=gch())== ' ' || c == '\t') ; */
6277c478bd9Sstevel@tonic-gate 				/* if (!space(c)) error("undefined action string"); */
6287c478bd9Sstevel@tonic-gate 				if(peek == ' ' || peek == '\t' || sectbegin == TRUE){
6297c478bd9Sstevel@tonic-gate 					fatal = 0;
6307c478bd9Sstevel@tonic-gate 					n_error++;
6317c478bd9Sstevel@tonic-gate 					error("executable statements should occur right after %%%%");
6327c478bd9Sstevel@tonic-gate 					fatal = 1;
6337c478bd9Sstevel@tonic-gate 					continue;
6347c478bd9Sstevel@tonic-gate 					}
6357c478bd9Sstevel@tonic-gate 				x = NEWE;
6367c478bd9Sstevel@tonic-gate 				break;
6377c478bd9Sstevel@tonic-gate 			case '%':
6387c478bd9Sstevel@tonic-gate 				if(prev != '\n') goto character;
6397c478bd9Sstevel@tonic-gate 				if(peek == '{'){	/* included code */
6407c478bd9Sstevel@tonic-gate 					(void)getl(buf);
6417c478bd9Sstevel@tonic-gate 					while(!eof&& getl(buf) && scomp(L_PctCbr,buf)!=0)
6427c478bd9Sstevel@tonic-gate 						if(buf[0]=='/' && buf[1]=='*')
6437c478bd9Sstevel@tonic-gate 							cpycom(buf);
6447c478bd9Sstevel@tonic-gate 						else
6451dd08564Sab 							(void) fprintf(fout,WSFMT("%ws\n"),buf);
6467c478bd9Sstevel@tonic-gate 					continue;
6477c478bd9Sstevel@tonic-gate 					}
6487c478bd9Sstevel@tonic-gate 				if(peek == '%'){
6497c478bd9Sstevel@tonic-gate 					c = gch();
6507c478bd9Sstevel@tonic-gate 					c = gch();
6517c478bd9Sstevel@tonic-gate 					x = DELIM;
6527c478bd9Sstevel@tonic-gate 					break;
6537c478bd9Sstevel@tonic-gate 					}
6547c478bd9Sstevel@tonic-gate 				goto character;
6557c478bd9Sstevel@tonic-gate 			case '|':
6567c478bd9Sstevel@tonic-gate 				if(peek == ' ' || peek == '\t' || peek == '\n'){
6577c478bd9Sstevel@tonic-gate 					if(ratfor)(void) fprintf(fout,"%d\n",30000+casecount++);
6587c478bd9Sstevel@tonic-gate 					else (void) fprintf(fout,"case %d:\n",casecount++);
6597c478bd9Sstevel@tonic-gate 					continue;
6607c478bd9Sstevel@tonic-gate 					}
6617c478bd9Sstevel@tonic-gate 				x = '|';
6627c478bd9Sstevel@tonic-gate 				break;
6637c478bd9Sstevel@tonic-gate 			case '$':
6647c478bd9Sstevel@tonic-gate 				if(peek == '\n' || peek == ' ' || peek == '\t' || peek == '|' || peek == '/'){
6657c478bd9Sstevel@tonic-gate 					x = c;
6667c478bd9Sstevel@tonic-gate 					break;
6677c478bd9Sstevel@tonic-gate 					}
6687c478bd9Sstevel@tonic-gate 				goto character;
6697c478bd9Sstevel@tonic-gate 			case '^':
6707c478bd9Sstevel@tonic-gate                                 if(peekon && (prev == '}')){
6717c478bd9Sstevel@tonic-gate                                         x = c;
6727c478bd9Sstevel@tonic-gate                                         break;
6737c478bd9Sstevel@tonic-gate                                 }
6747c478bd9Sstevel@tonic-gate 				if(prev != '\n' && scon != TRUE) goto character;
6757c478bd9Sstevel@tonic-gate 				/* valid only at line begin */
6767c478bd9Sstevel@tonic-gate 				x = c;
6777c478bd9Sstevel@tonic-gate 				break;
6787c478bd9Sstevel@tonic-gate 			case '?':
6797c478bd9Sstevel@tonic-gate 			case '+':
6807c478bd9Sstevel@tonic-gate 			case '*':
6817c478bd9Sstevel@tonic-gate 				if(prev == '\n' ) {
6827c478bd9Sstevel@tonic-gate 					fatal = 0;
6837c478bd9Sstevel@tonic-gate 					n_error++;
6847c478bd9Sstevel@tonic-gate 					error("illegal operator -- %c",c);
6857c478bd9Sstevel@tonic-gate 					fatal = 1;
6867c478bd9Sstevel@tonic-gate 				}
6877c478bd9Sstevel@tonic-gate 				/* FALLTHRU */
6887c478bd9Sstevel@tonic-gate 			case '.':
6897c478bd9Sstevel@tonic-gate 			case '(':
6907c478bd9Sstevel@tonic-gate 			case ')':
6917c478bd9Sstevel@tonic-gate 			case ',':
6927c478bd9Sstevel@tonic-gate 			case '/':
6937c478bd9Sstevel@tonic-gate 				x = c;
6947c478bd9Sstevel@tonic-gate 				break;
6957c478bd9Sstevel@tonic-gate 			case '}':
6967c478bd9Sstevel@tonic-gate 				iter = FALSE;
6977c478bd9Sstevel@tonic-gate 				x = c;
6987c478bd9Sstevel@tonic-gate 				break;
6997c478bd9Sstevel@tonic-gate 			case '{':	/* either iteration or definition */
7007c478bd9Sstevel@tonic-gate 				if(digit(c=gch())){	/* iteration */
7017c478bd9Sstevel@tonic-gate 					iter = TRUE;
7027c478bd9Sstevel@tonic-gate 					if(prev=='{') first_test = TRUE;
7037c478bd9Sstevel@tonic-gate 				ieval:
7047c478bd9Sstevel@tonic-gate 					i = 0;
7057c478bd9Sstevel@tonic-gate 					while(digit(c)){
7067c478bd9Sstevel@tonic-gate 						token[i++] = c;
7077c478bd9Sstevel@tonic-gate 						c = gch();
7087c478bd9Sstevel@tonic-gate 						}
7097c478bd9Sstevel@tonic-gate 					token[i] = 0;
7107c478bd9Sstevel@tonic-gate 					yylval.i = siconv(token);
7117c478bd9Sstevel@tonic-gate 					if(first_test) {
7127c478bd9Sstevel@tonic-gate 						first_test = FALSE;
7137c478bd9Sstevel@tonic-gate 						first_value = yylval.i;
7147c478bd9Sstevel@tonic-gate 					} else
7157c478bd9Sstevel@tonic-gate 						if(first_value>yylval.i)warning("the values between braces are reversed");
7167c478bd9Sstevel@tonic-gate 					ch = c;
7177c478bd9Sstevel@tonic-gate 					munput('c',&ch);
7187c478bd9Sstevel@tonic-gate 					x = ITER;
7197c478bd9Sstevel@tonic-gate 					break;
7207c478bd9Sstevel@tonic-gate 					}
7217c478bd9Sstevel@tonic-gate 				else {		/* definition */
7227c478bd9Sstevel@tonic-gate 					i = 0;
7237c478bd9Sstevel@tonic-gate 					while(c && c!='}'){
7247c478bd9Sstevel@tonic-gate 						token[i++] = c;
7257c478bd9Sstevel@tonic-gate 						if(i >= TOKENSIZE)
7267c478bd9Sstevel@tonic-gate 							error("definition too long");
7277c478bd9Sstevel@tonic-gate 						c = gch();
7287c478bd9Sstevel@tonic-gate 						}
7297c478bd9Sstevel@tonic-gate 					token[i] = 0;
7307c478bd9Sstevel@tonic-gate 					i = lookup(token,def);
7317c478bd9Sstevel@tonic-gate 					if(i < 0)
7327c478bd9Sstevel@tonic-gate 						error("definition %ws not found",token);
7337c478bd9Sstevel@tonic-gate 					else
7347c478bd9Sstevel@tonic-gate 						munput('s',(CHR *)(subs[i]));
7357c478bd9Sstevel@tonic-gate             				if (peek == '^')
7367c478bd9Sstevel@tonic-gate                                                 peekon = 1;
7377c478bd9Sstevel@tonic-gate 					continue;
7387c478bd9Sstevel@tonic-gate 					}
7397c478bd9Sstevel@tonic-gate 			case '<':		/* start condition ? */
7407c478bd9Sstevel@tonic-gate 				if(prev != '\n')  /* not at line begin, not start */
7417c478bd9Sstevel@tonic-gate 					goto character;
7427c478bd9Sstevel@tonic-gate 				t = slptr;
7437c478bd9Sstevel@tonic-gate 				do {
7447c478bd9Sstevel@tonic-gate 					i = 0;
7457c478bd9Sstevel@tonic-gate 					if(!isascii(c = gch()))
7467c478bd9Sstevel@tonic-gate 					    error("Non-ASCII characters in start condition.");
7477c478bd9Sstevel@tonic-gate 					while(c != ',' && c && c != '>'){
7487c478bd9Sstevel@tonic-gate 						token[i++] = c;
7497c478bd9Sstevel@tonic-gate 						if(i >= TOKENSIZE)
7507c478bd9Sstevel@tonic-gate 							error("string name too long");
7517c478bd9Sstevel@tonic-gate 						if(!isascii(c = gch()))
7527c478bd9Sstevel@tonic-gate 						    error("None-ASCII characters in start condition.");
7537c478bd9Sstevel@tonic-gate 						}
7547c478bd9Sstevel@tonic-gate 					token[i] = 0;
7557c478bd9Sstevel@tonic-gate 					if(i == 0)
7567c478bd9Sstevel@tonic-gate 						goto character;
7577c478bd9Sstevel@tonic-gate 					i = lookup(token,sname);
7587c478bd9Sstevel@tonic-gate 					lex_startcond_lookupval = i;
7597c478bd9Sstevel@tonic-gate 					if(i < 0) {
7607c478bd9Sstevel@tonic-gate 						fatal = 0;
7617c478bd9Sstevel@tonic-gate 						n_error++;
7627c478bd9Sstevel@tonic-gate 						error("undefined start condition %ws",token);
7637c478bd9Sstevel@tonic-gate 						fatal = 1;
7647c478bd9Sstevel@tonic-gate 						continue;
7657c478bd9Sstevel@tonic-gate 						}
7667c478bd9Sstevel@tonic-gate 					*slptr++ = i+1;
7677c478bd9Sstevel@tonic-gate 					} while(c && c != '>');
7687c478bd9Sstevel@tonic-gate 				*slptr++ = 0;
7697c478bd9Sstevel@tonic-gate 				/* check if previous value re-usable */
7707c478bd9Sstevel@tonic-gate 				for (xp=slist; xp<t; )
7717c478bd9Sstevel@tonic-gate 					{
7727c478bd9Sstevel@tonic-gate 					if (scomp(xp, t)==0)
7737c478bd9Sstevel@tonic-gate 						break;
7747c478bd9Sstevel@tonic-gate 					while (*xp++);
7757c478bd9Sstevel@tonic-gate 					}
7767c478bd9Sstevel@tonic-gate 				if (xp<t)
7777c478bd9Sstevel@tonic-gate 					{
7787c478bd9Sstevel@tonic-gate 					/* re-use previous pointer to string */
7797c478bd9Sstevel@tonic-gate 					slptr=t;
7807c478bd9Sstevel@tonic-gate 					t=xp;
7817c478bd9Sstevel@tonic-gate 					}
7827c478bd9Sstevel@tonic-gate 				if(slptr > slist+STARTSIZE)	/* note not packed */
7837c478bd9Sstevel@tonic-gate 					error("Too many start conditions used");
7847c478bd9Sstevel@tonic-gate 				yylval.cp = (CHR *)t;
7857c478bd9Sstevel@tonic-gate 
7867c478bd9Sstevel@tonic-gate 				/* XCU4: add XSCON */
7877c478bd9Sstevel@tonic-gate 
7887c478bd9Sstevel@tonic-gate 				if (exclusive[lex_startcond_lookupval])
7897c478bd9Sstevel@tonic-gate 					x = XSCON;
7907c478bd9Sstevel@tonic-gate 				else
7917c478bd9Sstevel@tonic-gate 					x = SCON;
7927c478bd9Sstevel@tonic-gate 				break;
7937c478bd9Sstevel@tonic-gate 			case '"':
7947c478bd9Sstevel@tonic-gate 				i = 0;
7951dd08564Sab 				/*LINTED: E_EQUALITY_NOT_ASSIGNMENT*/
7967c478bd9Sstevel@tonic-gate 				while((c=gch()) && c != '"' && c != '\n'){
7977c478bd9Sstevel@tonic-gate 					if(c == '\\') c = usescape(c=gch());
7987c478bd9Sstevel@tonic-gate 					remch(c);
7997c478bd9Sstevel@tonic-gate 					token[i++] = c;
8007c478bd9Sstevel@tonic-gate 					if(i >= TOKENSIZE){
8017c478bd9Sstevel@tonic-gate 						warning("String too long");
8027c478bd9Sstevel@tonic-gate 						i = TOKENSIZE-1;
8037c478bd9Sstevel@tonic-gate 						break;
8047c478bd9Sstevel@tonic-gate 						}
8057c478bd9Sstevel@tonic-gate 					}
8067c478bd9Sstevel@tonic-gate 				if(c == '\n') {
8077c478bd9Sstevel@tonic-gate 					yyline--;
8087c478bd9Sstevel@tonic-gate 					warning("Non-terminated string");
8097c478bd9Sstevel@tonic-gate 					yyline++;
8107c478bd9Sstevel@tonic-gate 					}
8117c478bd9Sstevel@tonic-gate 				token[i] = 0;
8127c478bd9Sstevel@tonic-gate 				if(i == 0)x = NULLS;
8137c478bd9Sstevel@tonic-gate 				else if(i == 1){
8147c478bd9Sstevel@tonic-gate 					yylval.i = (unsigned)token[0];
8157c478bd9Sstevel@tonic-gate 					x = CHAR;
8167c478bd9Sstevel@tonic-gate 					}
8177c478bd9Sstevel@tonic-gate 				else {
8187c478bd9Sstevel@tonic-gate 					yylval.cp = (CHR *)token;
8197c478bd9Sstevel@tonic-gate 					x = STR;
8207c478bd9Sstevel@tonic-gate 					}
8217c478bd9Sstevel@tonic-gate 				break;
8227c478bd9Sstevel@tonic-gate 			case '[':
8237c478bd9Sstevel@tonic-gate 				reverse = FALSE;
8247c478bd9Sstevel@tonic-gate 				x = CCL;
8257c478bd9Sstevel@tonic-gate 				if((c = gch()) == '^'){
8267c478bd9Sstevel@tonic-gate 					x = NCCL;
8277c478bd9Sstevel@tonic-gate 					reverse = TRUE;
8287c478bd9Sstevel@tonic-gate 					c = gch();
8297c478bd9Sstevel@tonic-gate 					}
8307c478bd9Sstevel@tonic-gate 				i = 0;
8317c478bd9Sstevel@tonic-gate 				while(c != ']' && c){
8327c478bd9Sstevel@tonic-gate 					static int light=TRUE, ESCAPE=FALSE;
8337c478bd9Sstevel@tonic-gate 					if(c == '-' && prev == '^' && reverse){
8347c478bd9Sstevel@tonic-gate 						symbol[(unsigned)c] = 1;
8357c478bd9Sstevel@tonic-gate 						c = gch();
8367c478bd9Sstevel@tonic-gate 						continue;
8377c478bd9Sstevel@tonic-gate 					}
8387c478bd9Sstevel@tonic-gate 					if(c == '\\') {
8397c478bd9Sstevel@tonic-gate 						c = usescape(c=gch());
8407c478bd9Sstevel@tonic-gate 						ESCAPE = TRUE;
8417c478bd9Sstevel@tonic-gate 					}
8427c478bd9Sstevel@tonic-gate 					if(c=='-' && !ESCAPE && prev!='[' && peek!=']'){
8437c478bd9Sstevel@tonic-gate 					/* range specified */
8447c478bd9Sstevel@tonic-gate 						if (light) {
8457c478bd9Sstevel@tonic-gate 							c = gch();
8467c478bd9Sstevel@tonic-gate 							if(c == '\\')
8477c478bd9Sstevel@tonic-gate 								c=usescape(c=gch());
8487c478bd9Sstevel@tonic-gate 							remch(c);
8497c478bd9Sstevel@tonic-gate 							k = c;
8507c478bd9Sstevel@tonic-gate 							ccs=wcsetno(k);
8517c478bd9Sstevel@tonic-gate 							if(wcsetno(j)!=ccs)
8527c478bd9Sstevel@tonic-gate 							    error("\
8537c478bd9Sstevel@tonic-gate Character range specified between different codesets.");
8547c478bd9Sstevel@tonic-gate 							if((unsigned)j > (unsigned)k) {
8557c478bd9Sstevel@tonic-gate 								n = j;
8567c478bd9Sstevel@tonic-gate 								j = k;
8577c478bd9Sstevel@tonic-gate 								k = n;
8587c478bd9Sstevel@tonic-gate 								}
8597c478bd9Sstevel@tonic-gate 							if(!handleeuc)
8607c478bd9Sstevel@tonic-gate 							if(!(('A'<=j && k<='Z') ||
8617c478bd9Sstevel@tonic-gate 						     	     ('a'<=j && k<='z') ||
8627c478bd9Sstevel@tonic-gate 						     	     ('0'<=j && k<='9')))
8637c478bd9Sstevel@tonic-gate 								warning("Non-portable Character Class");
8647c478bd9Sstevel@tonic-gate 							token[i++] = RANGE;
8657c478bd9Sstevel@tonic-gate 							token[i++] = j;
8667c478bd9Sstevel@tonic-gate 							token[i++] = k;
8677c478bd9Sstevel@tonic-gate 							light = FALSE;
8687c478bd9Sstevel@tonic-gate 						} else {
8697c478bd9Sstevel@tonic-gate 							error("unmatched hyphen");
8707c478bd9Sstevel@tonic-gate 							if(symbol[(unsigned)c])warning("\"%c\" redefined inside brackets",c);
8717c478bd9Sstevel@tonic-gate 							else symbol[(unsigned)c] = 1;
8727c478bd9Sstevel@tonic-gate 						}
8737c478bd9Sstevel@tonic-gate 						ESCAPE = FALSE;
8747c478bd9Sstevel@tonic-gate 					} else {
8757c478bd9Sstevel@tonic-gate 						j = c;
8767c478bd9Sstevel@tonic-gate 						remch(c);
8777c478bd9Sstevel@tonic-gate 						token[i++] = c; /* Remember whatever.*/
8787c478bd9Sstevel@tonic-gate 						light = TRUE;
8797c478bd9Sstevel@tonic-gate 						ESCAPE = FALSE;
8807c478bd9Sstevel@tonic-gate 					}
8817c478bd9Sstevel@tonic-gate 					c = gch();
8827c478bd9Sstevel@tonic-gate 				}
8837c478bd9Sstevel@tonic-gate 				/* try to pack ccl's */
8847c478bd9Sstevel@tonic-gate 
8857c478bd9Sstevel@tonic-gate 				token[i] = 0;
8867c478bd9Sstevel@tonic-gate 				ccp = ccl;
8877c478bd9Sstevel@tonic-gate 				while (ccp < ccptr && scomp(token, ccp) != 0) ccp++;
8887c478bd9Sstevel@tonic-gate 				if (ccp < ccptr) {  /* found in ccl */
8897c478bd9Sstevel@tonic-gate 				    yylval.cp = ccp;
8907c478bd9Sstevel@tonic-gate 				} else {            /* not in ccl, add it */
8917c478bd9Sstevel@tonic-gate 				    scopy(token,ccptr);
8927c478bd9Sstevel@tonic-gate 				    yylval.cp = ccptr;
8937c478bd9Sstevel@tonic-gate 				    ccptr += slength(token) + 1;
8947c478bd9Sstevel@tonic-gate 				    if(ccptr >= ccl+CCLSIZE)
8957c478bd9Sstevel@tonic-gate 				      error("Too many large character classes");
8967c478bd9Sstevel@tonic-gate 				}
8977c478bd9Sstevel@tonic-gate 				break;
8987c478bd9Sstevel@tonic-gate 			case '\\':
8997c478bd9Sstevel@tonic-gate 				c = usescape(c=gch());
900*1e819975SToomas Soome 				/* FALLTHROUGH */
9017c478bd9Sstevel@tonic-gate 			default:
9027c478bd9Sstevel@tonic-gate 			character:
9037c478bd9Sstevel@tonic-gate 				if(iter){	/* second part of an iteration */
9047c478bd9Sstevel@tonic-gate 					iter = FALSE;
9057c478bd9Sstevel@tonic-gate 					if('0' <= c && c <= '9')
9067c478bd9Sstevel@tonic-gate 						goto ieval;
9077c478bd9Sstevel@tonic-gate 					}
9087c478bd9Sstevel@tonic-gate 				remch(c);
9097c478bd9Sstevel@tonic-gate 				if(alpha(peek)){
9107c478bd9Sstevel@tonic-gate 					i = 0;
9117c478bd9Sstevel@tonic-gate 					yylval.cp = (CHR *)token;
9127c478bd9Sstevel@tonic-gate 					token[i++] = c;
9137c478bd9Sstevel@tonic-gate 					while(alpha(peek)) {
9147c478bd9Sstevel@tonic-gate 						remch(token[i++] = gch());
9157c478bd9Sstevel@tonic-gate 						if(i >= TOKENSIZE) {
9167c478bd9Sstevel@tonic-gate 							warning("string too long");
9177c478bd9Sstevel@tonic-gate 							i = TOKENSIZE - 1;
9187c478bd9Sstevel@tonic-gate 							break;
9197c478bd9Sstevel@tonic-gate 							}
9207c478bd9Sstevel@tonic-gate 						}
9217c478bd9Sstevel@tonic-gate 					if(peek == '?' || peek == '*' || peek == '+')
9227c478bd9Sstevel@tonic-gate 						munput('c',&token[--i]);
9237c478bd9Sstevel@tonic-gate 					token[i] = 0;
9247c478bd9Sstevel@tonic-gate 					if(i == 1){
9257c478bd9Sstevel@tonic-gate 						yylval.i = (unsigned)(token[0]);
9267c478bd9Sstevel@tonic-gate 						x = CHAR;
9277c478bd9Sstevel@tonic-gate 						}
9287c478bd9Sstevel@tonic-gate 					else x = STR;
9297c478bd9Sstevel@tonic-gate 					}
9307c478bd9Sstevel@tonic-gate 				else {
9317c478bd9Sstevel@tonic-gate 					yylval.i = (unsigned)c;
9327c478bd9Sstevel@tonic-gate 					x = CHAR;
9337c478bd9Sstevel@tonic-gate 					}
9347c478bd9Sstevel@tonic-gate 				}
9357c478bd9Sstevel@tonic-gate 			scon = FALSE;
9367c478bd9Sstevel@tonic-gate 			peekon = 0;
9377c478bd9Sstevel@tonic-gate 			if((x == SCON) || (x == XSCON))
9387c478bd9Sstevel@tonic-gate 				scon = TRUE;
9397c478bd9Sstevel@tonic-gate 			sectbegin = FALSE;
9407c478bd9Sstevel@tonic-gate 			return(freturn(x));
9417c478bd9Sstevel@tonic-gate 			/* NOTREACHED */
9427c478bd9Sstevel@tonic-gate 			}
9437c478bd9Sstevel@tonic-gate 		}
9447c478bd9Sstevel@tonic-gate 	/* section three */
9457c478bd9Sstevel@tonic-gate 	lgate();
9467c478bd9Sstevel@tonic-gate 	ptail();
9477c478bd9Sstevel@tonic-gate # ifdef DEBUG
9487c478bd9Sstevel@tonic-gate 	if(debug)
9497c478bd9Sstevel@tonic-gate 		(void) fprintf(fout,"\n/*this comes from section three - debug */\n");
9507c478bd9Sstevel@tonic-gate # endif
9517c478bd9Sstevel@tonic-gate 
9527c478bd9Sstevel@tonic-gate 	if(getl(buf) && !eof) {
9537c478bd9Sstevel@tonic-gate   		if (sargv[optind] == NULL)
9547c478bd9Sstevel@tonic-gate 			(void) fprintf(fout, "\n# line %d\n", yyline-1);
9557c478bd9Sstevel@tonic-gate 		else
9567c478bd9Sstevel@tonic-gate 			(void) fprintf(fout,
9577c478bd9Sstevel@tonic-gate 				"\n# line %d \"%s\"\n", yyline-1, sargv[optind]);
9581dd08564Sab 		(void) fprintf(fout,WSFMT("%ws\n"),buf);
9597c478bd9Sstevel@tonic-gate 		while(getl(buf) && !eof)
9601dd08564Sab 			(void) fprintf(fout,WSFMT("%ws\n"),buf);
9617c478bd9Sstevel@tonic-gate         }
9627c478bd9Sstevel@tonic-gate 
9637c478bd9Sstevel@tonic-gate 	return(freturn(0));
9647c478bd9Sstevel@tonic-gate 	}
9657c478bd9Sstevel@tonic-gate /* end of yylex */
9667c478bd9Sstevel@tonic-gate # ifdef DEBUG
freturn(i)9677c478bd9Sstevel@tonic-gate freturn(i)
9687c478bd9Sstevel@tonic-gate   int i; {
9697c478bd9Sstevel@tonic-gate 	if(yydebug) {
9707c478bd9Sstevel@tonic-gate 		(void) printf("now return ");
9717c478bd9Sstevel@tonic-gate 		if((unsigned)i < NCH) allprint(i);
9727c478bd9Sstevel@tonic-gate 		else (void) printf("%d",i);
9737c478bd9Sstevel@tonic-gate 		(void) printf("   yylval = ");
9747c478bd9Sstevel@tonic-gate 		switch(i){
9757c478bd9Sstevel@tonic-gate 			case STR: case CCL: case NCCL:
9767c478bd9Sstevel@tonic-gate 				strpt(yylval.cp);
9777c478bd9Sstevel@tonic-gate 				break;
9787c478bd9Sstevel@tonic-gate 			case CHAR:
9797c478bd9Sstevel@tonic-gate 				allprint(yylval.i);
9807c478bd9Sstevel@tonic-gate 				break;
9817c478bd9Sstevel@tonic-gate 			default:
9827c478bd9Sstevel@tonic-gate 				(void) printf("%d",yylval.i);
9837c478bd9Sstevel@tonic-gate 				break;
9847c478bd9Sstevel@tonic-gate 			}
9857c478bd9Sstevel@tonic-gate 		(void) putchar('\n');
9867c478bd9Sstevel@tonic-gate 		}
9877c478bd9Sstevel@tonic-gate 	return(i);
9887c478bd9Sstevel@tonic-gate 	}
9897c478bd9Sstevel@tonic-gate # endif
990