From 69f31db23b65d337e1bd00f9d48b6333439607f8 Mon Sep 17 00:00:00 2001 From: Aidan Hahn Date: Fri, 31 Dec 2021 11:00:13 -0800 Subject: [PATCH] WIP: testing closure types --- src/append.rs | 4 ++-- src/bin/main.rs | 1 - src/config.rs | 20 ++++++++++++-------- src/lib.rs | 4 ++-- src/stl.rs | 8 ++++---- src/str.rs | 3 ++- src/vars.rs | 4 ++-- 7 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/append.rs b/src/append.rs index 7a6c01d..415cf05 100644 --- a/src/append.rs +++ b/src/append.rs @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - +/* use crate::func::{FTable, Function, Args, Operation}; use crate::vars::{VTable}; use crate::segment::{Ctr, Ast, circuit, list_idx, list_append, new_ast}; @@ -65,4 +65,4 @@ pub fn get_append() -> Function { } ) }; -} +}*/ diff --git a/src/bin/main.rs b/src/bin/main.rs index 908da89..d2a5faa 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#![feature(type_alias_impl_trait)] use rustyline::error::ReadlineError; use rustyline::Editor; diff --git a/src/config.rs b/src/config.rs index ec066de..1a0a67e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -16,7 +16,7 @@ */ use crate::vars::{VTable, define}; -use crate::func::{FTable, Args, Function, Operation, func_declare}; +use crate::func::{FTable, Args, Function, Operation, InternalOperation, func_declare}; use crate::segment::{Ast, Ctr}; use crate::lex::lex; use crate::eval::eval; @@ -25,6 +25,14 @@ use std::rc::Rc; use std::cell::RefCell; use std::fs; +/* +fn get_prompt_default() -> InternalOperation { + |_: Ast, _: Rc>, _: Rc>| -> Ctr { + print!("λ "); + return Ctr::None; + } +}*/ + pub fn configure(filename: String, vars: Rc>, mut funcs: Rc>) { define(vars.clone(), String::from("CFG_RELISH_POSIX"), Rc::new(Ctr::String(String::from("0")))); define(vars.clone(), String::from("CFG_RELISH_ENV"), Rc::new(Ctr::String(String::from("1")))); @@ -34,18 +42,14 @@ pub fn configure(filename: String, vars: Rc>, mut funcs: Rc println!("{}", s) } + /* func_declare(funcs.clone(), Rc::new(RefCell::new(Function{ name: String::from("CFG_RELISH_PROMPT"), loose_syms: false, eval_lazy: false, args: Args::Lazy(0), - function: Operation::Internal( - |_: Ast, _: Rc>, _: Rc>| -> Ctr { - print!("λ "); - return Ctr::None; - } - ) - }))); + function: Operation::Internal(get_prompt_default()) + })));*/ match fs::read_to_string(filename) { Err(s) => { diff --git a/src/lib.rs b/src/lib.rs index f1b6570..8afda30 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,8 +39,8 @@ pub mod ast { pub mod stdlib { pub use crate::stl::{get_stdlib}; - pub use crate::str::{get_echo, get_concat}; - pub use crate::append::{get_append}; +// pub use crate::str::{get_echo, get_concat}; +// pub use crate::append::{get_append}; pub use crate::vars::{get_export}; } diff --git a/src/stl.rs b/src/stl.rs index b03eb9d..64450eb 100644 --- a/src/stl.rs +++ b/src/stl.rs @@ -16,8 +16,8 @@ */ use crate::segment::{Ctr}; -use crate::str::{get_echo, get_concat}; -use crate::append::get_append; +//use crate::str::{get_echo, get_concat}; +//use crate::append::get_append; use crate::func::{FTable, func_declare}; use crate::vars::{VTable, get_export}; use std::rc::Rc; @@ -25,7 +25,7 @@ use std::cell::RefCell; pub fn get_stdlib(conf: Rc>) -> Result>, String> { let ft = Rc::new(RefCell::new(FTable::new())); - if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(get_echo()))) { + /* if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(get_echo()))) { return Err(s) } if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(get_append()))) { @@ -33,7 +33,7 @@ pub fn get_stdlib(conf: Rc>) -> Result>, Stri } if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(get_concat()))) { return Err(s) - } + }*/ let mut cfg_env = true; match conf.borrow().get(&String::from("CFG_RELISH_ENV")) { diff --git a/src/str.rs b/src/str.rs index cf0bb09..19eb6bf 100644 --- a/src/str.rs +++ b/src/str.rs @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - +/* use crate::func::{FTable, Function, Args, Operation}; use crate::vars::{VTable}; use crate::segment::{Ctr, Ast, circuit, ast_as_string}; @@ -83,3 +83,4 @@ pub fn get_concat() -> Function { ) }; } +*/ diff --git a/src/vars.rs b/src/vars.rs index 0500ee3..cc5d8dd 100644 --- a/src/vars.rs +++ b/src/vars.rs @@ -50,7 +50,7 @@ pub fn get_export(env_cfg: bool) -> Function { } fn get_export_callback(env_cfg: bool) -> InternalOperation { - |a: Ast, b: Rc>, c: Rc>| -> Ctr { + InternalOperation(|a: Ast, b: Rc>, c: Rc>| -> Ctr { let inner = a.borrow_mut(); match &inner.car { Ctr::Symbol(identifier) => { @@ -98,5 +98,5 @@ fn get_export_callback(env_cfg: bool) -> InternalOperation { } return Ctr::None; - } + }) }