xref: /onnv-gate/usr/src/cmd/sgs/lex/common/nceucform (revision 0:68f95e015346)
1*0Sstevel@tonic-gate/*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate/*
23*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc.
24*0Sstevel@tonic-gate * All rights reserved.
25*0Sstevel@tonic-gate * Use is subject to license terms.
26*0Sstevel@tonic-gate */
27*0Sstevel@tonic-gate
28*0Sstevel@tonic-gate/*	Copyright (c) 1989 AT&T	*/
29*0Sstevel@tonic-gate/*	  All Rights Reserved  	*/
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gate
32*0Sstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
33*0Sstevel@tonic-gate
34*0Sstevel@tonic-gateint yylineno =1;
35*0Sstevel@tonic-gateint yygid;
36*0Sstevel@tonic-gate#define LONG_WCHAR_T 1
37*0Sstevel@tonic-gate# define YYU(x) x
38*0Sstevel@tonic-gate# define NLSTATE yyprevious=YYNEWLINE
39*0Sstevel@tonic-gatewchar_t yysbuf[YYLMAX];
40*0Sstevel@tonic-gatewchar_t *yysptr = yysbuf;
41*0Sstevel@tonic-gatestruct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
42*0Sstevel@tonic-gateint *yyfnd;
43*0Sstevel@tonic-gateextern struct yysvf *yyestate;
44*0Sstevel@tonic-gateint yyprevious = YYNEWLINE;
45*0Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
46*0Sstevel@tonic-gateint yylook(void)
47*0Sstevel@tonic-gate#else
48*0Sstevel@tonic-gateyylook()
49*0Sstevel@tonic-gate#endif
50*0Sstevel@tonic-gate{
51*0Sstevel@tonic-gate	struct yysvf *yystate, **lsp;
52*0Sstevel@tonic-gate	struct yywork *yyt;
53*0Sstevel@tonic-gate	struct yysvf *yyz;
54*0Sstevel@tonic-gate	int yych, yyfirst;
55*0Sstevel@tonic-gate	struct yywork *yyr;
56*0Sstevel@tonic-gate# ifdef LEXDEBUG
57*0Sstevel@tonic-gate	int debug;
58*0Sstevel@tonic-gate# endif
59*0Sstevel@tonic-gate	wchar_t *yylastch;
60*0Sstevel@tonic-gate	/* start off machines */
61*0Sstevel@tonic-gate# ifdef LEXDEBUG
62*0Sstevel@tonic-gate	debug = 0;
63*0Sstevel@tonic-gate# endif
64*0Sstevel@tonic-gate	yyfirst=1;
65*0Sstevel@tonic-gate	if (!yymorfg)
66*0Sstevel@tonic-gate		yylastch = YYTEXT;
67*0Sstevel@tonic-gate	else {
68*0Sstevel@tonic-gate		yymorfg=0;
69*0Sstevel@tonic-gate		yylastch = YYTEXT+YYLENG;
70*0Sstevel@tonic-gate		}
71*0Sstevel@tonic-gate	for(;;){
72*0Sstevel@tonic-gate		lsp = yylstate;
73*0Sstevel@tonic-gate		yyestate = yystate = yybgin;
74*0Sstevel@tonic-gate		if (yyprevious==YYNEWLINE) yystate++;
75*0Sstevel@tonic-gate		for (;;){
76*0Sstevel@tonic-gate# ifdef LEXDEBUG
77*0Sstevel@tonic-gate			if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
78*0Sstevel@tonic-gate# endif
79*0Sstevel@tonic-gate			yyt = yystate->yystoff;
80*0Sstevel@tonic-gate			if(yyt == yycrank && !yyfirst){  /* may not be any transitions */
81*0Sstevel@tonic-gate				yyz = yystate->yyother;
82*0Sstevel@tonic-gate				if(yyz == 0)break;
83*0Sstevel@tonic-gate				if(yyz->yystoff == yycrank)break;
84*0Sstevel@tonic-gate				}
85*0Sstevel@tonic-gate			*yylastch++ = yych = YYINPUT();
86*0Sstevel@tonic-gate#ifdef YYISARRAY
87*0Sstevel@tonic-gate			if(yylastch > &YYTEXT[YYLMAX]) {
88*0Sstevel@tonic-gate				fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
89*0Sstevel@tonic-gate				exit(1);
90*0Sstevel@tonic-gate			}
91*0Sstevel@tonic-gate#else
92*0Sstevel@tonic-gate			if (yylastch >= &YYTEXT[ yytextsz ]) {
93*0Sstevel@tonic-gate				int	x = yylastch - YYTEXT;
94*0Sstevel@tonic-gate
95*0Sstevel@tonic-gate				yytextsz += YYTEXTSZINC;
96*0Sstevel@tonic-gate#ifdef YYLEX_E /* -e */
97*0Sstevel@tonic-gate				if (YYTEXT == yy_twbuf) {
98*0Sstevel@tonic-gate					YYTEXT = (wchar_t *)
99*0Sstevel@tonic-gate						malloc(yytextsz *
100*0Sstevel@tonic-gate							sizeof (wchar_t));
101*0Sstevel@tonic-gate					memcpy(YYTEXT, yy_twbuf,
102*0Sstevel@tonic-gate						sizeof (yy_twbuf));
103*0Sstevel@tonic-gate					yytext = (wchar_t *)
104*0Sstevel@tonic-gate						malloc(yytextsz *
105*0Sstevel@tonic-gate							sizeof (wchar_t));
106*0Sstevel@tonic-gate					memcpy(yytext, yy_tbuf,
107*0Sstevel@tonic-gate						sizeof (yy_tbuf));
108*0Sstevel@tonic-gate#else
109*0Sstevel@tonic-gate				if (YYTEXT == yy_tbuf) {
110*0Sstevel@tonic-gate					YYTEXT = (wchar_t *)
111*0Sstevel@tonic-gate						malloc(yytextsz *
112*0Sstevel@tonic-gate							sizeof (wchar_t));
113*0Sstevel@tonic-gate					memcpy(YYTEXT, yy_tbuf,
114*0Sstevel@tonic-gate						sizeof (yy_tbuf));
115*0Sstevel@tonic-gate#endif
116*0Sstevel@tonic-gate				}
117*0Sstevel@tonic-gate				else {
118*0Sstevel@tonic-gate					YYTEXT = (wchar_t *)
119*0Sstevel@tonic-gate						realloc(YYTEXT, yytextsz);
120*0Sstevel@tonic-gate#ifdef YYLEX_E /* -e */
121*0Sstevel@tonic-gate					yytext = (wchar_t *)
122*0Sstevel@tonic-gate						realloc(yytext,
123*0Sstevel@tonic-gate						yytextsz * sizeof (wchar_t));
124*0Sstevel@tonic-gate#endif
125*0Sstevel@tonic-gate				}
126*0Sstevel@tonic-gate				if (!YYTEXT) {
127*0Sstevel@tonic-gate					fprintf(yyout,
128*0Sstevel@tonic-gate					"Cannot realloc YYTEXT\n");
129*0Sstevel@tonic-gate					exit(1);
130*0Sstevel@tonic-gate				}
131*0Sstevel@tonic-gate				yylastch = YYTEXT + x;
132*0Sstevel@tonic-gate			}
133*0Sstevel@tonic-gate#endif
134*0Sstevel@tonic-gate			yygid = yycgid(yych);
135*0Sstevel@tonic-gate			yyfirst=0;
136*0Sstevel@tonic-gate		tryagain:
137*0Sstevel@tonic-gate# ifdef LEXDEBUG
138*0Sstevel@tonic-gate			if(debug){
139*0Sstevel@tonic-gate				fprintf(yyout,"wchar_t ");
140*0Sstevel@tonic-gate				allprint(yych);
141*0Sstevel@tonic-gate				fprintf(yyout," gid %d\n", yygid);
142*0Sstevel@tonic-gate				}
143*0Sstevel@tonic-gate# endif
144*0Sstevel@tonic-gate			yyr = yyt;
145*0Sstevel@tonic-gate			if ( (uintptr_t)yyt > (uintptr_t)yycrank){
146*0Sstevel@tonic-gate				yyt = yyr + yygid;
147*0Sstevel@tonic-gate				if (yyt <= yytop && yyt->verify+yysvec == yystate){
148*0Sstevel@tonic-gate					if(yyt->advance+yysvec == YYLERR)	/* error transitions */
149*0Sstevel@tonic-gate						{YYUNPUT(*--yylastch);break;}
150*0Sstevel@tonic-gate					*lsp++ = yystate = yyt->advance+yysvec;
151*0Sstevel@tonic-gate					if(lsp > &yylstate[YYLMAX]) {
152*0Sstevel@tonic-gate						fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
153*0Sstevel@tonic-gate						exit(1);
154*0Sstevel@tonic-gate					}
155*0Sstevel@tonic-gate					goto contin;
156*0Sstevel@tonic-gate					}
157*0Sstevel@tonic-gate				}
158*0Sstevel@tonic-gate# ifdef YYOPTIM
159*0Sstevel@tonic-gate			else if((uintptr_t)yyt < (uintptr_t)yycrank) {	/* r < yycrank */
160*0Sstevel@tonic-gate				yyt = yyr = yycrank+(yycrank-yyt);
161*0Sstevel@tonic-gate# ifdef LEXDEBUG
162*0Sstevel@tonic-gate				if(debug)fprintf(yyout,"compressed state\n");
163*0Sstevel@tonic-gate# endif
164*0Sstevel@tonic-gate				yyt = yyt + yygid;
165*0Sstevel@tonic-gate				if(yyt <= yytop && yyt->verify+yysvec == yystate){
166*0Sstevel@tonic-gate					if(yyt->advance+yysvec == YYLERR)	/* error transitions */
167*0Sstevel@tonic-gate						{YYUNPUT(*--yylastch);break;}
168*0Sstevel@tonic-gate					*lsp++ = yystate = yyt->advance+yysvec;
169*0Sstevel@tonic-gate					if(lsp > &yylstate[YYLMAX]) {
170*0Sstevel@tonic-gate						fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
171*0Sstevel@tonic-gate						exit(1);
172*0Sstevel@tonic-gate					}
173*0Sstevel@tonic-gate					goto contin;
174*0Sstevel@tonic-gate					}
175*0Sstevel@tonic-gate				yyt = yyr + YYU(yymatch[yygid]);
176*0Sstevel@tonic-gate# ifdef LEXDEBUG
177*0Sstevel@tonic-gate				if(debug){
178*0Sstevel@tonic-gate					fprintf(yyout,"try fall back character ");
179*0Sstevel@tonic-gate					allprint_w(YYU(yymatch[yygid]));
180*0Sstevel@tonic-gate					fprintf(yyout," gid %d\n", yygid);
181*0Sstevel@tonic-gate					}
182*0Sstevel@tonic-gate# endif
183*0Sstevel@tonic-gate				if(yyt <= yytop && yyt->verify+yysvec == yystate){
184*0Sstevel@tonic-gate					if(yyt->advance+yysvec == YYLERR)	/* error transition */
185*0Sstevel@tonic-gate						{YYUNPUT(*--yylastch);break;}
186*0Sstevel@tonic-gate					*lsp++ = yystate = yyt->advance+yysvec;
187*0Sstevel@tonic-gate					if(lsp > &yylstate[YYLMAX]) {
188*0Sstevel@tonic-gate						fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
189*0Sstevel@tonic-gate						exit(1);
190*0Sstevel@tonic-gate					}
191*0Sstevel@tonic-gate					goto contin;
192*0Sstevel@tonic-gate					}
193*0Sstevel@tonic-gate				}
194*0Sstevel@tonic-gate			if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
195*0Sstevel@tonic-gate# ifdef LEXDEBUG
196*0Sstevel@tonic-gate				if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
197*0Sstevel@tonic-gate# endif
198*0Sstevel@tonic-gate				goto tryagain;
199*0Sstevel@tonic-gate				}
200*0Sstevel@tonic-gate# endif
201*0Sstevel@tonic-gate			else
202*0Sstevel@tonic-gate				{YYUNPUT(*--yylastch);break;}
203*0Sstevel@tonic-gate		contin:
204*0Sstevel@tonic-gate# ifdef LEXDEBUG
205*0Sstevel@tonic-gate			if(debug){
206*0Sstevel@tonic-gate				fprintf(yyout,"state %d wchar_t ",yystate-yysvec-1);
207*0Sstevel@tonic-gate				allprint_w(yych);
208*0Sstevel@tonic-gate				fprintf(yyout," gid %d\n", yygid);
209*0Sstevel@tonic-gate				}
210*0Sstevel@tonic-gate# endif
211*0Sstevel@tonic-gate			;
212*0Sstevel@tonic-gate			}
213*0Sstevel@tonic-gate# ifdef LEXDEBUG
214*0Sstevel@tonic-gate		if(debug){
215*0Sstevel@tonic-gate			fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
216*0Sstevel@tonic-gate			allprint_w(yych);
217*0Sstevel@tonic-gate			fprintf(yyout," gid %d\n", yygid);
218*0Sstevel@tonic-gate			}
219*0Sstevel@tonic-gate# endif
220*0Sstevel@tonic-gate		while (lsp-- > yylstate){
221*0Sstevel@tonic-gate			*yylastch-- = 0;
222*0Sstevel@tonic-gate			if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
223*0Sstevel@tonic-gate				yyolsp = lsp;
224*0Sstevel@tonic-gate				if(yyextra[*yyfnd]){		/* must backup */
225*0Sstevel@tonic-gate					while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
226*0Sstevel@tonic-gate						lsp--;
227*0Sstevel@tonic-gate						YYUNPUT(*yylastch--);
228*0Sstevel@tonic-gate						}
229*0Sstevel@tonic-gate					}
230*0Sstevel@tonic-gate				yyprevious = YYU(*yylastch);
231*0Sstevel@tonic-gate				yylsp = lsp;
232*0Sstevel@tonic-gate				YYLENG = yylastch-YYTEXT+1;
233*0Sstevel@tonic-gate				YYTEXT[YYLENG] = 0;
234*0Sstevel@tonic-gate# ifdef LEXDEBUG
235*0Sstevel@tonic-gate				if(debug){
236*0Sstevel@tonic-gate					fprintf(yyout,"\nmatch ");
237*0Sstevel@tonic-gate					sprint_w(YYTEXT);
238*0Sstevel@tonic-gate					fprintf(yyout," action %d\n",*yyfnd);
239*0Sstevel@tonic-gate					}
240*0Sstevel@tonic-gate# endif
241*0Sstevel@tonic-gate#ifdef YYLEX_E /* -e */
242*0Sstevel@tonic-gate				yyleng=wcstombs((char *)yytext, YYTEXT, sizeof(yytext)-1);
243*0Sstevel@tonic-gate#ifdef LEXDEBUG
244*0Sstevel@tonic-gate				if(yyleng>=sizeof(yytext)-1)
245*0Sstevel@tonic-gate					fprintf(yyout, "yytext[] too short\n");
246*0Sstevel@tonic-gate#endif
247*0Sstevel@tonic-gate#endif
248*0Sstevel@tonic-gate				return(*yyfnd++);
249*0Sstevel@tonic-gate				}
250*0Sstevel@tonic-gate			YYUNPUT(*yylastch);
251*0Sstevel@tonic-gate			}
252*0Sstevel@tonic-gate		if (YYTEXT[0] == 0  /* && feof(yyin) */)
253*0Sstevel@tonic-gate			{
254*0Sstevel@tonic-gate			yysptr=yysbuf;
255*0Sstevel@tonic-gate			return(0);
256*0Sstevel@tonic-gate			}
257*0Sstevel@tonic-gate		yyprevious = YYTEXT[0] = YYINPUT();
258*0Sstevel@tonic-gate		if (yyprevious>0)
259*0Sstevel@tonic-gate			YYOUTPUT(yyprevious);
260*0Sstevel@tonic-gate		yylastch=YYTEXT;
261*0Sstevel@tonic-gate# ifdef LEXDEBUG
262*0Sstevel@tonic-gate		if(debug)putchar('\n');
263*0Sstevel@tonic-gate# endif
264*0Sstevel@tonic-gate		}
265*0Sstevel@tonic-gate	}
266*0Sstevel@tonic-gateint
267*0Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
268*0Sstevel@tonic-gateyyback(int *p, int m)
269*0Sstevel@tonic-gate#else
270*0Sstevel@tonic-gateyyback(p, m)
271*0Sstevel@tonic-gate	int *p;
272*0Sstevel@tonic-gate	int m;
273*0Sstevel@tonic-gate#endif
274*0Sstevel@tonic-gate{
275*0Sstevel@tonic-gate	if (p==0) return(0);
276*0Sstevel@tonic-gate	while (*p) {
277*0Sstevel@tonic-gate		if (*p++ == m)
278*0Sstevel@tonic-gate			return(1);
279*0Sstevel@tonic-gate	}
280*0Sstevel@tonic-gate	return(0);
281*0Sstevel@tonic-gate}
282*0Sstevel@tonic-gate
283*0Sstevel@tonic-gate#ifdef YYLEX_E /* -e */
284*0Sstevel@tonic-gatewchar_t
285*0Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
286*0Sstevel@tonic-gateyywinput(void){
287*0Sstevel@tonic-gate#else
288*0Sstevel@tonic-gateyywinput(){
289*0Sstevel@tonic-gate#endif
290*0Sstevel@tonic-gate	unsigned char eucbuf[MB_LEN_MAX];
291*0Sstevel@tonic-gate	wchar_t wc;
292*0Sstevel@tonic-gate	unsigned char *p=eucbuf;
293*0Sstevel@tonic-gate	int n;
294*0Sstevel@tonic-gate
295*0Sstevel@tonic-gate#ifndef __cplusplus
296*0Sstevel@tonic-gate	*p++=input();
297*0Sstevel@tonic-gate	n=euclen(eucbuf);
298*0Sstevel@tonic-gate	while(--n>0) *p++=input();
299*0Sstevel@tonic-gate#else
300*0Sstevel@tonic-gate	*p++=lex_input();
301*0Sstevel@tonic-gate	n=euclen(eucbuf);
302*0Sstevel@tonic-gate	while(--n>0) *p++=lex_input();
303*0Sstevel@tonic-gate#endif
304*0Sstevel@tonic-gate	*p=0;
305*0Sstevel@tonic-gate
306*0Sstevel@tonic-gate	mbtowc( &wc, (char *)eucbuf, MB_LEN_MAX );
307*0Sstevel@tonic-gate	return wc;
308*0Sstevel@tonic-gate}
309*0Sstevel@tonic-gate
310*0Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
311*0Sstevel@tonic-gatevoid
312*0Sstevel@tonic-gateyywoutput(wchar_t wc)
313*0Sstevel@tonic-gate#else
314*0Sstevel@tonic-gateyywoutput(wc)
315*0Sstevel@tonic-gate	wchar_t wc;
316*0Sstevel@tonic-gate#endif
317*0Sstevel@tonic-gate{
318*0Sstevel@tonic-gate	unsigned char eucbuf[MB_LEN_MAX];
319*0Sstevel@tonic-gate	int n;
320*0Sstevel@tonic-gate	unsigned char *p=eucbuf;
321*0Sstevel@tonic-gate
322*0Sstevel@tonic-gate	n=wctomb( (char *)eucbuf, wc );
323*0Sstevel@tonic-gate#ifndef __cplusplus
324*0Sstevel@tonic-gate	while(n-->0) output(*p++);
325*0Sstevel@tonic-gate#else
326*0Sstevel@tonic-gate	while(n-->0) lex_output(*p++);
327*0Sstevel@tonic-gate#endif
328*0Sstevel@tonic-gate}
329*0Sstevel@tonic-gate
330*0Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
331*0Sstevel@tonic-gatevoid
332*0Sstevel@tonic-gateyywunput(wchar_t wc)
333*0Sstevel@tonic-gate#else
334*0Sstevel@tonic-gateyywunput(wc)
335*0Sstevel@tonic-gate	wchar_t wc;
336*0Sstevel@tonic-gate#endif
337*0Sstevel@tonic-gate{
338*0Sstevel@tonic-gate	unsigned char eucbuf[MB_LEN_MAX];
339*0Sstevel@tonic-gate	int n;
340*0Sstevel@tonic-gate	unsigned char *p;
341*0Sstevel@tonic-gate
342*0Sstevel@tonic-gate	n=wctomb( (char *)eucbuf, wc );
343*0Sstevel@tonic-gate	p=eucbuf+n;
344*0Sstevel@tonic-gate	while(n-->0) unput(*--p);
345*0Sstevel@tonic-gate}
346*0Sstevel@tonic-gate#endif
347*0Sstevel@tonic-gate
348*0Sstevel@tonic-gate#ifdef LONG_WCHAR_T
349*0Sstevel@tonic-gate#define yylinearize(lc) lc
350*0Sstevel@tonic-gate#else/*!LONG_WCHAR_T*/
351*0Sstevel@tonic-gateunsigned long
352*0Sstevel@tonic-gateyylinearize(wc)
353*0Sstevel@tonic-gate     wchar_t    wc;
354*0Sstevel@tonic-gate{
355*0Sstevel@tonic-gate	unsigned long   prefix;
356*0Sstevel@tonic-gate	switch(wc&0x8080){
357*0Sstevel@tonic-gate	      case 0x0000:      prefix=0x00000000; break;
358*0Sstevel@tonic-gate	      case 0x0080:      prefix=0x20000000; break;
359*0Sstevel@tonic-gate	      case 0x8000:      prefix=0x40000000; break;
360*0Sstevel@tonic-gate	      case 0x8080:      prefix=0x60000000; break;
361*0Sstevel@tonic-gate	}
362*0Sstevel@tonic-gate	return prefix|wc;
363*0Sstevel@tonic-gate}
364*0Sstevel@tonic-gate#endif/*!LONG_WCHAR_T*/
365*0Sstevel@tonic-gateint
366*0Sstevel@tonic-gateyycgid(c)
367*0Sstevel@tonic-gate     wchar_t	c;
368*0Sstevel@tonic-gate{
369*0Sstevel@tonic-gate	int first = 0;
370*0Sstevel@tonic-gate	int last = YYNCGIDTBL - 1;
371*0Sstevel@tonic-gate	unsigned long lc=yylinearize(c);
372*0Sstevel@tonic-gate
373*0Sstevel@tonic-gate	if( yycgidtbl[YYNCGIDTBL-1] < lc ) return YYNCGIDTBL*2-1;
374*0Sstevel@tonic-gate
375*0Sstevel@tonic-gate	while (last >= 0) {
376*0Sstevel@tonic-gate		int i = (first+last)/2;
377*0Sstevel@tonic-gate		if (lc == yycgidtbl[i])
378*0Sstevel@tonic-gate		    return (2*i);
379*0Sstevel@tonic-gate		else if ( yycgidtbl[i]<lc) {
380*0Sstevel@tonic-gate			if (lc<yycgidtbl[i+1])
381*0Sstevel@tonic-gate			    return (2*i+1);
382*0Sstevel@tonic-gate			else
383*0Sstevel@tonic-gate			    first = i + 1;
384*0Sstevel@tonic-gate		}else
385*0Sstevel@tonic-gate		    last = i - 1;
386*0Sstevel@tonic-gate	}
387*0Sstevel@tonic-gate	return 0; /*Error*/
388*0Sstevel@tonic-gate}
389*0Sstevel@tonic-gate
390*0Sstevel@tonic-gate
391*0Sstevel@tonic-gate
392*0Sstevel@tonic-gate
393*0Sstevel@tonic-gate
394*0Sstevel@tonic-gate	/* the following are only used in the lex library */
395*0Sstevel@tonic-gateint
396*0Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
397*0Sstevel@tonic-gateyyinput(void)
398*0Sstevel@tonic-gate#else
399*0Sstevel@tonic-gateyyinput()
400*0Sstevel@tonic-gate#endif
401*0Sstevel@tonic-gate{
402*0Sstevel@tonic-gate#ifndef __cplusplus
403*0Sstevel@tonic-gate	return(input());
404*0Sstevel@tonic-gate#else
405*0Sstevel@tonic-gate	return(lex_input());
406*0Sstevel@tonic-gate#endif
407*0Sstevel@tonic-gate	}
408*0Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
409*0Sstevel@tonic-gatevoid
410*0Sstevel@tonic-gateyyoutput(int c)
411*0Sstevel@tonic-gate#else
412*0Sstevel@tonic-gateyyoutput(c)
413*0Sstevel@tonic-gate  int c;
414*0Sstevel@tonic-gate#endif
415*0Sstevel@tonic-gate{
416*0Sstevel@tonic-gate#ifndef __cplusplus
417*0Sstevel@tonic-gate	output(c);
418*0Sstevel@tonic-gate#else
419*0Sstevel@tonic-gate	lex_output(c);
420*0Sstevel@tonic-gate#endif
421*0Sstevel@tonic-gate	}
422*0Sstevel@tonic-gate#if defined(__cplusplus) || defined(__STDC__)
423*0Sstevel@tonic-gatevoid
424*0Sstevel@tonic-gateyyunput(int c)
425*0Sstevel@tonic-gate#else
426*0Sstevel@tonic-gateyyunput(c)
427*0Sstevel@tonic-gate   int c;
428*0Sstevel@tonic-gate#endif
429*0Sstevel@tonic-gate{
430*0Sstevel@tonic-gate	unput(c);
431*0Sstevel@tonic-gate	}
432