diff --git a/README.md b/README.md index 7787b86..21e8cbb 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,9 @@ struct SemanticValue { // Cast semantic value template T& get(); template const T& get() const; + + // Get token + std::string str() const; }; struct SemanticValues : protected std::vector diff --git a/peglib.h b/peglib.h index 00c9b5c..cd803a0 100644 --- a/peglib.h +++ b/peglib.h @@ -171,6 +171,11 @@ struct SemanticValue const T& get() const { return val.get(); } + + std::string str() const { + return std::string(s, n); + } + }; struct SemanticValues : protected std::vector