Remove debug stuff

This commit is contained in:
Apache 2024-06-12 19:46:08 -05:00
parent ec48ff8852
commit 10a6a52c04
Signed by: apache
GPG key ID: 6B10F3EAF14F4C77
5 changed files with 40 additions and 5 deletions

View file

@ -40,6 +40,39 @@ impl LispState {
}
});
add_function(&mut table, "sub", |x| {
if x.len() != 2 {
return vec![LispValue::Nil]
}
if let (LispValue::Integer(lhs), LispValue::Integer(rhs)) = (&x[0], &x[1]) {
return vec![LispValue::Integer(lhs - rhs)];
}
vec![LispValue::Nil]
});
add_function(&mut table, "mul", |x| {
if x.len() != 2 {
return vec![LispValue::Nil]
}
if let (LispValue::Integer(lhs), LispValue::Integer(rhs)) = (&x[0], &x[1]) {
return vec![LispValue::Integer(lhs * rhs)];
}
vec![LispValue::Nil]
});
add_function(&mut table, "div", |x| {
if x.len() != 2 {
return vec![LispValue::Nil]
}
if let (LispValue::Integer(lhs), LispValue::Integer(rhs)) = (&x[0], &x[1]) {
return vec![LispValue::Integer(lhs / rhs)];
}
vec![LispValue::Nil]
});
LispState {
table
}

View file

@ -17,7 +17,6 @@ fn main() {
Vec::new()
}
};
println!("{:?}", tokens);
let instructions = parse(tokens);
let state = LispState::new();

View file

@ -112,7 +112,6 @@ fn parse_exp(tokens: Vec<Token>) -> Vec<OpCode> {
Token::CloseParen => {
panic!("Unexpected closing parenthesis");
},
_ => todo!()
}
i += 1;

View file

@ -1,3 +1,3 @@
; This is a comment
(print (add 1333 12423))
(print (add 1 (mul (div 16 2) (mul 13 2))))

View file

@ -107,7 +107,9 @@ impl Tokenizer {
tokens.push(Token::Integer(self.storage.iter().collect::<String>().parse().unwrap()));
self.storage.clear();
} else {
self.storage.push(char);
if char != '_' {
self.storage.push(char);
}
continue;
}
}
@ -166,7 +168,9 @@ impl Tokenizer {
} else if c.is_numeric() || c == '_' {
self.reading_num = true;
self.storage.clear();
self.storage.push(c);
if c != '_' {
self.storage.push(c);
}
continue;
}
}