Merge pull request #743 from Dmitry-Me/fixCommentTypo

Fix misspelled word
This commit is contained in:
PKEuS 2015-12-25 11:29:07 +01:00
commit 802b35145c
3 changed files with 8 additions and 8 deletions

View File

@ -3536,7 +3536,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
// Remove __asm..
simplifyAsm();
// Add parantheses to ternary operator where necessary
// Add parentheses to ternary operator where necessary
prepareTernaryOpForAST();
// Change initialisation of variable to assignment
@ -10229,10 +10229,10 @@ void Tokenizer::prepareTernaryOpForAST()
{
// http://en.cppreference.com/w/cpp/language/operator_precedence says about ternary operator:
// "The expression in the middle of the conditional operator (between ? and :) is parsed as if parenthesized: its precedence relative to ?: is ignored."
// The AST parser relies on this function to add such parantheses where necessary.
// The AST parser relies on this function to add such parentheses where necessary.
for (Token* tok = list.front(); tok; tok = tok->next()) {
if (tok->str() == "?") {
bool paranthesesNeeded = false;
bool parenthesesNeeded = false;
unsigned int depth = 0;
Token* tok2 = tok->next();
for (; tok2; tok2 = tok2->next()) {
@ -10245,13 +10245,13 @@ void Tokenizer::prepareTernaryOpForAST()
} else if (tok2->str() == ";" || (tok2->link() && tok2->str() != "{" && tok2->str() != "}"))
break;
else if (tok2->str() == ",")
paranthesesNeeded = true;
parenthesesNeeded = true;
else if (tok2->str() == "?") {
depth++;
paranthesesNeeded = true;
parenthesesNeeded = true;
}
}
if (paranthesesNeeded && tok2 && tok2->str() == ":") {
if (parenthesesNeeded && tok2 && tok2->str() == ":") {
tok->insertToken("(");
tok2->insertToken(")", emptyString, true);
Token::createMutualLinks(tok->next(), tok2->previous());

View File

@ -695,7 +695,7 @@ private:
bool simplifyStrlen();
/**
* Prepare ternary operators with parantheses so that the AST can be created
* Prepare ternary operators with parentheses so that the AST can be created
* */
void prepareTernaryOpForAST();

View File

@ -908,7 +908,7 @@ static void compileAssignTernary(Token *&tok, AST_state& state)
} else if (tok->str() == "?") {
// http://en.cppreference.com/w/cpp/language/operator_precedence says about ternary operator:
// "The expression in the middle of the conditional operator (between ? and :) is parsed as if parenthesized: its precedence relative to ?: is ignored."
// Hence, we rely on Tokenizer::prepareTernaryOpForAST() to add such parantheses where necessary.
// Hence, we rely on Tokenizer::prepareTernaryOpForAST() to add such parentheses where necessary.
if (tok->strAt(1) == ":") {
state.op.push(0);
}