I am currently working on a flex/bison project.
I need to parse multiple files in one execution, so i made a loop to run YYPARSE() multiple times.
When flex finds a lexical or syntactic error, the parsing of a file stops and the program starts parsing the next file. However, the parsing of that new file doesn't start from the beginning. Indeed, if the parsing stopped at line 8 for file 3 the parsing will start form line 8 in file 4.
How could i solve this problem ?
Thanks in advance.
Here is my main function in my bison.y file:
int main(int argc, char* argv[]){
DIR* dir;
struct dirent *ent;
int val = 0;
if ((dir = opendir ("../TpCompileHoho")) != NULL)
{
// print all the files and directories within directory
while ((ent = readdir (dir)) != NULL)
{
if ((strcmp(ent->d_name,".") != 0) && (strcmp(ent->d_name,"..") != 0) && (strstr(ent->d_name,".txt") != NULL))
{
yyin = fopen(ent->d_name,"r");
yyparse();
}
}
closedir (dir);
}
else
{
// could not open directory
perror ("could not open directory");
return EXIT_FAILURE;
}
}