1*14488Ssam #ifndef lint
2*14488Ssam static char sccsid[] = "@(#)header.c 4.1 (Berkeley) 08/11/83";
3*14488Ssam #endif
4*14488Ssam # include "ldefs.c"
phead1()5*14488Ssam phead1(){
6*14488Ssam ratfor ? rhd1() : chd1();
7*14488Ssam }
8*14488Ssam
chd1()9*14488Ssam chd1(){
10*14488Ssam fprintf(fout,"# include \"stdio.h\"\n");
11*14488Ssam if (ZCH>NCH)
12*14488Ssam fprintf(fout, "# define U(x) ((x)&0377)\n");
13*14488Ssam else
14*14488Ssam fprintf(fout, "# define U(x) x\n");
15*14488Ssam fprintf(fout, "# define NLSTATE yyprevious=YYNEWLINE\n");
16*14488Ssam fprintf(fout,"# define BEGIN yybgin = yysvec + 1 +\n");
17*14488Ssam fprintf(fout,"# define INITIAL 0\n");
18*14488Ssam fprintf(fout,"# define YYLERR yysvec\n");
19*14488Ssam fprintf(fout,"# define YYSTATE (yyestate-yysvec-1)\n");
20*14488Ssam if(optim)
21*14488Ssam fprintf(fout,"# define YYOPTIM 1\n");
22*14488Ssam # ifdef DEBUG
23*14488Ssam fprintf(fout,"# define LEXDEBUG 1\n");
24*14488Ssam # endif
25*14488Ssam fprintf(fout,"# define YYLMAX 200\n");
26*14488Ssam fprintf(fout,"# define output(c) putc(c,yyout)\n");
27*14488Ssam fprintf(fout, "%s%d%s\n",
28*14488Ssam "# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==",
29*14488Ssam ctable['\n'],
30*14488Ssam "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)");
31*14488Ssam fprintf(fout,
32*14488Ssam "# define unput(c) {yytchar= (c);if(yytchar=='\\n')yylineno--;*yysptr++=yytchar;}\n");
33*14488Ssam fprintf(fout,"# define yymore() (yymorfg=1)\n");
34*14488Ssam fprintf(fout,"# define ECHO fprintf(yyout, \"%%s\",yytext)\n");
35*14488Ssam fprintf(fout,"# define REJECT { nstr = yyreject(); goto yyfussy;}\n");
36*14488Ssam fprintf(fout,"int yyleng; extern char yytext[];\n");
37*14488Ssam fprintf(fout,"int yymorfg;\n");
38*14488Ssam fprintf(fout,"extern char *yysptr, yysbuf[];\n");
39*14488Ssam fprintf(fout,"int yytchar;\n");
40*14488Ssam fprintf(fout,"FILE *yyin ={stdin}, *yyout ={stdout};\n");
41*14488Ssam fprintf(fout,"extern int yylineno;\n");
42*14488Ssam fprintf(fout,"struct yysvf { \n");
43*14488Ssam fprintf(fout,"\tstruct yywork *yystoff;\n");
44*14488Ssam fprintf(fout,"\tstruct yysvf *yyother;\n");
45*14488Ssam fprintf(fout,"\tint *yystops;};\n");
46*14488Ssam fprintf(fout,"struct yysvf *yyestate;\n");
47*14488Ssam fprintf(fout,"extern struct yysvf yysvec[], *yybgin;\n");
48*14488Ssam }
49*14488Ssam
rhd1()50*14488Ssam rhd1(){
51*14488Ssam fprintf(fout,"integer function yylex(dummy)\n");
52*14488Ssam fprintf(fout,"define YYLMAX 200\n");
53*14488Ssam fprintf(fout,"define ECHO call yyecho(yytext,yyleng)\n");
54*14488Ssam fprintf(fout,"define REJECT nstr = yyrjct(yytext,yyleng);goto 30998\n");
55*14488Ssam fprintf(fout,"integer nstr,yylook,yywrap\n");
56*14488Ssam fprintf(fout,"integer yyleng, yytext(YYLMAX)\n");
57*14488Ssam fprintf(fout,"common /yyxel/ yyleng, yytext\n");
58*14488Ssam fprintf(fout,"common /yyldat/ yyfnd, yymorf, yyprev, yybgin, yylsp, yylsta\n");
59*14488Ssam fprintf(fout,"integer yyfnd, yymorf, yyprev, yybgin, yylsp, yylsta(YYLMAX)\n");
60*14488Ssam fprintf(fout,"for(;;){\n");
61*14488Ssam fprintf(fout,"\t30999 nstr = yylook(dummy)\n");
62*14488Ssam fprintf(fout,"\tgoto 30998\n");
63*14488Ssam fprintf(fout,"\t30000 k = yywrap(dummy)\n");
64*14488Ssam fprintf(fout,"\tif(k .ne. 0){\n");
65*14488Ssam fprintf(fout,"\tyylex=0; return; }\n");
66*14488Ssam fprintf(fout,"\t\telse goto 30998\n");
67*14488Ssam }
68*14488Ssam
phead2()69*14488Ssam phead2(){
70*14488Ssam if(!ratfor)chd2();
71*14488Ssam }
72*14488Ssam
chd2()73*14488Ssam chd2(){
74*14488Ssam fprintf(fout,"while((nstr = yylook()) >= 0)\n");
75*14488Ssam fprintf(fout,"yyfussy: switch(nstr){\n");
76*14488Ssam fprintf(fout,"case 0:\n");
77*14488Ssam fprintf(fout,"if(yywrap()) return(0); break;\n");
78*14488Ssam }
79*14488Ssam
ptail()80*14488Ssam ptail(){
81*14488Ssam if(!pflag)
82*14488Ssam ratfor ? rtail() : ctail();
83*14488Ssam pflag = 1;
84*14488Ssam }
85*14488Ssam
ctail()86*14488Ssam ctail(){
87*14488Ssam fprintf(fout,"case -1:\nbreak;\n"); /* for reject */
88*14488Ssam fprintf(fout,"default:\n");
89*14488Ssam fprintf(fout,"fprintf(yyout,\"bad switch yylook %%d\",nstr);\n");
90*14488Ssam fprintf(fout,"} return(0); }\n");
91*14488Ssam fprintf(fout,"/* end of yylex */\n");
92*14488Ssam }
93*14488Ssam
rtail()94*14488Ssam rtail(){
95*14488Ssam register int i;
96*14488Ssam fprintf(fout,"\n30998 if(nstr .lt. 0 .or. nstr .gt. %d)goto 30999\n",casecount);
97*14488Ssam fprintf(fout,"nstr = nstr + 1\n");
98*14488Ssam fprintf(fout,"goto(\n");
99*14488Ssam for(i=0; i<casecount; i++)
100*14488Ssam fprintf(fout,"%d,\n",30000+i);
101*14488Ssam fprintf(fout,"30999),nstr\n");
102*14488Ssam fprintf(fout,"30997 continue\n");
103*14488Ssam fprintf(fout,"}\nend\n");
104*14488Ssam }
statistics()105*14488Ssam statistics(){
106*14488Ssam fprintf(errorf,"%d/%d nodes(%%e), %d/%d positions(%%p), %d/%d (%%n), %ld transitions\n",
107*14488Ssam tptr, treesize, nxtpos-positions, maxpos, stnum+1, nstates, rcount);
108*14488Ssam fprintf(errorf, ", %d/%d packed char classes(%%k)", pcptr-pchar, pchlen);
109*14488Ssam if(optim)fprintf(errorf,", %d/%d packed transitions(%%a)",nptr, ntrans);
110*14488Ssam fprintf(errorf, ", %d/%d output slots(%%o)", yytop, outsize);
111*14488Ssam putc('\n',errorf);
112*14488Ssam }
113