This commit is contained in:
yhirose 2022-06-25 06:29:50 -04:00
parent b368726b40
commit 970537730f
3 changed files with 4 additions and 9 deletions

Binary file not shown.

View File

@ -1125,7 +1125,7 @@ public:
count++;
}
while (n - i > 0 && count < max_) {
while (count < max_) {
c.push_capture_scope();
auto se = scope_exit([&]() { c.pop_capture_scope(); });
auto save_sv_size = vs.size();
@ -2936,11 +2936,6 @@ inline size_t Recovery::parse_core(const char *s, size_t n,
if (success(len)) {
c.recovered = true;
if (c.log) {
c.error_info.output_log(c.log, c.s, c.l);
c.error_info.clear();
}
}
// Cut

View File

@ -1452,20 +1452,20 @@ rrr | sss
TEST(ErrorTest, Error_recovery_2) {
parser pg(R"(
START <- ENTRY ((',' ENTRY) / %recover((!(',' / Space) .)+))* (_ / %recover(.*))
START <- ENTRY (',' ENTRY)* _*
ENTRY <- '[' ITEM (',' ITEM)* ']'
ITEM <- WORD / NUM / %recover((!(',' / ']') .)+)
NUM <- [0-9]+ ![a-z]
WORD <- '"' [a-z]+ '"'
~_ <- Space*
~_ <- Space
Space <- [ \n]
)");
EXPECT_TRUE(!!pg);
std::vector<std::string> errors{
R"(1:6: syntax error, unexpected ']', expecting ','.)",
R"(1:6: syntax error, unexpected ']', expecting <Space>.)",
R"(1:18: syntax error, unexpected 'z', expecting <NUM>.)",
R"(1:24: syntax error, unexpected ',', expecting '"'.)",
R"(1:31: syntax error, unexpected 'ccc', expecting '"', <NUM>.)",