|
|
@ -23,6 +23,7 @@ public: |
|
|
|
template<typename T> |
|
|
|
template<typename T> |
|
|
|
bool fastIs() const = delete; |
|
|
|
bool fastIs() const = delete; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool isCollection() const { return false; } |
|
|
|
virtual bool isVector() const { return false; } |
|
|
|
virtual bool isVector() const { return false; } |
|
|
|
virtual bool isHashMap() const { return false; } |
|
|
|
virtual bool isHashMap() const { return false; } |
|
|
|
virtual bool isList() const { return false; } |
|
|
|
virtual bool isList() const { return false; } |
|
|
@ -30,17 +31,25 @@ public: |
|
|
|
virtual bool isNumber() const { return false; } |
|
|
|
virtual bool isNumber() const { return false; } |
|
|
|
virtual bool isSpecialSymbol() const { return false; } |
|
|
|
virtual bool isSpecialSymbol() const { return false; } |
|
|
|
virtual bool isSymbol() const { return false; } |
|
|
|
virtual bool isSymbol() const { return false; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
|
|
|
ASTNode() {} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// []
|
|
|
|
class Collection : public ASTNode { |
|
|
|
class Vector final : public ASTNode { |
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
Vector(); |
|
|
|
virtual ~Collection() override; |
|
|
|
virtual ~Vector(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool isVector() const override { return true; } |
|
|
|
virtual bool isCollection() const override { return true; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void addNode(ASTNode* node); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const std::vector<ASTNode*>& nodes() const { return m_nodes; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
|
|
|
Collection() {} |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
std::vector<ASTNode*> m_nodes; |
|
|
|
std::vector<ASTNode*> m_nodes; |
|
|
@ -48,34 +57,38 @@ private: |
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// []
|
|
|
|
|
|
|
|
class Vector final : public Collection { |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
Vector() = default; |
|
|
|
|
|
|
|
virtual ~Vector() = default; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool isCollection() const override { return false; } |
|
|
|
|
|
|
|
virtual bool isVector() const override { return true; } |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// {}
|
|
|
|
// {}
|
|
|
|
class HashMap final : public ASTNode { |
|
|
|
class HashMap final : public Collection { |
|
|
|
public: |
|
|
|
public: |
|
|
|
HashMap(); |
|
|
|
HashMap() = default; |
|
|
|
virtual ~HashMap(); |
|
|
|
virtual ~HashMap() = default; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool isCollection() const override { return false; } |
|
|
|
virtual bool isHashMap() const override { return true; } |
|
|
|
virtual bool isHashMap() const override { return true; } |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
std::vector<ASTNode*> m_nodes; |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// ()
|
|
|
|
// ()
|
|
|
|
class List final : public ASTNode { |
|
|
|
class List final : public Collection { |
|
|
|
public: |
|
|
|
public: |
|
|
|
List() = default; |
|
|
|
List() = default; |
|
|
|
virtual ~List() override; |
|
|
|
virtual ~List() = default; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool isCollection() const override { return false; } |
|
|
|
virtual bool isList() const override { return true; } |
|
|
|
virtual bool isList() const override { return true; } |
|
|
|
|
|
|
|
|
|
|
|
void addNode(ASTNode* node); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const std::vector<ASTNode*>& nodes() const { return m_nodes; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
std::vector<ASTNode*> m_nodes; |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
// -----------------------------------------
|
|
|
@ -143,6 +156,9 @@ private: |
|
|
|
// -----------------------------------------
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
// clang-format off
|
|
|
|
|
|
|
|
template<> |
|
|
|
|
|
|
|
inline bool ASTNode::fastIs<Collection>() const { return isCollection(); } |
|
|
|
|
|
|
|
|
|
|
|
template<> |
|
|
|
template<> |
|
|
|
inline bool ASTNode::fastIs<Vector>() const { return isVector(); } |
|
|
|
inline bool ASTNode::fastIs<Vector>() const { return isVector(); } |
|
|
|
|
|
|
|
|
|
|
|