Tokenizer: Fix minor problem with 'X&&Y'

This commit is contained in:
Daniel Marjamäki 2011-07-15 19:37:39 +02:00
parent d78d8660ab
commit 274fd2b985
2 changed files with 13 additions and 1 deletions

View File

@ -425,8 +425,14 @@ void Tokenizer::createTokens(std::istream &code)
// tokenize .125 into 0.125
CurrentToken = "0";
}
else if (ch=='&' && CurrentToken.empty() && code.peek() == '&')
else if (ch=='&' && code.peek() == '&')
{
if (!CurrentToken.empty())
{
addtoken(CurrentToken.c_str(), lineno, FileIndex, true);
CurrentToken.clear();
}
// &&
ch = (char)code.get();
addtoken("&&", lineno, FileIndex, true);

View File

@ -51,6 +51,7 @@ private:
TEST_CASE(tokenize15); // tokenize ".123"
TEST_CASE(tokenize16); // #2612 - segfault for "<><<"
TEST_CASE(tokenize17); // #2759
TEST_CASE(tokenize18); // tokenize "(X&&Y)" into "( X && Y )" instead of "( X & & Y )"
// don't freak out when the syntax is wrong
TEST_CASE(wrong_syntax);
@ -559,6 +560,11 @@ private:
ASSERT_EQUALS("class B : private :: A { } ;", tokenizeAndStringify("class B : private ::A { };"));
}
void tokenize18() // tokenize "(X&&Y)" into "( X && Y )" instead of "( X & & Y )"
{
ASSERT_EQUALS("( X && Y )", tokenizeAndStringify("(X&&Y)"));
}
void wrong_syntax()
{
{