Added another test case for %whitespace

This commit is contained in:
yhirose 2018-08-02 21:46:17 -04:00
parent f46737acbf
commit 4c8415c054

View File

@ -255,6 +255,23 @@ TEST_CASE("WHITESPACE test2", "[general]")
REQUIRE(items[2] == "three");
}
TEST_CASE("WHITESPACE test3", "[general]") {
peg::parser parser(R"(
StrQuot <- < '"' < (StrEscape / StrChars)* > '"' >
StrEscape <- '\\' any
StrChars <- (!'"' !'\\' any)+
any <- .
%whitespace <- [ \t]*
)");
parser["StrQuot"] = [](const SemanticValues& sv) {
REQUIRE(sv.token() == R"( aaa \" bbb )");
};
auto ret = parser.parse(R"( " aaa \" bbb " )");
REQUIRE(ret == true);
}
TEST_CASE("Word expression test", "[general]") {
peg::parser parser(R"(
ROOT <- 'hello' ','? 'world'