Skip to content

Commit

Permalink
Refactor token_type.rs: removed unused code and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DaviRain-Su committed Oct 23, 2023
1 parent be3e981 commit a52454a
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/token/token_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub enum TokenType {
/// "String"
STRING,

// 运算符
/// =
ASSIGN,
/// +
Expand All @@ -40,7 +39,6 @@ pub enum TokenType {
/// !=
NOTEQ,

// 分隔符
/// ,
COMMA,
/// ;
Expand All @@ -61,7 +59,6 @@ pub enum TokenType {
/// ]
RBRACKET,

// 关键字
/// fn
FUNCTION,
/// let
Expand Down Expand Up @@ -130,17 +127,13 @@ lazy_static! {
};
}

/// LookupIdent 通过检查关键字表来判断给定的标识符是否是关键字。如果是,则
/// 返回关键字的 TokenType 常量。如果不是,则返回 token.IDENT,这个 TokenType 表
/// 示当前是用户定义的标识符。
pub fn lookup_ident(ident: &str) -> TokenType {
match KEYWORDS.get(ident) {
Some(value) => value.clone(),
None => TokenType::IDENT,
}
}

// +-/*<>;(),:{}[]=!
pub fn lookup_char(ch: char) -> TokenType {
match ch {
'/' => TokenType::SLASH,
Expand Down

0 comments on commit a52454a

Please sign in to comment.