Added Function Tables
- Ftable struct - CallFunction procedure - Refactors to Cell, Ctr (consequently to lex too) - More recursive routines in Cell
This commit is contained in:
parent
bcb32b19d4
commit
af28692175
4 changed files with 267 additions and 50 deletions
20
src/lex.rs
20
src/lex.rs
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
|
||||
use std::boxed::Box;
|
||||
use crate::cell::{Ctr, append, Cell};
|
||||
use crate::cell::{Ctr, Cell};
|
||||
|
||||
const UNMATCHED_STR_DELIM: &str = "Unmatched string delimiter in input";
|
||||
const UNMATCHED_LIST_DELIM: &str = "Unmatched list delimiter in input";
|
||||
|
|
@ -161,24 +161,24 @@ fn process(document: String) -> Result<Box<Cell>, String> {
|
|||
let mut obj;
|
||||
if token.len() > 0 {
|
||||
if is_str {
|
||||
obj = Ctr::STRING(token);
|
||||
obj = Ctr::String(token);
|
||||
is_str = false;
|
||||
} else if token == "true" {
|
||||
obj = Ctr::BOOL(true);
|
||||
obj = Ctr::Bool(true);
|
||||
} else if token == "false" {
|
||||
obj = Ctr::BOOL(false);
|
||||
obj = Ctr::Bool(false);
|
||||
} else if let Ok(i) = token.parse::<i128>() {
|
||||
obj = Ctr::INTEGER(i);
|
||||
obj = Ctr::Integer(i);
|
||||
} else if let Ok(f) = token.parse::<f64>() {
|
||||
obj = Ctr::FLOAT(f);
|
||||
obj = Ctr::Float(f);
|
||||
} else if let Some(s) = tok_is_symbol(&token) {
|
||||
obj = Ctr::SYMBOL(s);
|
||||
obj = Ctr::Symbol(s);
|
||||
} else {
|
||||
return Err(format!("Unparsable token:{}", token));
|
||||
}
|
||||
|
||||
token = String::new();
|
||||
append(&mut current_cell_ref, obj);
|
||||
current_cell_ref.append(obj);
|
||||
}
|
||||
|
||||
if alloc_list {
|
||||
|
|
@ -188,9 +188,9 @@ fn process(document: String) -> Result<Box<Cell>, String> {
|
|||
}
|
||||
|
||||
// shortening this will lead to naught but pain
|
||||
obj = Ctr::CELL(Box::new(*current_cell_ref));
|
||||
obj = Ctr::Cell(Box::new(*current_cell_ref));
|
||||
current_cell_ref = ref_stack.pop().unwrap();
|
||||
append(&mut current_cell_ref, obj);
|
||||
current_cell_ref.append(obj);
|
||||
}
|
||||
|
||||
ref_stack.push(current_cell_ref);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue