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

LibCpp: Add support for parsing reference types

This commit is contained in:
Ali Mohammad Pur 2021-07-28 05:37:24 +04:30 committed by Andreas Kling
parent 3c1422d774
commit 3319114127
3 changed files with 60 additions and 0 deletions

View file

@ -1237,6 +1237,16 @@ NonnullRefPtr<Type> Parser::parse_type(ASTNode& parent)
type = ptr;
}
if (!eof() && (peek().type() == Token::Type::And || peek().type() == Token::Type::AndAnd)) {
type->set_end(position());
auto ref_token = consume();
auto ref = create_ast_node<Reference>(parent, type->start(), ref_token.end(), ref_token.type() == Token::Type::And ? Reference::Kind::Lvalue : Reference::Kind::Rvalue);
type->set_parent(*ref);
ref->set_referenced_type(type);
ref->set_end(position());
type = ref;
}
type->set_end(position());
return type;
}