mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 11:55:30 +00:00
Fix #118
This commit is contained in:
parent
8e890ced7f
commit
aefeb3ae35
@ -26,7 +26,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
|||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
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")
|
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")
|
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)
|
elseif(MSVC)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /wd4503 /wd4512 /utf-8")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /wd4503 /wd4512 /utf-8")
|
||||||
endif()
|
endif()
|
||||||
|
19
peglib.h
19
peglib.h
@ -1706,6 +1706,7 @@ struct Ope::Visitor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct IsReference : public Ope::Visitor {
|
struct IsReference : public Ope::Visitor {
|
||||||
|
using Ope::Visitor::visit;
|
||||||
void visit(Reference & /*ope*/) override { is_reference = true; }
|
void visit(Reference & /*ope*/) override { is_reference = true; }
|
||||||
bool is_reference = false;
|
bool is_reference = false;
|
||||||
};
|
};
|
||||||
@ -1741,6 +1742,8 @@ struct TraceOpeName : public Ope::Visitor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct AssignIDToDefinition : public Ope::Visitor {
|
struct AssignIDToDefinition : public Ope::Visitor {
|
||||||
|
using Ope::Visitor::visit;
|
||||||
|
|
||||||
void visit(Sequence &ope) override {
|
void visit(Sequence &ope) override {
|
||||||
for (auto op : ope.opes_) {
|
for (auto op : ope.opes_) {
|
||||||
op->accept(*this);
|
op->accept(*this);
|
||||||
@ -1768,6 +1771,8 @@ struct AssignIDToDefinition : public Ope::Visitor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct IsLiteralToken : public Ope::Visitor {
|
struct IsLiteralToken : public Ope::Visitor {
|
||||||
|
using Ope::Visitor::visit;
|
||||||
|
|
||||||
void visit(PrioritizedChoice &ope) override {
|
void visit(PrioritizedChoice &ope) override {
|
||||||
for (auto op : ope.opes_) {
|
for (auto op : ope.opes_) {
|
||||||
if (!IsLiteralToken::check(*op)) { return; }
|
if (!IsLiteralToken::check(*op)) { return; }
|
||||||
@ -1789,6 +1794,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct TokenChecker : public Ope::Visitor {
|
struct TokenChecker : public Ope::Visitor {
|
||||||
|
using Ope::Visitor::visit;
|
||||||
|
|
||||||
void visit(Sequence &ope) override {
|
void visit(Sequence &ope) override {
|
||||||
for (auto op : ope.opes_) {
|
for (auto op : ope.opes_) {
|
||||||
op->accept(*this);
|
op->accept(*this);
|
||||||
@ -1883,6 +1890,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct HasEmptyElement : public Ope::Visitor {
|
struct HasEmptyElement : public Ope::Visitor {
|
||||||
|
using Ope::Visitor::visit;
|
||||||
|
|
||||||
HasEmptyElement(std::list<std::pair<const char *, std::string>> &refs)
|
HasEmptyElement(std::list<std::pair<const char *, std::string>> &refs)
|
||||||
: refs_(refs) {}
|
: refs_(refs) {}
|
||||||
|
|
||||||
@ -1945,6 +1954,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct DetectInfiniteLoop : public Ope::Visitor {
|
struct DetectInfiniteLoop : public Ope::Visitor {
|
||||||
|
using Ope::Visitor::visit;
|
||||||
|
|
||||||
DetectInfiniteLoop(const char *s, const std::string &name) {
|
DetectInfiniteLoop(const char *s, const std::string &name) {
|
||||||
refs_.emplace_back(s, name);
|
refs_.emplace_back(s, name);
|
||||||
}
|
}
|
||||||
@ -1995,6 +2006,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ReferenceChecker : public Ope::Visitor {
|
struct ReferenceChecker : public Ope::Visitor {
|
||||||
|
using Ope::Visitor::visit;
|
||||||
|
|
||||||
ReferenceChecker(const Grammar &grammar,
|
ReferenceChecker(const Grammar &grammar,
|
||||||
const std::vector<std::string> ¶ms)
|
const std::vector<std::string> ¶ms)
|
||||||
: grammar_(grammar), params_(params) {}
|
: grammar_(grammar), params_(params) {}
|
||||||
@ -2031,6 +2044,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct LinkReferences : public Ope::Visitor {
|
struct LinkReferences : public Ope::Visitor {
|
||||||
|
using Ope::Visitor::visit;
|
||||||
|
|
||||||
LinkReferences(Grammar &grammar, const std::vector<std::string> ¶ms)
|
LinkReferences(Grammar &grammar, const std::vector<std::string> ¶ms)
|
||||||
: grammar_(grammar), params_(params) {}
|
: grammar_(grammar), params_(params) {}
|
||||||
|
|
||||||
@ -2063,6 +2078,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct FindReference : public Ope::Visitor {
|
struct FindReference : public Ope::Visitor {
|
||||||
|
using Ope::Visitor::visit;
|
||||||
|
|
||||||
FindReference(const std::vector<std::shared_ptr<Ope>> &args,
|
FindReference(const std::vector<std::shared_ptr<Ope>> &args,
|
||||||
const std::vector<std::string> ¶ms)
|
const std::vector<std::string> ¶ms)
|
||||||
: args_(args), params_(params) {}
|
: args_(args), params_(params) {}
|
||||||
@ -2140,6 +2157,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct IsPrioritizedChoice : public Ope::Visitor {
|
struct IsPrioritizedChoice : public Ope::Visitor {
|
||||||
|
using Ope::Visitor::visit;
|
||||||
|
|
||||||
void visit(PrioritizedChoice & /*ope*/) override { result_ = true; }
|
void visit(PrioritizedChoice & /*ope*/) override { result_ = true; }
|
||||||
|
|
||||||
static bool check(Ope &ope) {
|
static bool check(Ope &ope) {
|
||||||
|
Loading…
Reference in New Issue
Block a user