1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +00:00

LibCpp: Support non-field class members

Previously, we had a special ASTNode for class members,
"MemberDeclaration", which only represented fields.

This commit removes MemberDeclaration and instead uses regular
Declaration nodes for representing the members of a class.

This means that we can now also parse methods, inner-classes, and other
declarations that appear inside of a class.
This commit is contained in:
Itamar 2021-06-05 17:57:13 +03:00 committed by Andreas Kling
parent 8f074222e8
commit dcdb0c7035
6 changed files with 71 additions and 77 deletions

View file

@ -47,12 +47,12 @@ private:
Function,
Variable,
Enum,
Struct,
Namespace,
Class,
Namespace,
};
Optional<DeclarationType> match_declaration_in_translation_unit();
Optional<Parser::DeclarationType> match_class_member();
bool match_function_declaration();
bool match_comment();
bool match_preprocessor();
@ -62,7 +62,6 @@ private:
bool match_secondary_expression();
bool match_enum_declaration();
bool match_class_declaration();
bool match_struct_declaration();
bool match_literal();
bool match_unary_expression();
bool match_boolean_literal();
@ -93,8 +92,7 @@ private:
NonnullRefPtr<StringLiteral> parse_string_literal(ASTNode& parent);
NonnullRefPtr<ReturnStatement> parse_return_statement(ASTNode& parent);
NonnullRefPtr<EnumDeclaration> parse_enum_declaration(ASTNode& parent);
NonnullRefPtr<StructOrClassDeclaration> parse_struct_or_class_declaration(ASTNode& parent, StructOrClassDeclaration::Type);
NonnullRefPtr<MemberDeclaration> parse_member_declaration(ASTNode& parent);
NonnullRefPtr<StructOrClassDeclaration> parse_class_declaration(ASTNode& parent);
NonnullRefPtr<Expression> parse_literal(ASTNode& parent);
NonnullRefPtr<UnaryExpression> parse_unary_expression(ASTNode& parent);
NonnullRefPtr<BooleanLiteral> parse_boolean_literal(ASTNode& parent);
@ -114,6 +112,7 @@ private:
NonnullRefPtr<SizeofExpression> parse_sizeof_expression(ASTNode& parent);
NonnullRefPtr<BracedInitList> parse_braced_init_list(ASTNode& parent);
NonnullRefPtr<CStyleCastExpression> parse_c_style_cast_expression(ASTNode& parent);
NonnullRefPtrVector<Declaration> parse_class_members(ASTNode& parent);
bool match(Token::Type);
Token consume(Token::Type);