예제 #1
0
 static IStringTransform[] WithrdawAntecedent(Deletion lhs, Deletion rhs)
 {
     return
         TuplesToDeletions(StringTransformationOperators.WithdrawAntecedent(Tuple.Create(lhs.Position, lhs.Length),
             Tuple.Create(rhs.Length, rhs.Position)));
 }
예제 #2
0
 static bool TryCoallesce(Insertion antecedent, Deletion subsequent, out IStringTransform[] result)
 {
     uint lengthReduction = Math.Max(0,
         Math.Min(antecedent.Position + antecedent.Length, subsequent.Position + subsequent.Length) -
         Math.Max(antecedent.Position, subsequent.Position));
     if (lengthReduction > 0) {
         List<IStringTransform> temp = new List<IStringTransform>(2);
         if (lengthReduction < antecedent.Length) {
             temp.Add(new Insertion(Math.Min(antecedent.Position, subsequent.Position),
                 antecedent.Contents.Remove((int) Math.Max((uint) 0, subsequent.Position - antecedent.Position),
                     (int) lengthReduction)));
         }
         if (lengthReduction < subsequent.Length) {
             temp.Add(new Deletion(subsequent.Position, subsequent.Length - lengthReduction));
         }
         result = temp.ToArray();
         return true;
     } else {
         result = new IStringTransform[] {antecedent, subsequent};
         return false;
     }
 }
예제 #3
0
 static IStringTransform[] WithdrawSubsequent(Insertion lhs, Deletion rhs)
 {
     return TuplesToInsertions(StringTransformationOperators.WithdrawSubsequent(Tuple.Create(lhs.Position, lhs.Length, (uint)0),
         Tuple.Create(rhs.Position, rhs.Length)), lhs.Contents);
 }
예제 #4
0
 static bool TryCoallesce(Deletion antecedent, Insertion subsequent, out IStringTransform[] result)
 {
     result = new IStringTransform[] { antecedent, subsequent };
     return false;
 }
예제 #5
0
 static bool TryCoallesce(Deletion antecedent, Deletion subsequent, out IStringTransform[] result)
 {
     if (subsequent.Position == antecedent.Position) {
         result = new IStringTransform[]
         {new Deletion(antecedent.Position, antecedent.Length + subsequent.Length)};
         return true;
     } else {
         result = new IStringTransform[] {antecedent, subsequent};
         return false;
     }
 }
예제 #6
0
 static IStringTransform[] IntroduceSubsequent(Deletion lhs, Insertion rhs)
 {
     return TuplesToDeletions(StringTransformationOperators.IntroduceSubsequent(Tuple.Create(lhs.Position, lhs.Length),
         Tuple.Create(rhs.Position, rhs.Length, (uint)0)));
 }
예제 #7
0
 static IStringTransform[] IntroduceAntecedent(Insertion lhs, Deletion rhs)
 {
     return TuplesToInsertions(StringTransformationOperators.IntroduceAntecedent(Tuple.Create(lhs.Position, lhs.Length, (uint)0),
         Tuple.Create(rhs.Position, rhs.Length)), lhs.Contents);
 }
예제 #8
0
 static IStringTransform[] IntroduceAntecedent(Deletion lhs, Deletion rhs)
 {
     return TuplesToDeletions(StringTransformationOperators.IntroduceAntecedent(Tuple.Create(lhs.Position, lhs.Length),
         Tuple.Create(rhs.Position, rhs.Length)));
 }