From 11ed83e46fb0268c22005a6b8a9f094f8ea7208c Mon Sep 17 00:00:00 2001 From: yhirose Date: Wed, 26 Aug 2020 21:47:19 -0400 Subject: [PATCH] Fixed a code example in README --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 65a486b..d16a325 100644 --- a/README.md +++ b/README.md @@ -177,20 +177,18 @@ struct SemanticValues : protected std::vector The following example uses `<` ... ` >` operator, which is *token boundary* operator. ```cpp -auto syntax = R"( +peg::parser parser(R"( ROOT <- _ TOKEN (',' _ TOKEN)* TOKEN <- < [a-z0-9]+ > _ _ <- [ \t\r\n]* -)"; +)"); -peg pg(syntax); - -pg["TOKEN"] = [](const SemanticValues& sv) { +parser["TOKEN"] = [](const SemanticValues& sv) { // 'token' doesn't include trailing whitespaces auto token = sv.token(); }; -auto ret = pg.parse(" token1, token2 "); +auto ret = parser.parse(" token1, token2 "); ``` We can ignore unnecessary semantic values from the list by using `~` operator.