1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <inttypes.h>
4 # define U(x) x
5 # define NLSTATE fruprevious=YYNEWLINE
6 # define BEGIN frubgin = frusvec + 1 +
7 # define INITIAL 0
8 # define YYLERR frusvec
9 # define YYSTATE (fruestate-frusvec-1)
10 # define YYOPTIM 1
11 # ifndef YYLMAX
12 # define YYLMAX BUFSIZ
13 # endif
14 #ifndef __cplusplus
15 # define output(c) (void)putc(c,fruout)
16 #else
17 # define lex_output(c) (void)putc(c,fruout)
18 #endif
19 
20 #if defined(__cplusplus) || defined(__STDC__)
21 
22 #if defined(__cplusplus) && defined(__EXTERN_C__)
23 extern "C" {
24 #endif
25 	int fruback(int *, int);
26 	int fruinput(void);
27 	int frulook(void);
28 	void fruoutput(int);
29 	int fruracc(int);
30 	int frureject(void);
31 	void fruunput(int);
32 	int frulex(void);
33 #ifdef YYLEX_E
34 	void fruwoutput(wchar_t);
35 	wchar_t fruwinput(void);
36 	void yywunput(wchar_t);
37 #endif
38 #ifndef fruless
39 	int fruless(int);
40 #endif
41 #ifndef fruwrap
42 	int fruwrap(void);
43 #endif
44 #ifdef LEXDEBUG
45 	void allprint(char);
46 	void sprint(char *);
47 #endif
48 #if defined(__cplusplus) && defined(__EXTERN_C__)
49 }
50 #endif
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 	void exit(int);
56 #ifdef __cplusplus
57 }
58 #endif
59 
60 #endif
61 # define unput(c) {frutchar= (c);if(frutchar=='\n')frulineno--;*frusptr++=frutchar;}
62 # define yymore() (frumorfg=1)
63 #ifndef __cplusplus
64 # define input() (((frutchar=frusptr>frusbuf?U(*--frusptr):getc(fruin))==10?(frulineno++,frutchar):frutchar)==EOF?0:frutchar)
65 #else
66 # define lex_input() (((frutchar=frusptr>frusbuf?U(*--frusptr):getc(fruin))==10?(frulineno++,frutchar):frutchar)==EOF?0:frutchar)
67 #endif
68 #define ECHO fprintf(fruout, "%s",frutext)
69 # define REJECT { nstr = frureject(); goto yyfussy;}
70 int fruleng;
71 #define YYISARRAY
72 char frutext[YYLMAX];
73 int frumorfg;
74 extern char *frusptr, frusbuf[];
75 int frutchar;
76 FILE *fruin = {stdin}, *fruout = {stdout};
77 extern int frulineno;
78 struct yysvf {
79 	struct yywork *yystoff;
80 	struct yysvf *yyother;
81 	int *yystops;};
82 struct yysvf *fruestate;
83 extern struct yysvf frusvec[], *frubgin;
84 
85 # line 3 "../libfru/nameSyntaxLex.l"
86 /*
87  * CDDL HEADER START
88  *
89  * The contents of this file are subject to the terms of the
90  * Common Development and Distribution License, Version 1.0 only
91  * (the "License").  You may not use this file except in compliance
92  * with the License.
93  *
94  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95  * or http://www.opensolaris.org/os/licensing.
96  * See the License for the specific language governing permissions
97  * and limitations under the License.
98  *
99  * When distributing Covered Code, include this CDDL HEADER in each
100  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
101  * If applicable, add the following below this CDDL HEADER, with the
102  * fields enclosed by brackets "[]" replaced with your own identifying
103  * information: Portions Copyright [yyyy] [name of copyright owner]
104  *
105  * CDDL HEADER END
106  *
107  * Copyright (c) 2000 by Sun Microsystems, Inc.
108  * All rights reserved.
109  */
110 
111 #pragma ident	"%Z%%M%	%I%	%E% SMI"
112 
113 #include <string.h>
114 
115 
116 # line 32 "../libfru/nameSyntaxLex.l"
117 /* this is the lexer for the libfru NamingSyntax */
118 
119 # line 33 "../libfru/nameSyntaxLex.l"
120 /* parser.h MUST occur before nameSyntax.tab.h */
121 #include "Parser.h"
122 
123 extern char *gParserString;
124 
125 #undef input
126 #undef unput
127 #define input()(*gParserString++)
128 #define unput(c)(*--gParserString=c)
129 
130 #undef lex_input
131 #define lex_input()(*gParserString++)
132 
133 #include "y.tab.h"
134 
135 
136 # line 48 "../libfru/nameSyntaxLex.l"
137 /* Keep the separator symbols here because the lexer is the only one who knows
138  * about the string being parsed. */
139 
140 # define YYNEWLINE 10
141 int frulex(){
142 int nstr; extern int fruprevious;
143 #ifdef __cplusplus
144 /* to avoid CC and lint complaining yyfussy not being used ...*/
145 static int __lex_hack = 0;
146 if (__lex_hack) goto yyfussy;
147 #endif
148 while((nstr = frulook()) >= 0)
149 yyfussy: switch(nstr){
150 case 0:
151 if(fruwrap()) return(0); break;
152 case 1:
153 
154 # line 54 "../libfru/nameSyntaxLex.l"
155 { return LAST; }
156 break;
157 case 2:
158 
159 # line 55 "../libfru/nameSyntaxLex.l"
160 { return ADD; }
161 break;
162 case 3:
163 
164 # line 56 "../libfru/nameSyntaxLex.l"
165 { return SEPIDENT; }
166 break;
167 case 4:
168 
169 # line 57 "../libfru/nameSyntaxLex.l"
170 { return ITERBEGIN; }
171 break;
172 case 5:
173 
174 # line 58 "../libfru/nameSyntaxLex.l"
175 { return ITEREND; }
176 break;
177 case 6:
178 
179 # line 60 "../libfru/nameSyntaxLex.l"
180 { frulval.num = atoi (frutext); return NUMBER; }
181 break;
182 case 7:
183 
184 # line 61 "../libfru/nameSyntaxLex.l"
185 { frulval.name = strdup(frutext); return NAME; }
186 break;
187 case -1:
188 break;
189 default:
190 (void)fprintf(fruout,"bad switch frulook %d",nstr);
191 } return(0); }
192 /* end of frulex */
193 
194 # line 64 "../libfru/nameSyntaxLex.l"
195 
196 int fruvstop[] = {
197 0,
198 
199 1,
200 0,
201 
202 2,
203 0,
204 
205 3,
206 0,
207 
208 6,
209 7,
210 0,
211 
212 7,
213 0,
214 
215 4,
216 0,
217 
218 5,
219 0,
220 0};
221 # define YYTYPE unsigned char
222 struct yywork { YYTYPE verify, advance; } frucrank[] = {
223 0,0,	0,0,	0,0,	0,0,
224 0,0,	0,0,	0,0,	0,0,
225 0,0,	0,0,	0,0,	0,0,
226 0,0,	0,0,	0,0,	0,0,
227 0,0,	0,0,	0,0,	0,0,
228 0,0,	0,0,	0,0,	0,0,
229 0,0,	0,0,	0,0,	0,0,
230 0,0,	0,0,	0,0,	0,0,
231 0,0,	0,0,	0,0,	0,0,
232 0,0,	1,3,	0,0,	0,0,
233 0,0,	0,0,	0,0,	0,0,
234 1,4,	0,0,	0,0,	0,0,
235 1,5,	1,6,	1,6,	1,6,
236 1,6,	1,6,	1,6,	1,6,
237 1,6,	1,6,	1,6,	0,0,
238 0,0,	0,0,	0,0,	0,0,
239 0,0,	0,0,	1,7,	1,7,
240 1,7,	1,7,	1,7,	1,7,
241 1,7,	1,7,	1,7,	1,7,
242 1,7,	1,7,	1,7,	1,7,
243 1,7,	1,7,	1,7,	1,7,
244 1,7,	1,7,	1,7,	1,7,
245 1,7,	1,7,	1,7,	1,7,
246 1,8,	0,0,	1,9,	0,0,
247 1,7,	0,0,	1,7,	1,7,
248 1,7,	1,7,	1,7,	1,7,
249 1,7,	1,7,	1,7,	1,7,
250 1,7,	1,7,	1,7,	1,7,
251 1,7,	1,7,	1,7,	1,7,
252 1,7,	1,7,	1,7,	1,7,
253 1,7,	1,7,	1,7,	1,7,
254 6,6,	6,6,	6,6,	6,6,
255 6,6,	6,6,	6,6,	6,6,
256 6,6,	6,6,	0,0,	0,0,
257 0,0,	0,0,	0,0,	0,0,
258 0,0,	6,7,	6,7,	6,7,
259 6,7,	6,7,	6,7,	6,7,
260 6,7,	6,7,	6,7,	6,7,
261 6,7,	6,7,	6,7,	6,7,
262 6,7,	6,7,	6,7,	6,7,
263 6,7,	6,7,	6,7,	6,7,
264 6,7,	6,7,	6,7,	0,0,
265 0,0,	0,0,	0,0,	6,7,
266 0,0,	6,7,	6,7,	6,7,
267 6,7,	6,7,	6,7,	6,7,
268 6,7,	6,7,	6,7,	6,7,
269 6,7,	6,7,	6,7,	6,7,
270 6,7,	6,7,	6,7,	6,7,
271 6,7,	6,7,	6,7,	6,7,
272 6,7,	6,7,	6,7,	7,7,
273 7,7,	7,7,	7,7,	7,7,
274 7,7,	7,7,	7,7,	7,7,
275 7,7,	0,0,	0,0,	0,0,
276 0,0};
277 struct yysvf frusvec[] = {
278 0,	0,	0,
279 frucrank+1,	0,		0,
280 frucrank+0,	frusvec+1,	0,
281 frucrank+0,	0,		fruvstop+1,
282 frucrank+0,	0,		fruvstop+3,
283 frucrank+0,	0,		fruvstop+5,
284 frucrank+76,	0,		fruvstop+7,
285 frucrank+151,	frusvec+6,	fruvstop+10,
286 frucrank+0,	0,		fruvstop+12,
287 frucrank+0,	0,		fruvstop+14,
288 0,	0,	0};
289 struct yywork *frutop = frucrank+208;
290 struct yysvf *frubgin = frusvec+1;
291 char frumatch[] = {
292   0,   1,   1,   1,   1,   1,   1,   1,
293   1,   1,   1,   1,   1,   1,   1,   1,
294   1,   1,   1,   1,   1,   1,   1,   1,
295   1,   1,   1,   1,   1,   1,   1,   1,
296   1,   1,   1,   1,   1,   1,   1,   1,
297   1,   1,   1,   1,   1,   1,   1,   1,
298  48,  48,  48,  48,  48,  48,  48,  48,
299  48,  48,   1,   1,   1,   1,   1,   1,
300   1,  65,  65,  65,  65,  65,  65,  65,
301  65,  65,  65,  65,  65,  65,  65,  65,
302  65,  65,  65,  65,  65,  65,  65,  65,
303  65,  65,  65,   1,   1,   1,   1,  65,
304   1,  65,  65,  65,  65,  65,  65,  65,
305  65,  65,  65,  65,  65,  65,  65,  65,
306  65,  65,  65,  65,  65,  65,  65,  65,
307  65,  65,  65,   1,   1,   1,   1,   1,
308   1,   1,   1,   1,   1,   1,   1,   1,
309   1,   1,   1,   1,   1,   1,   1,   1,
310   1,   1,   1,   1,   1,   1,   1,   1,
311   1,   1,   1,   1,   1,   1,   1,   1,
312   1,   1,   1,   1,   1,   1,   1,   1,
313   1,   1,   1,   1,   1,   1,   1,   1,
314   1,   1,   1,   1,   1,   1,   1,   1,
315   1,   1,   1,   1,   1,   1,   1,   1,
316   1,   1,   1,   1,   1,   1,   1,   1,
317   1,   1,   1,   1,   1,   1,   1,   1,
318   1,   1,   1,   1,   1,   1,   1,   1,
319   1,   1,   1,   1,   1,   1,   1,   1,
320   1,   1,   1,   1,   1,   1,   1,   1,
321   1,   1,   1,   1,   1,   1,   1,   1,
322   1,   1,   1,   1,   1,   1,   1,   1,
323   1,   1,   1,   1,   1,   1,   1,   1,
324 0};
325 char fruextra[] = {
326 0,0,0,0,0,0,0,0,
327 0};
328 /*
329  * CDDL HEADER START
330  *
331  * The contents of this file are subject to the terms of the
332  * Common Development and Distribution License, Version 1.0 only
333  * (the "License").  You may not use this file except in compliance
334  * with the License.
335  *
336  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
337  * or http://www.opensolaris.org/os/licensing.
338  * See the License for the specific language governing permissions
339  * and limitations under the License.
340  *
341  * When distributing Covered Code, include this CDDL HEADER in each
342  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
343  * If applicable, add the following below this CDDL HEADER, with the
344  * fields enclosed by brackets "[]" replaced with your own identifying
345  * information: Portions Copyright [yyyy] [name of copyright owner]
346  *
347  * CDDL HEADER END
348  */
349 
350 /*	Copyright (c) 1989 AT&T	*/
351 /*	  All Rights Reserved  	*/
352 
353 #pragma ident	"%Z%%M%	%I%	%E% SMI"
354 
355 int frulineno =1;
356 # define YYU(x) x
357 # define NLSTATE fruprevious=YYNEWLINE
358 struct yysvf *frulstate [YYLMAX], **frulsp, **fruolsp;
359 char frusbuf[YYLMAX];
360 char *frusptr = frusbuf;
361 int *frufnd;
362 extern struct yysvf *fruestate;
363 int fruprevious = YYNEWLINE;
364 #if defined(__cplusplus) || defined(__STDC__)
365 int frulook(void)
366 #else
367 frulook()
368 #endif
369 {
370 	register struct yysvf *yystate, **lsp;
371 	register struct yywork *yyt;
372 	struct yysvf *yyz;
373 	int yych, yyfirst;
374 	struct yywork *yyr;
375 # ifdef LEXDEBUG
376 	int debug;
377 # endif
378 	char *yylastch;
379 	/* start off machines */
380 # ifdef LEXDEBUG
381 	debug = 0;
382 # endif
383 	yyfirst=1;
384 	if (!frumorfg)
385 		yylastch = frutext;
386 	else {
387 		frumorfg=0;
388 		yylastch = frutext+fruleng;
389 		}
390 	for(;;){
391 		lsp = frulstate;
392 		fruestate = yystate = frubgin;
393 		if (fruprevious==YYNEWLINE) yystate++;
394 		for (;;){
395 # ifdef LEXDEBUG
396 			if(debug)fprintf(fruout,"state %d\n",yystate-frusvec-1);
397 # endif
398 			yyt = yystate->yystoff;
399 			if(yyt == frucrank && !yyfirst){  /* may not be any transitions */
400 				yyz = yystate->yyother;
401 				if(yyz == 0)break;
402 				if(yyz->yystoff == frucrank)break;
403 				}
404 #ifndef __cplusplus
405 			*yylastch++ = yych = input();
406 #else
407 			*yylastch++ = yych = lex_input();
408 #endif
409 #ifdef YYISARRAY
410 			if(yylastch > &frutext[YYLMAX]) {
411 				fprintf(fruout,"Input string too long, limit %d\n",YYLMAX);
412 				exit(1);
413 			}
414 #else
415 			if (yylastch >= &frutext[ frutextsz ]) {
416 				int	x = yylastch - frutext;
417 
418 				frutextsz += YYTEXTSZINC;
419 				if (frutext == yy_tbuf) {
420 				    frutext = (char *) malloc(frutextsz);
421 				    memcpy(frutext, yy_tbuf, sizeof (yy_tbuf));
422 				}
423 				else
424 				    frutext = (char *) realloc(frutext, frutextsz);
425 				if (!frutext) {
426 				    fprintf(fruout,
427 					"Cannot realloc frutext\n");
428 				    exit(1);
429 				}
430 				yylastch = frutext + x;
431 			}
432 #endif
433 			yyfirst=0;
434 		tryagain:
435 # ifdef LEXDEBUG
436 			if(debug){
437 				fprintf(fruout,"char ");
438 				allprint(yych);
439 				putchar('\n');
440 				}
441 # endif
442 			yyr = yyt;
443 			if ( (uintptr_t)yyt > (uintptr_t)frucrank){
444 				yyt = yyr + yych;
445 				if (yyt <= frutop && yyt->verify+frusvec == yystate){
446 					if(yyt->advance+frusvec == YYLERR)	/* error transitions */
447 						{unput(*--yylastch);break;}
448 					*lsp++ = yystate = yyt->advance+frusvec;
449 					if(lsp > &frulstate[YYLMAX]) {
450 						fprintf(fruout,"Input string too long, limit %d\n",YYLMAX);
451 						exit(1);
452 					}
453 					goto contin;
454 					}
455 				}
456 # ifdef YYOPTIM
457 			else if((uintptr_t)yyt < (uintptr_t)frucrank) {	/* r < frucrank */
458 				yyt = yyr = frucrank+(frucrank-yyt);
459 # ifdef LEXDEBUG
460 				if(debug)fprintf(fruout,"compressed state\n");
461 # endif
462 				yyt = yyt + yych;
463 				if(yyt <= frutop && yyt->verify+frusvec == yystate){
464 					if(yyt->advance+frusvec == YYLERR)	/* error transitions */
465 						{unput(*--yylastch);break;}
466 					*lsp++ = yystate = yyt->advance+frusvec;
467 					if(lsp > &frulstate[YYLMAX]) {
468 						fprintf(fruout,"Input string too long, limit %d\n",YYLMAX);
469 						exit(1);
470 					}
471 					goto contin;
472 					}
473 				yyt = yyr + YYU(frumatch[yych]);
474 # ifdef LEXDEBUG
475 				if(debug){
476 					fprintf(fruout,"try fall back character ");
477 					allprint(YYU(frumatch[yych]));
478 					putchar('\n');
479 					}
480 # endif
481 				if(yyt <= frutop && yyt->verify+frusvec == yystate){
482 					if(yyt->advance+frusvec == YYLERR)	/* error transition */
483 						{unput(*--yylastch);break;}
484 					*lsp++ = yystate = yyt->advance+frusvec;
485 					if(lsp > &frulstate[YYLMAX]) {
486 						fprintf(fruout,"Input string too long, limit %d\n",YYLMAX);
487 						exit(1);
488 					}
489 					goto contin;
490 					}
491 				}
492 			if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != frucrank){
493 # ifdef LEXDEBUG
494 				if(debug)fprintf(fruout,"fall back to state %d\n",yystate-frusvec-1);
495 # endif
496 				goto tryagain;
497 				}
498 # endif
499 			else
500 				{unput(*--yylastch);break;}
501 		contin:
502 # ifdef LEXDEBUG
503 			if(debug){
504 				fprintf(fruout,"state %d char ",yystate-frusvec-1);
505 				allprint(yych);
506 				putchar('\n');
507 				}
508 # endif
509 			;
510 			}
511 # ifdef LEXDEBUG
512 		if(debug){
513 			fprintf(fruout,"stopped at %d with ",*(lsp-1)-frusvec-1);
514 			allprint(yych);
515 			putchar('\n');
516 			}
517 # endif
518 		while (lsp-- > frulstate){
519 			*yylastch-- = 0;
520 			if (*lsp != 0 && (frufnd= (*lsp)->yystops) && *frufnd > 0){
521 				fruolsp = lsp;
522 				if(fruextra[*frufnd]){		/* must backup */
523 					while(fruback((*lsp)->yystops,-*frufnd) != 1 && lsp > frulstate){
524 						lsp--;
525 						unput(*yylastch--);
526 						}
527 					}
528 				fruprevious = YYU(*yylastch);
529 				frulsp = lsp;
530 				fruleng = yylastch-frutext+1;
531 				frutext[fruleng] = 0;
532 # ifdef LEXDEBUG
533 				if(debug){
534 					fprintf(fruout,"\nmatch ");
535 					sprint(frutext);
536 					fprintf(fruout," action %d\n",*frufnd);
537 					}
538 # endif
539 				return(*frufnd++);
540 				}
541 			unput(*yylastch);
542 			}
543 		if (frutext[0] == 0  /* && feof(fruin) */)
544 			{
545 			frusptr=frusbuf;
546 			return(0);
547 			}
548 #ifndef __cplusplus
549 		fruprevious = frutext[0] = input();
550 		if (fruprevious>0)
551 			output(fruprevious);
552 #else
553 		fruprevious = frutext[0] = lex_input();
554 		if (fruprevious>0)
555 			lex_output(fruprevious);
556 #endif
557 		yylastch=frutext;
558 # ifdef LEXDEBUG
559 		if(debug)putchar('\n');
560 # endif
561 		}
562 	}
563 #if defined(__cplusplus) || defined(__STDC__)
564 int fruback(int *p, int m)
565 #else
566 fruback(p, m)
567 	int *p;
568 #endif
569 {
570 	if (p==0) return(0);
571 	while (*p) {
572 		if (*p++ == m)
573 			return(1);
574 	}
575 	return(0);
576 }
577 	/* the following are only used in the lex library */
578 #if defined(__cplusplus) || defined(__STDC__)
579 int fruinput(void)
580 #else
581 fruinput()
582 #endif
583 {
584 #ifndef __cplusplus
585 	return(input());
586 #else
587 	return(lex_input());
588 #endif
589 	}
590 #if defined(__cplusplus) || defined(__STDC__)
591 void fruoutput(int c)
592 #else
593 fruoutput(c)
594   int c;
595 #endif
596 {
597 #ifndef __cplusplus
598 	output(c);
599 #else
600 	lex_output(c);
601 #endif
602 	}
603 #if defined(__cplusplus) || defined(__STDC__)
604 void fruunput(int c)
605 #else
606 fruunput(c)
607    int c;
608 #endif
609 {
610 	unput(c);
611 	}
612