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();
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -4329,16 +4339,13 @@ bool Tokenizer::simplifyTokenList()
|
|||
simplifyFlowControl();
|
||||
|
||||
// Remove redundant consecutive braces, i.e. '.. { { .. } } ..' -> '.. { .. } ..'.
|
||||
{
|
||||
Token *tok = _tokens;
|
||||
while (tok) {
|
||||
if (Token::simpleMatch(tok, "{ {") && Token::simpleMatch(tok->next()->link(), "} }")) {
|
||||
//remove internal parentheses
|
||||
tok->next()->link()->deleteThis();
|
||||
tok->deleteNext();
|
||||
} else
|
||||
tok = tok->next();
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
if (!validate())
|
||||
|
|
Loading…
Reference in New Issue