Fix misspelled word

This commit is contained in:
Dmitry-Me 2015-12-25 11:51:08 +03:00
parent e8b2b5e934
commit 05cb4e16fe
3 changed files with 8 additions and 8 deletions

View File

@ -3536,7 +3536,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
// Remove __asm.. // Remove __asm..
simplifyAsm(); simplifyAsm();
// Add parantheses to ternary operator where necessary // Add parentheses to ternary operator where necessary
prepareTernaryOpForAST(); prepareTernaryOpForAST();
// Change initialisation of variable to assignment // 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: // 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 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()) { for (Token* tok = list.front(); tok; tok = tok->next()) {
if (tok->str() == "?") { if (tok->str() == "?") {
bool paranthesesNeeded = false; bool parenthesesNeeded = false;
unsigned int depth = 0; unsigned int depth = 0;
Token* tok2 = tok->next(); Token* tok2 = tok->next();
for (; tok2; tok2 = tok2->next()) { for (; tok2; tok2 = tok2->next()) {
@ -10245,13 +10245,13 @@ void Tokenizer::prepareTernaryOpForAST()
} else if (tok2->str() == ";" || (tok2->link() && tok2->str() != "{" && tok2->str() != "}")) } else if (tok2->str() == ";" || (tok2->link() && tok2->str() != "{" && tok2->str() != "}"))
break; break;
else if (tok2->str() == ",") else if (tok2->str() == ",")
paranthesesNeeded = true; parenthesesNeeded = true;
else if (tok2->str() == "?") { else if (tok2->str() == "?") {
depth++; depth++;
paranthesesNeeded = true; parenthesesNeeded = true;
} }
} }
if (paranthesesNeeded && tok2 && tok2->str() == ":") { if (parenthesesNeeded && tok2 && tok2->str() == ":") {
tok->insertToken("("); tok->insertToken("(");
tok2->insertToken(")", emptyString, true); tok2->insertToken(")", emptyString, true);
Token::createMutualLinks(tok->next(), tok2->previous()); Token::createMutualLinks(tok->next(), tok2->previous());

View File

@ -695,7 +695,7 @@ private:
bool simplifyStrlen(); 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(); void prepareTernaryOpForAST();

View File

@ -908,7 +908,7 @@ static void compileAssignTernary(Token *&tok, AST_state& state)
} else if (tok->str() == "?") { } else if (tok->str() == "?") {
// http://en.cppreference.com/w/cpp/language/operator_precedence says about ternary operator: // 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 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) == ":") { if (tok->strAt(1) == ":") {
state.op.push(0); state.op.push(0);
} }