From f16011e4d18ab96b9aa8594abe6f8a3be9d79072 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sat, 31 Jul 2021 02:11:59 +0430 Subject: [PATCH] LibCpp: Allow 'final' in a class declaration with inheritance --- Userland/Libraries/LibCpp/Parser.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibCpp/Parser.cpp b/Userland/Libraries/LibCpp/Parser.cpp index cb77f61061..cbb8259ed2 100644 --- a/Userland/Libraries/LibCpp/Parser.cpp +++ b/Userland/Libraries/LibCpp/Parser.cpp @@ -700,7 +700,12 @@ bool Parser::match_class_declaration() consume(Token::Type::Identifier); - if (peek().type() == Token::Type::Colon) { + auto has_final = match_keyword("final"); + + if (peek(has_final ? 1 : 0).type() == Token::Type::Colon) { + if (has_final) + consume(); + do { consume(); @@ -1158,8 +1163,13 @@ NonnullRefPtr Parser::parse_class_declaration(ASTNode& auto name_token = consume(Token::Type::Identifier); decl->set_name(text_of_token(name_token)); + auto has_final = match_keyword("final"); + // FIXME: Don't ignore this. - if (peek().type() == Token::Type::Colon) { + if (peek(has_final ? 1 : 0).type() == Token::Type::Colon) { + if (has_final) + consume(); + do { consume();