2025-04-07 15:40:38 +03:00
|
|
|
use super::runtime::*;
|
|
|
|
|
use super::parser::*;
|
|
|
|
|
use std::error::Error;
|
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
|
|
fn cat_vec(arr: Vec<String>) -> String {
|
|
|
|
|
let total_len: usize = arr.iter().map(|s| { s.len() }).sum();
|
|
|
|
|
arr.into_iter().fold(String::with_capacity(total_len), |mut acc, p| { acc.push_str(p.as_str()); acc })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function is supposed to compile all elements in one particular file */
|
|
|
|
|
pub fn plemege_to_value(mut x: Plemege, file_path: &str) -> Result<Value, Box<dyn Error>> {
|
|
|
|
|
match x {
|
|
|
|
|
Plemege::Package(map) => {
|
|
|
|
|
let mut new_dict: HashMap<String, Value> = HashMap::new();
|
|
|
|
|
for (key, thing) in map {
|
|
|
|
|
new_dict.insert(key, plemege_to_value(thing, file_path)?);
|
|
|
|
|
}
|
2025-04-08 01:46:36 +03:00
|
|
|
Ok(Value::Dict(new_dict))
|
2025-04-07 15:40:38 +03:00
|
|
|
},
|
|
|
|
|
Plemege::Element(el) => {
|
2025-04-08 01:46:36 +03:00
|
|
|
// Rc::new(|d_state: &DebugState, _: &Value, _: &Value, args: &[&Value]|)
|
2025-04-07 15:40:38 +03:00
|
|
|
// todo
|
|
|
|
|
Ok(Value::default())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|