WIP: testing closure types

This commit is contained in:
Aidan Hahn 2021-12-31 11:00:13 -08:00
parent 4cadb1a7eb
commit 69f31db23b
No known key found for this signature in database
GPG key ID: 327711E983899316
7 changed files with 24 additions and 20 deletions

View file

@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
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 {
}
)
};
}
}*/

View file

@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#![feature(type_alias_impl_trait)]
use rustyline::error::ReadlineError;
use rustyline::Editor;

View file

@ -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<RefCell<VTable>>, _: Rc<RefCell<FTable>>| -> Ctr {
print!("λ ");
return Ctr::None;
}
}*/
pub fn configure(filename: String, vars: Rc<RefCell<VTable>>, mut funcs: Rc<RefCell<FTable>>) {
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<RefCell<VTable>>, mut funcs: Rc<RefC
Err(s) => 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<RefCell<VTable>>, _: Rc<RefCell<FTable>>| -> Ctr {
print!("λ ");
return Ctr::None;
}
)
})));
function: Operation::Internal(get_prompt_default())
})));*/
match fs::read_to_string(filename) {
Err(s) => {

View file

@ -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};
}

View file

@ -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<RefCell<VTable>>) -> Result<Rc<RefCell<FTable>>, 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<RefCell<VTable>>) -> Result<Rc<RefCell<FTable>>, 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")) {

View file

@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
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 {
)
};
}
*/

View file

@ -50,7 +50,7 @@ pub fn get_export(env_cfg: bool) -> Function {
}
fn get_export_callback(env_cfg: bool) -> InternalOperation {
|a: Ast, b: Rc<RefCell<VTable>>, c: Rc<RefCell<FTable>>| -> Ctr {
InternalOperation(|a: Ast, b: Rc<RefCell<VTable>>, c: Rc<RefCell<FTable>>| -> 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;
}
})
}