1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +00:00

LibCpp: Match and ignore struct/class inheritance

This commit is contained in:
Ali Mohammad Pur 2021-07-28 05:05:58 +04:30 committed by Andreas Kling
parent dc68c765b7
commit c866a56f07

View file

@ -695,6 +695,19 @@ bool Parser::match_class_declaration()
consume(Token::Type::Identifier);
if (peek().type() == Token::Type::Colon) {
do {
consume();
while (match_keyword("private") || match_keyword("public") || match_keyword("protected") || match_keyword("virtual"))
consume();
if (!match_name())
return false;
parse_name(get_dummy_node());
} while (peek().type() == Token::Type::Comma);
}
return match(Token::Type::LeftCurly);
}
@ -1137,6 +1150,18 @@ NonnullRefPtr<StructOrClassDeclaration> Parser::parse_class_declaration(ASTNode&
auto name_token = consume(Token::Type::Identifier);
decl->set_name(text_of_token(name_token));
// FIXME: Don't ignore this.
if (peek().type() == Token::Type::Colon) {
do {
consume();
while (match_keyword("private") || match_keyword("public") || match_keyword("protected") || match_keyword("virtual"))
consume();
parse_name(get_dummy_node());
} while (peek().type() == Token::Type::Comma);
}
consume(Token::Type::LeftCurly);
while (!eof() && peek().type() != Token::Type::RightCurly) {