I have a question regarding how to parse nested files with the same structure using LEX/YACC.
Let's say that I have a file with the following structure
File_1
....
include File_2
include File_3
....
One possible approach is to call the function yyparse() within the YACC file each time I read a line such as
include File_n
but I understand this approach is not the good one, according to my lack of experience and poor knowledge in LEX/YACC there would be executing one LEX instance against two YACC parsing functions which may results in weird problems, isn't it?.
So, I was wondering which others options do I have?
Thanks!
After some research days, I figured out how to manage my problem.
Since my question did not receive much attention I guess my question was not formulated in an understandable way. Anyway, I am going to post the solution I found. I solved the problem in the lex file by following this tutorial.
Basically, I had to define a stack in order to save the current buffer state for the file that is currently being parsed when the include
statement is found, then I started to parse the included file, when the included file is finished I switched back to the first file.
I hope this answer may help someone around.