WIP Commit for stackoverflow
This commit is contained in:
parent
a967ac5c3e
commit
4cadb1a7eb
3 changed files with 47 additions and 39 deletions
|
|
@ -14,6 +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/>.
|
||||||
*/
|
*/
|
||||||
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
use rustyline::error::ReadlineError;
|
use rustyline::error::ReadlineError;
|
||||||
use rustyline::Editor;
|
use rustyline::Editor;
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@
|
||||||
* 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)]
|
||||||
|
|
||||||
mod segment;
|
mod segment;
|
||||||
mod lex;
|
mod lex;
|
||||||
mod func;
|
mod func;
|
||||||
|
|
|
||||||
13
src/vars.rs
13
src/vars.rs
|
|
@ -21,7 +21,7 @@ use std::collections::HashMap;
|
||||||
use std::env;
|
use std::env;
|
||||||
use crate::segment::{Ctr, Ast, ast_to_string};
|
use crate::segment::{Ctr, Ast, ast_to_string};
|
||||||
use crate::eval::eval;
|
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
|
/* Mapping between a string token and a tree of Segments
|
||||||
* The string token can be found in any Ctr::Symbol value
|
* The string token can be found in any Ctr::Symbol value
|
||||||
* it is expected that the trees stored are already evaluated
|
* 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,
|
loose_syms: true,
|
||||||
eval_lazy: true,
|
eval_lazy: true,
|
||||||
args: Args::Lazy(2),
|
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 {
|
|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 {
|
||||||
|
|
@ -81,6 +85,9 @@ pub fn get_export(env_cfg: bool) -> Function {
|
||||||
|
|
||||||
Ctr::None => {
|
Ctr::None => {
|
||||||
(*b).borrow_mut().remove(identifier);
|
(*b).borrow_mut().remove(identifier);
|
||||||
|
if env_cfg {
|
||||||
|
// TODO: unset variable
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => eprintln!("args not in standard form")
|
_ => eprintln!("args not in standard form")
|
||||||
|
|
@ -92,6 +99,4 @@ pub fn get_export(env_cfg: bool) -> Function {
|
||||||
|
|
||||||
return Ctr::None;
|
return Ctr::None;
|
||||||
}
|
}
|
||||||
)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue