ParserComponents.hpp: Add a "<<" operator overload (which takes a constant string reference as its argument) to the ParseTree class
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
e32b2172e5
commit
014ea9060b
|
@ -85,6 +85,7 @@ public:
|
|||
IS_PARSECOMPONENT inline void add(const T& component) { addComponent<T>(component); }
|
||||
IS_PARSECOMPONENT inline void addAll(const initializer_list<T>& components) { addAllComponents<T>(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<T>& 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
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue