mirror of
https://github.com/PaddiM8/kalker.git
synced 2024-12-13 18:10:42 +01:00
Added ans
variable.
This commit is contained in:
parent
20f15619a2
commit
b87b2d10bc
@ -26,6 +26,15 @@ impl<'a> Context<'a> {
|
||||
for (i, stmt) in statements.iter().enumerate() {
|
||||
let value = eval_stmt(self, stmt);
|
||||
|
||||
// Insert the last value into the `ans` variable.
|
||||
self.symbol_table.set(
|
||||
"ans",
|
||||
Stmt::VarDecl(
|
||||
String::from("ans"),
|
||||
Box::new(Expr::Literal(value.clone()?.to_string())),
|
||||
),
|
||||
);
|
||||
|
||||
if i == statements.len() - 1 {
|
||||
if let Stmt::Expr(_) = stmt {
|
||||
return Ok(Some(value?));
|
||||
|
Loading…
Reference in New Issue
Block a user