fn token_type_from_lexeme(&self, lexeme: &str) -> TokenType {
        if lexeme.starts_with('b') && lexeme == "break" {
            return TokenType::BREAK;
        }
        if lexeme.starts_with('c') {
            if lexeme == "case" {
                return TokenType::CASE;
            } else if lexeme == "char" {
                return TokenType::CHAR;
            } else if lexeme == "continue" {
                return TokenType::CONTINUE;
            }
        }
        if lexeme.starts_with('d') && lexeme == "default" {
            return TokenType::DEFAULT;
        }
        if lexeme.starts_with('e') {
            if lexeme == "else" {
                return TokenType::ELSE;
            } else if lexeme == "enum" {
                return TokenType::ENUM;
            }
        }
        if lexeme.starts_with('f') && lexeme == "for" {
            return TokenType::FOR;
        }
        if lexeme.starts_with('i') {
            if lexeme == "int" {
                return TokenType::INT;
            } else if lexeme == "if" {
                return TokenType::IF;
            }
        }
        if lexeme.starts_with('r') && lexeme == "return" {
            return TokenType::RETURN;
        }
        if lexeme.starts_with('s') {
            if lexeme == "struct" {
                return TokenType::STRUCT;
            } else if lexeme == "switch" {
                return TokenType::SWITCH;
            }
        }
        if lexeme.starts_with('v') && lexeme == "void" {
            return TokenType::VOID;
        }
        if lexeme.starts_with('w') && lexeme == "while" {
            return TokenType::WHILE;
        }

        return TokenType::IDENT;
    }
// Distinguish between identifiers and specific token types
// based on a lexeme
Distinguish between identifiers and specific token types
based on a lexeme
Distinguish between identifiers and specific token types based on a lexeme
fn token_type_from_lexeme(&self, lexeme: &str) -> TokenType {
        if lexeme.starts_with('b') && lexeme == "break" {
            return TokenType::BREAK;
        }
        if lexeme.starts_with('c') {
            if lexeme == "case" {
                return TokenType::CASE;
            } else if lexeme == "char" {
                return TokenType::CHAR;
            } else if lexeme == "continue" {
                return TokenType::CONTINUE;
            }
        }
        if lexeme.starts_with('d') && lexeme == "default" {
            return TokenType::DEFAULT;
        }
        if lexeme.starts_with('e') {
            if lexeme == "else" {
                return TokenType::ELSE;
            } else if lexeme == "enum" {
                return TokenType::ENUM;
            }
        }
        if lexeme.starts_with('f') && lexeme == "for" {
            return TokenType::FOR;
        }
        if lexeme.starts_with('i') {
            if lexeme == "int" {
                return TokenType::INT;
            } else if lexeme == "if" {
                return TokenType::IF;
            }
        }
        if lexeme.starts_with('r') && lexeme == "return" {
            return TokenType::RETURN;
        }
        if lexeme.starts_with('s') {
            if lexeme == "struct" {
                return TokenType::STRUCT;
            } else if lexeme == "switch" {
                return TokenType::SWITCH;
            }
        }
        if lexeme.starts_with('v') && lexeme == "void" {
            return TokenType::VOID;
        }
        if lexeme.starts_with('w') && lexeme == "while" {
            return TokenType::WHILE;
        }
        return TokenType::IDENT;
    }
fn token_type_from_lexeme ( & self , lexeme : & str ) -> TokenType { if lexeme . starts_with ( 'b' ) && lexeme == " " { return TokenType :: BREAK ; } if lexeme . starts_with ( 'c' ) { if lexeme == " " { return TokenType :: CASE ; } else if lexeme == " " { return TokenType :: CHAR ; } else if lexeme == " " { return TokenType :: CONTINUE ; } } if lexeme . starts_with ( 'd' ) && lexeme == " " { return TokenType :: DEFAULT ; } if lexeme . starts_with ( 'e' ) { if lexeme == " " { return TokenType :: ELSE ; } else if lexeme == " " { return TokenType :: ENUM ; } } if lexeme . starts_with ( 'f' ) && lexeme == " " { return TokenType :: FOR ; } if lexeme . starts_with ( 'i' ) { if lexeme == " " { return TokenType :: INT ; } else if lexeme == " " { return TokenType :: IF ; } } if lexeme . starts_with ( 'r' ) && lexeme == " " { return TokenType :: RETURN ; } if lexeme . starts_with ( 's' ) { if lexeme == " " { return TokenType :: STRUCT ; } else if lexeme == " " { return TokenType :: SWITCH ; } } if lexeme . starts_with ( 'v' ) && lexeme == " " { return TokenType :: VOID ; } if lexeme . starts_with ( 'w' ) && lexeme == " " { return TokenType :: WHILE ; } return TokenType :: IDENT ; }
Distinguish between identifiers and specific token types
based on a lexeme
Distinguish between identifiers and specific token types based on a lexeme
&self
lexeme
&str