So my question is pretty simple, I guess it has been answered before but I can’t get my hands on a good thread about it: can I parse a file once, gather some needed information to initialize my structures and then parse it “for real” a second time?
When I call yylex() twice it just doesn’t seem to do anything. Or is it that I need to reset the read pointer of my file? I’m a C noob so it may be a stupid question! Anyway any help will be appreciated.
Use
yyrestart(FILE *in).But note that the flex manual suggests that instead of a two-pass scanner like this, you should build a parse tree the first time.