|
|
@ -28,9 +28,11 @@ public: |
|
|
|
virtual bool isHashMap() const { return false; } |
|
|
|
virtual bool isHashMap() const { return false; } |
|
|
|
virtual bool isList() const { return false; } |
|
|
|
virtual bool isList() const { return false; } |
|
|
|
virtual bool isString() const { return false; } |
|
|
|
virtual bool isString() const { return false; } |
|
|
|
|
|
|
|
virtual bool isKeyword() const { return false; } |
|
|
|
virtual bool isNumber() const { return false; } |
|
|
|
virtual bool isNumber() const { return false; } |
|
|
|
virtual bool isSpecialSymbol() const { return false; } |
|
|
|
virtual bool isValue() const { return false; } |
|
|
|
virtual bool isSymbol() const { return false; } |
|
|
|
virtual bool isSymbol() const { return false; } |
|
|
|
|
|
|
|
virtual bool isFunction() const { return false; } |
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
protected: |
|
|
|
ASTNode() {} |
|
|
|
ASTNode() {} |
|
|
@ -109,6 +111,21 @@ private: |
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// :keyword
|
|
|
|
|
|
|
|
class Keyword final : public ASTNode { |
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
Keyword(const std::string& data); |
|
|
|
|
|
|
|
virtual ~Keyword() = default; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool isKeyword() const override { return true; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const std::string& keyword() const { return m_data; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
std::string m_data; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
// 123
|
|
|
|
// 123
|
|
|
|
class Number final : public ASTNode { |
|
|
|
class Number final : public ASTNode { |
|
|
|
public: |
|
|
|
public: |
|
|
@ -125,13 +142,15 @@ private: |
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// true, false, nil
|
|
|
|
// Symbols
|
|
|
|
class SpecialSymbol final : public ASTNode { |
|
|
|
class Symbol final : public ASTNode { |
|
|
|
public: |
|
|
|
public: |
|
|
|
SpecialSymbol(); |
|
|
|
Symbol(const std::string& symbol); |
|
|
|
virtual ~SpecialSymbol(); |
|
|
|
virtual ~Symbol() = default; |
|
|
|
|
|
|
|
|
|
|
|
virtual bool isSpecialSymbol() const override { return true; } |
|
|
|
virtual bool isSymbol() const override { return true; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const std::string& symbol() const { return m_symbol; } |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
std::string m_symbol; |
|
|
|
std::string m_symbol; |
|
|
@ -139,18 +158,19 @@ private: |
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// Other symbols
|
|
|
|
// true, false, nil
|
|
|
|
class Symbol final : public ASTNode { |
|
|
|
class Value final : public ASTNode { |
|
|
|
public: |
|
|
|
public: |
|
|
|
Symbol(const std::string& symbol); |
|
|
|
Value(const std::string& value); |
|
|
|
virtual ~Symbol() = default; |
|
|
|
virtual ~Value() = default; |
|
|
|
|
|
|
|
|
|
|
|
virtual bool isSymbol() const override { return true; } |
|
|
|
virtual bool isValue() const override { return true; } |
|
|
|
|
|
|
|
|
|
|
|
std::string symbol() const { return m_symbol; } |
|
|
|
const std::string& value() const { return m_value; } |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
std::string m_symbol; |
|
|
|
std::string m_value; |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
// -----------------------------------------
|
|
|
@ -172,13 +192,16 @@ template<> |
|
|
|
inline bool ASTNode::fastIs<String>() const { return isString(); } |
|
|
|
inline bool ASTNode::fastIs<String>() const { return isString(); } |
|
|
|
|
|
|
|
|
|
|
|
template<> |
|
|
|
template<> |
|
|
|
inline bool ASTNode::fastIs<Number>() const { return isNumber(); } |
|
|
|
inline bool ASTNode::fastIs<Keyword>() const { return isKeyword(); } |
|
|
|
|
|
|
|
|
|
|
|
template<> |
|
|
|
template<> |
|
|
|
inline bool ASTNode::fastIs<SpecialSymbol>() const { return isSpecialSymbol(); } |
|
|
|
inline bool ASTNode::fastIs<Number>() const { return isNumber(); } |
|
|
|
|
|
|
|
|
|
|
|
template<> |
|
|
|
template<> |
|
|
|
inline bool ASTNode::fastIs<Symbol>() const { return isSymbol(); } |
|
|
|
inline bool ASTNode::fastIs<Symbol>() const { return isSymbol(); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<> |
|
|
|
|
|
|
|
inline bool ASTNode::fastIs<Value>() const { return isValue(); } |
|
|
|
// clang-format on
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace blaze
|
|
|
|
} // namespace blaze
|
|
|
|