I wrote a parser using PLY and it does what I need. Now, I would like to parse multiple files using the parser class. Instead of instantiating the parser class for each file, I would like to re-use the same instantiated class for all files (so that I can accumulate some results in the parser class).
Parsing of one file may not complete nicely so that I would like to re-initialize the parser before feeding another file.
What is the correct way to re-initialize a PLY parser? (Or, I shouldn't reuse a parser?)
If you want to reuse the same parser for multiple files, but reset the stack each time, you can use the
restart
function:More can be found at the official documentation.