From ea3415752e4c03284f86fac790a13e857a5860be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pedro=20Henrique?= Date: Sat, 28 Oct 2023 03:03:28 +0000 Subject: [PATCH] refactor: Wrap matching into a helper function --- bin/src/main.rs | 6 +++--- matching/src/lib.rs | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/src/main.rs b/bin/src/main.rs index d7d3231..1b5506d 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -21,9 +21,9 @@ fn main() { let left_tree = parsing::parse_string(left, &parser_configuration).unwrap(); let right_tree = parsing::parse_string(right, &parser_configuration).unwrap(); - let matchings_left_base = matching::ordered_tree_matching(&left_tree, &base_tree); - let matchings_right_base = matching::ordered_tree_matching(&right_tree, &base_tree); - let matchings_left_right = matching::ordered_tree_matching(&left_tree, &right_tree); + let matchings_left_base = matching::calculate_matchings(&left_tree, &base_tree); + let matchings_right_base = matching::calculate_matchings(&right_tree, &base_tree); + let matchings_left_right = matching::calculate_matchings(&left_tree, &right_tree); let result = merge::merge( &base_tree, diff --git a/matching/src/lib.rs b/matching/src/lib.rs index 4417d75..475f157 100644 --- a/matching/src/lib.rs +++ b/matching/src/lib.rs @@ -6,3 +6,7 @@ mod ordered_tree_matching; pub use matching_entry::MatchingEntry; pub use matchings::Matchings; pub use ordered_tree_matching::ordered_tree_matching; + +pub fn calculate_matchings<'a>(left: &'a model::CSTNode, right: &'a model::CSTNode) -> Matchings<'a> { + return ordered_tree_matching::ordered_tree_matching(left, right); +}