mirror of
https://github.com/westes/flex.git
synced 2026-01-26 07:37:52 +00:00
30 lines
515 B
Plaintext
30 lines
515 B
Plaintext
%{
|
|
extern FILE *yyin;
|
|
|
|
void open_input_file(void)
|
|
{
|
|
char *file_name,buffer[1024];
|
|
|
|
yyin = NULL;
|
|
|
|
while(yyin == NULL){
|
|
printf("Input file: ");
|
|
file_name = fgets(buffer,1024,stdin);
|
|
if(file_name){
|
|
file_name[strlen(file_name)-1] = '\0';
|
|
yyin = fopen(file_name,"r");
|
|
if(yyin == NULL){
|
|
printf("Unable to open \"%s\"\n",file_name);
|
|
}
|
|
} else {
|
|
printf("stdin\n");
|
|
yyin = stdin;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
%}
|
|
%option user-init = "open_input_file();"
|
|
%%
|