Wire functions through everything, with some unimplemented, and add a basic scoped map.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use internment::ArcIntern;
|
||||
|
||||
use crate::eval::{EvalEnvironment, EvalError, PrimitiveType, Value};
|
||||
use crate::syntax::{ConstantType, Expression, Program, Statement};
|
||||
use crate::syntax::{ConstantType, Expression, Program, Statement, TopLevel};
|
||||
use std::str::FromStr;
|
||||
|
||||
impl Program {
|
||||
@@ -19,16 +19,19 @@ impl Program {
|
||||
let mut env = EvalEnvironment::empty();
|
||||
let mut stdout = String::new();
|
||||
|
||||
for stmt in self.statements.iter() {
|
||||
// at this point, evaluation is pretty simple. just walk through each
|
||||
// statement, in order, and record printouts as we come to them.
|
||||
for stmt in self.items.iter() {
|
||||
match stmt {
|
||||
Statement::Binding(_, name, value) => {
|
||||
TopLevel::Function(_name, _arg_names, _body) => {
|
||||
unimplemented!()
|
||||
}
|
||||
// at this point, evaluation is pretty simple. just walk through each
|
||||
// statement, in order, and record printouts as we come to them.
|
||||
TopLevel::Statement(Statement::Binding(_, name, value)) => {
|
||||
let actual_value = value.eval(&env)?;
|
||||
env = env.extend(name.clone().intern(), actual_value);
|
||||
}
|
||||
|
||||
Statement::Print(_, name) => {
|
||||
TopLevel::Statement(Statement::Print(_, name)) => {
|
||||
let value = env.lookup(name.clone().intern())?;
|
||||
let line = format!("{} = {}\n", name, value);
|
||||
stdout.push_str(&line);
|
||||
|
||||
Reference in New Issue
Block a user