forked from KPGPMC/furlang
@@ -95,7 +95,7 @@ public:
|
||||
* @param name Name of the function.
|
||||
* @param body Body of the function.
|
||||
*/
|
||||
function_definition_node(front::token name, body_h&& body)
|
||||
function_definition_node(front::token name, body_r&& body)
|
||||
: function_declaration_node(name), m_body(std::move(body)) {}
|
||||
public:
|
||||
/**
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
*
|
||||
* @return Body of the function.
|
||||
*/
|
||||
const body_h& body() const { return m_body; }
|
||||
const body_r& body() const { return m_body; }
|
||||
public:
|
||||
void accept(visitor& visitor) const override;
|
||||
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
protected:
|
||||
bool equal(const node& rhs) const override;
|
||||
private:
|
||||
body_h m_body;
|
||||
body_r m_body;
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#ifndef FURC_AST_FWD_HPP
|
||||
#define FURC_AST_FWD_HPP
|
||||
|
||||
#include "furc/diag.hpp"
|
||||
#include "furc/handle.hpp"
|
||||
#include "furlang/result.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -13,6 +15,29 @@ namespace furc {
|
||||
*/
|
||||
namespace ast {
|
||||
|
||||
/**
|
||||
* @brief AST error.
|
||||
*/
|
||||
struct error {
|
||||
location location; /**< Location of the error. */
|
||||
|
||||
/**
|
||||
* @brief Compares two AST errors for equality.
|
||||
*
|
||||
* @param other Error to compare against.
|
||||
* @return true if the errors are equal.
|
||||
*/
|
||||
bool operator==(const error& other) const { return location == other.location; }
|
||||
|
||||
/**
|
||||
* @brief Compares two AST errors for inequality.
|
||||
*
|
||||
* @param other Error to compare against.
|
||||
* @return true if the errors are not equal.
|
||||
*/
|
||||
bool operator!=(const error& other) const { return !this->operator==(other); }
|
||||
};
|
||||
|
||||
class node;
|
||||
|
||||
/**
|
||||
@@ -162,7 +187,7 @@ struct body {
|
||||
* @brief Alias for body result.
|
||||
* @see body
|
||||
*/
|
||||
using body_h = handle<body>;
|
||||
using body_r = furlang::result<body, error>;
|
||||
|
||||
class function_declaration_node;
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
*
|
||||
* @param body Body handle.
|
||||
*/
|
||||
compound_statement_node(body_h&& body)
|
||||
compound_statement_node(body_r&& body)
|
||||
: m_body(std::move(body)) {}
|
||||
public:
|
||||
/**
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
*
|
||||
* @return The body handle.
|
||||
*/
|
||||
const body_h& body() const { return m_body; }
|
||||
const body_r& body() const { return m_body; }
|
||||
public:
|
||||
/**
|
||||
* @brief Returns this node's statement type.
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
protected:
|
||||
bool equal(const node& rhs) const override;
|
||||
private:
|
||||
body_h m_body; /**< The body handle. */
|
||||
body_r m_body; /**< The body handle. */
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
ast::expression_node_h parse_expression_unary(std::uint32_t precedence);
|
||||
ast::expression_node_h parse_expression_rhs(ast::expression_node_h&& init, std::uint32_t precedence);
|
||||
|
||||
ast::body_h parse_body();
|
||||
ast::body_r parse_body();
|
||||
private:
|
||||
static ast::node_handle<ast::node> error_handle(const token_r& result);
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user