AST: Updated printAst
This commit is contained in:
parent
8a72bb8aa8
commit
2e2735518e
|
@ -1241,28 +1241,26 @@ static void astStringXml(const Token *tok, std::size_t indent, std::ostream &out
|
||||||
|
|
||||||
void Token::printAst(bool verbose, bool xml, std::ostream &out) const
|
void Token::printAst(bool verbose, bool xml, std::ostream &out) const
|
||||||
{
|
{
|
||||||
bool title = false;
|
std::set<const Token *> printed;
|
||||||
|
|
||||||
bool print = true;
|
|
||||||
for (const Token *tok = this; tok; tok = tok->next()) {
|
for (const Token *tok = this; tok; tok = tok->next()) {
|
||||||
if (print && tok->_astOperand1) {
|
if (!tok->_astParent && tok->_astOperand1) {
|
||||||
if (!title && !xml)
|
if (printed.empty() && !xml)
|
||||||
out << "\n\n##AST" << std::endl;
|
out << "\n\n##AST" << std::endl;
|
||||||
title = true;
|
else if (printed.find(tok) != printed.end())
|
||||||
|
continue;
|
||||||
|
printed.insert(tok);
|
||||||
|
|
||||||
if (xml) {
|
if (xml) {
|
||||||
out << "<ast scope=\"" << tok->scope() << "\" fileIndex=\"" << tok->fileIndex() << "\" linenr=\"" << tok->linenr() << "\">" << std::endl;
|
out << "<ast scope=\"" << tok->scope() << "\" fileIndex=\"" << tok->fileIndex() << "\" linenr=\"" << tok->linenr() << "\">" << std::endl;
|
||||||
astStringXml(tok->astTop(), 2U, out);
|
astStringXml(tok, 2U, out);
|
||||||
out << "</ast>" << std::endl;
|
out << "</ast>" << std::endl;
|
||||||
} else if (verbose)
|
} else if (verbose)
|
||||||
out << tok->astTop()->astStringVerbose(0,0) << std::endl;
|
out << tok->astStringVerbose(0,0) << std::endl;
|
||||||
else
|
else
|
||||||
out << tok->astTop()->astString(" ") << std::endl;
|
out << tok->astString(" ") << std::endl;
|
||||||
print = false;
|
|
||||||
if (tok->str() == "(")
|
if (tok->str() == "(")
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
}
|
}
|
||||||
if (Token::Match(tok, "[;{}]"))
|
|
||||||
print = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue