swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 1 | #include "AstNode.h" |
| 2 | |
| 3 | AstNode::AstNode(QString function, QList<AstNode> args) |
| 4 | { |
| 5 | _type = FUNC; |
| 6 | _stringVal = function; |
| 7 | _listVal = args; |
| 8 | } |
| 9 | |
| 10 | QList<AstNode> AstNode::funcArgs() |
| 11 | { |
| 12 | return _listVal; |
| 13 | } |
| 14 | |
| 15 | bool AstNode::isFunc() const |
| 16 | { |
| 17 | return _type == FUNC; |
| 18 | } |
| 19 | |
| 20 | AstNode::operator QString() const |
| 21 | { |
| 22 | if (isFunc()) |
| 23 | { |
| 24 | QStringList args; |
| 25 | |
| 26 | for (const AstNode &node : _listVal) |
| 27 | { |
| 28 | args.append(static_cast<QString>(node)); |
| 29 | } |
| 30 | |
| 31 | return "<" + _stringVal + " " + args.join(" ") + ">"; |
| 32 | } |
| 33 | |
| 34 | return TokenBase<AstNode>::operator QString(); |
| 35 | } |