To get a reasonable answer, you need to study your problem more carefully.
For example, what are you going to do with methods containing preprocessor directives?
void M() { #if FOO for(foo;bar;blah) { #else while(abc) { #endif Blah(); } }
This is stupid but legal, so you need to deal with it. Are you going to consider this an inconsistent bracket or not?
Can you provide a detailed specification of exactly what you want to define? As we saw several times on this site, people cannot successfully create a procedure that divides two numbers without a specification. You are talking about analysis, which is much more complicated than dividing two numbers; The code that executes what you describe in a real compiler is tens of thousands of lines.
source share