diff --git a/rottlib/src/lexer/lexing.rs b/rottlib/src/lexer/lexing.rs index 08ac024..2cf4628 100644 --- a/rottlib/src/lexer/lexing.rs +++ b/rottlib/src/lexer/lexing.rs @@ -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