feat: complete raw, const keyword

This commit is contained in:
lh123 2025-01-16 18:05:30 +08:00
parent 7d337c7f35
commit 9809143562
6 changed files with 144 additions and 8 deletions

View file

@ -339,13 +339,20 @@ fn lhs(p: &mut Parser<'_>, r: Restrictions) -> Option<(CompletedMarker, BlockLik
// // raw reference operator
// let _ = &raw mut foo;
// let _ = &raw const foo;
// let _ = &raw foo;
// }
T![&] => {
m = p.start();
p.bump(T![&]);
if p.at_contextual_kw(T![raw]) && [T![mut], T![const]].contains(&p.nth(1)) {
p.bump_remap(T![raw]);
p.bump_any();
if p.at_contextual_kw(T![raw]) {
if [T![mut], T![const]].contains(&p.nth(1)) {
p.bump_remap(T![raw]);
p.bump_any();
} else if p.nth_at(1, SyntaxKind::IDENT) {
// we treat raw as keyword in this case
// &raw foo;
p.bump_remap(T![raw]);
}
} else {
p.eat(T![mut]);
}