Add method for checking whether token can be type
This commit is contained in:
parent
41672a7125
commit
2a31ed08b8
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user