Remove debug output

This commit is contained in:
Sebastian Schmidt 2019-05-04 13:43:05 +02:00
parent 6a9d6b97df
commit 2ca7209d22

View File

@ -367,7 +367,7 @@ impl Node {
} }
fn insert_back_prioritized(&mut self, node: Node, is_root_node: bool) -> EvalexprResult<()> { fn insert_back_prioritized(&mut self, node: Node, is_root_node: bool) -> EvalexprResult<()> {
println!("Inserting {:?} into {:?}", node.operator, self.operator()); // println!("Inserting {:?} into {:?}", node.operator, self.operator());
if self.operator().precedence() < node.operator().precedence() || is_root_node if self.operator().precedence() < node.operator().precedence() || is_root_node
// Right-to-left chaining // Right-to-left chaining
|| (self.operator().precedence() == node.operator().precedence() && !self.operator().is_left_to_right() && !node.operator().is_left_to_right()) || (self.operator().precedence() == node.operator().precedence() && !self.operator().is_left_to_right() && !node.operator().is_left_to_right())
@ -381,13 +381,13 @@ impl Node {
|| (self.children.last().unwrap().operator().precedence() || (self.children.last().unwrap().operator().precedence()
== node.operator().precedence() && !self.children.last().unwrap().operator().is_left_to_right() && !node.operator().is_left_to_right()) == node.operator().precedence() && !self.children.last().unwrap().operator().is_left_to_right() && !node.operator().is_left_to_right())
{ {
println!("Recursing into {:?}", self.children.last().unwrap().operator()); // println!("Recursing into {:?}", self.children.last().unwrap().operator());
self.children self.children
.last_mut() .last_mut()
.unwrap() .unwrap()
.insert_back_prioritized(node, false) .insert_back_prioritized(node, false)
} else { } else {
println!("Rotating"); // println!("Rotating");
if node.operator().is_leaf() { if node.operator().is_leaf() {
return Err(EvalexprError::AppendedToLeafNode); return Err(EvalexprError::AppendedToLeafNode);
} }
@ -400,7 +400,7 @@ impl Node {
Ok(()) Ok(())
} }
} else { } else {
println!("Inserting as specified"); // println!("Inserting as specified");
self.children.push(node); self.children.push(node);
Ok(()) Ok(())
} }
@ -431,8 +431,8 @@ fn collapse_root_stack_to(root_stack: &mut Vec<Node>, mut root: Node, collapse_g
} }
fn collapse_all_sequences(root_stack: &mut Vec<Node>) -> EvalexprResult<()> { fn collapse_all_sequences(root_stack: &mut Vec<Node>) -> EvalexprResult<()> {
println!("Collapsing all sequences"); // println!("Collapsing all sequences");
println!("Initial root stack is: {:?}", root_stack); // println!("Initial root stack is: {:?}", root_stack);
let mut root = if let Some(root) = root_stack.pop() { let mut root = if let Some(root) = root_stack.pop() {
root root
} else { } else {
@ -440,7 +440,7 @@ fn collapse_all_sequences(root_stack: &mut Vec<Node>) -> EvalexprResult<()> {
}; };
loop { loop {
println!("Root is: {:?}", root); // println!("Root is: {:?}", root);
if root.operator() == &Operator::RootNode { if root.operator() == &Operator::RootNode {
root_stack.push(root); root_stack.push(root);
break; break;
@ -461,7 +461,7 @@ fn collapse_all_sequences(root_stack: &mut Vec<Node>) -> EvalexprResult<()> {
} }
} }
println!("Root stack after collapsing all sequences is: {:?}", root_stack); // println!("Root stack after collapsing all sequences is: {:?}", root_stack);
Ok(()) Ok(())
} }
@ -535,8 +535,8 @@ pub(crate) fn tokens_to_operator_tree(tokens: Vec<Token>) -> EvalexprResult<Node
// Need to pop and then repush here, because Rust 1.33.0 cannot release the mutable borrow of root_stack before the end of this complete if-statement // Need to pop and then repush here, because Rust 1.33.0 cannot release the mutable borrow of root_stack before the end of this complete if-statement
if let Some(mut root) = root_stack.pop() { if let Some(mut root) = root_stack.pop() {
if node.operator().is_sequence() { if node.operator().is_sequence() {
println!("Found a sequence operator"); // println!("Found a sequence operator");
println!("Stack before sequence operation: {:?}, {:?}", root_stack, root); // println!("Stack before sequence operation: {:?}, {:?}", root_stack, root);
// If root.operator() and node.operator() are of the same variant, ... // If root.operator() and node.operator() are of the same variant, ...
if mem::discriminant(root.operator()) == mem::discriminant(node.operator()) { if mem::discriminant(root.operator()) == mem::discriminant(node.operator()) {
// ... we create a new root node for the next expression in the sequence // ... we create a new root node for the next expression in the sequence
@ -569,7 +569,7 @@ pub(crate) fn tokens_to_operator_tree(tokens: Vec<Token>) -> EvalexprResult<Node
root_stack.push(node); root_stack.push(node);
} }
} }
println!("Stack after sequence operation: {:?}", root_stack); // println!("Stack after sequence operation: {:?}", root_stack);
} else if root.operator().is_sequence() { } else if root.operator().is_sequence() {
if let Some(mut last_root_child) = root.children.pop() { if let Some(mut last_root_child) = root.children.pop() {
last_root_child.insert_back_prioritized(node, true)?; last_root_child.insert_back_prioritized(node, true)?;