Actually just three programming languages in a trenchcoat
at main 19 lines 513 B view raw
1use trilogy_scanner::{Token, TokenType}; 2 3/// Trait that describes a pattern that can be used to match certain 4/// tokens, similar to [std::str::Pattern][]. 5pub(crate) trait TokenPattern { 6 fn matches(&self, token: &Token) -> bool; 7} 8 9impl TokenPattern for TokenType { 10 fn matches(&self, token: &Token) -> bool { 11 token.token_type == *self 12 } 13} 14 15impl<const N: usize> TokenPattern for [TokenType; N] { 16 fn matches(&self, token: &Token) -> bool { 17 self.contains(&token.token_type) 18 } 19}