Removed unused errors

This commit is contained in:
Robert Bendun 2022-05-30 00:02:50 +02:00
parent 25e730c8d3
commit 2eee11e476
3 changed files with 7 additions and 37 deletions

View File

@ -106,11 +106,8 @@ void assert(bool condition, std::string message, Location loc)
std::ostream& operator<<(std::ostream& os, Error const& err) std::ostream& operator<<(std::ostream& os, Error const& err)
{ {
std::string_view short_description = visit(Overloaded { std::string_view short_description = visit(Overloaded {
[](errors::Expected_Keyword const&) { return "Expected keyword"; },
[](errors::Failed_Numeric_Parsing const&) { return "Failed to parse a number"; }, [](errors::Failed_Numeric_Parsing const&) { return "Failed to parse a number"; },
[](errors::Music_Literal_Used_As_Identifier const&) { return "Music literal in place of identifier"; },
[](errors::Not_Callable const&) { return "Value not callable"; }, [](errors::Not_Callable const&) { return "Value not callable"; },
[](errors::Undefined_Identifier const&) { return "Undefined identifier"; },
[](errors::Undefined_Operator const&) { return "Undefined operator"; }, [](errors::Undefined_Operator const&) { return "Undefined operator"; },
[](errors::Unexpected_Empty_Source const&) { return "Unexpected end of file"; }, [](errors::Unexpected_Empty_Source const&) { return "Unexpected end of file"; },
[](errors::Unexpected_Keyword const&) { return "Unexpected keyword"; }, [](errors::Unexpected_Keyword const&) { return "Unexpected keyword"; },
@ -158,10 +155,7 @@ std::ostream& operator<<(std::ostream& os, Error const& err)
} }
}, },
[&os](errors::Expected_Keyword const&) { unimplemented(); },
[&os](errors::Music_Literal_Used_As_Identifier const&) { unimplemented(); },
[&os](errors::Not_Callable const&) { unimplemented(); }, [&os](errors::Not_Callable const&) { unimplemented(); },
[&os](errors::Undefined_Identifier const&) { unimplemented(); },
[&os](errors::Undefined_Operator const&) { unimplemented(); }, [&os](errors::Undefined_Operator const&) { unimplemented(); },
[&os](errors::Unexpected_Keyword const&) { unimplemented(); }, [&os](errors::Unexpected_Keyword const&) { unimplemented(); },
[&os](errors::Unexpected_Empty_Source const&) { unimplemented(); } [&os](errors::Unexpected_Empty_Source const&) { unimplemented(); }

View File

@ -59,16 +59,6 @@ namespace errors
std::errc reason; std::errc reason;
}; };
struct Undefined_Identifier
{
};
struct Expected_Keyword
{
std::string_view keyword;
std::string_view received_type = {};
};
struct Expected_Expression_Separator_Before struct Expected_Expression_Separator_Before
{ {
std::string_view what; std::string_view what;
@ -89,17 +79,15 @@ namespace errors
std::string_view type; std::string_view type;
}; };
struct Music_Literal_Used_As_Identifier
{
std::string_view source;
/// Why only identifier can be used?
std::string_view identifier_context;
};
/// Collection of messages that are considered internal and should not be printed to the end user. /// Collection of messages that are considered internal and should not be printed to the end user.
namespace internal namespace internal
{ {
struct Expected_Keyword
{
std::string_view keyword;
std::string_view received_type = {};
};
struct Unexpected_Token struct Unexpected_Token
{ {
/// Type of the token /// Type of the token
@ -115,11 +103,8 @@ namespace errors
using Details = std::variant< using Details = std::variant<
Expected_Expression_Separator_Before, Expected_Expression_Separator_Before,
Expected_Keyword,
Failed_Numeric_Parsing, Failed_Numeric_Parsing,
Music_Literal_Used_As_Identifier,
Not_Callable, Not_Callable,
Undefined_Identifier,
Undefined_Operator, Undefined_Operator,
Unexpected_Empty_Source, Unexpected_Empty_Source,
Unexpected_Keyword, Unexpected_Keyword,

View File

@ -68,16 +68,7 @@ Result<Ast> Parser::parse_expression()
Result<Ast> Parser::parse_variable_declaration() Result<Ast> Parser::parse_variable_declaration()
{ {
if (!expect(Token::Type::Keyword, "var")) { assert(expect(Token::Type::Keyword, "var"), "Parser::parse_variable_declaration must be called only on expressions that starts with 'var'");
Error error;
errors::Expected_Keyword kw { .keyword = "var" };
if (token_id >= tokens.size()) {
kw.received_type = type_name(peek()->type);
error.location = peek()->location;
}
error.details = std::move(kw);
return error;
}
auto var = consume(); auto var = consume();
auto lvalue = Try(parse_many(*this, &Parser::parse_identifier, std::nullopt, At_Least::One)); auto lvalue = Try(parse_many(*this, &Parser::parse_identifier, std::nullopt, At_Least::One));