So far, I've seen how to parse a string and a complete file; however, I haven't
seen how to parse something like c's #include "file" and then start parsing
file until it's done, and then resume parsing after the #include.
What's the best way to do this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One approach is to do an initial pass to handle all of the preprocessor instructions, such as #define, #include, etc. and create a composite file with all of the preprocessor instructions and references already resolved. However, if you need to retain some traceability of what came from the original source, and what came from the include file, this would not work as well.
Something else to try would be to use a parse action attached to the #include expression, and have the parse action parse the header file before returning to parse the remainder of the source file.
In either case, you would need to guard against recursive inclusion taking you down an infinite loop of #includes.
HTH,
-- Paul
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So far, I've seen how to parse a string and a complete file; however, I haven't
seen how to parse something like c's #include "file" and then start parsing
file until it's done, and then resume parsing after the #include.
What's the best way to do this?
One approach is to do an initial pass to handle all of the preprocessor instructions, such as #define, #include, etc. and create a composite file with all of the preprocessor instructions and references already resolved. However, if you need to retain some traceability of what came from the original source, and what came from the include file, this would not work as well.
Something else to try would be to use a parse action attached to the #include expression, and have the parse action parse the header file before returning to parse the remainder of the source file.
In either case, you would need to guard against recursive inclusion taking you down an infinite loop of #includes.
HTH,
-- Paul