Skip to content

Commit

Permalink
Fix #118
Browse files Browse the repository at this point in the history
  • Loading branch information
yhirose committed Jun 20, 2020
1 parent 8e890ce commit aefeb3a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything -Wno-c++98-compat -Wno-padded -Wno-weak-vtables -Wno-exit-time-destructors -Wno-c++2a-compat -Wno-switch-enum -Wno-c++98-compat-pedantic")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Wextra -Woverloaded-virtual")
elseif(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /wd4503 /wd4512 /utf-8")
endif()
Expand Down
19 changes: 19 additions & 0 deletions peglib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,7 @@ struct Ope::Visitor {
};

struct IsReference : public Ope::Visitor {
using Ope::Visitor::visit;
void visit(Reference & /*ope*/) override { is_reference = true; }
bool is_reference = false;
};
Expand Down Expand Up @@ -1741,6 +1742,8 @@ struct TraceOpeName : public Ope::Visitor {
};

struct AssignIDToDefinition : public Ope::Visitor {
using Ope::Visitor::visit;

void visit(Sequence &ope) override {
for (auto op : ope.opes_) {
op->accept(*this);
Expand Down Expand Up @@ -1768,6 +1771,8 @@ struct AssignIDToDefinition : public Ope::Visitor {
};

struct IsLiteralToken : public Ope::Visitor {
using Ope::Visitor::visit;

void visit(PrioritizedChoice &ope) override {
for (auto op : ope.opes_) {
if (!IsLiteralToken::check(*op)) { return; }
Expand All @@ -1789,6 +1794,8 @@ struct IsLiteralToken : public Ope::Visitor {
};

struct TokenChecker : public Ope::Visitor {
using Ope::Visitor::visit;

void visit(Sequence &ope) override {
for (auto op : ope.opes_) {
op->accept(*this);
Expand Down Expand Up @@ -1883,6 +1890,8 @@ struct DetectLeftRecursion : public Ope::Visitor {
};

struct HasEmptyElement : public Ope::Visitor {
using Ope::Visitor::visit;

HasEmptyElement(std::list<std::pair<const char *, std::string>> &refs)
: refs_(refs) {}

Expand Down Expand Up @@ -1945,6 +1954,8 @@ struct HasEmptyElement : public Ope::Visitor {
};

struct DetectInfiniteLoop : public Ope::Visitor {
using Ope::Visitor::visit;

DetectInfiniteLoop(const char *s, const std::string &name) {
refs_.emplace_back(s, name);
}
Expand Down Expand Up @@ -1995,6 +2006,8 @@ struct DetectInfiniteLoop : public Ope::Visitor {
};

struct ReferenceChecker : public Ope::Visitor {
using Ope::Visitor::visit;

ReferenceChecker(const Grammar &grammar,
const std::vector<std::string> &params)
: grammar_(grammar), params_(params) {}
Expand Down Expand Up @@ -2031,6 +2044,8 @@ struct ReferenceChecker : public Ope::Visitor {
};

struct LinkReferences : public Ope::Visitor {
using Ope::Visitor::visit;

LinkReferences(Grammar &grammar, const std::vector<std::string> &params)
: grammar_(grammar), params_(params) {}

Expand Down Expand Up @@ -2063,6 +2078,8 @@ struct LinkReferences : public Ope::Visitor {
};

struct FindReference : public Ope::Visitor {
using Ope::Visitor::visit;

FindReference(const std::vector<std::shared_ptr<Ope>> &args,
const std::vector<std::string> &params)
: args_(args), params_(params) {}
Expand Down Expand Up @@ -2140,6 +2157,8 @@ struct FindReference : public Ope::Visitor {
};

struct IsPrioritizedChoice : public Ope::Visitor {
using Ope::Visitor::visit;

void visit(PrioritizedChoice & /*ope*/) override { result_ = true; }

static bool check(Ope &ope) {
Expand Down

0 comments on commit aefeb3a

Please sign in to comment.