mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2025-01-22 13:25:30 +00:00
Fixed backtracking problem.
This commit is contained in:
parent
85eb054106
commit
53ead0be7c
8
peglib.h
8
peglib.h
@ -673,7 +673,12 @@ public:
|
||||
size_t parse(const char* s, size_t n, SemanticValues& sv, Context& c, any& dt) const override {
|
||||
const auto& rule = *ope_;
|
||||
auto len = rule.parse(s, n, sv, c, dt);
|
||||
return success(len) ? len : 0;
|
||||
if (success(len)) {
|
||||
return len;
|
||||
} else {
|
||||
sv.rewind(s);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void accept(Visitor& v) override;
|
||||
@ -716,6 +721,7 @@ public:
|
||||
c.set_error_pos(s);
|
||||
return -1;
|
||||
} else {
|
||||
sv.rewind(s);
|
||||
c.error_pos = error_pos;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user