Remove handle #7
@@ -36,6 +36,15 @@ struct error {
|
|||||||
* @return true if the errors are not equal.
|
* @return true if the errors are not equal.
|
||||||
*/
|
*/
|
||||||
bool operator!=(const error& other) const { return !this->operator==(other); }
|
bool operator!=(const error& other) const { return !this->operator==(other); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Prints an AST error to output stream.
|
||||||
|
*
|
||||||
|
* @param os Output stream.
|
||||||
|
* @param error AST error to print.
|
||||||
|
* @return The output stream.
|
||||||
|
*/
|
||||||
|
friend std::ostream& operator<<(std::ostream& os, const error& error);
|
||||||
};
|
};
|
||||||
|
|
||||||
class node;
|
class node;
|
||||||
|
|||||||
+7
-3
@@ -8,6 +8,10 @@
|
|||||||
|
|
||||||
namespace furc::ast {
|
namespace furc::ast {
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& os, const error& error) {
|
||||||
|
return os << error.location << ": ERROR: unknown";
|
||||||
|
}
|
||||||
|
|
||||||
bool literal_node::equal(const node& rhs) const {
|
bool literal_node::equal(const node& rhs) const {
|
||||||
return literal_type() == reinterpret_cast<const literal_node&>(rhs).literal_type();
|
return literal_type() == reinterpret_cast<const literal_node&>(rhs).literal_type();
|
||||||
}
|
}
|
||||||
@@ -47,8 +51,8 @@ void var_read_expression_node::accept(visitor& visitor) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& var_read_expression_node::print(std::ostream& os) const {
|
std::ostream& var_read_expression_node::print(std::ostream& os) const {
|
||||||
if (m_name.present()) return os << *m_name;
|
if (m_name.has_error()) return os << m_name.error();
|
||||||
return os << m_name.error();
|
return os << *m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool var_read_expression_node::equal(const node& rhsNode) const {
|
bool var_read_expression_node::equal(const node& rhsNode) const {
|
||||||
@@ -162,7 +166,7 @@ std::ostream& function_definition_node::print(std::ostream& os) const {
|
|||||||
os << entry << '\n';
|
os << entry << '\n';
|
||||||
return os << m_body->end << ": " << p_name->string << " end";
|
return os << m_body->end << ": " << p_name->string << " end";
|
||||||
}
|
}
|
||||||
return os << m_body.error().location << ": ERROR: unknown";
|
return os << m_body.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool function_definition_node::equal(const node& rhs) const {
|
bool function_definition_node::equal(const node& rhs) const {
|
||||||
|
|||||||
Reference in New Issue
Block a user