2025-02-06 18:55:54 +01:00
|
|
|
use crate::token::TokenType::{self, *};
|
|
|
|
use lazy_static::lazy_static;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
lazy_static! {
|
2025-02-07 09:21:23 +01:00
|
|
|
/// Mapping of reserved keywords to their respective TokenType.
|
2025-02-06 18:55:54 +01:00
|
|
|
pub static ref KEYWORDS: HashMap<std::string::String, TokenType> = {
|
|
|
|
let mut m = HashMap::new();
|
|
|
|
m.insert("and".into(), And);
|
|
|
|
m.insert("class".into(), Class);
|
|
|
|
m.insert("else".into(), Else);
|
|
|
|
m.insert("false".into(), False);
|
|
|
|
m.insert("for".into(), For);
|
|
|
|
m.insert("fun".into(), Fun);
|
|
|
|
m.insert("if".into(), If);
|
|
|
|
m.insert("nil".into(), Nil);
|
|
|
|
m.insert("or".into(), Or);
|
|
|
|
m.insert("print".into(), Print);
|
|
|
|
m.insert("return".into(), Return);
|
|
|
|
m.insert("super".into(), Super);
|
|
|
|
m.insert("true".into(), True);
|
|
|
|
m.insert("var".into(), Var);
|
|
|
|
m.insert("while".into(), While);
|
|
|
|
m
|
|
|
|
};
|
|
|
|
}
|