extend the interpreter

This commit is contained in:
YannAhlgrim
2026-05-12 18:27:35 +02:00
parent 5fc4d355a8
commit 60f0d1cadc
3 changed files with 73 additions and 3 deletions
+18
View File
@@ -12,6 +12,12 @@ pub const IDENT: &str = "IDENT";
pub const INT: &str = "INT";
pub const ASSIGN: &str = "=";
pub const PLUS: &str = "+";
pub const MINUS: &str = "-";
pub const BANG: &str = "!";
pub const ASTERISK: &str = "*";
pub const SLASH: &str = "/";
pub const LT: &str = "<";
pub const GT: &str = ">";
pub const COMMA: &str = ",";
pub const SEMICOLON: &str = ";";
pub const LPAREN: &str = "(";
@@ -20,11 +26,23 @@ pub const LBRACE: &str = "{";
pub const RBRACE: &str = "}";
pub const FUNCTION: &str = "FUNCTION";
pub const LET: &str = "LET";
pub const TRUE: &str = "TRUE";
pub const FALSE: &str = "FALSE";
pub const IF: &str = "IF";
pub const ELSE: &str = "ELSE";
pub const RETURN: &str = "RETURN";
pub const EQ: &str = "EQ";
pub const NQ: &str = "NQ";
pub fn lookup_ident(ident: &str) -> &'static str {
match ident {
"fn" => FUNCTION,
"let" => LET,
"true" => TRUE,
"false" => FALSE,
"if" => IF,
"else" => ELSE,
"return" => RETURN,
_ => IDENT,
}
}