This resource has not currently been approved, and is not currently linked to from our directory of resources. It is being displayed here for preview by the author and moderators only.
3. Skip of development environment complex key constructions not influencing the program processing.
We have already examined the way of skipping single keywords which are senseless for our program but impede code parsing. Unfortunately, sometimes it is even more difficult. Let's take for demonstration such constructions as __pragma and __noop which you may see in header files of VisualC++:
__forceinline DWORD HEAP_MAKE_TAG_FLAGS (
DWORD TagBase, DWORD Tag )
{
__pragma(warning(push)) __pragma(warning(disable : 4548)) do {__noop(TagBase);} while((0,0) __pragma(warning(pop)) );
return ((DWORD)((TagBase) + ((Tag) << 18)));
}
|
You may look for description of __pragma and __noop constructions in MSDN. The next points are important for our program: a) they are not of interest for us; b) they have some parameters; c) they impede code analysis.
Let's add new lexemes at first, as it was told before, but now let's use InitializeOtherKeywords() function for this purpose:
static void InitializeOtherKeywords(bool recognizeOccExtensions)
{
...
verify(Lex::RecordKeyword("__pragma", MSPRAGMA));
verify(Lex::RecordKeyword("__noop", MS__NOOP));
...
}
|
Solution consists in modifying Lex::ReadToken function so that when we come across with DECLSPEC or MSPRAGMA lexeme we skip it. And then we skip all the lexemes related to __pragma and __noop parameters. For skipping all the unnecessary lexemes we use SkipDeclspecToken() function as it is shown further.
ptrdiff_t Lex::ReadToken(char*& ptr, ptrdiff_t& len)
{
...
else if(t == DECLSPEC){
SkipDeclspecToken();
continue;
}
else if(t == MSPRAGMA) { // NEW
SkipDeclspecToken();
continue;
}
else if(t == MS__NOOP) { //NEW
SkipDeclspecToken();
continue;
}
...
}
|