mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 11:55:30 +00:00
Fix #246
This commit is contained in:
parent
6bab6fb851
commit
dde4aaeb2f
9
peglib.h
9
peglib.h
@ -4676,9 +4676,9 @@ private:
|
|||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
inline void enable_tracing(parser &parser, std::ostream &os) {
|
inline void enable_tracing(parser &parser, std::ostream &os) {
|
||||||
size_t prev_pos = 0;
|
|
||||||
parser.enable_trace(
|
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 pos = static_cast<size_t>(s - c.s);
|
||||||
auto backtrack = (pos < prev_pos ? "*" : "");
|
auto backtrack = (pos < prev_pos ? "*" : "");
|
||||||
std::string indent;
|
std::string indent;
|
||||||
@ -4695,7 +4695,7 @@ inline void enable_tracing(parser &parser, std::ostream &os) {
|
|||||||
}
|
}
|
||||||
os << "E " << pos + 1 << backtrack << "\t" << indent << "┌" << name
|
os << "E " << pos + 1 << backtrack << "\t" << indent << "┌" << name
|
||||||
<< " #" << c.trace_ids.back() << std::endl;
|
<< " #" << 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 &ope, auto s, auto, auto &sv, auto &c, auto &, auto len,
|
||||||
auto &) {
|
auto &) {
|
||||||
@ -4727,7 +4727,8 @@ inline void enable_tracing(parser &parser, std::ostream &os) {
|
|||||||
<< c.trace_ids.back() << choice.str() << token << matched
|
<< c.trace_ids.back() << choice.str() << token << matched
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
},
|
},
|
||||||
[&](auto &) {}, [&](auto &) {});
|
[&](auto &trace_data) { trace_data = static_cast<size_t>(0); },
|
||||||
|
[&](auto &) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user