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";
|
||||
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;
|
||||
}
|
||||
|
||||
else if (State==Id && std::isspace(line[i]))
|
||||
else if (State==Id)
|
||||
{
|
||||
strId = strdup(CurrentToken);
|
||||
memset(CurrentToken, 0, sizeof(CurrentToken));
|
||||
pToken = CurrentToken;
|
||||
State = Space2;
|
||||
continue;
|
||||
if ( std::isspace( line[i] ) )
|
||||
{
|
||||
strId = strdup(CurrentToken);
|
||||
memset(CurrentToken, 0, sizeof(CurrentToken));
|
||||
pToken = CurrentToken;
|
||||
State = Space2;
|
||||
continue;
|
||||
}
|
||||
else if ( ! std::isalnum(line[i]) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*pToken = line[i];
|
||||
|
|
Loading…
Reference in New Issue