Fix partial strings ending in lists

This commit is contained in:
bakaq
2024-08-16 08:08:05 -03:00
parent 8736526b35
commit c1b88cee99

View File

@@ -227,7 +227,9 @@ impl Value {
Value::List(elems) Value::List(elems)
} }
}, },
_ => Value::Structure(".".into(), vec![head, tail]), _ => {
Value::Structure(".".into(), vec![head, tail])
}
}; };
term_stack.push(list); term_stack.push(list);
} }
@@ -326,11 +328,23 @@ impl Value {
(HeapCellValueTag::PStr, atom) => { (HeapCellValueTag::PStr, atom) => {
let tail = term_stack.pop().unwrap(); let tail = term_stack.pop().unwrap();
if let Value::Atom(atom) = tail { match tail {
Value::Atom(atom) => {
if atom == "[]" { if atom == "[]" {
term_stack.push(Value::String(atom.as_str().to_string())); term_stack.push(Value::String(atom.as_str().to_string()));
} }
} else { },
Value::List(l) => {
let mut list: Vec<Value> = atom
.as_str()
.to_string()
.chars()
.map(|x| Value::Atom(x.to_string()))
.collect();
list.extend(l.into_iter());
term_stack.push(Value::List(list));
},
_ => {
let mut list: Vec<Value> = atom let mut list: Vec<Value> = atom
.as_str() .as_str()
.to_string() .to_string()
@@ -359,6 +373,7 @@ impl Value {
term_stack.push(partial_list); term_stack.push(partial_list);
} }
} }
}
// I dont know if this is needed here. // I dont know if this is needed here.
/* /*
(HeapCellValueTag::PStrLoc, h) => { (HeapCellValueTag::PStrLoc, h) => {