mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 11:55:30 +00:00
Added built-in EOI support
This commit is contained in:
parent
9a9b63ac2c
commit
0e8406ebeb
24
peglib.h
24
peglib.h
@ -2400,19 +2400,24 @@ private:
|
|||||||
scope_exit([&]() { c.ignore_trace_state = save_ignore_trace_state; });
|
scope_exit([&]() { c.ignore_trace_state = save_ignore_trace_state; });
|
||||||
|
|
||||||
auto len = whitespaceOpe->parse(s, n, vs, c, dt);
|
auto len = whitespaceOpe->parse(s, n, vs, c, dt);
|
||||||
if (fail(len)) {
|
if (fail(len)) { return Result{false, c.recovered, i, c.error_info}; }
|
||||||
return Result{false, c.recovered, i, c.error_info};
|
|
||||||
}
|
|
||||||
|
|
||||||
i = len;
|
i = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto len = ope->parse(s + i, n - i, vs, c, dt);
|
auto len = ope->parse(s + i, n - i, vs, c, dt);
|
||||||
if (success(len)) {
|
auto ret = success(len);
|
||||||
return Result{true, c.recovered, i + len, c.error_info};
|
if (ret) {
|
||||||
} else {
|
i += len;
|
||||||
return Result{false, c.recovered, i, c.error_info};
|
if (i < n) {
|
||||||
|
if (c.error_info.error_pos - c.s < s + i - c.s) {
|
||||||
|
c.error_info.message_pos = s + i;
|
||||||
|
c.error_info.message = "expected end of input";
|
||||||
|
}
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return Result{ret, c.recovered, i, c.error_info};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Holder> holder_;
|
std::shared_ptr<Holder> holder_;
|
||||||
@ -4457,9 +4462,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool post_process(const char *s, size_t n,
|
bool post_process(const char *s, size_t n,
|
||||||
const Definition::Result &r) const {
|
const Definition::Result &r) const {
|
||||||
auto ret = r.ret && r.len == n;
|
if (log && !r.ret) { r.error_info.output_log(log, s, n); }
|
||||||
if (log && !ret) { r.error_info.output_log(log, s, n); }
|
return r.ret && !r.recovered;
|
||||||
return ret && !r.recovered;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> get_no_ast_opt_rules() const {
|
std::vector<std::string> get_no_ast_opt_rules() const {
|
||||||
|
Loading…
Reference in New Issue
Block a user