Fixed #1823 (tokenize && wrong)

This commit is contained in:
Daniel Marjamäki 2010-07-05 22:41:02 +02:00
parent b02fc037ed
commit 18a75edd20
2 changed files with 8 additions and 1 deletions

View File

@ -341,6 +341,13 @@ void Tokenizer::createTokens(std::istream &code)
{
// Don't separate doubles "4.2e+10"
}
else if (ch=='&' && CurrentToken.empty() && code.peek() == '&')
{
// &&
ch = code.get();
addtoken("&&", lineno, FileIndex, true);
continue;
}
else
{
if (CurrentToken == "#file")
@ -1672,7 +1679,6 @@ bool Tokenizer::tokenize(std::istream &code, const char FileName[], const std::s
{
{ "<", "<", "<<" },
{ "&", "&", "&&" },
{ "|", "|", "||" },
{ "+", "=", "+=" },

View File

@ -520,6 +520,7 @@ private:
ASSERT_EQUALS("( p1 || ! p2 )", tokenizeAndStringify("( p1 != NULL || p2 == NULL )", true));
ASSERT_EQUALS("( p1 && ! p2 )", tokenizeAndStringify("( p1 != NULL && p2 == NULL )", true));
ASSERT_EQUALS("a & & b", tokenizeAndStringify("a & &b", true));
ASSERT_EQUALS("( ! p )", tokenizeAndStringify("( p == false )", true));
ASSERT_EQUALS("( ! p )", tokenizeAndStringify("( p == 0 )", true));