10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*4538Sdamico * Common Development and Distribution License (the "License"). 6*4538Sdamico * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*4538Sdamico * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 270Sstevel@tonic-gate /* All Rights Reserved */ 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 31*4538Sdamico #include "ldefs.h" 320Sstevel@tonic-gate 330Sstevel@tonic-gate static void rhd1(void); 340Sstevel@tonic-gate static void chd1(void); 350Sstevel@tonic-gate static void chd2(void); 360Sstevel@tonic-gate static void ctail(void); 370Sstevel@tonic-gate static void rtail(void); 380Sstevel@tonic-gate 390Sstevel@tonic-gate void 400Sstevel@tonic-gate phead1(void) 410Sstevel@tonic-gate { 420Sstevel@tonic-gate ratfor ? rhd1() : chd1(); 430Sstevel@tonic-gate } 440Sstevel@tonic-gate 450Sstevel@tonic-gate static void 460Sstevel@tonic-gate chd1(void) 470Sstevel@tonic-gate { 480Sstevel@tonic-gate if (*v_stmp == 'y') 490Sstevel@tonic-gate (void) fprintf(fout, "#ident\t\"lex: %s %s\"\n", 500Sstevel@tonic-gate (const char *)SGU_PKG, (const char *)SGU_REL); 510Sstevel@tonic-gate if (handleeuc) { 520Sstevel@tonic-gate fprintf(fout, "#ifndef EUC\n"); 530Sstevel@tonic-gate fprintf(fout, "#define EUC\n"); 540Sstevel@tonic-gate fprintf(fout, "#endif\n"); 550Sstevel@tonic-gate fprintf(fout, "#include <stdio.h>\n"); 560Sstevel@tonic-gate fprintf(fout, "#include <stdlib.h>\n"); 570Sstevel@tonic-gate fprintf(fout, "#include <inttypes.h>\n"); 580Sstevel@tonic-gate fprintf(fout, "#include <widec.h>\n"); 590Sstevel@tonic-gate if (widecio) { /* -w option */ 600Sstevel@tonic-gate fprintf(fout, "#define YYTEXT yytext\n"); 610Sstevel@tonic-gate fprintf(fout, "#define YYLENG yyleng\n"); 620Sstevel@tonic-gate fprintf(fout, "#ifndef __cplusplus\n"); 630Sstevel@tonic-gate fprintf(fout, "#define YYINPUT input\n"); 640Sstevel@tonic-gate fprintf(fout, "#define YYOUTPUT output\n"); 650Sstevel@tonic-gate fprintf(fout, "#else\n"); 660Sstevel@tonic-gate fprintf(fout, "#define YYINPUT lex_input\n"); 670Sstevel@tonic-gate fprintf(fout, "#define YYOUTPUT lex_output\n"); 680Sstevel@tonic-gate fprintf(fout, "#endif\n"); 690Sstevel@tonic-gate fprintf(fout, "#define YYUNPUT unput\n"); 700Sstevel@tonic-gate } else { /* -e option */ 710Sstevel@tonic-gate fprintf(fout, "#include <limits.h>\n"); 720Sstevel@tonic-gate fprintf(fout, "#include <sys/euc.h>\n"); 730Sstevel@tonic-gate fprintf(fout, "#define YYLEX_E 1\n"); 740Sstevel@tonic-gate fprintf(fout, "#define YYTEXT yywtext\n"); 750Sstevel@tonic-gate fprintf(fout, "#define YYLENG yywleng\n"); 760Sstevel@tonic-gate fprintf(fout, "#define YYINPUT yywinput\n"); 770Sstevel@tonic-gate fprintf(fout, "#define YYOUTPUT yywoutput\n"); 780Sstevel@tonic-gate fprintf(fout, "#define YYUNPUT yywunput\n"); 790Sstevel@tonic-gate } 800Sstevel@tonic-gate } else { /* ASCII compatibility mode. */ 810Sstevel@tonic-gate fprintf(fout, "#include <stdio.h>\n"); 820Sstevel@tonic-gate fprintf(fout, "#include <stdlib.h>\n"); 830Sstevel@tonic-gate fprintf(fout, "#include <inttypes.h>\n"); 840Sstevel@tonic-gate } 850Sstevel@tonic-gate if (ZCH > NCH) 860Sstevel@tonic-gate (void) fprintf(fout, "# define U(x) ((x)&0377)\n"); 870Sstevel@tonic-gate else 880Sstevel@tonic-gate (void) fprintf(fout, "# define U(x) x\n"); 890Sstevel@tonic-gate (void) fprintf(fout, "# define NLSTATE yyprevious=YYNEWLINE\n"); 900Sstevel@tonic-gate (void) fprintf(fout, "# define BEGIN yybgin = yysvec + 1 +\n"); 910Sstevel@tonic-gate (void) fprintf(fout, "# define INITIAL 0\n"); 920Sstevel@tonic-gate (void) fprintf(fout, "# define YYLERR yysvec\n"); 930Sstevel@tonic-gate (void) fprintf(fout, "# define YYSTATE (yyestate-yysvec-1)\n"); 940Sstevel@tonic-gate if (optim) 950Sstevel@tonic-gate (void) fprintf(fout, "# define YYOPTIM 1\n"); 960Sstevel@tonic-gate #ifdef DEBUG 970Sstevel@tonic-gate (void) fprintf(fout, "# define LEXDEBUG 1\n"); 980Sstevel@tonic-gate #endif 990Sstevel@tonic-gate (void) fprintf(fout, "# ifndef YYLMAX \n"); 1000Sstevel@tonic-gate (void) fprintf(fout, "# define YYLMAX BUFSIZ\n"); 1010Sstevel@tonic-gate (void) fprintf(fout, "# endif \n"); 1020Sstevel@tonic-gate (void) fprintf(fout, "#ifndef __cplusplus\n"); 1030Sstevel@tonic-gate if (widecio) 1040Sstevel@tonic-gate (void) fprintf(fout, 1050Sstevel@tonic-gate "# define output(c) (void)putwc(c,yyout)\n"); 1060Sstevel@tonic-gate else 1070Sstevel@tonic-gate (void) fprintf(fout, 1080Sstevel@tonic-gate "# define output(c) (void)putc(c,yyout)\n"); 1090Sstevel@tonic-gate (void) fprintf(fout, "#else\n"); 1100Sstevel@tonic-gate if (widecio) 1110Sstevel@tonic-gate (void) fprintf(fout, 1120Sstevel@tonic-gate "# define lex_output(c) (void)putwc(c,yyout)\n"); 1130Sstevel@tonic-gate else 1140Sstevel@tonic-gate (void) fprintf(fout, 1150Sstevel@tonic-gate "# define lex_output(c) (void)putc(c,yyout)\n"); 1160Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1170Sstevel@tonic-gate (void) fprintf(fout, 1180Sstevel@tonic-gate "\n#if defined(__cplusplus) || defined(__STDC__)\n"); 1190Sstevel@tonic-gate (void) fprintf(fout, 1200Sstevel@tonic-gate "\n#if defined(__cplusplus) && defined(__EXTERN_C__)\n"); 1210Sstevel@tonic-gate (void) fprintf(fout, "extern \"C\" {\n"); 1220Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1230Sstevel@tonic-gate (void) fprintf(fout, "\tint yyback(int *, int);\n"); /* ? */ 1240Sstevel@tonic-gate (void) fprintf(fout, "\tint yyinput(void);\n"); /* ? */ 1250Sstevel@tonic-gate (void) fprintf(fout, "\tint yylook(void);\n"); /* ? */ 1260Sstevel@tonic-gate (void) fprintf(fout, "\tvoid yyoutput(int);\n"); /* ? */ 1270Sstevel@tonic-gate (void) fprintf(fout, "\tint yyracc(int);\n"); /* ? */ 1280Sstevel@tonic-gate (void) fprintf(fout, "\tint yyreject(void);\n"); /* ? */ 1290Sstevel@tonic-gate (void) fprintf(fout, "\tvoid yyunput(int);\n"); /* ? */ 1300Sstevel@tonic-gate (void) fprintf(fout, "\tint yylex(void);\n"); 1310Sstevel@tonic-gate (void) fprintf(fout, "#ifdef YYLEX_E\n"); 1320Sstevel@tonic-gate (void) fprintf(fout, "\tvoid yywoutput(wchar_t);\n"); 1330Sstevel@tonic-gate (void) fprintf(fout, "\twchar_t yywinput(void);\n"); 1340Sstevel@tonic-gate (void) fprintf(fout, "\tvoid yywunput(wchar_t);\n"); 1350Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate /* XCU4: type of yyless is int */ 1380Sstevel@tonic-gate (void) fprintf(fout, "#ifndef yyless\n"); 1390Sstevel@tonic-gate (void) fprintf(fout, "\tint yyless(int);\n"); 1400Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1410Sstevel@tonic-gate (void) fprintf(fout, "#ifndef yywrap\n"); 1420Sstevel@tonic-gate (void) fprintf(fout, "\tint yywrap(void);\n"); 1430Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1440Sstevel@tonic-gate (void) fprintf(fout, "#ifdef LEXDEBUG\n"); 1450Sstevel@tonic-gate (void) fprintf(fout, "\tvoid allprint(char);\n"); 1460Sstevel@tonic-gate (void) fprintf(fout, "\tvoid sprint(char *);\n"); 1470Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1480Sstevel@tonic-gate (void) fprintf(fout, 1490Sstevel@tonic-gate "#if defined(__cplusplus) && defined(__EXTERN_C__)\n"); 1500Sstevel@tonic-gate (void) fprintf(fout, "}\n"); 1510Sstevel@tonic-gate (void) fprintf(fout, "#endif\n\n"); 1520Sstevel@tonic-gate (void) fprintf(fout, "#ifdef __cplusplus\n"); 1530Sstevel@tonic-gate (void) fprintf(fout, "extern \"C\" {\n"); 1540Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1550Sstevel@tonic-gate (void) fprintf(fout, "\tvoid exit(int);\n"); 1560Sstevel@tonic-gate (void) fprintf(fout, "#ifdef __cplusplus\n"); 1570Sstevel@tonic-gate (void) fprintf(fout, "}\n"); 1580Sstevel@tonic-gate (void) fprintf(fout, "#endif\n\n"); 1590Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1600Sstevel@tonic-gate (void) fprintf(fout, 1610Sstevel@tonic-gate "# define unput(c)" 1620Sstevel@tonic-gate " {yytchar= (c);if(yytchar=='\\n')yylineno--;*yysptr++=yytchar;}\n"); 1630Sstevel@tonic-gate (void) fprintf(fout, "# define yymore() (yymorfg=1)\n"); 1640Sstevel@tonic-gate if (widecio) { 1650Sstevel@tonic-gate (void) fprintf(fout, "#ifndef __cplusplus\n"); 1660Sstevel@tonic-gate (void) fprintf(fout, "%s%d%s\n", 1670Sstevel@tonic-gate "# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getwc(yyin))==", 168*4538Sdamico ctable['\n'], 1690Sstevel@tonic-gate "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); 1700Sstevel@tonic-gate (void) fprintf(fout, "#else\n"); 1710Sstevel@tonic-gate (void) fprintf(fout, "%s%d%s\n", 1720Sstevel@tonic-gate "# define lex_input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getwc(yyin))==", 173*4538Sdamico ctable['\n'], 1740Sstevel@tonic-gate "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); 1750Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1760Sstevel@tonic-gate (void) fprintf(fout, 1770Sstevel@tonic-gate "# define ECHO (void)fprintf(yyout, \"%%ws\",yytext)\n"); 1780Sstevel@tonic-gate (void) fprintf(fout, 1790Sstevel@tonic-gate "# define REJECT { nstr = yyreject_w(); goto yyfussy;}\n"); 1800Sstevel@tonic-gate (void) fprintf(fout, "#define yyless yyless_w\n"); 1810Sstevel@tonic-gate (void) fprintf(fout, "int yyleng;\n"); 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate /* 1840Sstevel@tonic-gate * XCU4: 1850Sstevel@tonic-gate * If %array, yytext[] contains the token. 1860Sstevel@tonic-gate * If %pointer, yytext is a pointer to yy_tbuf[]. 1870Sstevel@tonic-gate */ 1880Sstevel@tonic-gate 1890Sstevel@tonic-gate if (isArray) { 1900Sstevel@tonic-gate (void) fprintf(fout, "#define YYISARRAY\n"); 1910Sstevel@tonic-gate (void) fprintf(fout, "wchar_t yytext[YYLMAX];\n"); 1920Sstevel@tonic-gate } else { 1930Sstevel@tonic-gate (void) fprintf(fout, "wchar_t yy_tbuf[YYLMAX];\n"); 1940Sstevel@tonic-gate (void) fprintf(fout, "wchar_t * yytext = yy_tbuf;\n"); 1950Sstevel@tonic-gate (void) fprintf(fout, "int yytextsz = YYLMAX;\n"); 1960Sstevel@tonic-gate (void) fprintf(fout, "#ifndef YYTEXTSZINC\n"); 1970Sstevel@tonic-gate (void) fprintf(fout, "#define YYTEXTSZINC 100\n"); 1980Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1990Sstevel@tonic-gate } 2000Sstevel@tonic-gate } else { 2010Sstevel@tonic-gate (void) fprintf(fout, "#ifndef __cplusplus\n"); 2020Sstevel@tonic-gate (void) fprintf(fout, "%s%d%s\n", 2030Sstevel@tonic-gate "# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==", 204*4538Sdamico ctable['\n'], 2050Sstevel@tonic-gate "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); 2060Sstevel@tonic-gate (void) fprintf(fout, "#else\n"); 2070Sstevel@tonic-gate (void) fprintf(fout, "%s%d%s\n", 2080Sstevel@tonic-gate "# define lex_input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==", 209*4538Sdamico ctable['\n'], 2100Sstevel@tonic-gate "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); 2110Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 2120Sstevel@tonic-gate fprintf(fout, "#define ECHO fprintf(yyout, \"%%s\",yytext)\n"); 2130Sstevel@tonic-gate if (handleeuc) { 2140Sstevel@tonic-gate (void) fprintf(fout, 2150Sstevel@tonic-gate "# define REJECT { nstr = yyreject_e(); goto yyfussy;}\n"); 2160Sstevel@tonic-gate (void) fprintf(fout, "int yyleng;\n"); 2170Sstevel@tonic-gate (void) fprintf(fout, "size_t yywleng;\n"); 2180Sstevel@tonic-gate /* 2190Sstevel@tonic-gate * XCU4: 2200Sstevel@tonic-gate * If %array, yytext[] contains the token. 2210Sstevel@tonic-gate * If %pointer, yytext is a pointer to yy_tbuf[]. 2220Sstevel@tonic-gate */ 2230Sstevel@tonic-gate if (isArray) { 2240Sstevel@tonic-gate (void) fprintf(fout, "#define YYISARRAY\n"); 2250Sstevel@tonic-gate (void) fprintf(fout, 2260Sstevel@tonic-gate "unsigned char yytext[YYLMAX*MB_LEN_MAX];\n"); 2270Sstevel@tonic-gate (void) fprintf(fout, 2280Sstevel@tonic-gate "wchar_t yywtext[YYLMAX];\n"); 2290Sstevel@tonic-gate } else { 2300Sstevel@tonic-gate (void) fprintf(fout, 2310Sstevel@tonic-gate "wchar_t yy_twbuf[YYLMAX];\n"); 2320Sstevel@tonic-gate (void) fprintf(fout, 2330Sstevel@tonic-gate "wchar_t yy_tbuf[YYLMAX*MB_LEN_MAX];\n"); 2340Sstevel@tonic-gate (void) fprintf(fout, 2350Sstevel@tonic-gate "unsigned char * yytext =" 2360Sstevel@tonic-gate "(unsigned char *)yy_tbuf;\n"); 2370Sstevel@tonic-gate (void) fprintf(fout, 2380Sstevel@tonic-gate "wchar_t * yywtext = yy_twbuf;\n"); 2390Sstevel@tonic-gate (void) fprintf(fout, 240*4538Sdamico "int yytextsz = YYLMAX;\n"); 2410Sstevel@tonic-gate (void) fprintf(fout, "#ifndef YYTEXTSZINC\n"); 2420Sstevel@tonic-gate (void) fprintf(fout, 243*4538Sdamico "#define YYTEXTSZINC 100\n"); 2440Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 2450Sstevel@tonic-gate } 2460Sstevel@tonic-gate } else { 2470Sstevel@tonic-gate (void) fprintf(fout, 2480Sstevel@tonic-gate "# define REJECT { nstr = yyreject(); goto yyfussy;}\n"); 2490Sstevel@tonic-gate (void) fprintf(fout, "int yyleng;\n"); 2500Sstevel@tonic-gate 2510Sstevel@tonic-gate /* 2520Sstevel@tonic-gate * XCU4: 2530Sstevel@tonic-gate * If %array, yytext[] contains the token. 2540Sstevel@tonic-gate * If %pointer, yytext is a pointer to yy_tbuf[]. 2550Sstevel@tonic-gate */ 2560Sstevel@tonic-gate if (isArray) { 2570Sstevel@tonic-gate (void) fprintf(fout, "#define YYISARRAY\n"); 2580Sstevel@tonic-gate (void) fprintf(fout, "char yytext[YYLMAX];\n"); 2590Sstevel@tonic-gate } else { 2600Sstevel@tonic-gate (void) fprintf(fout, "char yy_tbuf[YYLMAX];\n"); 2610Sstevel@tonic-gate (void) fprintf(fout, 2620Sstevel@tonic-gate "char * yytext = yy_tbuf;\n"); 2630Sstevel@tonic-gate (void) fprintf(fout, 264*4538Sdamico "int yytextsz = YYLMAX;\n"); 2650Sstevel@tonic-gate (void) fprintf(fout, "#ifndef YYTEXTSZINC\n"); 2660Sstevel@tonic-gate (void) fprintf(fout, 267*4538Sdamico "#define YYTEXTSZINC 100\n"); 2680Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 2690Sstevel@tonic-gate } 2700Sstevel@tonic-gate } 2710Sstevel@tonic-gate } 2720Sstevel@tonic-gate (void) fprintf(fout, "int yymorfg;\n"); 2730Sstevel@tonic-gate if (handleeuc) 2740Sstevel@tonic-gate (void) fprintf(fout, "extern wchar_t *yysptr, yysbuf[];\n"); 2750Sstevel@tonic-gate else 2760Sstevel@tonic-gate (void) fprintf(fout, "extern char *yysptr, yysbuf[];\n"); 2770Sstevel@tonic-gate (void) fprintf(fout, "int yytchar;\n"); 2780Sstevel@tonic-gate (void) fprintf(fout, "FILE *yyin = {stdin}, *yyout = {stdout};\n"); 2790Sstevel@tonic-gate (void) fprintf(fout, "extern int yylineno;\n"); 2800Sstevel@tonic-gate (void) fprintf(fout, "struct yysvf { \n"); 2810Sstevel@tonic-gate (void) fprintf(fout, "\tstruct yywork *yystoff;\n"); 2820Sstevel@tonic-gate (void) fprintf(fout, "\tstruct yysvf *yyother;\n"); 2830Sstevel@tonic-gate (void) fprintf(fout, "\tint *yystops;};\n"); 2840Sstevel@tonic-gate (void) fprintf(fout, "struct yysvf *yyestate;\n"); 2850Sstevel@tonic-gate (void) fprintf(fout, "extern struct yysvf yysvec[], *yybgin;\n"); 2860Sstevel@tonic-gate } 2870Sstevel@tonic-gate 2880Sstevel@tonic-gate static void 2890Sstevel@tonic-gate rhd1(void) 2900Sstevel@tonic-gate { 2910Sstevel@tonic-gate (void) fprintf(fout, "integer function yylex(dummy)\n"); 2920Sstevel@tonic-gate (void) fprintf(fout, "define YYLMAX 200\n"); 2930Sstevel@tonic-gate (void) fprintf(fout, "define ECHO call yyecho(yytext,yyleng)\n"); 2940Sstevel@tonic-gate (void) fprintf(fout, 2950Sstevel@tonic-gate "define REJECT nstr = yyrjct(yytext,yyleng);goto 30998\n"); 2960Sstevel@tonic-gate (void) fprintf(fout, "integer nstr,yylook,yywrap\n"); 2970Sstevel@tonic-gate (void) fprintf(fout, "integer yyleng, yytext(YYLMAX)\n"); 2980Sstevel@tonic-gate (void) fprintf(fout, "common /yyxel/ yyleng, yytext\n"); 2990Sstevel@tonic-gate (void) fprintf(fout, 3000Sstevel@tonic-gate "common /yyldat/ yyfnd, yymorf, yyprev, yybgin, yylsp, yylsta\n"); 3010Sstevel@tonic-gate (void) fprintf(fout, 3020Sstevel@tonic-gate "integer yyfnd, yymorf, yyprev, yybgin, yylsp, yylsta(YYLMAX)\n"); 3030Sstevel@tonic-gate (void) fprintf(fout, "for(;;){\n"); 3040Sstevel@tonic-gate (void) fprintf(fout, "\t30999 nstr = yylook(dummy)\n"); 3050Sstevel@tonic-gate (void) fprintf(fout, "\tgoto 30998\n"); 3060Sstevel@tonic-gate (void) fprintf(fout, "\t30000 k = yywrap(dummy)\n"); 3070Sstevel@tonic-gate (void) fprintf(fout, "\tif(k .ne. 0){\n"); 3080Sstevel@tonic-gate (void) fprintf(fout, "\tyylex=0; return; }\n"); 3090Sstevel@tonic-gate (void) fprintf(fout, "\t\telse goto 30998\n"); 3100Sstevel@tonic-gate } 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate void 3130Sstevel@tonic-gate phead2(void) 3140Sstevel@tonic-gate { 3150Sstevel@tonic-gate if (!ratfor) 3160Sstevel@tonic-gate chd2(); 3170Sstevel@tonic-gate } 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate static void 3200Sstevel@tonic-gate chd2(void) 3210Sstevel@tonic-gate { 3220Sstevel@tonic-gate (void) fprintf(fout, "#ifdef __cplusplus\n"); 3230Sstevel@tonic-gate (void) fprintf(fout, 3240Sstevel@tonic-gate "/* to avoid CC and lint complaining yyfussy not being used ...*/\n"); 3250Sstevel@tonic-gate (void) fprintf(fout, "static int __lex_hack = 0;\n"); 3260Sstevel@tonic-gate (void) fprintf(fout, "if (__lex_hack) goto yyfussy;\n"); 3270Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 3280Sstevel@tonic-gate (void) fprintf(fout, "while((nstr = yylook()) >= 0)\n"); 3290Sstevel@tonic-gate (void) fprintf(fout, "yyfussy: switch(nstr){\n"); 3300Sstevel@tonic-gate (void) fprintf(fout, "case 0:\n"); 3310Sstevel@tonic-gate (void) fprintf(fout, "if(yywrap()) return(0); break;\n"); 3320Sstevel@tonic-gate } 3330Sstevel@tonic-gate 3340Sstevel@tonic-gate void 3350Sstevel@tonic-gate ptail(void) 3360Sstevel@tonic-gate { 3370Sstevel@tonic-gate if (!pflag) 3380Sstevel@tonic-gate ratfor ? rtail() : ctail(); 3390Sstevel@tonic-gate pflag = 1; 3400Sstevel@tonic-gate } 3410Sstevel@tonic-gate 3420Sstevel@tonic-gate static void 3430Sstevel@tonic-gate ctail(void) 3440Sstevel@tonic-gate { 3450Sstevel@tonic-gate (void) fprintf(fout, "case -1:\nbreak;\n"); /* for reject */ 3460Sstevel@tonic-gate (void) fprintf(fout, "default:\n"); 3470Sstevel@tonic-gate (void) fprintf(fout, 3480Sstevel@tonic-gate "(void)fprintf(yyout,\"bad switch yylook %%d\",nstr);\n"); 3490Sstevel@tonic-gate (void) fprintf(fout, "} return(0); }\n"); 3500Sstevel@tonic-gate (void) fprintf(fout, "/* end of yylex */\n"); 3510Sstevel@tonic-gate } 3520Sstevel@tonic-gate 3530Sstevel@tonic-gate static void 3540Sstevel@tonic-gate rtail(void) 3550Sstevel@tonic-gate { 3560Sstevel@tonic-gate int i; 3570Sstevel@tonic-gate (void) fprintf(fout, 3580Sstevel@tonic-gate "\n30998 if(nstr .lt. 0 .or. nstr .gt. %d)goto 30999\n", casecount); 3590Sstevel@tonic-gate (void) fprintf(fout, "nstr = nstr + 1\n"); 3600Sstevel@tonic-gate (void) fprintf(fout, "goto(\n"); 3610Sstevel@tonic-gate for (i = 0; i < casecount; i++) 3620Sstevel@tonic-gate (void) fprintf(fout, "%d,\n", 30000+i); 3630Sstevel@tonic-gate (void) fprintf(fout, "30999),nstr\n"); 3640Sstevel@tonic-gate (void) fprintf(fout, "30997 continue\n"); 3650Sstevel@tonic-gate (void) fprintf(fout, "}\nend\n"); 3660Sstevel@tonic-gate } 3670Sstevel@tonic-gate 3680Sstevel@tonic-gate void 3690Sstevel@tonic-gate statistics(void) 3700Sstevel@tonic-gate { 3710Sstevel@tonic-gate (void) fprintf(errorf, 3720Sstevel@tonic-gate "%d/%d nodes(%%e), %d/%d positions(%%p), %d/%d (%%n), %ld transitions,\n", 373*4538Sdamico tptr, treesize, nxtpos-positions, maxpos, stnum + 1, nstates, 374*4538Sdamico rcount); 3750Sstevel@tonic-gate (void) fprintf(errorf, 3760Sstevel@tonic-gate "%d/%d packed char classes(%%k), ", pcptr-pchar, pchlen); 3770Sstevel@tonic-gate if (optim) 3780Sstevel@tonic-gate (void) fprintf(errorf, 3790Sstevel@tonic-gate " %d/%d packed transitions(%%a), ", nptr, ntrans); 3800Sstevel@tonic-gate (void) fprintf(errorf, " %d/%d output slots(%%o)", yytop, outsize); 3810Sstevel@tonic-gate (void) putc('\n', errorf); 3820Sstevel@tonic-gate } 383