| 1664 | } |
| 1665 | |
| 1666 | void Token::printAst(bool xml, const std::vector<std::string> &fileNames, std::ostream &out) const |
| 1667 | { |
| 1668 | if (!xml) |
| 1669 | out << "\n\n##AST" << std::endl; |
| 1670 | |
| 1671 | std::set<const Token *> printed; |
| 1672 | for (const Token *tok = this; tok; tok = tok->next()) { |
| 1673 | if (!tok->mImpl->mAstParent && tok->mImpl->mAstOperand1) { |
| 1674 | if (printed.find(tok) != printed.end()) |
| 1675 | continue; |
| 1676 | printed.insert(tok); |
| 1677 | |
| 1678 | if (xml) { |
| 1679 | out << "<ast scope=\"" << tok->scope() << "\" fileIndex=\"" << tok->fileIndex() << "\" linenr=\"" << tok->linenr() |
| 1680 | << "\" column=\"" << tok->column() << "\">" << std::endl; |
| 1681 | astStringXml(tok, 2U, out); |
| 1682 | out << "</ast>" << std::endl; |
| 1683 | } else |
| 1684 | out << "[" << fileNames[tok->fileIndex()] << ":" << tok->linenr() << "]" << std::endl << tok->astStringVerbose() << std::endl; |
| 1685 | if (tok->str() == "(") |
| 1686 | tok = tok->link(); |
| 1687 | } |
| 1688 | } |
| 1689 | } |
| 1690 | |
| 1691 | static void indent(std::string &str, const nonneg int indent1, const nonneg int indent2) |
| 1692 | { |
no test coverage detected