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) {