diff options
author | Itamar <itamar8910@gmail.com> | 2021-06-05 17:57:13 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-09 22:26:46 +0200 |
commit | dcdb0c7035d78ca8dedfe33372a6b39e63660028 (patch) | |
tree | e5421e51ce4f9db14766dfd39ac30f88a48bb263 /Userland/Libraries/LibCpp/Parser.h | |
parent | 8f074222e806d7d090bfee380bc87e5995e526fb (diff) | |
download | serenity-dcdb0c7035d78ca8dedfe33372a6b39e63660028.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibCpp/Parser.h')
-rw-r--r-- | Userland/Libraries/LibCpp/Parser.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Userland/Libraries/LibCpp/Parser.h b/Userland/Libraries/LibCpp/Parser.h index 6296722946..a99d965452 100644 --- a/Userland/Libraries/LibCpp/Parser.h +++ b/Userland/Libraries/LibCpp/Parser.h @@ -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); |