From 772686a2fc605023bce370e52dd5746d5c306367 Mon Sep 17 00:00:00 2001 From: Robert Bendun Date: Mon, 20 Jun 2022 13:21:37 +0200 Subject: [PATCH] Better error reporting of not mached parens --- src/errors.cc | 6 ++++-- src/parser.cc | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/errors.cc b/src/errors.cc index 743644d..04cb52f 100644 --- a/src/errors.cc +++ b/src/errors.cc @@ -185,8 +185,10 @@ std::ostream& operator<<(std::ostream& os, Error const& err) Lines::the.print(os, std::string(loc->filename), loc->line, loc->line); - os << pretty::begin_comment << "\nThis error is considered an internal one. It should not be displayed to the end user.\n" << pretty::end; - encourage_contact(os); + os << pretty::begin_comment << "\nThis error is considered an internal one. It should not be displayed to the end user.\n"; + os << "\n"; + os << "This error message is temporary and will be replaced by better one in the future\n"; + os << pretty::end; }, [&](errors::Expected_Expression_Separator_Before const& err) { diff --git a/src/parser.cc b/src/parser.cc index 5212fc7..5dfe760 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -271,7 +271,10 @@ Result Parser::parse_atomic_expression() } } } - unimplemented("Don't know why it stopped, maybe end of file?"); + return Error { + .details = errors::Unexpected_Empty_Source {}, + .location = {} + }; } consume(); if (is_lambda) { @@ -287,7 +290,15 @@ Result Parser::parse_atomic_expression() consume(); auto ast = Try(parse_sequence()); if (not expect(Token::Type::Close_Paren)) { - unimplemented("Error handling of this code is not implemented yet"); + auto const& token = Try(peek()); + return Error { + .details = errors::internal::Unexpected_Token { + .type = type_name(token.type), + .source = token.source, + .when = "waiting for closing paren ')'" + }, + .location = token.location + }; } consume(); return ast;