%{
#include <stdio.h>
extern FILE *yyin, *yyout; // External file pointers for input and output
%}
%%
. { fprintf(yyout, "%s", yytext); } // Print each matched character to output file
%%
int main() {
extern FILE *yyin, *yyout;
// Open input
.txt for reading and output
.txt for writing
yyin = fopen("input.txt", "r");
if (!yyin) {
perror("Error opening input file");
return 1;
}
yyout = fopen("output.txt", "w");
if (!yyout) {
perror("Error opening output file");
return 1;
}
yylex(); // Start lexical analysis
fclose
(yyin
); // Close input file after processing
fclose
(yyout
); // Close output file after processing
return 0;
}
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CmV4dGVybiBGSUxFICp5eWluLCAqeXlvdXQ7ICAvLyBFeHRlcm5hbCBmaWxlIHBvaW50ZXJzIGZvciBpbnB1dCBhbmQgb3V0cHV0CiV9CgolJSAKLiB7IGZwcmludGYoeXlvdXQsICIlcyIsIHl5dGV4dCk7IH0gIC8vIFByaW50IGVhY2ggbWF0Y2hlZCBjaGFyYWN0ZXIgdG8gb3V0cHV0IGZpbGUKJSUgCgppbnQgbWFpbigpIHsKICAgIGV4dGVybiBGSUxFICp5eWluLCAqeXlvdXQ7CgogICAgLy8gT3BlbiBpbnB1dC50eHQgZm9yIHJlYWRpbmcgYW5kIG91dHB1dC50eHQgZm9yIHdyaXRpbmcKICAgIHl5aW4gPSBmb3BlbigiaW5wdXQudHh0IiwgInIiKTsKICAgIGlmICgheXlpbikgewogICAgICAgIHBlcnJvcigiRXJyb3Igb3BlbmluZyBpbnB1dCBmaWxlIik7CiAgICAgICAgcmV0dXJuIDE7CiAgICB9CiAgICAKICAgIHl5b3V0ID0gZm9wZW4oIm91dHB1dC50eHQiLCAidyIpOwogICAgaWYgKCF5eW91dCkgewogICAgICAgIHBlcnJvcigiRXJyb3Igb3BlbmluZyBvdXRwdXQgZmlsZSIpOwogICAgICAgIHJldHVybiAxOwogICAgfQoKICAgIHl5bGV4KCk7ICAvLyBTdGFydCBsZXhpY2FsIGFuYWx5c2lzCiAgICBmY2xvc2UoeXlpbik7ICAvLyBDbG9zZSBpbnB1dCBmaWxlIGFmdGVyIHByb2Nlc3NpbmcKICAgIGZjbG9zZSh5eW91dCk7IC8vIENsb3NlIG91dHB1dCBmaWxlIGFmdGVyIHByb2Nlc3NpbmcKCiAgICByZXR1cm4gMDsKfQo=