%{
#include <stdio.h>
%}
%%
// Match integers
[0-9]+ { printf("%s\n", yytext); }
// Ignore everything else
. ;
%%
// Main function
int main(int argc, char **argv) {
if (argc > 1) {
FILE *file = fopen(argv[1], "r");
if (file) {
yyin = file;
yylex();
fclose(file);
} else {
perror("Error opening file");
return 1;
}
} else {
fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
return 1;
}
return 0;
}
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CiV9CgolJQoKLy8gTWF0Y2ggaW50ZWdlcnMKWzAtOV0rICAgeyBwcmludGYoIiVzXG4iLCB5eXRleHQpOyB9CgovLyBJZ25vcmUgZXZlcnl0aGluZyBlbHNlCi4gICAgICAgIDsKCiUlCgovLyBNYWluIGZ1bmN0aW9uCmludCBtYWluKGludCBhcmdjLCBjaGFyICoqYXJndikgewogICAgaWYgKGFyZ2MgPiAxKSB7CiAgICAgICAgRklMRSAqZmlsZSA9IGZvcGVuKGFyZ3ZbMV0sICJyIik7CiAgICAgICAgaWYgKGZpbGUpIHsKICAgICAgICAgICAgeXlpbiA9IGZpbGU7CiAgICAgICAgICAgIHl5bGV4KCk7CiAgICAgICAgICAgIGZjbG9zZShmaWxlKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBwZXJyb3IoIkVycm9yIG9wZW5pbmcgZmlsZSIpOwogICAgICAgICAgICByZXR1cm4gMTsKICAgICAgICB9CiAgICB9IGVsc2UgewogICAgICAgIGZwcmludGYoc3RkZXJyLCAiVXNhZ2U6ICVzIDxmaWxlbmFtZT5cbiIsIGFyZ3ZbMF0pOwogICAgICAgIHJldHVybiAxOwogICAgfQogICAgcmV0dXJuIDA7Cn0K