in progress commit

- added vars to lib
- fixed adders and getters to both vtable and ftable
- made function operations a dual type (enum)
- prototyped calling of stored external ASTs with
arguments (additional operation type
- stub for eval
- added index function to Cell
This commit is contained in:
Aidan 2021-02-14 16:33:17 -08:00
parent 61e3985592
commit d2f60314f9
No known key found for this signature in database
GPG key ID: 327711E983899316
6 changed files with 162 additions and 54 deletions

View file

@ -17,7 +17,7 @@
use std::boxed::Box;
use std::collections::HashMap;
use crate::cell::{Ctr, Cell};
use crate::cell::{Ctr};
/* Mapping between a string token and a tree of Cells
* The string token can be found in any Ctr::Symbol value
@ -25,23 +25,25 @@ use crate::cell::{Ctr, Cell};
* Considerations: should I use a structure of cells for this?
* Current thoughts: if this was a language without proper data types, yes.
*/
pub type VTable = HashMap<String, Cell>;
pub type VTable = HashMap<String, Box<Ctr>>;
impl VTable {
pub fn define(
&mut self,
identifier: String,
var_tree: Box<Cell>
) {
if let Some(boxed_cell) = self.insert(identifier, var_tree) {
drop(boxed_cell);
}
}
pub fn get(
&self,
identifier: String
) -> Option<Box<Cell>> {
self.get(identifier)
pub fn define(
vt: Box<VTable>,
identifier: String,
var_tree: Box<Ctr>
) {
if let Some(boxed_cell) = vt.insert(identifier, var_tree) {
drop(boxed_cell);
}
}
pub fn get(
vt: Box<VTable>,
identifier: String
) -> Option<Box<Ctr>> {
if let Some(c) = vt.get(&identifier) {
Some(*c)
} else {
None
}
}