My bison / flex parser start by reading input from a file:
FILE *myfile = fopen(file.c_str(), "r");
yyin = myfile;
yyparse();
At some point after that, it reads and parse input from a string in memory:
yy_scan_string(str.c_str());
yyparse();
yy_delete_buffer(YY_CURRENT_BUFFER);
It seems to work well up to this point. However, when the program needs to read and parse input from the file again using the first code it doesn't work (terminates with segmentation fault). Is there a fix to this issue?