2024-03-17 07:58:28 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "libsyntax_global.h"
|
2025-02-02 12:54:32 +00:00
|
|
|
|
#include "libtokens.h"
|
2024-03-17 07:58:28 +00:00
|
|
|
|
#include <memory>
|
2025-02-02 12:54:32 +00:00
|
|
|
|
#include <QtCore/QList>
|
2024-03-17 07:58:28 +00:00
|
|
|
|
#include <tuple>
|
|
|
|
|
#include <functional>
|
|
|
|
|
namespace ast_basic {
|
2024-07-12 21:52:32 +00:00
|
|
|
|
class IExprInst;
|
2024-07-28 06:41:54 +00:00
|
|
|
|
class ExprElement;
|
2024-03-17 07:58:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace lib_syntax {
|
2024-06-18 03:54:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>쳣
|
|
|
|
|
*/
|
2024-06-20 13:36:46 +00:00
|
|
|
|
class LIBSYNTAX_EXPORT SyntaxException {
|
2024-06-18 03:54:36 +00:00
|
|
|
|
private:
|
|
|
|
|
QString msg_store;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
SyntaxException(const QString& message);
|
|
|
|
|
virtual ~SyntaxException() = default;
|
|
|
|
|
|
|
|
|
|
virtual QString message() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFB7A8><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD> ===================================================================================================
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľӿ<EFBFBD>
|
|
|
|
|
*/
|
2025-02-04 14:26:34 +00:00
|
|
|
|
class MatchCursor {
|
|
|
|
|
private:
|
|
|
|
|
QList<std::shared_ptr<ast_basic::IExprInst>> _expr_through; //<2F><><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
QList<QString> _total_errors; // <20><><EFBFBD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
QList<QString> _exprs_errors; // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
std::shared_ptr<lib_token::IToken> _current_token = nullptr; // <20><>ǰToken
|
|
|
|
|
std::shared_ptr<lib_words::IPrimitiveWord> _remains_word = nullptr; // ʣ<><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-07-12 04:53:43 +00:00
|
|
|
|
|
2025-02-04 14:26:34 +00:00
|
|
|
|
public:
|
|
|
|
|
MatchCursor();
|
|
|
|
|
MatchCursor(const MatchCursor& other);
|
|
|
|
|
virtual ~MatchCursor() = default;
|
|
|
|
|
|
|
|
|
|
virtual void enterExprs(std::shared_ptr<ast_basic::IExprInst> ins);
|
|
|
|
|
virtual std::shared_ptr<ast_basic::IExprInst> currentExprs() const;
|
|
|
|
|
virtual void logExprsError(const QString& msg);
|
|
|
|
|
virtual void quitExprs();
|
|
|
|
|
|
|
|
|
|
virtual bool mustStop() const;
|
|
|
|
|
virtual int exprsErrorCount() const;
|
|
|
|
|
virtual int totalErrorCount() const;
|
|
|
|
|
virtual QList<QString> totalErrors() const;
|
|
|
|
|
|
|
|
|
|
virtual void setCurrent(std::shared_ptr<lib_token::IToken> t, std::shared_ptr<lib_words::IPrimitiveWord> remains);
|
|
|
|
|
virtual std::shared_ptr<lib_token::IToken> currentToken() const;
|
|
|
|
|
virtual std::shared_ptr<lib_words::IPrimitiveWord> currentWords() const;
|
2024-06-18 03:54:36 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>
|
|
|
|
|
*/
|
2024-07-12 21:52:32 +00:00
|
|
|
|
class IBasicRule {
|
2024-06-18 03:54:36 +00:00
|
|
|
|
public:
|
|
|
|
|
/**
|
2025-02-04 14:26:34 +00:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵʷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*
|
|
|
|
|
* \return <EFBFBD>ʷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-06-18 03:54:36 +00:00
|
|
|
|
*/
|
2025-02-04 14:26:34 +00:00
|
|
|
|
virtual QString present() const = 0;
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-06-18 14:59:41 +00:00
|
|
|
|
* @param rt_inst <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param head <EFBFBD>б<EFBFBD>ͷ
|
|
|
|
|
* @return <EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><EFBFBD><EFBFBD><ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>ͷ,ƥ<EFBFBD>䳤<EFBFBD><EFBFBD>>
|
2024-06-18 03:54:36 +00:00
|
|
|
|
*/
|
2025-02-04 14:26:34 +00:00
|
|
|
|
virtual QList<std::shared_ptr<MatchCursor>> parse(std::shared_ptr<const MatchCursor> cursor) const = 0;
|
|
|
|
|
};
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
2025-02-04 14:26:34 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
class ICompositRule : public IBasicRule {
|
|
|
|
|
public:
|
2024-06-18 03:54:36 +00:00
|
|
|
|
/**
|
2025-02-04 14:26:34 +00:00
|
|
|
|
* @brief <EFBFBD>ӹ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return
|
2024-06-18 03:54:36 +00:00
|
|
|
|
*/
|
2025-02-04 14:26:34 +00:00
|
|
|
|
virtual QList<std::shared_ptr<const IBasicRule>> children() const = 0;
|
2024-06-18 03:54:36 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-07-28 08:37:31 +00:00
|
|
|
|
template<typename elem>
|
|
|
|
|
using token_proc = void(*)(std::shared_ptr<elem> expr_inst, std::shared_ptr<const lib_token::IToken> token);
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief tokenƥ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2024-07-28 08:37:31 +00:00
|
|
|
|
template<typename elem, token_proc<elem> xproc = nullptr>
|
|
|
|
|
class TokenMatch : public IBasicRule, public std::enable_shared_from_this<TokenMatch<elem, xproc>> {
|
2024-06-18 03:54:36 +00:00
|
|
|
|
private:
|
2025-02-04 14:26:34 +00:00
|
|
|
|
std::shared_ptr<const lib_token::ITokenProcess> _define_peers;
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
|
|
|
|
public:
|
2025-02-04 14:26:34 +00:00
|
|
|
|
TokenMatch(std::shared_ptr<const lib_token::ITokenProcess> define) : _define_peers(define) { }
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
2024-07-12 21:52:32 +00:00
|
|
|
|
// IBasicRule interface
|
2024-06-18 03:54:36 +00:00
|
|
|
|
public:
|
2025-02-04 14:26:34 +00:00
|
|
|
|
virtual QList<std::shared_ptr<MatchCursor>> parse(std::shared_ptr<const MatchCursor> current) const override {
|
|
|
|
|
auto w_this = current->currentWords();
|
2024-07-28 08:37:31 +00:00
|
|
|
|
|
2025-02-04 14:26:34 +00:00
|
|
|
|
auto match_result = _define_peers->analysis(w_this);
|
2024-07-28 08:37:31 +00:00
|
|
|
|
if (std::get<0>(match_result)) {
|
2025-02-04 14:26:34 +00:00
|
|
|
|
auto current_inst = current->currentExprs();
|
2024-07-28 08:37:31 +00:00
|
|
|
|
current_inst->addToken(std::get<0>(match_result));
|
|
|
|
|
if (xproc) {
|
|
|
|
|
xproc(std::dynamic_pointer_cast<elem>(current_inst), std::get<0>(match_result));
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-04 14:26:34 +00:00
|
|
|
|
auto remains = w_this->nextWord();
|
2024-07-28 08:37:31 +00:00
|
|
|
|
if (std::get<1>(match_result)) {
|
2025-02-04 14:26:34 +00:00
|
|
|
|
remains = std::make_shared<lib_words::WordImpl>(std::get<1>(match_result), remains);
|
2024-07-28 08:37:31 +00:00
|
|
|
|
}
|
2025-02-04 14:26:34 +00:00
|
|
|
|
|
|
|
|
|
auto clone_ins = std::make_shared<MatchCursor>(current);
|
|
|
|
|
auto chain = std::make_shared<lib_token::TokenChain>(std::get<0>(match_result), current->currentToken());
|
|
|
|
|
clone_ins->setCurrent(std::get<0>(chain, remains));
|
|
|
|
|
return QList<std::shared_ptr<MatchCursor>>() << clone_ins;
|
2024-07-28 08:37:31 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
2025-02-04 14:26:34 +00:00
|
|
|
|
QList<std::shared_ptr<MatchCursor>> retvals;
|
|
|
|
|
// <20><>һ<EFBFBD><D2BB>
|
|
|
|
|
auto short_one = std::make_shared<MatchCursor>(current);
|
|
|
|
|
short_one->logExprsError(QString(u8"Syntax[0x00001]<5D>ƥ<EFB7A8><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȱʧ\"%1\"<row:%2,col:%3,file:%4>")
|
|
|
|
|
.arg(this->_define_peers->reviseWords())
|
|
|
|
|
.arg(w_this->row()).arg(w_this->column()).arg(w_this->file()));
|
|
|
|
|
retvals << short_one;
|
|
|
|
|
|
|
|
|
|
// <20><>һ<EFBFBD><D2BB>
|
|
|
|
|
auto error_one = std::make_shared<MatchCursor>(current);
|
|
|
|
|
error_one->logExprsError(QString(u8"Syntax[0x00001]<5D>ƥ<EFB7A8><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\"%1\"<row:%2,col:%3,file:%4>")
|
|
|
|
|
.arg(w_this->content()).arg(w_this->row()).arg(w_this->column()).arg(w_this->file()));
|
|
|
|
|
|
|
|
|
|
auto tkins = std::make_shared<lib_token::TokenContent>(
|
|
|
|
|
w_this->row(), w_this->column(), w_this->position(),
|
|
|
|
|
w_this->content(), w_this->file(), this->_define_peers);
|
|
|
|
|
auto tkchain = std::make_shared<lib_token::TokenChain>(tkins, error_one->currentToken());
|
|
|
|
|
error_one->setCurrent(tkchain, w_this->nextWord());
|
|
|
|
|
retvals << error_one;
|
|
|
|
|
|
|
|
|
|
// <20><>һ<EFBFBD><D2BB>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-28 08:37:31 +00:00
|
|
|
|
rt_inst->appendParseErrors(rt_inst->currentFile(), head->position(),
|
|
|
|
|
QString(u8"Syntax[0x00001]<5D>ƥ<EFB7A8><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6>\"%1\"<row:%2,col:%3>(Ӧ<><D3A6>Ϊ<EFBFBD><CEAA>%4)\n\tĿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%5<><35>\n")
|
2025-02-04 14:26:34 +00:00
|
|
|
|
.arg(head->content()).arg(head->row()).arg(head->column()).arg(this->_define_peers->reviseWords())
|
|
|
|
|
.arg(rt_inst->currentExprRule()->present()));
|
2024-07-28 08:37:31 +00:00
|
|
|
|
return std::make_tuple(IBasicRule::MatchResult::Part, head);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-02-04 14:26:34 +00:00
|
|
|
|
virtual QString present() const override {
|
|
|
|
|
return QString(u8"%1").arg(this->_define_peers->reviseWords());
|
2024-07-28 08:37:31 +00:00
|
|
|
|
}
|
2024-06-18 03:54:36 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2024-07-12 21:52:32 +00:00
|
|
|
|
class LIBSYNTAX_EXPORT Any : public IBasicRule, public std::enable_shared_from_this<Any> {
|
2024-06-18 03:54:36 +00:00
|
|
|
|
private:
|
2024-07-12 21:52:32 +00:00
|
|
|
|
QList<std::shared_ptr<const IBasicRule>> mbrs_store;
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
2025-02-02 12:54:32 +00:00
|
|
|
|
std::tuple<MatchResult, uint, std::shared_ptr<const IBasicRule>, std::shared_ptr<const lib_words::IWordBase>> rule_select(std::shared_ptr<const lib_words::IWordBase> head) const;
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
|
|
|
|
public:
|
2024-07-12 21:52:32 +00:00
|
|
|
|
Any(const QList<std::shared_ptr<const IBasicRule>> mbrs);
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
2024-07-12 21:52:32 +00:00
|
|
|
|
// IBasicRule interface
|
2024-06-18 03:54:36 +00:00
|
|
|
|
public:
|
2024-07-12 21:52:32 +00:00
|
|
|
|
virtual QList<std::shared_ptr<const IBasicRule>> children() const override;
|
2025-02-02 12:54:32 +00:00
|
|
|
|
virtual std::tuple<IBasicRule::MatchResult, std::shared_ptr<const lib_words::IWordBase>>
|
|
|
|
|
parse(std::shared_ptr<IContext> rt_inst, std::shared_ptr<const lib_words::IWordBase> head) const override;
|
2025-02-04 14:26:34 +00:00
|
|
|
|
virtual QString present() const override;
|
2024-06-18 03:54:36 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2024-07-12 21:52:32 +00:00
|
|
|
|
class LIBSYNTAX_EXPORT Seqs : public IBasicRule, public std::enable_shared_from_this<Seqs> {
|
2024-06-18 03:54:36 +00:00
|
|
|
|
private:
|
2024-07-12 21:52:32 +00:00
|
|
|
|
QList<std::shared_ptr<const IBasicRule>> mbrs_store;
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
|
|
|
|
public:
|
2024-07-12 21:52:32 +00:00
|
|
|
|
Seqs(const QList<std::shared_ptr<const IBasicRule>> mbrs);
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
2024-07-12 21:52:32 +00:00
|
|
|
|
// IBasicRule interface
|
2024-06-18 03:54:36 +00:00
|
|
|
|
public:
|
2024-07-12 21:52:32 +00:00
|
|
|
|
virtual QList<std::shared_ptr<const IBasicRule>> children() const override;
|
2025-02-02 12:54:32 +00:00
|
|
|
|
virtual std::tuple<IBasicRule::MatchResult, std::shared_ptr<const lib_words::IWordBase>>
|
|
|
|
|
parse(std::shared_ptr<IContext> rt_inst, std::shared_ptr<const lib_words::IWordBase> head) const override;
|
2025-02-04 14:26:34 +00:00
|
|
|
|
virtual QString present() const override;
|
2024-06-18 03:54:36 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>ƥ<EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2024-07-12 21:52:32 +00:00
|
|
|
|
class LIBSYNTAX_EXPORT Rept : public IBasicRule, public std::enable_shared_from_this<Rept> {
|
2024-06-18 03:54:36 +00:00
|
|
|
|
private:
|
2024-07-12 21:52:32 +00:00
|
|
|
|
std::shared_ptr<const IBasicRule> rule_peer;
|
2024-06-18 03:54:36 +00:00
|
|
|
|
int min_match, max_match;
|
|
|
|
|
|
|
|
|
|
public:
|
2024-07-12 21:52:32 +00:00
|
|
|
|
Rept(std::shared_ptr<const IBasicRule> rule, int min, int max);
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
2024-07-12 21:52:32 +00:00
|
|
|
|
// IBasicRule interface
|
2024-06-18 03:54:36 +00:00
|
|
|
|
public:
|
2024-07-12 21:52:32 +00:00
|
|
|
|
virtual QList<std::shared_ptr<const IBasicRule>> children() const override;
|
2025-02-02 12:54:32 +00:00
|
|
|
|
virtual std::tuple<IBasicRule::MatchResult, std::shared_ptr<const lib_words::IWordBase>>
|
|
|
|
|
parse(std::shared_ptr<IContext> rt_inst, std::shared_ptr<const lib_words::IWordBase> head) const override;
|
2025-02-04 14:26:34 +00:00
|
|
|
|
virtual QString present() const override;
|
2024-06-18 03:54:36 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ʵ<EFB7A8><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ===================================================================================================
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
2024-07-12 21:52:32 +00:00
|
|
|
|
class LIBSYNTAX_EXPORT ExprRule : public lib_syntax::IBasicRule, public std::enable_shared_from_this<ExprRule> {
|
2024-06-18 03:54:36 +00:00
|
|
|
|
public:
|
2024-06-20 13:36:46 +00:00
|
|
|
|
typedef QList<std::shared_ptr<const lib_token::IToken>> TokenSeqs;
|
2024-07-12 04:53:43 +00:00
|
|
|
|
ExprRule(const QString& rule_name, int expr_mark);
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
2024-07-12 21:52:32 +00:00
|
|
|
|
virtual std::shared_ptr<const ExprRule> reloadRule(std::shared_ptr<const IBasicRule> rule);
|
2024-06-18 03:54:36 +00:00
|
|
|
|
virtual QString name() const;
|
|
|
|
|
virtual int typeMark() const;
|
|
|
|
|
|
2024-07-12 21:52:32 +00:00
|
|
|
|
virtual std::shared_ptr<ast_basic::IExprInst> newEmptyInstance() const = 0;
|
2024-07-12 04:53:43 +00:00
|
|
|
|
virtual std::shared_ptr<ExprRule> makeCopy() const = 0;
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
2024-07-12 21:52:32 +00:00
|
|
|
|
// IBasicRule interface
|
2024-06-18 03:54:36 +00:00
|
|
|
|
public:
|
2024-07-12 21:52:32 +00:00
|
|
|
|
virtual QList<std::shared_ptr<const lib_syntax::IBasicRule>> children() const override;
|
2025-02-02 12:54:32 +00:00
|
|
|
|
virtual std::tuple<IBasicRule::MatchResult, std::shared_ptr<const lib_words::IWordBase>>
|
|
|
|
|
parse(std::shared_ptr<IContext> rt_inst, std::shared_ptr<const lib_words::IWordBase> head) const override;
|
2025-02-04 14:26:34 +00:00
|
|
|
|
virtual QString present() const override;
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
2024-07-13 05:17:56 +00:00
|
|
|
|
protected:
|
2024-07-12 21:52:32 +00:00
|
|
|
|
std::shared_ptr<const lib_syntax::IBasicRule> child_store;
|
2024-07-13 05:17:56 +00:00
|
|
|
|
|
|
|
|
|
private:
|
2024-06-18 03:54:36 +00:00
|
|
|
|
QString name_store;
|
|
|
|
|
int mark_store;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD>Ԫ<EFBFBD>ؽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|
|
|
|
*/
|
|
|
|
|
template<class ExprType>
|
2024-07-12 04:53:43 +00:00
|
|
|
|
class ElementRule : public ExprRule {
|
2024-06-18 03:54:36 +00:00
|
|
|
|
public:
|
|
|
|
|
ElementRule(const QString& rule_name, int expr_mark)
|
2025-02-04 14:26:34 +00:00
|
|
|
|
:ExprRule(rule_name, expr_mark) { }
|
2024-06-18 03:54:36 +00:00
|
|
|
|
|
2024-07-12 21:52:32 +00:00
|
|
|
|
virtual std::shared_ptr<ast_basic::IExprInst> newEmptyInstance() const {
|
|
|
|
|
return std::dynamic_pointer_cast<ast_basic::IExprInst>(
|
2024-06-18 03:54:36 +00:00
|
|
|
|
std::make_shared<ExprType>(this->shared_from_this()));
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 04:53:43 +00:00
|
|
|
|
virtual std::shared_ptr<ExprRule> makeCopy() const {
|
2024-06-18 03:54:36 +00:00
|
|
|
|
return std::make_shared<ElementRule<ExprType>>(name(), typeMark());
|
|
|
|
|
}
|
|
|
|
|
};
|
2024-03-17 07:58:28 +00:00
|
|
|
|
} // namespace lib_syntax
|