mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 11:55:30 +00:00
Fix #217
This commit is contained in:
parent
b368726b40
commit
970537730f
BIN
docs/native.wasm
BIN
docs/native.wasm
Binary file not shown.
7
peglib.h
7
peglib.h
@ -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
|
||||||
|
@ -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>.)",
|
||||||
|
Loading…
Reference in New Issue
Block a user