46 lines
1015 B
C++
46 lines
1015 B
C++
#pragma once
|
|
|
|
#include "libparse_global.h"
|
|
#include <ast_basic.h>
|
|
#include <ast_gen.h>
|
|
|
|
namespace lib_parse {
|
|
/**
|
|
* @brief 检查机制异常
|
|
*/
|
|
class LIBPARSE_EXPORT CheckException {
|
|
private:
|
|
QString msg_store;
|
|
|
|
public:
|
|
CheckException(const QString& msg);
|
|
virtual ~CheckException() = default;
|
|
|
|
virtual QString message() const;
|
|
};
|
|
|
|
|
|
/**
|
|
* @brief 校验机制提供类型
|
|
*/
|
|
class CheckProvider {
|
|
public:
|
|
virtual QString name() const = 0;
|
|
virtual void validCheck(std::shared_ptr<const ast_gen::ElementAccess> root) const = 0;
|
|
};
|
|
|
|
|
|
/**
|
|
* @brief 解析器对外接口
|
|
*/
|
|
class LIBPARSE_EXPORT Analyzer {
|
|
private:
|
|
QList<std::shared_ptr<const CheckProvider>> check_providers;
|
|
|
|
public:
|
|
Analyzer(const QList<std::shared_ptr<const CheckProvider>>& providers);
|
|
|
|
std::shared_ptr<const ast_gen::ElementAccess> validCheckWith(std::shared_ptr<const ast_gen::ElementAccess> root) const;
|
|
};
|
|
}
|