aboutsummaryrefslogtreecommitdiffstats
path: root/src/runtime.rs
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2021-11-25 09:28:39 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2021-11-25 09:53:55 +0200
commita4dac3826c0e438e8f9991b0eba9608a6c111048 (patch)
tree004d23195cd25ee7337a023ec2cc09c3ab31bfe3 /src/runtime.rs
parent7f9207d9742c062c2a23ca53aa48420217558e7a (diff)
Add REPL
Diffstat (limited to 'src/runtime.rs')
-rw-r--r--src/runtime.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/runtime.rs b/src/runtime.rs
index 6eff337..07d8a70 100644
--- a/src/runtime.rs
+++ b/src/runtime.rs
@@ -184,6 +184,8 @@ pub fn reduce_term(
}
Term::Builtin(_) => Ok((Rc::clone(&term_rc), 0)),
Term::Lazy(symbol) => {
+ // TODO: alpha conversion
+ // Lift all substituted vs by current v_inc, and then update v_inc to match
if resolve_lazy {
let table_lookup_value = symbol_table
.get(symbol)
@@ -353,10 +355,11 @@ pub type ProcessResult = Result<(Vec<Rc<Term>>, HashMap<String, Rc<Term>>), Stri
pub fn process(
program: &ast::Program,
- initial_symbol_table: Option<HashMap<String, Rc<Term>>>,
+ initial_symbol_table: Option<&mut HashMap<String, Rc<Term>>>,
) -> ProcessResult {
- let mut symbol_table: HashMap<String, Rc<Term>> =
- initial_symbol_table.unwrap_or(HashMap::new());
+ let empty_symbol_table = &mut HashMap::new();
+ let symbol_table: &mut HashMap<String, Rc<Term>> =
+ initial_symbol_table.unwrap_or(empty_symbol_table);
let mut output_terms: Vec<Rc<Term>> = vec![];
@@ -390,5 +393,5 @@ pub fn process(
}
}
- Ok((output_terms, symbol_table))
+ Ok((output_terms, symbol_table.clone()))
}