mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 20:05:31 +00:00
Code cleanup
This commit is contained in:
parent
3482a08465
commit
347113d4fd
29
test/test.cc
29
test/test.cc
@ -106,13 +106,12 @@ TEST_CASE("String capture test2", "[general]")
|
|||||||
|
|
||||||
TEST_CASE("String capture test3", "[general]")
|
TEST_CASE("String capture test3", "[general]")
|
||||||
{
|
{
|
||||||
auto syntax =
|
parser pg(R"(
|
||||||
" ROOT <- _ TOKEN* "
|
ROOT <- _ TOKEN*
|
||||||
" TOKEN <- '[' < (!']' .)+ > ']' _ "
|
TOKEN <- '[' < (!']' .)+ > ']' _
|
||||||
" _ <- [ \t\r\n]* "
|
_ <- [ \t\r\n]*
|
||||||
;
|
)");
|
||||||
|
|
||||||
parser pg(syntax);
|
|
||||||
|
|
||||||
std::vector<std::string> tags;
|
std::vector<std::string> tags;
|
||||||
|
|
||||||
@ -450,14 +449,12 @@ TEST_CASE("mutable lambda test", "[general]")
|
|||||||
|
|
||||||
TEST_CASE("Simple calculator test", "[general]")
|
TEST_CASE("Simple calculator test", "[general]")
|
||||||
{
|
{
|
||||||
auto syntax = R"(
|
parser parser(R"(
|
||||||
Additive <- Multitive '+' Additive / Multitive
|
Additive <- Multitive '+' Additive / Multitive
|
||||||
Multitive <- Primary '*' Multitive / Primary
|
Multitive <- Primary '*' Multitive / Primary
|
||||||
Primary <- '(' Additive ')' / Number
|
Primary <- '(' Additive ')' / Number
|
||||||
Number <- [0-9]+
|
Number <- [0-9]+
|
||||||
)";
|
)");
|
||||||
|
|
||||||
parser parser(syntax);
|
|
||||||
|
|
||||||
parser["Additive"] = [](const SemanticValues& sv) {
|
parser["Additive"] = [](const SemanticValues& sv) {
|
||||||
switch (sv.choice()) {
|
switch (sv.choice()) {
|
||||||
@ -816,9 +813,9 @@ TEST_CASE("Semantic values test", "[general]")
|
|||||||
|
|
||||||
TEST_CASE("Ordered choice count", "[general]")
|
TEST_CASE("Ordered choice count", "[general]")
|
||||||
{
|
{
|
||||||
auto syntax = R"(S <- 'a' / 'b')";
|
parser parser(R"(
|
||||||
|
S <- 'a' / 'b'
|
||||||
parser parser(syntax);
|
)");
|
||||||
|
|
||||||
parser["S"] = [](const SemanticValues& sv) {
|
parser["S"] = [](const SemanticValues& sv) {
|
||||||
REQUIRE(sv.choice() == 1);
|
REQUIRE(sv.choice() == 1);
|
||||||
@ -830,9 +827,9 @@ TEST_CASE("Ordered choice count", "[general]")
|
|||||||
|
|
||||||
TEST_CASE("Ordered choice count 2", "[general]")
|
TEST_CASE("Ordered choice count 2", "[general]")
|
||||||
{
|
{
|
||||||
auto syntax = R"(S <- ('a' / 'b')*)";
|
parser parser(R"(
|
||||||
|
S <- ('a' / 'b')*
|
||||||
parser parser(syntax);
|
)");
|
||||||
|
|
||||||
parser["S"] = [](const SemanticValues& sv) {
|
parser["S"] = [](const SemanticValues& sv) {
|
||||||
REQUIRE(sv.choice() == 0);
|
REQUIRE(sv.choice() == 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user