From 6b2a14511f749f53d74e8245a090ae86fca22b01 Mon Sep 17 00:00:00 2001 From: Fedor Isakov Date: Mon, 23 Sep 2019 17:43:14 +0200 Subject: [PATCH] A little documentation for RuleMatcher. --- .../src/jetbrains/mps/logic/reactor/core/RuleMatcher.kt | 5 ++++- .../mps/logic/reactor/core/internal/RuleMatcherImpl.kt | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/RuleMatcher.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/RuleMatcher.kt index 9c382e5d..688527c4 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/RuleMatcher.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/RuleMatcher.kt @@ -20,7 +20,10 @@ import jetbrains.mps.logic.reactor.core.internal.RuleMatcherImpl import jetbrains.mps.logic.reactor.program.Rule /** - * Abstracts a rule matching algorithm. + * Abstracts a rule matching algorithm. + * + * A RuleMatcher corresponds to a single rule. + * The method [probe] provides a factory of [RuleMatchingProbe], which is the main handler of match operations. * * @author Fedor Isakov */ diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/RuleMatcherImpl.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/RuleMatcherImpl.kt index 2587f91c..3ab2d0da 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/RuleMatcherImpl.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/RuleMatcherImpl.kt @@ -36,6 +36,12 @@ fun IntArray.toSignature() = TIntArrayList(this) /** + * This implementation of [RuleMatcher] is based on a simple algorithm which enumerates all possible + * permutations of occurrences potentially matching the rule's head. + * + * Optimizations are in place to cut out permutations that don't fit for the reason that the arguments are mismatched + * and/or logical variables are not unifiable with the substitutions calculated previously. + * * @author Fedor Isakov */ internal class RuleMatcherImpl(private val ruleLookup: RuleLookup,