Ciao,
mi chiedevo se e' possibile parserizzare due volte uno stesso file d'input in Yacc/Bison.
In questo modo potrei, nella prima lettura del file, crearmi una struttura dati che mi contenga tutte le informazioni che mi serviranno in un secondo momento e poi, nella seconda lettura, usare tale struttura dati per ricavarmi tutte le informazioni che mi servono.

Nel main ho queste istruzioni:

ofstream * designs_defines;
bool second_time = false;

main( int argc, char *argv[] )
{ extern FILE *yyin;
++argv; --argc;
string fname = argv[0];

designs_defines = new ofstream();
string base_file_name = fname.substr(0, fname.length() - 4);
designs_defines->open( (base_file_name + "_defines.h").c_str(), ios::trunc );
yyin = fopen( argv[0], "r" );
/*yydebug = 1;*/
errors = 0;
SystemObject * st = new SystemObject();
yyparse (st);
printf ( "Parse Completed\n" );

....

}

quindi ho provato a modificare tale codice in questo modo:

ofstream * designs_defines;
bool second_time = false;

main( int argc, char *argv[] )
{ extern FILE *yyin;
++argv; --argc;
string fname = argv[0];

designs_defines = new ofstream();
string base_file_name = fname.substr(0, fname.length() - 4);
designs_defines->open( (base_file_name + "_defines.h").c_str(), ios::trunc );
yyin = fopen( argv[0], "r" );
/*yydebug = 1;*/
errors = 0;
SystemObject * st = new SystemObject();
yyparse (st);


second_time = true;
SystemObject * st2 = new SystemObject();
yyparse(st2);


printf ( "Parse Completed\n" );

....

}

dove il valore booleano "second_time" verra' utilizzato all'interno di una grammatica del parser per poter ricavare delle informazioni che potranno essere disponibili solo se viene effettuata la seconda lettura del file di input.
In questo modo non viene effettuata alcuna altra lettura del file, inoltre dopo aver passato il file di input al parser, questo termina con "syntax error 1".

Grazie in anticipo a chiunque mi aiuti e se questo messaggio non e' molto chiaro o se avete bisogno di altre informazioni, chiedetemi pure!!