mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibCpp: Support parsing class declarations
This commit is contained in:
parent
247f8f8dbb
commit
4831dc0e30
2 changed files with 11 additions and 0 deletions
|
@ -128,6 +128,8 @@ NonnullRefPtr<Declaration> Parser::parse_declaration(ASTNode& parent, Declaratio
|
||||||
return parse_variable_declaration(parent);
|
return parse_variable_declaration(parent);
|
||||||
case DeclarationType::Enum:
|
case DeclarationType::Enum:
|
||||||
return parse_enum_declaration(parent);
|
return parse_enum_declaration(parent);
|
||||||
|
case DeclarationType::Class:
|
||||||
|
return parse_struct_or_class_declaration(parent, StructOrClassDeclaration::Type::Class);
|
||||||
case DeclarationType::Struct:
|
case DeclarationType::Struct:
|
||||||
return parse_struct_or_class_declaration(parent, StructOrClassDeclaration::Type::Struct);
|
return parse_struct_or_class_declaration(parent, StructOrClassDeclaration::Type::Struct);
|
||||||
case DeclarationType::Namespace:
|
case DeclarationType::Namespace:
|
||||||
|
@ -640,6 +642,8 @@ Optional<Parser::DeclarationType> Parser::match_declaration_in_translation_unit(
|
||||||
return DeclarationType::Function;
|
return DeclarationType::Function;
|
||||||
if (match_enum_declaration())
|
if (match_enum_declaration())
|
||||||
return DeclarationType::Enum;
|
return DeclarationType::Enum;
|
||||||
|
if (match_class_declaration())
|
||||||
|
return DeclarationType::Class;
|
||||||
if (match_struct_declaration())
|
if (match_struct_declaration())
|
||||||
return DeclarationType::Struct;
|
return DeclarationType::Struct;
|
||||||
if (match_namespace_declaration())
|
if (match_namespace_declaration())
|
||||||
|
@ -654,6 +658,11 @@ bool Parser::match_enum_declaration()
|
||||||
return match_keyword("enum");
|
return match_keyword("enum");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Parser::match_class_declaration()
|
||||||
|
{
|
||||||
|
return match_keyword("class");
|
||||||
|
}
|
||||||
|
|
||||||
bool Parser::match_struct_declaration()
|
bool Parser::match_struct_declaration()
|
||||||
{
|
{
|
||||||
return match_keyword("struct");
|
return match_keyword("struct");
|
||||||
|
|
|
@ -69,6 +69,7 @@ private:
|
||||||
Enum,
|
Enum,
|
||||||
Struct,
|
Struct,
|
||||||
Namespace,
|
Namespace,
|
||||||
|
Class,
|
||||||
};
|
};
|
||||||
|
|
||||||
Optional<DeclarationType> match_declaration_in_translation_unit();
|
Optional<DeclarationType> match_declaration_in_translation_unit();
|
||||||
|
@ -80,6 +81,7 @@ private:
|
||||||
bool match_expression();
|
bool match_expression();
|
||||||
bool match_secondary_expression();
|
bool match_secondary_expression();
|
||||||
bool match_enum_declaration();
|
bool match_enum_declaration();
|
||||||
|
bool match_class_declaration();
|
||||||
bool match_struct_declaration();
|
bool match_struct_declaration();
|
||||||
bool match_literal();
|
bool match_literal();
|
||||||
bool match_unary_expression();
|
bool match_unary_expression();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue