mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 20:05:31 +00:00
Renamed 'before/after' to 'enter/exit'.
This commit is contained in:
parent
bbd7699c81
commit
a9cea16325
12
peglib.h
12
peglib.h
@ -1301,8 +1301,8 @@ public:
|
||||
std::string name;
|
||||
size_t id;
|
||||
Action action;
|
||||
std::function<void (any& dt)> before;
|
||||
std::function<void (any& dt)> after;
|
||||
std::function<void (any& dt)> enter;
|
||||
std::function<void (any& dt)> exit;
|
||||
std::function<std::string ()> error_message;
|
||||
bool ignoreSemanticValue;
|
||||
std::shared_ptr<Ope> whiteSpaceOpe;
|
||||
@ -1373,8 +1373,8 @@ inline size_t Holder::parse(const char* s, size_t n, SemanticValues& sv, Context
|
||||
|
||||
auto& chldsv = c.push();
|
||||
|
||||
if (outer_->before) {
|
||||
outer_->before(dt);
|
||||
if (outer_->enter) {
|
||||
outer_->enter(dt);
|
||||
}
|
||||
|
||||
auto ope = ope_;
|
||||
@ -1415,8 +1415,8 @@ inline size_t Holder::parse(const char* s, size_t n, SemanticValues& sv, Context
|
||||
}
|
||||
}
|
||||
|
||||
if (outer_->after) {
|
||||
outer_->after(dt);
|
||||
if (outer_->exit) {
|
||||
outer_->exit(dt);
|
||||
}
|
||||
|
||||
c.pop();
|
||||
|
@ -213,7 +213,7 @@ TEST_CASE("Lambda action test", "[general]")
|
||||
REQUIRE(ss == "hello");
|
||||
}
|
||||
|
||||
TEST_CASE("before/after handlers test", "[general]")
|
||||
TEST_CASE("enter/exit handlers test", "[general]")
|
||||
{
|
||||
parser parser(R"(
|
||||
START <- LTOKEN '=' RTOKEN
|
||||
@ -222,11 +222,11 @@ TEST_CASE("before/after handlers test", "[general]")
|
||||
TOKEN <- [A-Za-z]+
|
||||
)");
|
||||
|
||||
parser["LTOKEN"].before = [&](any& dt) {
|
||||
parser["LTOKEN"].enter = [&](any& dt) {
|
||||
auto& require_upper_case = *dt.get<bool*>();
|
||||
require_upper_case = false;
|
||||
};
|
||||
parser["LTOKEN"].after = [&](any& dt) {
|
||||
parser["LTOKEN"].exit = [&](any& dt) {
|
||||
auto& require_upper_case = *dt.get<bool*>();
|
||||
require_upper_case = true;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user