diff --git a/docs/native.wasm b/docs/native.wasm index f6d0f32..9377c0c 100644 Binary files a/docs/native.wasm and b/docs/native.wasm differ diff --git a/peglib.h b/peglib.h index 38d6276..b7910e0 100644 --- a/peglib.h +++ b/peglib.h @@ -2872,7 +2872,9 @@ private: }; g["Sequence"] = [&](const SemanticValues &vs) { - if (vs.size() == 1) { + if (vs.empty()) { + return npd(dot()); + } else if (vs.size() == 1) { return std::any_cast>(vs[0]); } else { std::vector> opes; diff --git a/test/test2.cc b/test/test2.cc index 4c60112..24a7eff 100644 --- a/test/test2.cc +++ b/test/test2.cc @@ -159,6 +159,14 @@ TEST_CASE("Infinite loop 7", "[infinite loop]") { REQUIRE(!pg); } +TEST_CASE("Infinite loop 8", "[infinite loop]") { + parser pg(R"( + ROOT <- ('A' /)* + )"); + + REQUIRE(!pg); +} + TEST_CASE("Not infinite 1", "[infinite loop]") { parser pg(R"( Numbers <- Number* EOF diff --git a/test/test3.cc b/test/test3.cc index 377864e..c9e191d 100644 --- a/test/test3.cc +++ b/test/test3.cc @@ -42,6 +42,11 @@ TEST_CASE("PEG Expression", "[peg]") REQUIRE(exact(g, "Expression", "") == true); REQUIRE(exact(g, "Expression", " ") == false); REQUIRE(exact(g, "Expression", " a b ") == false); + + // NOTE: The followings are actually allowed in the original Ford's paper... + REQUIRE(exact(g, "Expression", "a//b ") == true); + REQUIRE(exact(g, "Expression", "a // b ") == true); + REQUIRE(exact(g, "Expression", "a / / b ") == true); } TEST_CASE("PEG Sequence", "[peg]")