From a4dac3826c0e438e8f9991b0eba9608a6c111048 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Thu, 25 Nov 2021 09:28:39 +0200 Subject: Add REPL --- src/runtime.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/runtime.rs') 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>, HashMap>), Stri pub fn process( program: &ast::Program, - initial_symbol_table: Option>>, + initial_symbol_table: Option<&mut HashMap>>, ) -> ProcessResult { - let mut symbol_table: HashMap> = - initial_symbol_table.unwrap_or(HashMap::new()); + let empty_symbol_table = &mut HashMap::new(); + let symbol_table: &mut HashMap> = + initial_symbol_table.unwrap_or(empty_symbol_table); let mut output_terms: Vec> = vec![]; @@ -390,5 +393,5 @@ pub fn process( } } - Ok((output_terms, symbol_table)) + Ok((output_terms, symbol_table.clone())) } -- cgit v1.3