@@ -51,13 +51,15 @@ protected:
|
||||
* @brief Var read expression AST node.
|
||||
*/
|
||||
class var_read_expression_node final : public expression_node {
|
||||
public:
|
||||
using name_type = furlang::result<std::string_view, error>; /**< Name type alias. */
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new var read expression node object from a name handle.
|
||||
*
|
||||
* @param name Handle to the name.
|
||||
*/
|
||||
var_read_expression_node(handle<std::string_view>&& name)
|
||||
var_read_expression_node(name_type&& name)
|
||||
: m_name(std::move(name)) {}
|
||||
|
||||
/**
|
||||
@@ -65,14 +67,14 @@ public:
|
||||
*
|
||||
* @return Name of the variable.
|
||||
*/
|
||||
const handle<std::string_view>& get_name() const { return m_name; }
|
||||
const name_type& get_name() const { return m_name; }
|
||||
|
||||
/**
|
||||
* @brief Returns the variable's name.
|
||||
*
|
||||
* @return Name of the variable.
|
||||
*/
|
||||
handle<std::string_view>&& move_name() { return std::move(m_name); }
|
||||
name_type&& move_name() { return std::move(m_name); }
|
||||
public:
|
||||
/**
|
||||
* @brief Returns this node's expression type.
|
||||
@@ -87,7 +89,7 @@ public:
|
||||
protected:
|
||||
bool equal(const node& rhs) const override;
|
||||
private:
|
||||
handle<std::string_view> m_name;
|
||||
name_type m_name;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,13 +49,15 @@ protected:
|
||||
* @brief String literal AST node.
|
||||
*/
|
||||
class string_literal_node final : public literal_node {
|
||||
public:
|
||||
using value_type = furlang::result<std::string_view, error>; /**< Value type. */
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new string literal node object from a handle.
|
||||
*
|
||||
* @param value A handle to value.
|
||||
* @param value A string view result.
|
||||
*/
|
||||
string_literal_node(handle<std::string_view>&& value)
|
||||
string_literal_node(value_type&& value)
|
||||
: m_value(std::move(value)) {}
|
||||
public:
|
||||
/**
|
||||
@@ -68,9 +70,9 @@ public:
|
||||
/**
|
||||
* @brief Returns this node's value.
|
||||
*
|
||||
* @return A handle to the value.
|
||||
* @return A string view result.
|
||||
*/
|
||||
const handle<std::string_view>& value() const { return m_value; }
|
||||
const value_type& value() const { return m_value; }
|
||||
public:
|
||||
void accept(visitor& visitor) const override;
|
||||
|
||||
@@ -78,20 +80,22 @@ public:
|
||||
protected:
|
||||
bool equal(const node& rhs) const override;
|
||||
private:
|
||||
handle<std::string_view> m_value;
|
||||
value_type m_value;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Integer literal AST node.
|
||||
*/
|
||||
class integer_literal_node final : public literal_node {
|
||||
public:
|
||||
using value_type = furlang::result<front::integer_token, error>; /**< Value type. */
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new integer literal node object from a handle.
|
||||
*
|
||||
* @param value A handle to the value.
|
||||
* @param value An integer result.
|
||||
*/
|
||||
integer_literal_node(handle<front::integer_token>&& value)
|
||||
integer_literal_node(value_type&& value)
|
||||
: m_value(std::move(value)) {}
|
||||
public:
|
||||
/**
|
||||
@@ -104,9 +108,9 @@ public:
|
||||
/**
|
||||
* @brief Returns this node's value.
|
||||
*
|
||||
* @return A handle to the value.
|
||||
* @return An integer result.
|
||||
*/
|
||||
const handle<front::integer_token>& value() const { return m_value; }
|
||||
const value_type& value() const { return m_value; }
|
||||
|
||||
/**
|
||||
* @brief Compares this node with an integer token for equality.
|
||||
@@ -122,7 +126,7 @@ public:
|
||||
protected:
|
||||
bool equal(const node& rhs) const override;
|
||||
private:
|
||||
handle<front::integer_token> m_value;
|
||||
value_type m_value;
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
|
||||
Reference in New Issue
Block a user