new fixes for lexing process, tests to go with them

This commit is contained in:
Aidan Hahn 2021-09-18 16:48:24 -07:00
parent 5ed8a054d3
commit 72598c2168
No known key found for this signature in database
GPG key ID: 327711E983899316
3 changed files with 43 additions and 9 deletions

View file

@ -111,6 +111,11 @@ fn process(document: String) -> Result<Ast, String> {
match c {
// add a new Seg reference to the stack
'(' => {
if is_str {
token.push(c);
continue
}
if token != "" {
return Err("list started in middle of another token".to_string());
}
@ -135,7 +140,7 @@ fn process(document: String) -> Result<Ast, String> {
}
// add to token
_ => {
token.push(c)
token.push(c);
}
}
@ -149,11 +154,13 @@ fn process(document: String) -> Result<Ast, String> {
let mut current_seg_ref = ref_stack.pop().unwrap();
let mut obj;
if token.len() > 0 {
if is_str {
obj = Ctr::String(token);
is_str = false;
} else if token == "true" {
if is_str {
obj = Ctr::String(token);
is_str = false;
token = String::new();
list_append(current_seg_ref.clone(), obj);
} else if token.len() > 0 {
if token == "true" {
obj = Ctr::Bool(true);
} else if token == "false" {
obj = Ctr::Bool(false);

View file

@ -41,14 +41,13 @@ pub fn get_echo() -> Function {
Ctr::Seg(c) => string.push_str(ast_as_string(c.clone(), true).as_str()),
Ctr::None => ()
}
string.push_str(" ");
return true;
}) {
// TODO: use custom logger
println!("Echo failure!")
}
return Ctr::String(string);
return Ctr::String(string);
}
)
};