mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 11:55:30 +00:00
Fixed error report problems
This commit is contained in:
parent
222466d07a
commit
8c68f4cff8
BIN
docs/native.wasm
BIN
docs/native.wasm
Binary file not shown.
17
peglib.h
17
peglib.h
@ -901,7 +901,6 @@ public:
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto save_error_pos = c.error_pos;
|
|
||||||
while (n - i > 0 && count < max_) {
|
while (n - i > 0 && count < max_) {
|
||||||
c.push_capture_scope();
|
c.push_capture_scope();
|
||||||
auto se = scope_exit([&]() { c.pop_capture_scope(); });
|
auto se = scope_exit([&]() { c.pop_capture_scope(); });
|
||||||
@ -921,7 +920,6 @@ public:
|
|||||||
vs.tokens.erase(vs.tokens.begin() +
|
vs.tokens.erase(vs.tokens.begin() +
|
||||||
static_cast<std::ptrdiff_t>(save_tok_size));
|
static_cast<std::ptrdiff_t>(save_tok_size));
|
||||||
}
|
}
|
||||||
c.error_pos = save_error_pos;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i += len;
|
i += len;
|
||||||
@ -987,7 +985,6 @@ public:
|
|||||||
|
|
||||||
size_t parse_core(const char *s, size_t n, SemanticValues & /*vs*/,
|
size_t parse_core(const char *s, size_t n, SemanticValues & /*vs*/,
|
||||||
Context &c, std::any &dt) const override {
|
Context &c, std::any &dt) const override {
|
||||||
auto save_error_pos = c.error_pos;
|
|
||||||
auto &chldsv = c.push();
|
auto &chldsv = c.push();
|
||||||
c.push_capture_scope();
|
c.push_capture_scope();
|
||||||
auto se = scope_exit([&]() {
|
auto se = scope_exit([&]() {
|
||||||
@ -999,7 +996,6 @@ public:
|
|||||||
c.set_error_pos(s);
|
c.set_error_pos(s);
|
||||||
return static_cast<size_t>(-1);
|
return static_cast<size_t>(-1);
|
||||||
} else {
|
} else {
|
||||||
c.error_pos = save_error_pos;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2104,6 +2100,11 @@ private:
|
|||||||
enablePackratParsing, tracer_enter, tracer_leave);
|
enablePackratParsing, tracer_enter, tracer_leave);
|
||||||
|
|
||||||
auto len = ope->parse(s, n, vs, cxt, dt);
|
auto len = ope->parse(s, n, vs, cxt, dt);
|
||||||
|
if (success(len)) {
|
||||||
|
cxt.error_pos = nullptr;
|
||||||
|
cxt.message_pos = nullptr;
|
||||||
|
cxt.message.clear();
|
||||||
|
}
|
||||||
return Result{success(len), len, cxt.error_pos, cxt.message_pos,
|
return Result{success(len), len, cxt.error_pos, cxt.message_pos,
|
||||||
cxt.message};
|
cxt.message};
|
||||||
}
|
}
|
||||||
@ -2417,8 +2418,6 @@ inline size_t PrecedenceClimbing::parse_expression(const char *s, size_t n,
|
|||||||
};
|
};
|
||||||
auto action_se = scope_exit([&]() { rule.action = std::move(action); });
|
auto action_se = scope_exit([&]() { rule.action = std::move(action); });
|
||||||
|
|
||||||
auto save_error_pos = c.error_pos;
|
|
||||||
|
|
||||||
auto i = len;
|
auto i = len;
|
||||||
while (i < n) {
|
while (i < n) {
|
||||||
std::vector<std::any> save_values(vs.begin(), vs.end());
|
std::vector<std::any> save_values(vs.begin(), vs.end());
|
||||||
@ -2428,10 +2427,7 @@ inline size_t PrecedenceClimbing::parse_expression(const char *s, size_t n,
|
|||||||
auto chl = binop_->parse(s + i, n - i, chv, c, dt);
|
auto chl = binop_->parse(s + i, n - i, chv, c, dt);
|
||||||
c.pop();
|
c.pop();
|
||||||
|
|
||||||
if (fail(chl)) {
|
if (fail(chl)) { break; }
|
||||||
c.error_pos = save_error_pos;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto it = info_.find(tok);
|
auto it = info_.find(tok);
|
||||||
if (it == info_.end()) { break; }
|
if (it == info_.end()) { break; }
|
||||||
@ -2454,7 +2450,6 @@ inline size_t PrecedenceClimbing::parse_expression(const char *s, size_t n,
|
|||||||
if (fail(chl)) {
|
if (fail(chl)) {
|
||||||
vs.assign(save_values.begin(), save_values.end());
|
vs.assign(save_values.begin(), save_values.end());
|
||||||
vs.tokens = save_tokens;
|
vs.tokens = save_tokens;
|
||||||
c.error_pos = save_error_pos;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user