Updated tokenizer. To handle "#define f1(a,b) (a+b)" better
This commit is contained in:
parent
101afe4344
commit
d0cffeaa8c
|
@ -766,5 +766,13 @@ static void unused_variable()
|
||||||
"}\n";
|
"}\n";
|
||||||
check( CheckVariableScope, __LINE__, test5, "" );
|
check( CheckVariableScope, __LINE__, test5, "" );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char test6[] = "static void f()\n"
|
||||||
|
"{\n"
|
||||||
|
"#define F1(x, y, z) (z ^ (x & (y ^ z)))\n"
|
||||||
|
"}\n";
|
||||||
|
check( CheckVariableScope, __LINE__, test6, "" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
19
tokenize.cpp
19
tokenize.cpp
|
@ -328,13 +328,20 @@ void TokenizeCode(std::istream &code, const unsigned int FileIndex)
|
||||||
State = (State==Space1) ? Id : Value;
|
State = (State==Space1) ? Id : Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (State==Id && std::isspace(line[i]))
|
else if (State==Id)
|
||||||
{
|
{
|
||||||
strId = strdup(CurrentToken);
|
if ( std::isspace( line[i] ) )
|
||||||
memset(CurrentToken, 0, sizeof(CurrentToken));
|
{
|
||||||
pToken = CurrentToken;
|
strId = strdup(CurrentToken);
|
||||||
State = Space2;
|
memset(CurrentToken, 0, sizeof(CurrentToken));
|
||||||
continue;
|
pToken = CurrentToken;
|
||||||
|
State = Space2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if ( ! std::isalnum(line[i]) )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*pToken = line[i];
|
*pToken = line[i];
|
||||||
|
|
Loading…
Reference in New Issue