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++; count++;
} }
while (n - i > 0 && count < max_) { while (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(); });
auto save_sv_size = vs.size(); 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)) { if (success(len)) {
c.recovered = true; c.recovered = true;
if (c.log) {
c.error_info.output_log(c.log, c.s, c.l);
c.error_info.clear();
}
} }
// Cut // Cut

View File

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