Skip to content

Commit

Permalink
Fix #246
Browse files Browse the repository at this point in the history
  • Loading branch information
yhirose committed Sep 20, 2022
1 parent 6bab6fb commit dde4aae
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions peglib.h
Original file line number Diff line number Diff line change
Expand Up @@ -4676,9 +4676,9 @@ class parser {
*---------------------------------------------------------------------------*/

inline void enable_tracing(parser &parser, std::ostream &os) {
size_t prev_pos = 0;
parser.enable_trace(
[&](auto &ope, auto s, auto, auto &, auto &c, auto &, auto &) {
[&](auto &ope, auto s, auto, auto &, auto &c, auto &, auto &trace_data) {
auto prev_pos = std::any_cast<size_t>(trace_data);
auto pos = static_cast<size_t>(s - c.s);
auto backtrack = (pos < prev_pos ? "*" : "");
std::string indent;
Expand All @@ -4695,7 +4695,7 @@ inline void enable_tracing(parser &parser, std::ostream &os) {
}
os << "E " << pos + 1 << backtrack << "\t" << indent << "" << name
<< " #" << c.trace_ids.back() << std::endl;
prev_pos = static_cast<size_t>(pos);
trace_data = static_cast<size_t>(pos);
},
[&](auto &ope, auto s, auto, auto &sv, auto &c, auto &, auto len,
auto &) {
Expand Down Expand Up @@ -4727,7 +4727,8 @@ inline void enable_tracing(parser &parser, std::ostream &os) {
<< c.trace_ids.back() << choice.str() << token << matched
<< std::endl;
},
[&](auto &) {}, [&](auto &) {});
[&](auto &trace_data) { trace_data = static_cast<size_t>(0); },
[&](auto &) {});
}

/*-----------------------------------------------------------------------------
Expand Down

0 comments on commit dde4aae

Please sign in to comment.