4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* Copyright (c) 1988 AT&T */
27 /* All Rights Reserved */
29 #pragma ident "%Z%%M% %I% %E% SMI"
33 static void rhd1(void);
34 static void chd1(void);
35 static void chd2(void);
36 static void ctail(void);
37 static void rtail(void);
42 ratfor
? rhd1() : chd1();
49 (void) fprintf(fout
, "#ident\t\"lex: %s %s\"\n",
50 (const char *)SGU_PKG
, (const char *)SGU_REL
);
52 (void) fprintf(fout
, "#ifndef EUC\n");
53 (void) fprintf(fout
, "#define EUC\n");
54 (void) fprintf(fout
, "#endif\n");
55 (void) fprintf(fout
, "#include <stdio.h>\n");
56 (void) fprintf(fout
, "#include <stdlib.h>\n");
57 (void) fprintf(fout
, "#include <inttypes.h>\n");
58 (void) fprintf(fout
, "#include <widec.h>\n");
59 if (widecio
) { /* -w option */
60 (void) fprintf(fout
, "#define YYTEXT yytext\n");
61 (void) fprintf(fout
, "#define YYLENG yyleng\n");
62 (void) fprintf(fout
, "#ifndef __cplusplus\n");
63 (void) fprintf(fout
, "#define YYINPUT input\n");
64 (void) fprintf(fout
, "#define YYOUTPUT output\n");
65 (void) fprintf(fout
, "#else\n");
66 (void) fprintf(fout
, "#define YYINPUT lex_input\n");
67 (void) fprintf(fout
, "#define YYOUTPUT lex_output\n");
68 (void) fprintf(fout
, "#endif\n");
69 (void) fprintf(fout
, "#define YYUNPUT unput\n");
70 } else { /* -e option */
71 (void) fprintf(fout
, "#include <limits.h>\n");
72 (void) fprintf(fout
, "#include <sys/euc.h>\n");
73 (void) fprintf(fout
, "#define YYLEX_E 1\n");
74 (void) fprintf(fout
, "#define YYTEXT yywtext\n");
75 (void) fprintf(fout
, "#define YYLENG yywleng\n");
76 (void) fprintf(fout
, "#define YYINPUT yywinput\n");
77 (void) fprintf(fout
, "#define YYOUTPUT yywoutput\n");
78 (void) fprintf(fout
, "#define YYUNPUT yywunput\n");
80 } else { /* ASCII compatibility mode. */
81 (void) fprintf(fout
, "#include <stdio.h>\n");
82 (void) fprintf(fout
, "#include <stdlib.h>\n");
83 (void) fprintf(fout
, "#include <inttypes.h>\n");
86 (void) fprintf(fout
, "# define U(x) ((x)&0377)\n");
88 (void) fprintf(fout
, "# define U(x) x\n");
89 (void) fprintf(fout
, "# define NLSTATE yyprevious=YYNEWLINE\n");
90 (void) fprintf(fout
, "# define BEGIN yybgin = yysvec + 1 +\n");
91 (void) fprintf(fout
, "# define INITIAL 0\n");
92 (void) fprintf(fout
, "# define YYLERR yysvec\n");
93 (void) fprintf(fout
, "# define YYSTATE (yyestate-yysvec-1)\n");
95 (void) fprintf(fout
, "# define YYOPTIM 1\n");
97 (void) fprintf(fout
, "# define LEXDEBUG 1\n");
99 (void) fprintf(fout
, "# ifndef YYLMAX \n");
100 (void) fprintf(fout
, "# define YYLMAX BUFSIZ\n");
101 (void) fprintf(fout
, "# endif \n");
102 (void) fprintf(fout
, "#ifndef __cplusplus\n");
105 "# define output(c) (void)putwc(c,yyout)\n");
108 "# define output(c) (void)putc(c,yyout)\n");
109 (void) fprintf(fout
, "#else\n");
112 "# define lex_output(c) (void)putwc(c,yyout)\n");
115 "# define lex_output(c) (void)putc(c,yyout)\n");
116 (void) fprintf(fout
, "#endif\n");
118 "\n#if defined(__cplusplus) || defined(__STDC__)\n");
120 "\n#if defined(__cplusplus) && defined(__EXTERN_C__)\n");
121 (void) fprintf(fout
, "extern \"C\" {\n");
122 (void) fprintf(fout
, "#endif\n");
123 (void) fprintf(fout
, "\tint yyback(int *, int);\n"); /* ? */
124 (void) fprintf(fout
, "\tint yyinput(void);\n"); /* ? */
125 (void) fprintf(fout
, "\tint yylook(void);\n"); /* ? */
126 (void) fprintf(fout
, "\tvoid yyoutput(int);\n"); /* ? */
127 (void) fprintf(fout
, "\tint yyracc(int);\n"); /* ? */
128 (void) fprintf(fout
, "\tint yyreject(void);\n"); /* ? */
129 (void) fprintf(fout
, "\tvoid yyunput(int);\n"); /* ? */
130 (void) fprintf(fout
, "\tint yylex(void);\n");
131 (void) fprintf(fout
, "#ifdef YYLEX_E\n");
132 (void) fprintf(fout
, "\tvoid yywoutput(wchar_t);\n");
133 (void) fprintf(fout
, "\twchar_t yywinput(void);\n");
134 (void) fprintf(fout
, "\tvoid yywunput(wchar_t);\n");
135 (void) fprintf(fout
, "#endif\n");
137 /* XCU4: type of yyless is int */
138 (void) fprintf(fout
, "#ifndef yyless\n");
139 (void) fprintf(fout
, "\tint yyless(int);\n");
140 (void) fprintf(fout
, "#endif\n");
141 (void) fprintf(fout
, "#ifndef yywrap\n");
142 (void) fprintf(fout
, "\tint yywrap(void);\n");
143 (void) fprintf(fout
, "#endif\n");
144 (void) fprintf(fout
, "#ifdef LEXDEBUG\n");
145 (void) fprintf(fout
, "\tvoid allprint(char);\n");
146 (void) fprintf(fout
, "\tvoid sprint(char *);\n");
147 (void) fprintf(fout
, "#endif\n");
149 "#if defined(__cplusplus) && defined(__EXTERN_C__)\n");
150 (void) fprintf(fout
, "}\n");
151 (void) fprintf(fout
, "#endif\n\n");
152 (void) fprintf(fout
, "#ifdef __cplusplus\n");
153 (void) fprintf(fout
, "extern \"C\" {\n");
154 (void) fprintf(fout
, "#endif\n");
155 (void) fprintf(fout
, "\tvoid exit(int);\n");
156 (void) fprintf(fout
, "#ifdef __cplusplus\n");
157 (void) fprintf(fout
, "}\n");
158 (void) fprintf(fout
, "#endif\n\n");
159 (void) fprintf(fout
, "#endif\n");
162 " {yytchar= (c);if(yytchar=='\\n')yylineno--;*yysptr++=yytchar;}\n");
163 (void) fprintf(fout
, "# define yymore() (yymorfg=1)\n");
165 (void) fprintf(fout
, "#ifndef __cplusplus\n");
166 (void) fprintf(fout
, "%s%d%s\n",
167 "# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getwc(yyin))==",
169 "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)");
170 (void) fprintf(fout
, "#else\n");
171 (void) fprintf(fout
, "%s%d%s\n",
172 "# define lex_input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getwc(yyin))==",
174 "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)");
175 (void) fprintf(fout
, "#endif\n");
177 "# define ECHO (void)fprintf(yyout, \"%%ws\",yytext)\n");
179 "# define REJECT { nstr = yyreject_w(); goto yyfussy;}\n");
180 (void) fprintf(fout
, "#define yyless yyless_w\n");
181 (void) fprintf(fout
, "int yyleng;\n");
185 * If %array, yytext[] contains the token.
186 * If %pointer, yytext is a pointer to yy_tbuf[].
190 (void) fprintf(fout
, "#define YYISARRAY\n");
191 (void) fprintf(fout
, "wchar_t yytext[YYLMAX];\n");
193 (void) fprintf(fout
, "wchar_t yy_tbuf[YYLMAX];\n");
194 (void) fprintf(fout
, "wchar_t * yytext = yy_tbuf;\n");
195 (void) fprintf(fout
, "int yytextsz = YYLMAX;\n");
196 (void) fprintf(fout
, "#ifndef YYTEXTSZINC\n");
197 (void) fprintf(fout
, "#define YYTEXTSZINC 100\n");
198 (void) fprintf(fout
, "#endif\n");
201 (void) fprintf(fout
, "#ifndef __cplusplus\n");
202 (void) fprintf(fout
, "%s%d%s\n",
203 "# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==",
205 "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)");
206 (void) fprintf(fout
, "#else\n");
207 (void) fprintf(fout
, "%s%d%s\n",
208 "# define lex_input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==",
210 "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)");
211 (void) fprintf(fout
, "#endif\n");
213 "#define ECHO fprintf(yyout, \"%%s\",yytext)\n");
216 "# define REJECT { nstr = yyreject_e(); goto yyfussy;}\n");
217 (void) fprintf(fout
, "int yyleng;\n");
218 (void) fprintf(fout
, "size_t yywleng;\n");
221 * If %array, yytext[] contains the token.
222 * If %pointer, yytext is a pointer to yy_tbuf[].
225 (void) fprintf(fout
, "#define YYISARRAY\n");
227 "unsigned char yytext[YYLMAX*MB_LEN_MAX];\n");
229 "wchar_t yywtext[YYLMAX];\n");
232 "wchar_t yy_twbuf[YYLMAX];\n");
234 "wchar_t yy_tbuf[YYLMAX*MB_LEN_MAX];\n");
236 "unsigned char * yytext ="
237 "(unsigned char *)yy_tbuf;\n");
239 "wchar_t * yywtext = yy_twbuf;\n");
241 "int yytextsz = YYLMAX;\n");
242 (void) fprintf(fout
, "#ifndef YYTEXTSZINC\n");
244 "#define YYTEXTSZINC 100\n");
245 (void) fprintf(fout
, "#endif\n");
249 "# define REJECT { nstr = yyreject(); goto yyfussy;}\n");
250 (void) fprintf(fout
, "int yyleng;\n");
254 * If %array, yytext[] contains the token.
255 * If %pointer, yytext is a pointer to yy_tbuf[].
258 (void) fprintf(fout
, "#define YYISARRAY\n");
259 (void) fprintf(fout
, "char yytext[YYLMAX];\n");
261 (void) fprintf(fout
, "char yy_tbuf[YYLMAX];\n");
263 "char * yytext = yy_tbuf;\n");
265 "int yytextsz = YYLMAX;\n");
266 (void) fprintf(fout
, "#ifndef YYTEXTSZINC\n");
268 "#define YYTEXTSZINC 100\n");
269 (void) fprintf(fout
, "#endif\n");
273 (void) fprintf(fout
, "int yymorfg;\n");
275 (void) fprintf(fout
, "extern wchar_t *yysptr, yysbuf[];\n");
277 (void) fprintf(fout
, "extern char *yysptr, yysbuf[];\n");
278 (void) fprintf(fout
, "int yytchar;\n");
279 (void) fprintf(fout
, "FILE *yyin = {stdin}, *yyout = {stdout};\n");
280 (void) fprintf(fout
, "extern int yylineno;\n");
281 (void) fprintf(fout
, "struct yysvf { \n");
282 (void) fprintf(fout
, "\tstruct yywork *yystoff;\n");
283 (void) fprintf(fout
, "\tstruct yysvf *yyother;\n");
284 (void) fprintf(fout
, "\tint *yystops;};\n");
285 (void) fprintf(fout
, "struct yysvf *yyestate;\n");
286 (void) fprintf(fout
, "extern struct yysvf yysvec[], *yybgin;\n");
292 (void) fprintf(fout
, "integer function yylex(dummy)\n");
293 (void) fprintf(fout
, "define YYLMAX 200\n");
294 (void) fprintf(fout
, "define ECHO call yyecho(yytext,yyleng)\n");
296 "define REJECT nstr = yyrjct(yytext,yyleng);goto 30998\n");
297 (void) fprintf(fout
, "integer nstr,yylook,yywrap\n");
298 (void) fprintf(fout
, "integer yyleng, yytext(YYLMAX)\n");
299 (void) fprintf(fout
, "common /yyxel/ yyleng, yytext\n");
301 "common /yyldat/ yyfnd, yymorf, yyprev, yybgin, yylsp, yylsta\n");
303 "integer yyfnd, yymorf, yyprev, yybgin, yylsp, yylsta(YYLMAX)\n");
304 (void) fprintf(fout
, "for(;;){\n");
305 (void) fprintf(fout
, "\t30999 nstr = yylook(dummy)\n");
306 (void) fprintf(fout
, "\tgoto 30998\n");
307 (void) fprintf(fout
, "\t30000 k = yywrap(dummy)\n");
308 (void) fprintf(fout
, "\tif(k .ne. 0){\n");
309 (void) fprintf(fout
, "\tyylex=0; return; }\n");
310 (void) fprintf(fout
, "\t\telse goto 30998\n");
323 (void) fprintf(fout
, "#ifdef __cplusplus\n");
325 "/* to avoid CC and lint complaining yyfussy not being used ...*/\n");
326 (void) fprintf(fout
, "static int __lex_hack = 0;\n");
327 (void) fprintf(fout
, "if (__lex_hack) goto yyfussy;\n");
328 (void) fprintf(fout
, "#endif\n");
329 (void) fprintf(fout
, "while((nstr = yylook()) >= 0)\n");
330 (void) fprintf(fout
, "yyfussy: switch(nstr){\n");
331 (void) fprintf(fout
, "case 0:\n");
332 (void) fprintf(fout
, "if(yywrap()) return(0); break;\n");
339 ratfor
? rtail() : ctail();
346 (void) fprintf(fout
, "case -1:\nbreak;\n"); /* for reject */
347 (void) fprintf(fout
, "default:\n");
349 "(void)fprintf(yyout,\"bad switch yylook %%d\",nstr);\n");
350 (void) fprintf(fout
, "} return(0); }\n");
351 (void) fprintf(fout
, "/* end of yylex */\n");
359 "\n30998 if(nstr .lt. 0 .or. nstr .gt. %d)goto 30999\n", casecount
);
360 (void) fprintf(fout
, "nstr = nstr + 1\n");
361 (void) fprintf(fout
, "goto(\n");
362 for (i
= 0; i
< casecount
; i
++)
363 (void) fprintf(fout
, "%d,\n", 30000+i
);
364 (void) fprintf(fout
, "30999),nstr\n");
365 (void) fprintf(fout
, "30997 continue\n");
366 (void) fprintf(fout
, "}\nend\n");
372 (void) fprintf(errorf
,
373 "%d/%d nodes(%%e), %d/%d positions(%%p), %d/%d (%%n), %ld transitions,\n",
374 tptr
, treesize
, (int)(nxtpos
-positions
), maxpos
, stnum
+ 1,
376 (void) fprintf(errorf
,
377 "%d/%d packed char classes(%%k), ", (int)(pcptr
-pchar
), pchlen
);
379 (void) fprintf(errorf
,
380 " %d/%d packed transitions(%%a), ", nptr
, ntrans
);
381 (void) fprintf(errorf
, " %d/%d output slots(%%o)", yytop
, outsize
);
382 (void) putc('\n', errorf
);