mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 20:05:31 +00:00
extended parameters for enter and leave callbacks
This commit is contained in:
parent
99380c2d72
commit
fc03a32d1f
30
peglib.h
30
peglib.h
@ -1740,19 +1740,19 @@ public:
|
|||||||
return is_token_;
|
return is_token_;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
size_t id;
|
size_t id;
|
||||||
Action action;
|
Action action;
|
||||||
std::function<void (any& dt)> enter;
|
std::function<void (const char* s, size_t n, any& dt)> enter;
|
||||||
std::function<void (any& dt)> leave;
|
std::function<void (const char* s, size_t n, size_t matchlen, any& value, any& dt)> leave;
|
||||||
std::function<std::string ()> error_message;
|
std::function<std::string ()> error_message;
|
||||||
bool ignoreSemanticValue;
|
bool ignoreSemanticValue;
|
||||||
std::shared_ptr<Ope> whitespaceOpe;
|
std::shared_ptr<Ope> whitespaceOpe;
|
||||||
std::shared_ptr<Ope> wordOpe;
|
std::shared_ptr<Ope> wordOpe;
|
||||||
bool enablePackratParsing;
|
bool enablePackratParsing;
|
||||||
bool is_macro;
|
bool is_macro;
|
||||||
std::vector<std::string> params;
|
std::vector<std::string> params;
|
||||||
Tracer tracer;
|
Tracer tracer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Reference;
|
friend class Reference;
|
||||||
@ -1883,14 +1883,14 @@ inline size_t Holder::parse(const char* s, size_t n, SemanticValues& sv, Context
|
|||||||
|
|
||||||
c.packrat(s, outer_->id, len, val, [&](any& a_val) {
|
c.packrat(s, outer_->id, len, val, [&](any& a_val) {
|
||||||
if (outer_->enter) {
|
if (outer_->enter) {
|
||||||
outer_->enter(dt);
|
outer_->enter(s, n, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto se2 = make_scope_exit([&]() {
|
auto se2 = make_scope_exit([&]() {
|
||||||
c.pop();
|
c.pop();
|
||||||
|
|
||||||
if (outer_->leave) {
|
if (outer_->leave) {
|
||||||
outer_->leave(dt);
|
outer_->leave(s, n, len, a_val, dt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user