extend the interpreter
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user