From fa5ffd821181b437f95041c50db459c5ce7af0c9 Mon Sep 17 00:00:00 2001 From: yhirose Date: Wed, 1 Aug 2018 14:58:24 -0400 Subject: [PATCH] fix #43 --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b0c62b9..03b7a54 100644 --- a/README.md +++ b/README.md @@ -35,13 +35,14 @@ This is a simple calculator sample. It shows how to define grammar, associate sa // (1) Include the header file #include #include +#include using namespace peg; using namespace std; int main(void) { // (2) Make a parser - auto syntax = R"( + auto grammar = R"( # Grammar for Calculator... Additive <- Multitive '+' Additive / Multitive Multitive <- Primary '*' Multitive / Primary @@ -50,7 +51,14 @@ int main(void) { %whitespace <- [ \t]* )"; - parser parser(syntax); + parser parser; + + parser.log = [](size_t line, size_t col, const string& msg) { + cerr << line << ":" << col << ": " << msg << "\n"; + }; + + auto ok = parser.load_grammar(grammar); + assert(ok); // (3) Setup actions parser["Additive"] = [](const SemanticValues& sv) {