1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 18:28:10 +00:00

LibCpp: Support 'auto' Type

This commit is contained in:
Itamar 2021-05-17 10:40:19 +03:00 committed by Andreas Kling
parent eeb98335d5
commit f28d944122
3 changed files with 27 additions and 9 deletions

View file

@ -235,6 +235,10 @@ bool Parser::match_type()
ScopeGuard state_guard = [this] { load_state(); };
parse_type_qualifiers();
if (match_keyword("auto")) {
return true;
}
if (match_keyword("struct")) {
consume(Token::Type::Keyword); // Consume struct prefix
}
@ -1104,16 +1108,22 @@ NonnullRefPtr<Type> Parser::parse_type(ASTNode& parent)
auto qualifiers = parse_type_qualifiers();
type->m_qualifiers = move(qualifiers);
if (match_keyword("struct")) {
consume(Token::Type::Keyword); // Consume struct prefix
}
if (match_keyword("auto")) {
consume(Token::Type::Keyword);
type->m_is_auto = true;
} else {
if (!match_name()) {
type->set_end(position());
error(String::formatted("expected name instead of: {}", peek().text()));
return type;
if (match_keyword("struct")) {
consume(Token::Type::Keyword); // Consume struct prefix
}
if (!match_name()) {
type->set_end(position());
error(String::formatted("expected name instead of: {}", peek().text()));
return type;
}
type->m_name = parse_name(*type);
}
type->m_name = parse_name(*type);
while (!eof() && peek().type() == Token::Type::Asterisk) {
type->set_end(position());