Fixed tokenizer: "return - 2 ;" --> "return -2 ;"

This commit is contained in:
Reijo Tomperi 2009-03-18 20:48:06 +02:00
parent ca055dc830
commit 2fb4c52728
2 changed files with 7 additions and 0 deletions

View File

@ -344,6 +344,12 @@ void Tokenizer::tokenize(std::istream &code, const char FileName[])
tok->next()->str((std::string("-") + tok->strAt(2)).c_str());
tok->next()->deleteNext();
}
if (Token::Match(tok, "return - %num%") && tok->strAt(2)[0] != '-')
{
tok->next()->str((std::string("-") + tok->strAt(2)).c_str());
tok->next()->deleteNext();
}
}
// Combine tokens..

View File

@ -178,6 +178,7 @@ private:
ASSERT_EQUALS("i = -12", tokenizeAndStringify("i = -12"));
ASSERT_EQUALS("1 - 2", tokenizeAndStringify("1-2"));
ASSERT_EQUALS("foo ( -1 ) - 2", tokenizeAndStringify("foo(-1)-2"));
ASSERT_EQUALS("int f ( ) { return -2 ; }", tokenizeAndStringify("int f(){return -2;}"));
}