vyre 0.4.0

GPU compute intermediate representation with a standard operation library
Documentation
use super::Token;

pub fn parse(pattern: &[u8]) -> Vec<Token> {
    let mut tokens = Vec::with_capacity(pattern.len());
    let mut index = 0usize;
    while index < pattern.len() {
        match pattern[index] {
            b'\\' if index + 1 < pattern.len() => {
                tokens.push(Token::Literal(pattern[index + 1]));
                index += 2;
            }
            b'?' => {
                tokens.push(Token::Any);
                index += 1;
            }
            b'*' => {
                if !matches!(tokens.last(), Some(Token::Star)) {
                    tokens.push(Token::Star);
                }
                index += 1;
            }
            byte => {
                tokens.push(Token::Literal(byte));
                index += 1;
            }
        }
    }
    tokens
}