Add method for checking whether token can be type

This commit is contained in:
dkanus 2025-09-16 08:14:22 +07:00
parent 41672a7125
commit 2a31ed08b8

View File

@ -388,6 +388,22 @@ impl Token {
Token::BlockComment | Token::Brace(BraceKind::CppBlock) | Token::Error
)
}
/// Returns `true` if this token can appear in type position
/// (either a built-in type keyword or an identifier).
pub fn is_valid_type_name_token(&self) -> bool {
matches!(
self,
Token::Int
| Token::Float
| Token::Bool
| Token::Byte
| Token::String
| Token::Array
| Token::Name
| Token::Identifier
)
}
}
/// Consume a /* ... */ block comment with arbitrary nesting