WIP Commit for stackoverflow

This commit is contained in:
Aidan Hahn 2021-12-30 21:14:24 -08:00
parent a967ac5c3e
commit 4cadb1a7eb
No known key found for this signature in database
GPG key ID: 327711E983899316
3 changed files with 47 additions and 39 deletions

View file

@ -14,6 +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/>.
*/
#![feature(type_alias_impl_trait)]
use rustyline::error::ReadlineError;
use rustyline::Editor;

View file

@ -15,6 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#![feature(type_alias_impl_trait)]
mod segment;
mod lex;
mod func;

View file

@ -21,7 +21,7 @@ use std::collections::HashMap;
use std::env;
use crate::segment::{Ctr, Ast, ast_to_string};
use crate::eval::eval;
use crate::func::{Function, Operation, Args, FTable};
use crate::func::{Function, Operation, InternalOperation, Args, FTable};
/* Mapping between a string token and a tree of Segments
* The string token can be found in any Ctr::Symbol value
* it is expected that the trees stored are already evaluated
@ -45,7 +45,11 @@ pub fn get_export(env_cfg: bool) -> Function {
loose_syms: true,
eval_lazy: true,
args: Args::Lazy(2),
function: Operation::Internal(
function: Operation::Internal(get_export_callback(env_cfg)),
};
}
fn get_export_callback(env_cfg: bool) -> InternalOperation {
|a: Ast, b: Rc<RefCell<VTable>>, c: Rc<RefCell<FTable>>| -> Ctr {
let inner = a.borrow_mut();
match &inner.car {
@ -81,6 +85,9 @@ pub fn get_export(env_cfg: bool) -> Function {
Ctr::None => {
(*b).borrow_mut().remove(identifier);
if env_cfg {
// TODO: unset variable
}
},
_ => eprintln!("args not in standard form")
@ -92,6 +99,4 @@ pub fn get_export(env_cfg: bool) -> Function {
return Ctr::None;
}
)
};
}