diff --git a/libSyntax/libsyntax.h b/libSyntax/libsyntax.h index 094a026..1b97494 100644 --- a/libSyntax/libsyntax.h +++ b/libSyntax/libsyntax.h @@ -178,7 +178,7 @@ namespace lib_syntax { /** * @brief token匹配 */ - template XProc = nullptr> + template XProc = nullptr> requires std::derived_from class TokenMatch : public IBasicRule, public std::enable_shared_from_this> { private: diff --git a/libSyntax/syntax_novel.cpp b/libSyntax/syntax_novel.cpp index 37123a9..c7c7610 100644 --- a/libSyntax/syntax_novel.cpp +++ b/libSyntax/syntax_novel.cpp @@ -253,7 +253,7 @@ class MM : public lib_syntax::IBasicRule { #include "syntax_templets.h" std::shared_ptr NovalSyntax::getSyntaxTree() { - lib_composit::TypeList vv; + lib_composit::__types_list vv; return std::make_shared(); } diff --git a/libSyntax/syntax_templets.h b/libSyntax/syntax_templets.h index ad7ece2..b27bc33 100644 --- a/libSyntax/syntax_templets.h +++ b/libSyntax/syntax_templets.h @@ -4,9 +4,9 @@ #include namespace lib_composit { - template class TypeList; + template class __types_list; - template<> class TypeList<> { + template<> class __types_list<> { public: static QList> getRules() { return QList>(); @@ -15,25 +15,25 @@ namespace lib_composit { template requires std::derived_from - class TypeList : public TypeList { + class __types_list : public __types_list { public: static QList> getRules() { - auto list = TypeList::getRules(); + auto list = __types_list::getRules(); list.prepend(std::make_shared()); return list; } }; template - class AnyR : public lib_syntax::Any, public TypeList { + class AnyR : public lib_syntax::Any, public __types_list { public: - AnyR() : Any(TypeList::getRules()){ } + AnyR() : Any(__types_list::getRules()){ } }; template - class SeqsR : public lib_syntax::Seqs, public TypeList { + class SeqsR : public lib_syntax::Seqs, public __types_list { public: - SeqsR() : Seqs(TypeList::getRules()){ } + SeqsR() : Seqs(__types_list::getRules()){ } }; template @@ -42,7 +42,7 @@ namespace lib_composit { ReptR() : Rept(std::make_shared(), min, max){ } }; - template xproc = nullptr> + template xproc = nullptr> requires std::derived_from && std::derived_from class TokenR : public lib_syntax::TokenMatch { public: diff --git a/libSyntax/tokens_impl.h b/libSyntax/tokens_impl.h index 691787d..c283197 100644 --- a/libSyntax/tokens_impl.h +++ b/libSyntax/tokens_impl.h @@ -5,8 +5,8 @@ namespace lib_token { - template - using TokenProcs = void(*)(std::shared_ptr expr, std::shared_ptr t); + template requires std::derived_from + using TokenProc = void(*)(std::shared_ptr expr, std::shared_ptr t); // 基础token实现 =================================================== @@ -48,7 +48,7 @@ namespace lib_token { /** * @brief 动作Token */ - template proc> + template p> requires std::derived_from class ActionToken : public IActionToken { private: std::shared_ptr _bind_content; @@ -60,7 +60,7 @@ namespace lib_token { virtual std::shared_ptr makeSure(std::shared_ptr expr) { auto expr_inst = std::dynamic_pointer_cast(expr); - proc(expr_inst, shared_from_this()); + p(expr_inst, shared_from_this()); return expr; } @@ -91,8 +91,7 @@ namespace lib_token { /** * @brief 表达式起始token */ - template - requires std::derived_from + template requires std::derived_from class ExprBeginToken : public IActionToken { private: std::shared_ptr _prev_token = nullptr; @@ -149,8 +148,7 @@ namespace lib_token { /** * @brief 表达式终止token */ - template - requires std::derived_from + template requires std::derived_from class ExprEndToken : public IActionToken { private: std::shared_ptr _prev_token = nullptr;