Add simplification of the consecutive braces before the end of 'tokenize()' function.
This commit is contained in:
parent
5cbfbe31c1
commit
ed6a0e14c4
|
@ -2500,6 +2500,16 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
tok->next()->deleteNext();
|
tok->next()->deleteNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove redundant consecutive braces, i.e. '.. { { .. } } ..' -> '.. { .. } ..'.
|
||||||
|
for (Token *tok = _tokens; tok; ) {
|
||||||
|
if (Token::simpleMatch(tok, "{ {") && Token::simpleMatch(tok->next()->link(), "} }")) {
|
||||||
|
//remove internal parentheses
|
||||||
|
tok->next()->link()->deleteThis();
|
||||||
|
tok->deleteNext();
|
||||||
|
} else
|
||||||
|
tok = tok->next();
|
||||||
|
}
|
||||||
|
|
||||||
return validate();
|
return validate();
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -4329,16 +4339,13 @@ bool Tokenizer::simplifyTokenList()
|
||||||
simplifyFlowControl();
|
simplifyFlowControl();
|
||||||
|
|
||||||
// Remove redundant consecutive braces, i.e. '.. { { .. } } ..' -> '.. { .. } ..'.
|
// Remove redundant consecutive braces, i.e. '.. { { .. } } ..' -> '.. { .. } ..'.
|
||||||
{
|
for (Token *tok = _tokens; tok; ) {
|
||||||
Token *tok = _tokens;
|
if (Token::simpleMatch(tok, "{ {") && Token::simpleMatch(tok->next()->link(), "} }")) {
|
||||||
while (tok) {
|
//remove internal parentheses
|
||||||
if (Token::simpleMatch(tok, "{ {") && Token::simpleMatch(tok->next()->link(), "} }")) {
|
tok->next()->link()->deleteThis();
|
||||||
//remove internal parentheses
|
tok->deleteNext();
|
||||||
tok->next()->link()->deleteThis();
|
} else
|
||||||
tok->deleteNext();
|
tok = tok->next();
|
||||||
} else
|
|
||||||
tok = tok->next();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validate())
|
if (!validate())
|
||||||
|
|
Loading…
Reference in New Issue