Fix stringifier

This commit is contained in:
Felipe g 2022-08-19 13:20:18 -03:00
parent acab6d95b8
commit 5c07dd97e8

View File

@ -1893,9 +1893,14 @@ pub fn interpret_as_string(term: &Term) -> Option<String> {
if let Term::Ctr { name, args, .. } = term {
if name == "String.cons" && args.len() == 2 {
if let Term::Num { numb, .. } = *args[0] {
let chr = ascii::escape_default(numb as u8).to_string();
text.push_str(&chr);
term = &*args[1];
// TODO: In the future we will just have to push the str to the text
// if the parser accepts escaped chars.
if ascii::escape_default(numb as u8).count() > 1 {
return None
} else {
text.push(char::from_u32(numb as u32).unwrap_or('\0'));
term = &*args[1];
}
} else {
return None;
}