#include "libparse.h" using namespace lib_parse; using namespace ast_gen; CheckException::CheckException(const QString& msg) : msg_store(msg) {} QString CheckException::message() const { return msg_store; } Analyzer::Analyzer(const QList >& providers) : check_providers(providers) {} #include #include std::shared_ptr Analyzer::validCheckWith(std::shared_ptr root) const { for (auto& v : check_providers){ QTime time_stamp = QTime::currentTime(); v->validCheck(root); auto current_stamp = QTime::currentTime(); qDebug().noquote() << QString("%校验器:%2 消耗时间:%1 ms。").arg(time_stamp.msecsTo(current_stamp)).arg(v->name()); } return root; } bool VisitEntry::visitWith(std::shared_ptr syntax_elm, std::shared_ptr visitor) { switch (visitor->mode()) { case VisitMode::FirstParent: { if (visitor->visit(syntax_elm)) { for (auto& e : syntax_elm->children()) { visitWith(e, visitor); } } return true; }break; case VisitMode::LastParent:{ bool exc_continue = true; for (auto& e : syntax_elm->children()) { if(!visitWith(e, visitor)){ exc_continue = false; break; } } if(exc_continue) visitor->visit(syntax_elm); return exc_continue; }break; default: break; } return false; }