removed some unneeded debug, shunting yard boilerplate

This commit is contained in:
Christoph J. Scherr 2023-02-13 22:16:42 +01:00
parent 55c3e142b7
commit 09c2f91ce3
3 changed files with 15 additions and 23 deletions

View File

@ -149,24 +149,12 @@ fn find_brace_groups(haystack: String) -> Vec<Vec<(usize, usize)>> {
for (index, char) in haystack.chars().enumerate() {
match char {
'(' => {
#[cfg(debug_assertions)]
{
dbg!(char);
dbg!(index);
}
parenthesis_group.push((index, 0));
parenthesis_open = parenthesis_open + 1;
parenthesis_last_opened.push(parenthesis_open_processed);
parenthesis_open_processed = parenthesis_open_processed + 1;
},
')' => {
#[cfg(debug_assertions)]
{
dbg!(char);
dbg!(index);
dbg!(parenthesis_last_opened.len());
dbg!(parenthesis_last_opened[parenthesis_last_opened.len() - 1]);
}
parenthesis_group[parenthesis_last_opened[parenthesis_last_opened.len() - 1]].1 = index;
parenthesis_open = parenthesis_open - 1;
parenthesis_closed_processed = parenthesis_closed_processed + 1;
@ -241,7 +229,6 @@ impl Expression {
task = Task::new(task_text_full.as_str(), "");
}
let child_full_text = task_text_full + "(" + text + ")";
dbg!(&child_full_text);
let child = Expression::new(text.to_string(), child_full_text, task, depth+1);
children.push(child);
}
@ -254,12 +241,10 @@ impl Expression {
full_text: normalize_string(expression_full_text),
task: task,
complex: false,
outer_value: Some(0.0),
outer_value: None,
children: children,
depth: depth,
};
#[cfg(debug_assertions)]
dbg!(&expression);
expression
}
@ -283,14 +268,17 @@ impl Expression {
* another developers shunting yard algorithm or implement it by myself.
*/
// TODO check if we have any unknown values.
// iterate through children, substitute childrens text with childrens results (as string
// slice).
for child in self.children {
dbg!(normalized_text.replace(child.full_text.as_str(), "0"/* debug only */));
normalized_text = normalized_text.replace(child.full_text.as_str(), "0");
normalized_text = normalized_text.replace(child.full_text.clone().as_str(), child.process().as_str());
}
todo!();
// TODO Shunting yards algorithm, as we now have only calculatable values left.
// Implement this as public module in shunting_yard.rs
// self.result = MYRESULT
return "RESULT_STILL_NOT_IMPLEMENTED".to_string();
}
// wrapper for normalize_string()

View File

@ -48,8 +48,12 @@ fn main() {
for expression_text in expression_texts_concat {
expression_vec.push(Expression::new(expression_text.clone(), expression_text, Task::None, 0));
}
#[cfg(debug_assertions)]
{
dbg!(&expression_vec);
}
for expression in expression_vec {
expression.process();
println!("{}", expression.process());
}
}

0
src/shunting_yard.rs Normal file
View File