blob: 28593f623299b15f323d9a45a16b134d65e3394f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
%{
int scans = 0;
int prints = 0;
%}
%%
scanf {
scans++;
fprintf(yyout, "readf");
};
printf {
prints++;
fprintf(yyout, "writef");
}
. fprintf(yyout, "%s", yytext);
\n fprintf(yyout, "\n");
%%
int main(void) {
yyin=fopen("4/input", "r+");
yyout=fopen("4/output", "w");
yylex();
printf("%d printf occurrence(s)\n", prints);
printf("%d scanf occurrence(s)\n", scans);
}
int yywrap()
{
return(1);
}
|