WIP: testing closure types
This commit is contained in:
parent
4cadb1a7eb
commit
69f31db23b
7 changed files with 24 additions and 20 deletions
|
|
@ -14,7 +14,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
use crate::func::{FTable, Function, Args, Operation};
|
use crate::func::{FTable, Function, Args, Operation};
|
||||||
use crate::vars::{VTable};
|
use crate::vars::{VTable};
|
||||||
use crate::segment::{Ctr, Ast, circuit, list_idx, list_append, new_ast};
|
use crate::segment::{Ctr, Ast, circuit, list_idx, list_append, new_ast};
|
||||||
|
|
@ -65,4 +65,4 @@ pub fn get_append() -> Function {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
}
|
}*/
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#![feature(type_alias_impl_trait)]
|
|
||||||
|
|
||||||
use rustyline::error::ReadlineError;
|
use rustyline::error::ReadlineError;
|
||||||
use rustyline::Editor;
|
use rustyline::Editor;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use crate::vars::{VTable, define};
|
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::segment::{Ast, Ctr};
|
||||||
use crate::lex::lex;
|
use crate::lex::lex;
|
||||||
use crate::eval::eval;
|
use crate::eval::eval;
|
||||||
|
|
@ -25,6 +25,14 @@ use std::rc::Rc;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::fs;
|
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>>) {
|
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_POSIX"), Rc::new(Ctr::String(String::from("0"))));
|
||||||
define(vars.clone(), String::from("CFG_RELISH_ENV"), Rc::new(Ctr::String(String::from("1"))));
|
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)
|
Err(s) => println!("{}", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func_declare(funcs.clone(), Rc::new(RefCell::new(Function{
|
func_declare(funcs.clone(), Rc::new(RefCell::new(Function{
|
||||||
name: String::from("CFG_RELISH_PROMPT"),
|
name: String::from("CFG_RELISH_PROMPT"),
|
||||||
loose_syms: false,
|
loose_syms: false,
|
||||||
eval_lazy: false,
|
eval_lazy: false,
|
||||||
args: Args::Lazy(0),
|
args: Args::Lazy(0),
|
||||||
function: Operation::Internal(
|
function: Operation::Internal(get_prompt_default())
|
||||||
|_: Ast, _: Rc<RefCell<VTable>>, _: Rc<RefCell<FTable>>| -> Ctr {
|
})));*/
|
||||||
print!("λ ");
|
|
||||||
return Ctr::None;
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})));
|
|
||||||
|
|
||||||
match fs::read_to_string(filename) {
|
match fs::read_to_string(filename) {
|
||||||
Err(s) => {
|
Err(s) => {
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ pub mod ast {
|
||||||
|
|
||||||
pub mod stdlib {
|
pub mod stdlib {
|
||||||
pub use crate::stl::{get_stdlib};
|
pub use crate::stl::{get_stdlib};
|
||||||
pub use crate::str::{get_echo, get_concat};
|
// pub use crate::str::{get_echo, get_concat};
|
||||||
pub use crate::append::{get_append};
|
// pub use crate::append::{get_append};
|
||||||
pub use crate::vars::{get_export};
|
pub use crate::vars::{get_export};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use crate::segment::{Ctr};
|
use crate::segment::{Ctr};
|
||||||
use crate::str::{get_echo, get_concat};
|
//use crate::str::{get_echo, get_concat};
|
||||||
use crate::append::get_append;
|
//use crate::append::get_append;
|
||||||
use crate::func::{FTable, func_declare};
|
use crate::func::{FTable, func_declare};
|
||||||
use crate::vars::{VTable, get_export};
|
use crate::vars::{VTable, get_export};
|
||||||
use std::rc::Rc;
|
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> {
|
pub fn get_stdlib(conf: Rc<RefCell<VTable>>) -> Result<Rc<RefCell<FTable>>, String> {
|
||||||
let ft = Rc::new(RefCell::new(FTable::new()));
|
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)
|
return Err(s)
|
||||||
}
|
}
|
||||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(get_append()))) {
|
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()))) {
|
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(get_concat()))) {
|
||||||
return Err(s)
|
return Err(s)
|
||||||
}
|
}*/
|
||||||
|
|
||||||
let mut cfg_env = true;
|
let mut cfg_env = true;
|
||||||
match conf.borrow().get(&String::from("CFG_RELISH_ENV")) {
|
match conf.borrow().get(&String::from("CFG_RELISH_ENV")) {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
use crate::func::{FTable, Function, Args, Operation};
|
use crate::func::{FTable, Function, Args, Operation};
|
||||||
use crate::vars::{VTable};
|
use crate::vars::{VTable};
|
||||||
use crate::segment::{Ctr, Ast, circuit, ast_as_string};
|
use crate::segment::{Ctr, Ast, circuit, ast_as_string};
|
||||||
|
|
@ -83,3 +83,4 @@ pub fn get_concat() -> Function {
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ pub fn get_export(env_cfg: bool) -> Function {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_export_callback(env_cfg: bool) -> InternalOperation {
|
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();
|
let inner = a.borrow_mut();
|
||||||
match &inner.car {
|
match &inner.car {
|
||||||
Ctr::Symbol(identifier) => {
|
Ctr::Symbol(identifier) => {
|
||||||
|
|
@ -98,5 +98,5 @@ fn get_export_callback(env_cfg: bool) -> InternalOperation {
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ctr::None;
|
return Ctr::None;
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue