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) 1988 AT&T */ 29*0Sstevel@tonic-gate /* All Rights Reserved */ 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate #include "ldefs.c" 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate static void rhd1(void); 36*0Sstevel@tonic-gate static void chd1(void); 37*0Sstevel@tonic-gate static void chd2(void); 38*0Sstevel@tonic-gate static void ctail(void); 39*0Sstevel@tonic-gate static void rtail(void); 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate void 42*0Sstevel@tonic-gate phead1(void) 43*0Sstevel@tonic-gate { 44*0Sstevel@tonic-gate ratfor ? rhd1() : chd1(); 45*0Sstevel@tonic-gate } 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate static void 48*0Sstevel@tonic-gate chd1(void) 49*0Sstevel@tonic-gate { 50*0Sstevel@tonic-gate if (*v_stmp == 'y') 51*0Sstevel@tonic-gate (void) fprintf(fout, "#ident\t\"lex: %s %s\"\n", 52*0Sstevel@tonic-gate (const char *)SGU_PKG, (const char *)SGU_REL); 53*0Sstevel@tonic-gate if (handleeuc) { 54*0Sstevel@tonic-gate fprintf(fout, "#ifndef EUC\n"); 55*0Sstevel@tonic-gate fprintf(fout, "#define EUC\n"); 56*0Sstevel@tonic-gate fprintf(fout, "#endif\n"); 57*0Sstevel@tonic-gate fprintf(fout, "#include <stdio.h>\n"); 58*0Sstevel@tonic-gate fprintf(fout, "#include <stdlib.h>\n"); 59*0Sstevel@tonic-gate fprintf(fout, "#include <inttypes.h>\n"); 60*0Sstevel@tonic-gate fprintf(fout, "#include <widec.h>\n"); 61*0Sstevel@tonic-gate if (widecio) { /* -w option */ 62*0Sstevel@tonic-gate fprintf(fout, "#define YYTEXT yytext\n"); 63*0Sstevel@tonic-gate fprintf(fout, "#define YYLENG yyleng\n"); 64*0Sstevel@tonic-gate fprintf(fout, "#ifndef __cplusplus\n"); 65*0Sstevel@tonic-gate fprintf(fout, "#define YYINPUT input\n"); 66*0Sstevel@tonic-gate fprintf(fout, "#define YYOUTPUT output\n"); 67*0Sstevel@tonic-gate fprintf(fout, "#else\n"); 68*0Sstevel@tonic-gate fprintf(fout, "#define YYINPUT lex_input\n"); 69*0Sstevel@tonic-gate fprintf(fout, "#define YYOUTPUT lex_output\n"); 70*0Sstevel@tonic-gate fprintf(fout, "#endif\n"); 71*0Sstevel@tonic-gate fprintf(fout, "#define YYUNPUT unput\n"); 72*0Sstevel@tonic-gate } else { /* -e option */ 73*0Sstevel@tonic-gate fprintf(fout, "#include <limits.h>\n"); 74*0Sstevel@tonic-gate fprintf(fout, "#include <sys/euc.h>\n"); 75*0Sstevel@tonic-gate fprintf(fout, "#define YYLEX_E 1\n"); 76*0Sstevel@tonic-gate fprintf(fout, "#define YYTEXT yywtext\n"); 77*0Sstevel@tonic-gate fprintf(fout, "#define YYLENG yywleng\n"); 78*0Sstevel@tonic-gate fprintf(fout, "#define YYINPUT yywinput\n"); 79*0Sstevel@tonic-gate fprintf(fout, "#define YYOUTPUT yywoutput\n"); 80*0Sstevel@tonic-gate fprintf(fout, "#define YYUNPUT yywunput\n"); 81*0Sstevel@tonic-gate } 82*0Sstevel@tonic-gate } else { /* ASCII compatibility mode. */ 83*0Sstevel@tonic-gate fprintf(fout, "#include <stdio.h>\n"); 84*0Sstevel@tonic-gate fprintf(fout, "#include <stdlib.h>\n"); 85*0Sstevel@tonic-gate fprintf(fout, "#include <inttypes.h>\n"); 86*0Sstevel@tonic-gate } 87*0Sstevel@tonic-gate if (ZCH > NCH) 88*0Sstevel@tonic-gate (void) fprintf(fout, "# define U(x) ((x)&0377)\n"); 89*0Sstevel@tonic-gate else 90*0Sstevel@tonic-gate (void) fprintf(fout, "# define U(x) x\n"); 91*0Sstevel@tonic-gate (void) fprintf(fout, "# define NLSTATE yyprevious=YYNEWLINE\n"); 92*0Sstevel@tonic-gate (void) fprintf(fout, "# define BEGIN yybgin = yysvec + 1 +\n"); 93*0Sstevel@tonic-gate (void) fprintf(fout, "# define INITIAL 0\n"); 94*0Sstevel@tonic-gate (void) fprintf(fout, "# define YYLERR yysvec\n"); 95*0Sstevel@tonic-gate (void) fprintf(fout, "# define YYSTATE (yyestate-yysvec-1)\n"); 96*0Sstevel@tonic-gate if (optim) 97*0Sstevel@tonic-gate (void) fprintf(fout, "# define YYOPTIM 1\n"); 98*0Sstevel@tonic-gate #ifdef DEBUG 99*0Sstevel@tonic-gate (void) fprintf(fout, "# define LEXDEBUG 1\n"); 100*0Sstevel@tonic-gate #endif 101*0Sstevel@tonic-gate (void) fprintf(fout, "# ifndef YYLMAX \n"); 102*0Sstevel@tonic-gate (void) fprintf(fout, "# define YYLMAX BUFSIZ\n"); 103*0Sstevel@tonic-gate (void) fprintf(fout, "# endif \n"); 104*0Sstevel@tonic-gate (void) fprintf(fout, "#ifndef __cplusplus\n"); 105*0Sstevel@tonic-gate if (widecio) 106*0Sstevel@tonic-gate (void) fprintf(fout, 107*0Sstevel@tonic-gate "# define output(c) (void)putwc(c,yyout)\n"); 108*0Sstevel@tonic-gate else 109*0Sstevel@tonic-gate (void) fprintf(fout, 110*0Sstevel@tonic-gate "# define output(c) (void)putc(c,yyout)\n"); 111*0Sstevel@tonic-gate (void) fprintf(fout, "#else\n"); 112*0Sstevel@tonic-gate if (widecio) 113*0Sstevel@tonic-gate (void) fprintf(fout, 114*0Sstevel@tonic-gate "# define lex_output(c) (void)putwc(c,yyout)\n"); 115*0Sstevel@tonic-gate else 116*0Sstevel@tonic-gate (void) fprintf(fout, 117*0Sstevel@tonic-gate "# define lex_output(c) (void)putc(c,yyout)\n"); 118*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 119*0Sstevel@tonic-gate (void) fprintf(fout, 120*0Sstevel@tonic-gate "\n#if defined(__cplusplus) || defined(__STDC__)\n"); 121*0Sstevel@tonic-gate (void) fprintf(fout, 122*0Sstevel@tonic-gate "\n#if defined(__cplusplus) && defined(__EXTERN_C__)\n"); 123*0Sstevel@tonic-gate (void) fprintf(fout, "extern \"C\" {\n"); 124*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 125*0Sstevel@tonic-gate (void) fprintf(fout, "\tint yyback(int *, int);\n"); /* ? */ 126*0Sstevel@tonic-gate (void) fprintf(fout, "\tint yyinput(void);\n"); /* ? */ 127*0Sstevel@tonic-gate (void) fprintf(fout, "\tint yylook(void);\n"); /* ? */ 128*0Sstevel@tonic-gate (void) fprintf(fout, "\tvoid yyoutput(int);\n"); /* ? */ 129*0Sstevel@tonic-gate (void) fprintf(fout, "\tint yyracc(int);\n"); /* ? */ 130*0Sstevel@tonic-gate (void) fprintf(fout, "\tint yyreject(void);\n"); /* ? */ 131*0Sstevel@tonic-gate (void) fprintf(fout, "\tvoid yyunput(int);\n"); /* ? */ 132*0Sstevel@tonic-gate (void) fprintf(fout, "\tint yylex(void);\n"); 133*0Sstevel@tonic-gate (void) fprintf(fout, "#ifdef YYLEX_E\n"); 134*0Sstevel@tonic-gate (void) fprintf(fout, "\tvoid yywoutput(wchar_t);\n"); 135*0Sstevel@tonic-gate (void) fprintf(fout, "\twchar_t yywinput(void);\n"); 136*0Sstevel@tonic-gate (void) fprintf(fout, "\tvoid yywunput(wchar_t);\n"); 137*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 138*0Sstevel@tonic-gate 139*0Sstevel@tonic-gate /* XCU4: type of yyless is int */ 140*0Sstevel@tonic-gate (void) fprintf(fout, "#ifndef yyless\n"); 141*0Sstevel@tonic-gate (void) fprintf(fout, "\tint yyless(int);\n"); 142*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 143*0Sstevel@tonic-gate (void) fprintf(fout, "#ifndef yywrap\n"); 144*0Sstevel@tonic-gate (void) fprintf(fout, "\tint yywrap(void);\n"); 145*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 146*0Sstevel@tonic-gate (void) fprintf(fout, "#ifdef LEXDEBUG\n"); 147*0Sstevel@tonic-gate (void) fprintf(fout, "\tvoid allprint(char);\n"); 148*0Sstevel@tonic-gate (void) fprintf(fout, "\tvoid sprint(char *);\n"); 149*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 150*0Sstevel@tonic-gate (void) fprintf(fout, 151*0Sstevel@tonic-gate "#if defined(__cplusplus) && defined(__EXTERN_C__)\n"); 152*0Sstevel@tonic-gate (void) fprintf(fout, "}\n"); 153*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n\n"); 154*0Sstevel@tonic-gate (void) fprintf(fout, "#ifdef __cplusplus\n"); 155*0Sstevel@tonic-gate (void) fprintf(fout, "extern \"C\" {\n"); 156*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 157*0Sstevel@tonic-gate (void) fprintf(fout, "\tvoid exit(int);\n"); 158*0Sstevel@tonic-gate (void) fprintf(fout, "#ifdef __cplusplus\n"); 159*0Sstevel@tonic-gate (void) fprintf(fout, "}\n"); 160*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n\n"); 161*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 162*0Sstevel@tonic-gate (void) fprintf(fout, 163*0Sstevel@tonic-gate "# define unput(c)" 164*0Sstevel@tonic-gate " {yytchar= (c);if(yytchar=='\\n')yylineno--;*yysptr++=yytchar;}\n"); 165*0Sstevel@tonic-gate (void) fprintf(fout, "# define yymore() (yymorfg=1)\n"); 166*0Sstevel@tonic-gate if (widecio) { 167*0Sstevel@tonic-gate (void) fprintf(fout, "#ifndef __cplusplus\n"); 168*0Sstevel@tonic-gate (void) fprintf(fout, "%s%d%s\n", 169*0Sstevel@tonic-gate "# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getwc(yyin))==", 170*0Sstevel@tonic-gate ctable['\n'], 171*0Sstevel@tonic-gate "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); 172*0Sstevel@tonic-gate (void) fprintf(fout, "#else\n"); 173*0Sstevel@tonic-gate (void) fprintf(fout, "%s%d%s\n", 174*0Sstevel@tonic-gate "# define lex_input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getwc(yyin))==", 175*0Sstevel@tonic-gate ctable['\n'], 176*0Sstevel@tonic-gate "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); 177*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 178*0Sstevel@tonic-gate (void) fprintf(fout, 179*0Sstevel@tonic-gate "# define ECHO (void)fprintf(yyout, \"%%ws\",yytext)\n"); 180*0Sstevel@tonic-gate (void) fprintf(fout, 181*0Sstevel@tonic-gate "# define REJECT { nstr = yyreject_w(); goto yyfussy;}\n"); 182*0Sstevel@tonic-gate (void) fprintf(fout, "#define yyless yyless_w\n"); 183*0Sstevel@tonic-gate (void) fprintf(fout, "int yyleng;\n"); 184*0Sstevel@tonic-gate 185*0Sstevel@tonic-gate /* 186*0Sstevel@tonic-gate * XCU4: 187*0Sstevel@tonic-gate * If %array, yytext[] contains the token. 188*0Sstevel@tonic-gate * If %pointer, yytext is a pointer to yy_tbuf[]. 189*0Sstevel@tonic-gate */ 190*0Sstevel@tonic-gate 191*0Sstevel@tonic-gate if (isArray) { 192*0Sstevel@tonic-gate (void) fprintf(fout, "#define YYISARRAY\n"); 193*0Sstevel@tonic-gate (void) fprintf(fout, "wchar_t yytext[YYLMAX];\n"); 194*0Sstevel@tonic-gate } else { 195*0Sstevel@tonic-gate (void) fprintf(fout, "wchar_t yy_tbuf[YYLMAX];\n"); 196*0Sstevel@tonic-gate (void) fprintf(fout, "wchar_t * yytext = yy_tbuf;\n"); 197*0Sstevel@tonic-gate (void) fprintf(fout, "int yytextsz = YYLMAX;\n"); 198*0Sstevel@tonic-gate (void) fprintf(fout, "#ifndef YYTEXTSZINC\n"); 199*0Sstevel@tonic-gate (void) fprintf(fout, "#define YYTEXTSZINC 100\n"); 200*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 201*0Sstevel@tonic-gate } 202*0Sstevel@tonic-gate } else { 203*0Sstevel@tonic-gate (void) fprintf(fout, "#ifndef __cplusplus\n"); 204*0Sstevel@tonic-gate (void) fprintf(fout, "%s%d%s\n", 205*0Sstevel@tonic-gate "# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==", 206*0Sstevel@tonic-gate ctable['\n'], 207*0Sstevel@tonic-gate "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); 208*0Sstevel@tonic-gate (void) fprintf(fout, "#else\n"); 209*0Sstevel@tonic-gate (void) fprintf(fout, "%s%d%s\n", 210*0Sstevel@tonic-gate "# define lex_input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==", 211*0Sstevel@tonic-gate ctable['\n'], 212*0Sstevel@tonic-gate "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); 213*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 214*0Sstevel@tonic-gate fprintf(fout, "#define ECHO fprintf(yyout, \"%%s\",yytext)\n"); 215*0Sstevel@tonic-gate if (handleeuc) { 216*0Sstevel@tonic-gate (void) fprintf(fout, 217*0Sstevel@tonic-gate "# define REJECT { nstr = yyreject_e(); goto yyfussy;}\n"); 218*0Sstevel@tonic-gate (void) fprintf(fout, "int yyleng;\n"); 219*0Sstevel@tonic-gate (void) fprintf(fout, "size_t yywleng;\n"); 220*0Sstevel@tonic-gate /* 221*0Sstevel@tonic-gate * XCU4: 222*0Sstevel@tonic-gate * If %array, yytext[] contains the token. 223*0Sstevel@tonic-gate * If %pointer, yytext is a pointer to yy_tbuf[]. 224*0Sstevel@tonic-gate */ 225*0Sstevel@tonic-gate if (isArray) { 226*0Sstevel@tonic-gate (void) fprintf(fout, "#define YYISARRAY\n"); 227*0Sstevel@tonic-gate (void) fprintf(fout, 228*0Sstevel@tonic-gate "unsigned char yytext[YYLMAX*MB_LEN_MAX];\n"); 229*0Sstevel@tonic-gate (void) fprintf(fout, 230*0Sstevel@tonic-gate "wchar_t yywtext[YYLMAX];\n"); 231*0Sstevel@tonic-gate } else { 232*0Sstevel@tonic-gate (void) fprintf(fout, 233*0Sstevel@tonic-gate "wchar_t yy_twbuf[YYLMAX];\n"); 234*0Sstevel@tonic-gate (void) fprintf(fout, 235*0Sstevel@tonic-gate "wchar_t yy_tbuf[YYLMAX*MB_LEN_MAX];\n"); 236*0Sstevel@tonic-gate (void) fprintf(fout, 237*0Sstevel@tonic-gate "unsigned char * yytext =" 238*0Sstevel@tonic-gate "(unsigned char *)yy_tbuf;\n"); 239*0Sstevel@tonic-gate (void) fprintf(fout, 240*0Sstevel@tonic-gate "wchar_t * yywtext = yy_twbuf;\n"); 241*0Sstevel@tonic-gate (void) fprintf(fout, 242*0Sstevel@tonic-gate "int yytextsz = YYLMAX;\n"); 243*0Sstevel@tonic-gate (void) fprintf(fout, "#ifndef YYTEXTSZINC\n"); 244*0Sstevel@tonic-gate (void) fprintf(fout, 245*0Sstevel@tonic-gate "#define YYTEXTSZINC 100\n"); 246*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 247*0Sstevel@tonic-gate } 248*0Sstevel@tonic-gate } else { 249*0Sstevel@tonic-gate (void) fprintf(fout, 250*0Sstevel@tonic-gate "# define REJECT { nstr = yyreject(); goto yyfussy;}\n"); 251*0Sstevel@tonic-gate (void) fprintf(fout, "int yyleng;\n"); 252*0Sstevel@tonic-gate 253*0Sstevel@tonic-gate /* 254*0Sstevel@tonic-gate * XCU4: 255*0Sstevel@tonic-gate * If %array, yytext[] contains the token. 256*0Sstevel@tonic-gate * If %pointer, yytext is a pointer to yy_tbuf[]. 257*0Sstevel@tonic-gate */ 258*0Sstevel@tonic-gate if (isArray) { 259*0Sstevel@tonic-gate (void) fprintf(fout, "#define YYISARRAY\n"); 260*0Sstevel@tonic-gate (void) fprintf(fout, "char yytext[YYLMAX];\n"); 261*0Sstevel@tonic-gate } else { 262*0Sstevel@tonic-gate (void) fprintf(fout, "char yy_tbuf[YYLMAX];\n"); 263*0Sstevel@tonic-gate (void) fprintf(fout, 264*0Sstevel@tonic-gate "char * yytext = yy_tbuf;\n"); 265*0Sstevel@tonic-gate (void) fprintf(fout, 266*0Sstevel@tonic-gate "int yytextsz = YYLMAX;\n"); 267*0Sstevel@tonic-gate (void) fprintf(fout, "#ifndef YYTEXTSZINC\n"); 268*0Sstevel@tonic-gate (void) fprintf(fout, 269*0Sstevel@tonic-gate "#define YYTEXTSZINC 100\n"); 270*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 271*0Sstevel@tonic-gate } 272*0Sstevel@tonic-gate } 273*0Sstevel@tonic-gate } 274*0Sstevel@tonic-gate (void) fprintf(fout, "int yymorfg;\n"); 275*0Sstevel@tonic-gate if (handleeuc) 276*0Sstevel@tonic-gate (void) fprintf(fout, "extern wchar_t *yysptr, yysbuf[];\n"); 277*0Sstevel@tonic-gate else 278*0Sstevel@tonic-gate (void) fprintf(fout, "extern char *yysptr, yysbuf[];\n"); 279*0Sstevel@tonic-gate (void) fprintf(fout, "int yytchar;\n"); 280*0Sstevel@tonic-gate (void) fprintf(fout, "FILE *yyin = {stdin}, *yyout = {stdout};\n"); 281*0Sstevel@tonic-gate (void) fprintf(fout, "extern int yylineno;\n"); 282*0Sstevel@tonic-gate (void) fprintf(fout, "struct yysvf { \n"); 283*0Sstevel@tonic-gate (void) fprintf(fout, "\tstruct yywork *yystoff;\n"); 284*0Sstevel@tonic-gate (void) fprintf(fout, "\tstruct yysvf *yyother;\n"); 285*0Sstevel@tonic-gate (void) fprintf(fout, "\tint *yystops;};\n"); 286*0Sstevel@tonic-gate (void) fprintf(fout, "struct yysvf *yyestate;\n"); 287*0Sstevel@tonic-gate (void) fprintf(fout, "extern struct yysvf yysvec[], *yybgin;\n"); 288*0Sstevel@tonic-gate } 289*0Sstevel@tonic-gate 290*0Sstevel@tonic-gate static void 291*0Sstevel@tonic-gate rhd1(void) 292*0Sstevel@tonic-gate { 293*0Sstevel@tonic-gate (void) fprintf(fout, "integer function yylex(dummy)\n"); 294*0Sstevel@tonic-gate (void) fprintf(fout, "define YYLMAX 200\n"); 295*0Sstevel@tonic-gate (void) fprintf(fout, "define ECHO call yyecho(yytext,yyleng)\n"); 296*0Sstevel@tonic-gate (void) fprintf(fout, 297*0Sstevel@tonic-gate "define REJECT nstr = yyrjct(yytext,yyleng);goto 30998\n"); 298*0Sstevel@tonic-gate (void) fprintf(fout, "integer nstr,yylook,yywrap\n"); 299*0Sstevel@tonic-gate (void) fprintf(fout, "integer yyleng, yytext(YYLMAX)\n"); 300*0Sstevel@tonic-gate (void) fprintf(fout, "common /yyxel/ yyleng, yytext\n"); 301*0Sstevel@tonic-gate (void) fprintf(fout, 302*0Sstevel@tonic-gate "common /yyldat/ yyfnd, yymorf, yyprev, yybgin, yylsp, yylsta\n"); 303*0Sstevel@tonic-gate (void) fprintf(fout, 304*0Sstevel@tonic-gate "integer yyfnd, yymorf, yyprev, yybgin, yylsp, yylsta(YYLMAX)\n"); 305*0Sstevel@tonic-gate (void) fprintf(fout, "for(;;){\n"); 306*0Sstevel@tonic-gate (void) fprintf(fout, "\t30999 nstr = yylook(dummy)\n"); 307*0Sstevel@tonic-gate (void) fprintf(fout, "\tgoto 30998\n"); 308*0Sstevel@tonic-gate (void) fprintf(fout, "\t30000 k = yywrap(dummy)\n"); 309*0Sstevel@tonic-gate (void) fprintf(fout, "\tif(k .ne. 0){\n"); 310*0Sstevel@tonic-gate (void) fprintf(fout, "\tyylex=0; return; }\n"); 311*0Sstevel@tonic-gate (void) fprintf(fout, "\t\telse goto 30998\n"); 312*0Sstevel@tonic-gate } 313*0Sstevel@tonic-gate 314*0Sstevel@tonic-gate void 315*0Sstevel@tonic-gate phead2(void) 316*0Sstevel@tonic-gate { 317*0Sstevel@tonic-gate if (!ratfor) 318*0Sstevel@tonic-gate chd2(); 319*0Sstevel@tonic-gate } 320*0Sstevel@tonic-gate 321*0Sstevel@tonic-gate static void 322*0Sstevel@tonic-gate chd2(void) 323*0Sstevel@tonic-gate { 324*0Sstevel@tonic-gate (void) fprintf(fout, "#ifdef __cplusplus\n"); 325*0Sstevel@tonic-gate (void) fprintf(fout, 326*0Sstevel@tonic-gate "/* to avoid CC and lint complaining yyfussy not being used ...*/\n"); 327*0Sstevel@tonic-gate (void) fprintf(fout, "static int __lex_hack = 0;\n"); 328*0Sstevel@tonic-gate (void) fprintf(fout, "if (__lex_hack) goto yyfussy;\n"); 329*0Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 330*0Sstevel@tonic-gate (void) fprintf(fout, "while((nstr = yylook()) >= 0)\n"); 331*0Sstevel@tonic-gate (void) fprintf(fout, "yyfussy: switch(nstr){\n"); 332*0Sstevel@tonic-gate (void) fprintf(fout, "case 0:\n"); 333*0Sstevel@tonic-gate (void) fprintf(fout, "if(yywrap()) return(0); break;\n"); 334*0Sstevel@tonic-gate } 335*0Sstevel@tonic-gate 336*0Sstevel@tonic-gate void 337*0Sstevel@tonic-gate ptail(void) 338*0Sstevel@tonic-gate { 339*0Sstevel@tonic-gate if (!pflag) 340*0Sstevel@tonic-gate ratfor ? rtail() : ctail(); 341*0Sstevel@tonic-gate pflag = 1; 342*0Sstevel@tonic-gate } 343*0Sstevel@tonic-gate 344*0Sstevel@tonic-gate static void 345*0Sstevel@tonic-gate ctail(void) 346*0Sstevel@tonic-gate { 347*0Sstevel@tonic-gate (void) fprintf(fout, "case -1:\nbreak;\n"); /* for reject */ 348*0Sstevel@tonic-gate (void) fprintf(fout, "default:\n"); 349*0Sstevel@tonic-gate (void) fprintf(fout, 350*0Sstevel@tonic-gate "(void)fprintf(yyout,\"bad switch yylook %%d\",nstr);\n"); 351*0Sstevel@tonic-gate (void) fprintf(fout, "} return(0); }\n"); 352*0Sstevel@tonic-gate (void) fprintf(fout, "/* end of yylex */\n"); 353*0Sstevel@tonic-gate } 354*0Sstevel@tonic-gate 355*0Sstevel@tonic-gate static void 356*0Sstevel@tonic-gate rtail(void) 357*0Sstevel@tonic-gate { 358*0Sstevel@tonic-gate int i; 359*0Sstevel@tonic-gate (void) fprintf(fout, 360*0Sstevel@tonic-gate "\n30998 if(nstr .lt. 0 .or. nstr .gt. %d)goto 30999\n", casecount); 361*0Sstevel@tonic-gate (void) fprintf(fout, "nstr = nstr + 1\n"); 362*0Sstevel@tonic-gate (void) fprintf(fout, "goto(\n"); 363*0Sstevel@tonic-gate for (i = 0; i < casecount; i++) 364*0Sstevel@tonic-gate (void) fprintf(fout, "%d,\n", 30000+i); 365*0Sstevel@tonic-gate (void) fprintf(fout, "30999),nstr\n"); 366*0Sstevel@tonic-gate (void) fprintf(fout, "30997 continue\n"); 367*0Sstevel@tonic-gate (void) fprintf(fout, "}\nend\n"); 368*0Sstevel@tonic-gate } 369*0Sstevel@tonic-gate 370*0Sstevel@tonic-gate void 371*0Sstevel@tonic-gate statistics(void) 372*0Sstevel@tonic-gate { 373*0Sstevel@tonic-gate (void) fprintf(errorf, 374*0Sstevel@tonic-gate "%d/%d nodes(%%e), %d/%d positions(%%p), %d/%d (%%n), %ld transitions,\n", 375*0Sstevel@tonic-gate tptr, treesize, nxtpos-positions, maxpos, stnum + 1, nstates, rcount); 376*0Sstevel@tonic-gate (void) fprintf(errorf, 377*0Sstevel@tonic-gate "%d/%d packed char classes(%%k), ", pcptr-pchar, pchlen); 378*0Sstevel@tonic-gate if (optim) 379*0Sstevel@tonic-gate (void) fprintf(errorf, 380*0Sstevel@tonic-gate " %d/%d packed transitions(%%a), ", nptr, ntrans); 381*0Sstevel@tonic-gate (void) fprintf(errorf, " %d/%d output slots(%%o)", yytop, outsize); 382*0Sstevel@tonic-gate (void) putc('\n', errorf); 383*0Sstevel@tonic-gate } 384