diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-07-31 02:11:59 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-02 01:03:59 +0200 |
commit | f16011e4d18ab96b9aa8594abe6f8a3be9d79072 (patch) | |
tree | 1cedc563a2481d2f2d5bc85ef95626077e5b1ef5 | |
parent | 010be01694a986e3763da45a546bdb58d5fbc93b (diff) | |
download | serenity-f16011e4d18ab96b9aa8594abe6f8a3be9d79072.zip |
LibCpp: Allow 'final' in a class declaration with inheritance
-rw-r--r-- | Userland/Libraries/LibCpp/Parser.cpp | 14 |
1 files 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<StructOrClassDeclaration> 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(); |