diff --git a/src/headers/parsing/ParseComponents.hpp b/src/headers/parsing/ParseComponents.hpp index 79df329..603052a 100644 --- a/src/headers/parsing/ParseComponents.hpp +++ b/src/headers/parsing/ParseComponents.hpp @@ -85,6 +85,7 @@ public: IS_PARSECOMPONENT inline void add(const T& component) { addComponent(component); } IS_PARSECOMPONENT inline void addAll(const initializer_list& components) { addAllComponents(components); } IS_PARSECOMPONENT inline ParseTree& operator<<(const T& component) { add(component); return *this; } + ParseTree& operator<<(const string&); ParseTree(): subComponents() {}; IS_PARSECOMPONENT inline explicit ParseTree(const T& element): ParseTree() { addComponent(element); } IS_PARSECOMPONENT inline ParseTree(const initializer_list& elements): ParseTree() { addAllComponents(elements); } @@ -114,7 +115,7 @@ namespace StandardComponents { }; struct String: ParseComponent { const string content; - explicit String(const char* string): content(string) {} + explicit String(string content_string): content(move(content_string)) {} }; } struct Call: ParseTree, Reference { @@ -130,4 +131,8 @@ namespace StandardComponents { }; } +ParseTree& ParseTree::operator<<(const string& text) { + return *this << StandardComponents::types::String(text); +} + #endif //YERBACON_PARSECOMPONENTS_HPP \ No newline at end of file diff --git a/src/headers/parsing/Parser.hpp b/src/headers/parsing/Parser.hpp index 0e3f6af..2a69526 100644 --- a/src/headers/parsing/Parser.hpp +++ b/src/headers/parsing/Parser.hpp @@ -56,7 +56,7 @@ namespace Parser { parseTree << types::Integer(v, p); break; } - case STRING: parseTree << types::String(current.toktext.data()); break; + case STRING: parseTree << current.toktext; break; case IDENTIFIER: { if (current.toktext == "class" || current.toktext == "structure") { if (next.toktype == IDENTIFIER) {