17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 567298654Sdamico * Common Development and Distribution License (the "License"). 667298654Sdamico * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*1dd08564Sab196087 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 3167298654Sdamico #include "ldefs.h" 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate static void rhd1(void); 347c478bd9Sstevel@tonic-gate static void chd1(void); 357c478bd9Sstevel@tonic-gate static void chd2(void); 367c478bd9Sstevel@tonic-gate static void ctail(void); 377c478bd9Sstevel@tonic-gate static void rtail(void); 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate void 407c478bd9Sstevel@tonic-gate phead1(void) 417c478bd9Sstevel@tonic-gate { 427c478bd9Sstevel@tonic-gate ratfor ? rhd1() : chd1(); 437c478bd9Sstevel@tonic-gate } 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate static void 467c478bd9Sstevel@tonic-gate chd1(void) 477c478bd9Sstevel@tonic-gate { 487c478bd9Sstevel@tonic-gate if (*v_stmp == 'y') 497c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#ident\t\"lex: %s %s\"\n", 507c478bd9Sstevel@tonic-gate (const char *)SGU_PKG, (const char *)SGU_REL); 517c478bd9Sstevel@tonic-gate if (handleeuc) { 52*1dd08564Sab196087 (void) fprintf(fout, "#ifndef EUC\n"); 53*1dd08564Sab196087 (void) fprintf(fout, "#define EUC\n"); 54*1dd08564Sab196087 (void) fprintf(fout, "#endif\n"); 55*1dd08564Sab196087 (void) fprintf(fout, "#include <stdio.h>\n"); 56*1dd08564Sab196087 (void) fprintf(fout, "#include <stdlib.h>\n"); 57*1dd08564Sab196087 (void) fprintf(fout, "#include <inttypes.h>\n"); 58*1dd08564Sab196087 (void) fprintf(fout, "#include <widec.h>\n"); 597c478bd9Sstevel@tonic-gate if (widecio) { /* -w option */ 60*1dd08564Sab196087 (void) fprintf(fout, "#define YYTEXT yytext\n"); 61*1dd08564Sab196087 (void) fprintf(fout, "#define YYLENG yyleng\n"); 62*1dd08564Sab196087 (void) fprintf(fout, "#ifndef __cplusplus\n"); 63*1dd08564Sab196087 (void) fprintf(fout, "#define YYINPUT input\n"); 64*1dd08564Sab196087 (void) fprintf(fout, "#define YYOUTPUT output\n"); 65*1dd08564Sab196087 (void) fprintf(fout, "#else\n"); 66*1dd08564Sab196087 (void) fprintf(fout, "#define YYINPUT lex_input\n"); 67*1dd08564Sab196087 (void) fprintf(fout, "#define YYOUTPUT lex_output\n"); 68*1dd08564Sab196087 (void) fprintf(fout, "#endif\n"); 69*1dd08564Sab196087 (void) fprintf(fout, "#define YYUNPUT unput\n"); 707c478bd9Sstevel@tonic-gate } else { /* -e option */ 71*1dd08564Sab196087 (void) fprintf(fout, "#include <limits.h>\n"); 72*1dd08564Sab196087 (void) fprintf(fout, "#include <sys/euc.h>\n"); 73*1dd08564Sab196087 (void) fprintf(fout, "#define YYLEX_E 1\n"); 74*1dd08564Sab196087 (void) fprintf(fout, "#define YYTEXT yywtext\n"); 75*1dd08564Sab196087 (void) fprintf(fout, "#define YYLENG yywleng\n"); 76*1dd08564Sab196087 (void) fprintf(fout, "#define YYINPUT yywinput\n"); 77*1dd08564Sab196087 (void) fprintf(fout, "#define YYOUTPUT yywoutput\n"); 78*1dd08564Sab196087 (void) fprintf(fout, "#define YYUNPUT yywunput\n"); 797c478bd9Sstevel@tonic-gate } 807c478bd9Sstevel@tonic-gate } else { /* ASCII compatibility mode. */ 81*1dd08564Sab196087 (void) fprintf(fout, "#include <stdio.h>\n"); 82*1dd08564Sab196087 (void) fprintf(fout, "#include <stdlib.h>\n"); 83*1dd08564Sab196087 (void) fprintf(fout, "#include <inttypes.h>\n"); 847c478bd9Sstevel@tonic-gate } 857c478bd9Sstevel@tonic-gate if (ZCH > NCH) 867c478bd9Sstevel@tonic-gate (void) fprintf(fout, "# define U(x) ((x)&0377)\n"); 877c478bd9Sstevel@tonic-gate else 887c478bd9Sstevel@tonic-gate (void) fprintf(fout, "# define U(x) x\n"); 897c478bd9Sstevel@tonic-gate (void) fprintf(fout, "# define NLSTATE yyprevious=YYNEWLINE\n"); 907c478bd9Sstevel@tonic-gate (void) fprintf(fout, "# define BEGIN yybgin = yysvec + 1 +\n"); 917c478bd9Sstevel@tonic-gate (void) fprintf(fout, "# define INITIAL 0\n"); 927c478bd9Sstevel@tonic-gate (void) fprintf(fout, "# define YYLERR yysvec\n"); 937c478bd9Sstevel@tonic-gate (void) fprintf(fout, "# define YYSTATE (yyestate-yysvec-1)\n"); 947c478bd9Sstevel@tonic-gate if (optim) 957c478bd9Sstevel@tonic-gate (void) fprintf(fout, "# define YYOPTIM 1\n"); 967c478bd9Sstevel@tonic-gate #ifdef DEBUG 977c478bd9Sstevel@tonic-gate (void) fprintf(fout, "# define LEXDEBUG 1\n"); 987c478bd9Sstevel@tonic-gate #endif 997c478bd9Sstevel@tonic-gate (void) fprintf(fout, "# ifndef YYLMAX \n"); 1007c478bd9Sstevel@tonic-gate (void) fprintf(fout, "# define YYLMAX BUFSIZ\n"); 1017c478bd9Sstevel@tonic-gate (void) fprintf(fout, "# endif \n"); 1027c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#ifndef __cplusplus\n"); 1037c478bd9Sstevel@tonic-gate if (widecio) 1047c478bd9Sstevel@tonic-gate (void) fprintf(fout, 1057c478bd9Sstevel@tonic-gate "# define output(c) (void)putwc(c,yyout)\n"); 1067c478bd9Sstevel@tonic-gate else 1077c478bd9Sstevel@tonic-gate (void) fprintf(fout, 1087c478bd9Sstevel@tonic-gate "# define output(c) (void)putc(c,yyout)\n"); 1097c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#else\n"); 1107c478bd9Sstevel@tonic-gate if (widecio) 1117c478bd9Sstevel@tonic-gate (void) fprintf(fout, 1127c478bd9Sstevel@tonic-gate "# define lex_output(c) (void)putwc(c,yyout)\n"); 1137c478bd9Sstevel@tonic-gate else 1147c478bd9Sstevel@tonic-gate (void) fprintf(fout, 1157c478bd9Sstevel@tonic-gate "# define lex_output(c) (void)putc(c,yyout)\n"); 1167c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1177c478bd9Sstevel@tonic-gate (void) fprintf(fout, 1187c478bd9Sstevel@tonic-gate "\n#if defined(__cplusplus) || defined(__STDC__)\n"); 1197c478bd9Sstevel@tonic-gate (void) fprintf(fout, 1207c478bd9Sstevel@tonic-gate "\n#if defined(__cplusplus) && defined(__EXTERN_C__)\n"); 1217c478bd9Sstevel@tonic-gate (void) fprintf(fout, "extern \"C\" {\n"); 1227c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1237c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tint yyback(int *, int);\n"); /* ? */ 1247c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tint yyinput(void);\n"); /* ? */ 1257c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tint yylook(void);\n"); /* ? */ 1267c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tvoid yyoutput(int);\n"); /* ? */ 1277c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tint yyracc(int);\n"); /* ? */ 1287c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tint yyreject(void);\n"); /* ? */ 1297c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tvoid yyunput(int);\n"); /* ? */ 1307c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tint yylex(void);\n"); 1317c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#ifdef YYLEX_E\n"); 1327c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tvoid yywoutput(wchar_t);\n"); 1337c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\twchar_t yywinput(void);\n"); 1347c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tvoid yywunput(wchar_t);\n"); 1357c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate /* XCU4: type of yyless is int */ 1387c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#ifndef yyless\n"); 1397c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tint yyless(int);\n"); 1407c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1417c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#ifndef yywrap\n"); 1427c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tint yywrap(void);\n"); 1437c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1447c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#ifdef LEXDEBUG\n"); 1457c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tvoid allprint(char);\n"); 1467c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tvoid sprint(char *);\n"); 1477c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1487c478bd9Sstevel@tonic-gate (void) fprintf(fout, 1497c478bd9Sstevel@tonic-gate "#if defined(__cplusplus) && defined(__EXTERN_C__)\n"); 1507c478bd9Sstevel@tonic-gate (void) fprintf(fout, "}\n"); 1517c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n\n"); 1527c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#ifdef __cplusplus\n"); 1537c478bd9Sstevel@tonic-gate (void) fprintf(fout, "extern \"C\" {\n"); 1547c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1557c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tvoid exit(int);\n"); 1567c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#ifdef __cplusplus\n"); 1577c478bd9Sstevel@tonic-gate (void) fprintf(fout, "}\n"); 1587c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n\n"); 1597c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1607c478bd9Sstevel@tonic-gate (void) fprintf(fout, 1617c478bd9Sstevel@tonic-gate "# define unput(c)" 1627c478bd9Sstevel@tonic-gate " {yytchar= (c);if(yytchar=='\\n')yylineno--;*yysptr++=yytchar;}\n"); 1637c478bd9Sstevel@tonic-gate (void) fprintf(fout, "# define yymore() (yymorfg=1)\n"); 1647c478bd9Sstevel@tonic-gate if (widecio) { 1657c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#ifndef __cplusplus\n"); 1667c478bd9Sstevel@tonic-gate (void) fprintf(fout, "%s%d%s\n", 1677c478bd9Sstevel@tonic-gate "# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getwc(yyin))==", 1687c478bd9Sstevel@tonic-gate ctable['\n'], 1697c478bd9Sstevel@tonic-gate "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); 1707c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#else\n"); 1717c478bd9Sstevel@tonic-gate (void) fprintf(fout, "%s%d%s\n", 1727c478bd9Sstevel@tonic-gate "# define lex_input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getwc(yyin))==", 1737c478bd9Sstevel@tonic-gate ctable['\n'], 1747c478bd9Sstevel@tonic-gate "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); 1757c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1767c478bd9Sstevel@tonic-gate (void) fprintf(fout, 1777c478bd9Sstevel@tonic-gate "# define ECHO (void)fprintf(yyout, \"%%ws\",yytext)\n"); 1787c478bd9Sstevel@tonic-gate (void) fprintf(fout, 1797c478bd9Sstevel@tonic-gate "# define REJECT { nstr = yyreject_w(); goto yyfussy;}\n"); 1807c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#define yyless yyless_w\n"); 1817c478bd9Sstevel@tonic-gate (void) fprintf(fout, "int yyleng;\n"); 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate /* 1847c478bd9Sstevel@tonic-gate * XCU4: 1857c478bd9Sstevel@tonic-gate * If %array, yytext[] contains the token. 1867c478bd9Sstevel@tonic-gate * If %pointer, yytext is a pointer to yy_tbuf[]. 1877c478bd9Sstevel@tonic-gate */ 1887c478bd9Sstevel@tonic-gate 1897c478bd9Sstevel@tonic-gate if (isArray) { 1907c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#define YYISARRAY\n"); 1917c478bd9Sstevel@tonic-gate (void) fprintf(fout, "wchar_t yytext[YYLMAX];\n"); 1927c478bd9Sstevel@tonic-gate } else { 1937c478bd9Sstevel@tonic-gate (void) fprintf(fout, "wchar_t yy_tbuf[YYLMAX];\n"); 1947c478bd9Sstevel@tonic-gate (void) fprintf(fout, "wchar_t * yytext = yy_tbuf;\n"); 1957c478bd9Sstevel@tonic-gate (void) fprintf(fout, "int yytextsz = YYLMAX;\n"); 1967c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#ifndef YYTEXTSZINC\n"); 1977c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#define YYTEXTSZINC 100\n"); 1987c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 1997c478bd9Sstevel@tonic-gate } 2007c478bd9Sstevel@tonic-gate } else { 2017c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#ifndef __cplusplus\n"); 2027c478bd9Sstevel@tonic-gate (void) fprintf(fout, "%s%d%s\n", 2037c478bd9Sstevel@tonic-gate "# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==", 2047c478bd9Sstevel@tonic-gate ctable['\n'], 2057c478bd9Sstevel@tonic-gate "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); 2067c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#else\n"); 2077c478bd9Sstevel@tonic-gate (void) fprintf(fout, "%s%d%s\n", 2087c478bd9Sstevel@tonic-gate "# define lex_input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==", 2097c478bd9Sstevel@tonic-gate ctable['\n'], 2107c478bd9Sstevel@tonic-gate "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); 2117c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 212*1dd08564Sab196087 (void) fprintf(fout, 213*1dd08564Sab196087 "#define ECHO fprintf(yyout, \"%%s\",yytext)\n"); 2147c478bd9Sstevel@tonic-gate if (handleeuc) { 2157c478bd9Sstevel@tonic-gate (void) fprintf(fout, 2167c478bd9Sstevel@tonic-gate "# define REJECT { nstr = yyreject_e(); goto yyfussy;}\n"); 2177c478bd9Sstevel@tonic-gate (void) fprintf(fout, "int yyleng;\n"); 2187c478bd9Sstevel@tonic-gate (void) fprintf(fout, "size_t yywleng;\n"); 2197c478bd9Sstevel@tonic-gate /* 2207c478bd9Sstevel@tonic-gate * XCU4: 2217c478bd9Sstevel@tonic-gate * If %array, yytext[] contains the token. 2227c478bd9Sstevel@tonic-gate * If %pointer, yytext is a pointer to yy_tbuf[]. 2237c478bd9Sstevel@tonic-gate */ 2247c478bd9Sstevel@tonic-gate if (isArray) { 2257c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#define YYISARRAY\n"); 2267c478bd9Sstevel@tonic-gate (void) fprintf(fout, 2277c478bd9Sstevel@tonic-gate "unsigned char yytext[YYLMAX*MB_LEN_MAX];\n"); 2287c478bd9Sstevel@tonic-gate (void) fprintf(fout, 2297c478bd9Sstevel@tonic-gate "wchar_t yywtext[YYLMAX];\n"); 2307c478bd9Sstevel@tonic-gate } else { 2317c478bd9Sstevel@tonic-gate (void) fprintf(fout, 2327c478bd9Sstevel@tonic-gate "wchar_t yy_twbuf[YYLMAX];\n"); 2337c478bd9Sstevel@tonic-gate (void) fprintf(fout, 2347c478bd9Sstevel@tonic-gate "wchar_t yy_tbuf[YYLMAX*MB_LEN_MAX];\n"); 2357c478bd9Sstevel@tonic-gate (void) fprintf(fout, 2367c478bd9Sstevel@tonic-gate "unsigned char * yytext =" 2377c478bd9Sstevel@tonic-gate "(unsigned char *)yy_tbuf;\n"); 2387c478bd9Sstevel@tonic-gate (void) fprintf(fout, 2397c478bd9Sstevel@tonic-gate "wchar_t * yywtext = yy_twbuf;\n"); 2407c478bd9Sstevel@tonic-gate (void) fprintf(fout, 2417c478bd9Sstevel@tonic-gate "int yytextsz = YYLMAX;\n"); 2427c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#ifndef YYTEXTSZINC\n"); 2437c478bd9Sstevel@tonic-gate (void) fprintf(fout, 2447c478bd9Sstevel@tonic-gate "#define YYTEXTSZINC 100\n"); 2457c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 2467c478bd9Sstevel@tonic-gate } 2477c478bd9Sstevel@tonic-gate } else { 2487c478bd9Sstevel@tonic-gate (void) fprintf(fout, 2497c478bd9Sstevel@tonic-gate "# define REJECT { nstr = yyreject(); goto yyfussy;}\n"); 2507c478bd9Sstevel@tonic-gate (void) fprintf(fout, "int yyleng;\n"); 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate /* 2537c478bd9Sstevel@tonic-gate * XCU4: 2547c478bd9Sstevel@tonic-gate * If %array, yytext[] contains the token. 2557c478bd9Sstevel@tonic-gate * If %pointer, yytext is a pointer to yy_tbuf[]. 2567c478bd9Sstevel@tonic-gate */ 2577c478bd9Sstevel@tonic-gate if (isArray) { 2587c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#define YYISARRAY\n"); 2597c478bd9Sstevel@tonic-gate (void) fprintf(fout, "char yytext[YYLMAX];\n"); 2607c478bd9Sstevel@tonic-gate } else { 2617c478bd9Sstevel@tonic-gate (void) fprintf(fout, "char yy_tbuf[YYLMAX];\n"); 2627c478bd9Sstevel@tonic-gate (void) fprintf(fout, 2637c478bd9Sstevel@tonic-gate "char * yytext = yy_tbuf;\n"); 2647c478bd9Sstevel@tonic-gate (void) fprintf(fout, 2657c478bd9Sstevel@tonic-gate "int yytextsz = YYLMAX;\n"); 2667c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#ifndef YYTEXTSZINC\n"); 2677c478bd9Sstevel@tonic-gate (void) fprintf(fout, 2687c478bd9Sstevel@tonic-gate "#define YYTEXTSZINC 100\n"); 2697c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 2707c478bd9Sstevel@tonic-gate } 2717c478bd9Sstevel@tonic-gate } 2727c478bd9Sstevel@tonic-gate } 2737c478bd9Sstevel@tonic-gate (void) fprintf(fout, "int yymorfg;\n"); 2747c478bd9Sstevel@tonic-gate if (handleeuc) 2757c478bd9Sstevel@tonic-gate (void) fprintf(fout, "extern wchar_t *yysptr, yysbuf[];\n"); 2767c478bd9Sstevel@tonic-gate else 2777c478bd9Sstevel@tonic-gate (void) fprintf(fout, "extern char *yysptr, yysbuf[];\n"); 2787c478bd9Sstevel@tonic-gate (void) fprintf(fout, "int yytchar;\n"); 2797c478bd9Sstevel@tonic-gate (void) fprintf(fout, "FILE *yyin = {stdin}, *yyout = {stdout};\n"); 2807c478bd9Sstevel@tonic-gate (void) fprintf(fout, "extern int yylineno;\n"); 2817c478bd9Sstevel@tonic-gate (void) fprintf(fout, "struct yysvf { \n"); 2827c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tstruct yywork *yystoff;\n"); 2837c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tstruct yysvf *yyother;\n"); 2847c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tint *yystops;};\n"); 2857c478bd9Sstevel@tonic-gate (void) fprintf(fout, "struct yysvf *yyestate;\n"); 2867c478bd9Sstevel@tonic-gate (void) fprintf(fout, "extern struct yysvf yysvec[], *yybgin;\n"); 2877c478bd9Sstevel@tonic-gate } 2887c478bd9Sstevel@tonic-gate 2897c478bd9Sstevel@tonic-gate static void 2907c478bd9Sstevel@tonic-gate rhd1(void) 2917c478bd9Sstevel@tonic-gate { 2927c478bd9Sstevel@tonic-gate (void) fprintf(fout, "integer function yylex(dummy)\n"); 2937c478bd9Sstevel@tonic-gate (void) fprintf(fout, "define YYLMAX 200\n"); 2947c478bd9Sstevel@tonic-gate (void) fprintf(fout, "define ECHO call yyecho(yytext,yyleng)\n"); 2957c478bd9Sstevel@tonic-gate (void) fprintf(fout, 2967c478bd9Sstevel@tonic-gate "define REJECT nstr = yyrjct(yytext,yyleng);goto 30998\n"); 2977c478bd9Sstevel@tonic-gate (void) fprintf(fout, "integer nstr,yylook,yywrap\n"); 2987c478bd9Sstevel@tonic-gate (void) fprintf(fout, "integer yyleng, yytext(YYLMAX)\n"); 2997c478bd9Sstevel@tonic-gate (void) fprintf(fout, "common /yyxel/ yyleng, yytext\n"); 3007c478bd9Sstevel@tonic-gate (void) fprintf(fout, 3017c478bd9Sstevel@tonic-gate "common /yyldat/ yyfnd, yymorf, yyprev, yybgin, yylsp, yylsta\n"); 3027c478bd9Sstevel@tonic-gate (void) fprintf(fout, 3037c478bd9Sstevel@tonic-gate "integer yyfnd, yymorf, yyprev, yybgin, yylsp, yylsta(YYLMAX)\n"); 3047c478bd9Sstevel@tonic-gate (void) fprintf(fout, "for(;;){\n"); 3057c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\t30999 nstr = yylook(dummy)\n"); 3067c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tgoto 30998\n"); 3077c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\t30000 k = yywrap(dummy)\n"); 3087c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tif(k .ne. 0){\n"); 3097c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\tyylex=0; return; }\n"); 3107c478bd9Sstevel@tonic-gate (void) fprintf(fout, "\t\telse goto 30998\n"); 3117c478bd9Sstevel@tonic-gate } 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate void 3147c478bd9Sstevel@tonic-gate phead2(void) 3157c478bd9Sstevel@tonic-gate { 3167c478bd9Sstevel@tonic-gate if (!ratfor) 3177c478bd9Sstevel@tonic-gate chd2(); 3187c478bd9Sstevel@tonic-gate } 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate static void 3217c478bd9Sstevel@tonic-gate chd2(void) 3227c478bd9Sstevel@tonic-gate { 3237c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#ifdef __cplusplus\n"); 3247c478bd9Sstevel@tonic-gate (void) fprintf(fout, 3257c478bd9Sstevel@tonic-gate "/* to avoid CC and lint complaining yyfussy not being used ...*/\n"); 3267c478bd9Sstevel@tonic-gate (void) fprintf(fout, "static int __lex_hack = 0;\n"); 3277c478bd9Sstevel@tonic-gate (void) fprintf(fout, "if (__lex_hack) goto yyfussy;\n"); 3287c478bd9Sstevel@tonic-gate (void) fprintf(fout, "#endif\n"); 3297c478bd9Sstevel@tonic-gate (void) fprintf(fout, "while((nstr = yylook()) >= 0)\n"); 3307c478bd9Sstevel@tonic-gate (void) fprintf(fout, "yyfussy: switch(nstr){\n"); 3317c478bd9Sstevel@tonic-gate (void) fprintf(fout, "case 0:\n"); 3327c478bd9Sstevel@tonic-gate (void) fprintf(fout, "if(yywrap()) return(0); break;\n"); 3337c478bd9Sstevel@tonic-gate } 3347c478bd9Sstevel@tonic-gate 3357c478bd9Sstevel@tonic-gate void 3367c478bd9Sstevel@tonic-gate ptail(void) 3377c478bd9Sstevel@tonic-gate { 3387c478bd9Sstevel@tonic-gate if (!pflag) 3397c478bd9Sstevel@tonic-gate ratfor ? rtail() : ctail(); 3407c478bd9Sstevel@tonic-gate pflag = 1; 3417c478bd9Sstevel@tonic-gate } 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate static void 3447c478bd9Sstevel@tonic-gate ctail(void) 3457c478bd9Sstevel@tonic-gate { 3467c478bd9Sstevel@tonic-gate (void) fprintf(fout, "case -1:\nbreak;\n"); /* for reject */ 3477c478bd9Sstevel@tonic-gate (void) fprintf(fout, "default:\n"); 3487c478bd9Sstevel@tonic-gate (void) fprintf(fout, 3497c478bd9Sstevel@tonic-gate "(void)fprintf(yyout,\"bad switch yylook %%d\",nstr);\n"); 3507c478bd9Sstevel@tonic-gate (void) fprintf(fout, "} return(0); }\n"); 3517c478bd9Sstevel@tonic-gate (void) fprintf(fout, "/* end of yylex */\n"); 3527c478bd9Sstevel@tonic-gate } 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate static void 3557c478bd9Sstevel@tonic-gate rtail(void) 3567c478bd9Sstevel@tonic-gate { 3577c478bd9Sstevel@tonic-gate int i; 3587c478bd9Sstevel@tonic-gate (void) fprintf(fout, 3597c478bd9Sstevel@tonic-gate "\n30998 if(nstr .lt. 0 .or. nstr .gt. %d)goto 30999\n", casecount); 3607c478bd9Sstevel@tonic-gate (void) fprintf(fout, "nstr = nstr + 1\n"); 3617c478bd9Sstevel@tonic-gate (void) fprintf(fout, "goto(\n"); 3627c478bd9Sstevel@tonic-gate for (i = 0; i < casecount; i++) 3637c478bd9Sstevel@tonic-gate (void) fprintf(fout, "%d,\n", 30000+i); 3647c478bd9Sstevel@tonic-gate (void) fprintf(fout, "30999),nstr\n"); 3657c478bd9Sstevel@tonic-gate (void) fprintf(fout, "30997 continue\n"); 3667c478bd9Sstevel@tonic-gate (void) fprintf(fout, "}\nend\n"); 3677c478bd9Sstevel@tonic-gate } 3687c478bd9Sstevel@tonic-gate 3697c478bd9Sstevel@tonic-gate void 3707c478bd9Sstevel@tonic-gate statistics(void) 3717c478bd9Sstevel@tonic-gate { 3727c478bd9Sstevel@tonic-gate (void) fprintf(errorf, 3737c478bd9Sstevel@tonic-gate "%d/%d nodes(%%e), %d/%d positions(%%p), %d/%d (%%n), %ld transitions,\n", 374*1dd08564Sab196087 tptr, treesize, (int)(nxtpos-positions), maxpos, stnum + 1, 375*1dd08564Sab196087 nstates, rcount); 3767c478bd9Sstevel@tonic-gate (void) fprintf(errorf, 377*1dd08564Sab196087 "%d/%d packed char classes(%%k), ", (int)(pcptr-pchar), pchlen); 3787c478bd9Sstevel@tonic-gate if (optim) 3797c478bd9Sstevel@tonic-gate (void) fprintf(errorf, 3807c478bd9Sstevel@tonic-gate " %d/%d packed transitions(%%a), ", nptr, ntrans); 3817c478bd9Sstevel@tonic-gate (void) fprintf(errorf, " %d/%d output slots(%%o)", yytop, outsize); 3827c478bd9Sstevel@tonic-gate (void) putc('\n', errorf); 3837c478bd9Sstevel@tonic-gate } 384