USG_PG3/usr/source/lexgen1/header.c
# include "../lexgen1/ldefs.c"
head1()
{
ratfor ? rhd1() : chd1();
}
chd1()
{
printf(output, "extern int yyleng; extern char yytext[];\n");
printf(output, "extern struct {int *yyaa, *yybb, *yycc;} %ssvec[], *yybgin;\n",label);
if (scomp(label, "yy"))
{
printf(output, "int (*yyplex)() &yylexl;\n");
printf(output, "\nyylex() {\n");
printf(output, "return( (*yyplex)() );\n");
printf(output, "}\n");
}
printf(output, "# define REJECT {nstr=yyreject(); goto fussy;}\n");
printf(output, "# define ECHO printf(\"%%s\", yytext);\n");
printf(output, "\n\n%slexl() {\n", label);
printf(output, "int nstr;\n");
}
rhd1()
{
printf(output, "integer function yylex(dummy)\n");
printf(output, "define YYLMAX 200\n");
printf(output, "define ECHO call yyecho(yytext, yyleng)\n");
printf(output, "define REJECT nstr= yyrjec(yytext, yyleng); goto 30998\n");
printf(output, "integer nstr, yywrap, yylook\n");
printf(output, "integer yyleng, yytext(YYLMAX)\n");
printf(output, "common /yyxel/ yyleng, yytext\n");
printf(output, "common /yyldat/ yyfnd, yymorf, yyprev, yybgin, yylsp, yylsta\n");
printf(output, "integer yyfnd, yymorf, yyprev, yybgin, yylsp, yylsta(YYLMAX)\n");
printf(output, "for(;;)\n");
printf(output, "\t{\n");
printf(output, "\t30999 nstr = yylook(dummy)\n");
printf(output, "\tgo to 30998\n");
printf(output, "\t30000 k = yywrap(dummy)\n");
printf(output, "\t if (k .ne. 0) {\n");
printf(output, "\t\t yylex=0; return;}\n");
printf(output, "\t\t else goto 30999\n");
}
head2()
{
ratfor ? 0 : chd2();
}
chd2()
{
printf(output, "\nwhile((nstr=%slook()) >= 0)\n", label);
printf(output, "fussy: switch(nstr)\n {\n");
printf(output, "\n case 0:\n if (yywrap()) return(0); break;\n");
}
defclass()
{
int len, c;
char nsp[40], *name, *vsp[100], *val, *tp;
for (name=nsp; !space(*name = getchar()); name++);
*name++ = 0;
while (space(c=getchar()));
ungetc(c, cin);
gets(val=vsp);
tp = definition(nsp, clenf(vsp)+1, 0);
while (*tp++ = *val++);
}