Exemple #1
0
 static IStringTransform[] WithdrawSubsequent(Insertion lhs, Insertion rhs)
 {
     return TuplesToInsertions(StringTransformationOperators.WithdrawSubsequent(Tuple.Create(lhs.Position, lhs.Length, (uint)0),
         Tuple.Create(rhs.Position, rhs.Length, (uint)0)), lhs.Contents);
 }
Exemple #2
0
 static IStringTransform[] WithdrawAntecedent(Deletion lhs, Insertion rhs)
 {
     return TuplesToDeletions(StringTransformationOperators.WithdrawAntecedent(Tuple.Create(lhs.Position, lhs.Length),
         Tuple.Create(rhs.Position, rhs.Length, (uint)0)));
 }
Exemple #3
0
 static bool TryCoallesce(Insertion antecedent, Insertion subsequent, out IStringTransform[] result)
 {
     if (subsequent.Position >= antecedent.Position &&
         subsequent.Position <= antecedent.Position + antecedent.Length) {
         result = new IStringTransform[] {
             new Insertion(antecedent.Position,
                 antecedent.Contents.Substring(0, (int) (subsequent.Position - antecedent.Position)) +
                 subsequent.Contents +
                 antecedent.Contents.Substring((int) (subsequent.Position - antecedent.Position)))
         };
         return true;
     }
     else {
         result = new IStringTransform[] { antecedent, subsequent };
         return false;
     }
 }
Exemple #4
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;
     }
 }
Exemple #5
0
 static bool TryCoallesce(Deletion antecedent, Insertion subsequent, out IStringTransform[] result)
 {
     result = new IStringTransform[] { antecedent, subsequent };
     return false;
 }
Exemple #6
0
 static IStringTransform[] IntroduceSubsequent(Insertion lhs, Deletion rhs)
 {
     return TuplesToInsertions(StringTransformationOperators.IntroduceSubsequent(Tuple.Create(lhs.Position, lhs.Length, (uint)0),
         Tuple.Create(rhs.Position, rhs.Length)), lhs.Contents);
 }