From 49d6f0387f7b7cc3c6a51ef8fcdf519da98487f6 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 16 Feb 2017 20:03:48 -0500 Subject: Added transform tokens --- lib/token.h | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'lib/token.h') diff --git a/lib/token.h b/lib/token.h index e7f8c28..f3188c9 100644 --- a/lib/token.h +++ b/lib/token.h @@ -18,7 +18,8 @@ namespace verbly { literal, part, fillin, - utterance + utterance, + transform }; // Copy & move constructors @@ -87,6 +88,7 @@ namespace verbly { token(); token(std::vector parts); + token(std::initializer_list pieces); iterator begin(); const_iterator begin() const; @@ -96,7 +98,35 @@ namespace verbly { token& operator<<(token arg); + // Transform + + static token separator(std::string param, token inner); + static token punctuation(std::string param, token inner); + static token definiteArticle(token inner); + static token capitalize(token inner); + + token& getInnerToken(); + const token& getInnerToken() const; + private: + + std::string compileHelper( + std::string separator, + bool definiteArticle, + bool capitalize) const; + + enum class transform_type { + separator, + punctuation, + definite_article, + capitalize + }; + + token( + transform_type type, + std::string param, + token inner); + union { struct { word word_; @@ -106,6 +136,11 @@ namespace verbly { part part_; std::set fillin_; std::list utterance_; + struct { + transform_type type_; + std::string param_; + std::unique_ptr inner_; + } transform_; }; type type_; }; -- cgit 1.4.1