I am trying to write a state machine that breaks the source file and breaks it into sections, which are either the compiler or the preprocessor business. Not a deep workaround, I'm just looking for sections that are either comments or preprocessor directives. (without macros, without conditionally compiled blocks, etc.)
The comments are quite simple, but I'm not 100% sure when it is legal to specify a preprocessor directive. For example, does the following line match?
int i; #include <derp.h>
Are there any special cases where some directives are allowed while others are not?
I searched google and SO and did not find a question that answers this.
Please be responsible for BOTH C and C ++, I noted both intentionally and intentionally.
source share