30 lines
794 B
Rust
30 lines
794 B
Rust
mod tests;
|
|
|
|
use crate::ast::Node;
|
|
|
|
// fn cancel_double_negation(ast: Node<char>) {
|
|
// let mut new_ast = ast.clone();
|
|
|
|
// fn recursion(ast: &mut Node<char>, node_count: usize) {
|
|
// match ast {
|
|
// Node::Unary { operator: _, operand } => {
|
|
// recursion(&mut *operand, node_count + 1);
|
|
// },
|
|
// Node::Binary { operator: _, lhs, rhs } => {
|
|
// recursion(&mut *lhs, node_count + 1);
|
|
// recursion(&mut *rhs, node_count + 1);
|
|
// },
|
|
// Node::Leaf(c) => (),
|
|
// }
|
|
// }
|
|
|
|
// recursion(&mut new_ast, 0);
|
|
|
|
// new_ast
|
|
// }
|
|
|
|
fn negation_normal_form(formula: &str) -> String {
|
|
let ast = Node::<char>::parse_formula(formula);
|
|
|
|
Node::<char>::ast_to_formula(ast)
|
|
} |