mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 20:05:31 +00:00
Fix #63
This commit is contained in:
parent
ac8c93f415
commit
2d276c8cd9
3
peglib.h
3
peglib.h
@ -2374,6 +2374,9 @@ inline void DetectLeftRecursion::visit(Reference& ope) {
|
|||||||
refs_.insert(ope.name_);
|
refs_.insert(ope.name_);
|
||||||
if (ope.rule_) {
|
if (ope.rule_) {
|
||||||
ope.rule_->accept(*this);
|
ope.rule_->accept(*this);
|
||||||
|
if (done_ == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
done_ = true;
|
done_ = true;
|
||||||
|
11
test/test.cc
11
test/test.cc
@ -1032,6 +1032,17 @@ TEST_CASE("Left recursive with zom test", "[left recursive]")
|
|||||||
REQUIRE(!parser);
|
REQUIRE(!parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Left recursive with a ZOM content rule", "[left recursive]")
|
||||||
|
{
|
||||||
|
parser parser(R"(
|
||||||
|
A <- B
|
||||||
|
B <- _ A
|
||||||
|
_ <- ' '* # Zero or more
|
||||||
|
)");
|
||||||
|
|
||||||
|
REQUIRE(!parser);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("Left recursive with empty string test", "[left recursive]")
|
TEST_CASE("Left recursive with empty string test", "[left recursive]")
|
||||||
{
|
{
|
||||||
parser parser(
|
parser parser(
|
||||||
|
Loading…
Reference in New Issue
Block a user