Add always disabled gen parse support

This commit is contained in:
Lukas Wirth 2024-07-17 10:49:12 +02:00
parent 983c9c122e
commit 7011094685
32 changed files with 376 additions and 55 deletions

View file

@ -352,13 +352,22 @@ pub enum BlockModifier {
Unsafe(SyntaxToken),
Try(SyntaxToken),
Const(SyntaxToken),
AsyncGen(SyntaxToken),
Gen(SyntaxToken),
Label(ast::Label),
}
impl ast::BlockExpr {
pub fn modifier(&self) -> Option<BlockModifier> {
self.async_token()
.map(BlockModifier::Async)
self.gen_token()
.map(|v| {
if self.async_token().is_some() {
BlockModifier::AsyncGen(v)
} else {
BlockModifier::Gen(v)
}
})
.or_else(|| self.async_token().map(BlockModifier::Async))
.or_else(|| self.unsafe_token().map(BlockModifier::Unsafe))
.or_else(|| self.try_token().map(BlockModifier::Try))
.or_else(|| self.const_token().map(BlockModifier::Const))