From 26877dc456c1ba5c3d5413cc70868770b0119159 Mon Sep 17 00:00:00 2001 From: yhirose Date: Thu, 2 Jun 2022 16:33:07 -0400 Subject: [PATCH] Refactoring --- peglib.h | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/peglib.h b/peglib.h index f344202..c57a738 100644 --- a/peglib.h +++ b/peglib.h @@ -1745,7 +1745,7 @@ struct Ope::Visitor { virtual void visit(Cut &) {} }; -template struct OpeType : public Ope::Visitor { +template struct IsOpeType : public Ope::Visitor { void visit(Sequence &) override { ret_ = std::is_same::value; } void visit(PrioritizedChoice &) override { ret_ = std::is_same::value; @@ -1799,7 +1799,7 @@ template struct OpeType : public Ope::Visitor { void visit(Cut &) override { ret_ = std::is_same::value; } static bool check(const Ope &ope) { - OpeType vis; + IsOpeType vis; const_cast(ope).accept(vis); return vis.ret_; } @@ -2274,19 +2274,6 @@ private: const std::vector ¶ms_; }; -struct IsPrioritizedChoice : public Ope::Visitor { - void visit(PrioritizedChoice &) override { result_ = true; } - - static bool check(Ope &ope) { - IsPrioritizedChoice vis; - ope.accept(vis); - return vis.result_; - } - -private: - bool result_ = false; -}; - /* * Keywords */ @@ -2610,7 +2597,7 @@ inline void Context::trace_leave(const Ope &ope, const char *a_s, size_t n, inline bool Context::is_traceable(const Ope &ope) const { if (tracer_enter && tracer_leave) { if (ignore_trace_state) { return false; } - return !OpeType::check(ope); + return !IsOpeType::check(ope); } return false; } @@ -2707,7 +2694,7 @@ inline size_t Holder::parse_core(const char *s, size_t n, SemanticValues &vs, chldsv.sv_ = std::string_view(s, len); chldsv.name_ = outer_->name; - if (!IsPrioritizedChoice::check(*ope_)) { + if (!IsOpeType::check(*ope_)) { chldsv.choice_count_ = 0; chldsv.choice_ = 0; }