Fixed tokenizer: "return - 2 ;" --> "return -2 ;"
This commit is contained in:
parent
ca055dc830
commit
2fb4c52728
|
@ -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()->str((std::string("-") + tok->strAt(2)).c_str());
|
||||||
tok->next()->deleteNext();
|
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..
|
// Combine tokens..
|
||||||
|
|
|
@ -178,6 +178,7 @@ private:
|
||||||
ASSERT_EQUALS("i = -12", tokenizeAndStringify("i = -12"));
|
ASSERT_EQUALS("i = -12", tokenizeAndStringify("i = -12"));
|
||||||
ASSERT_EQUALS("1 - 2", tokenizeAndStringify("1-2"));
|
ASSERT_EQUALS("1 - 2", tokenizeAndStringify("1-2"));
|
||||||
ASSERT_EQUALS("foo ( -1 ) - 2", tokenizeAndStringify("foo(-1)-2"));
|
ASSERT_EQUALS("foo ( -1 ) - 2", tokenizeAndStringify("foo(-1)-2"));
|
||||||
|
ASSERT_EQUALS("int f ( ) { return -2 ; }", tokenizeAndStringify("int f(){return -2;}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue